Skip to content

Commit

Permalink
rename #usesSpecialVariables-> #needsSlotClassDefinition
Browse files Browse the repository at this point in the history
rename #usesSpecialSlot -> slotsNeedFullDefinition
rename #usesSpecialClassVariables -> classVariablesNeedFullDefinition
in addition:

simplify #=>
remove dead code: #asValidInstVarName

fixes #3338
  • Loading branch information
MarcusDenker committed May 13, 2019
1 parent 3b62865 commit 4943b21
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/Kernel/Class.class.st
Expand Up @@ -447,7 +447,7 @@ Class >> definitionForNautilus [
"Answer a String that defines the receiver."

| aStream poolString |
(self usesSpecialVariables or: [ Slot showSlotClassDefinition ])
(self needsSlotClassDefinition or: [ Slot showSlotClassDefinition ])
ifTrue: [ ^ self definitionForNautilusWithSlots ].
poolString := self sharedPoolsString.
aStream := (String new: 800) writeStream.
Expand Down
36 changes: 18 additions & 18 deletions src/Kernel/ClassDescription.class.st
Expand Up @@ -334,6 +334,12 @@ ClassDescription >> classThatDefinesInstanceVariable: instVarName [
^self superclass ifNotNil: [self superclass classThatDefinesInstanceVariable: instVarName]
]

{ #category : #slots }
ClassDescription >> classVariablesNeedFullDefinition [

^self classVariables anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #printing }
ClassDescription >> classVariablesString [
"Answer a string of my class variable names separated by spaces."
Expand Down Expand Up @@ -843,6 +849,12 @@ ClassDescription >> methodsTaggedWith: aSymbol [
^self localMethods select: [ :each | each isTaggedWith: aSymbol ]
]

{ #category : #slots }
ClassDescription >> needsSlotClassDefinition [
"return true if we define something else than InstanceVariableSlots or normal class variables"
^self slotsNeedFullDefinition or: [ self class slotsNeedFullDefinition or: [self classVariablesNeedFullDefinition ]]
]

{ #category : #private }
ClassDescription >> newInstanceFrom: oldInstance variable: variable size: instSize [
"Create a new instance of the receiver based on the given old instance.
Expand Down Expand Up @@ -1158,6 +1170,12 @@ ClassDescription >> slots [
^self classLayout visibleSlots
]

{ #category : #slots }
ClassDescription >> slotsNeedFullDefinition [
"return true if we define something else than InstanceVariableSlots"
^self slots anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #private }
ClassDescription >> spaceUsed [
^super spaceUsed + (self hasClassSide
Expand Down Expand Up @@ -1328,24 +1346,6 @@ ClassDescription >> usesPoolVarNamed: aString [
^ false
]

{ #category : #slots }
ClassDescription >> usesSpecialClassVariables [

^self classVariables anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #slots }
ClassDescription >> usesSpecialSlot [
"return true if we define something else than InstanceVariableSlots"
^self slots anySatisfy: [ :each | each needsFullDefinition ]
]

{ #category : #slots }
ClassDescription >> usesSpecialVariables [
"return true if we define something else than InstanceVariableSlots"
^self usesSpecialSlot or: [ self class usesSpecialSlot or: [self usesSpecialClassVariables ]]
]

{ #category : #compiling }
ClassDescription >> wantsChangeSetLogging [
"Answer whether code submitted for the receiver should be remembered by the changeSet mechanism."
Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Metaclass.class.st
Expand Up @@ -118,7 +118,7 @@ Metaclass >> definition [
[:strm |
strm print: self.

(self usesSpecialSlot or: [ Slot showSlotClassDefinition ])
(self slotsNeedFullDefinition or: [ Slot showSlotClassDefinition ])
ifFalse: [
strm
crtab;
Expand Down
2 changes: 1 addition & 1 deletion src/Monticello/Class.extension.st
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Class }
{ #category : #'*Monticello' }
Class >> asClassDefinition [
"we use a very ugly hack to encode complex slots as string with MC... later MC should model Slots directly"
self usesSpecialVariables ifFalse: [
self needsSlotClassDefinition ifFalse: [
^MCClassDefinition
name: self name
superclassName: (self superclass ifNil: [ nil asString ] ifNotNil: [ self superclass name ])
Expand Down
22 changes: 11 additions & 11 deletions src/Monticello/MCClassDefinition.class.st
Expand Up @@ -186,7 +186,7 @@ MCClassDefinition >> classInstanceVariables [

variables ifNil: [ ^ #() ].

^self usesSpecialVariables
^self needsSlotClassDefinition
ifTrue: [ self variablesOfType: #isClassInstanceVariable]
ifFalse: [self classInstanceVariablesString asSlotCollection]
]
Expand Down Expand Up @@ -223,7 +223,7 @@ MCClassDefinition >> classVarNames [

{ #category : #printing }
MCClassDefinition >> classVariables [
^self usesSpecialVariables
^self needsSlotClassDefinition
ifTrue: [self sortedVariablesOfType: #isClassVariable ]
ifFalse: [(self classVariablesString substrings: ' ') collect: [:x | x asSymbol => ClassVariable]].

Expand Down Expand Up @@ -391,7 +391,7 @@ MCClassDefinition >> instVarNames [

{ #category : #printing }
MCClassDefinition >> instanceVariables [
^self usesSpecialVariables
^self needsSlotClassDefinition
ifTrue: [self variablesOfType: #isInstanceVariable]
ifFalse: [self instanceVariablesString asSlotCollection]
]
Expand Down Expand Up @@ -431,6 +431,14 @@ MCClassDefinition >> load [
self createClass
]

{ #category : #installing }
MCClassDefinition >> needsSlotClassDefinition [
"this checks if any ivar or class var is using more than just standard definitions.
Complex vars are encoded with a string that starts with a # or one that has a space"

^self variables anySatisfy: [:var | (var name beginsWith:'#') or: [ var name includes: Character space ]]
]

{ #category : #accessing }
MCClassDefinition >> poolDictionaries [
^ self selectVariables: #isPoolImport
Expand Down Expand Up @@ -623,14 +631,6 @@ MCClassDefinition >> unload [
Smalltalk globals removeClassNamed: name
]

{ #category : #installing }
MCClassDefinition >> usesSpecialVariables [
"this checks if any ivar or class var is using more than just standard definitions.
Complex vars are encoded with a string that starts with a # or one that has a space"

^self variables anySatisfy: [:var | (var name beginsWith:'#') or: [ var name includes: Character space ]]
]

{ #category : #accessing }
MCClassDefinition >> variables [
^ variables ifNil: [ variables := OrderedCollection new ]
Expand Down
4 changes: 2 additions & 2 deletions src/Monticello/MCTraitDefinition.class.st
Expand Up @@ -64,7 +64,7 @@ MCTraitDefinition >> accept: aVisitor [
{ #category : #printing }
MCTraitDefinition >> classSlotDefinitionString [

^ self usesSpecialVariables
^ self needsSlotClassDefinition
ifTrue: [ self classInstanceVariables asString ]
ifFalse: [
String streamContents: [ :stream |
Expand Down Expand Up @@ -207,7 +207,7 @@ MCTraitDefinition >> slotDefinitionString [

variables ifNil: [ ^ '{ }' ].

^ self usesSpecialVariables
^ self needsSlotClassDefinition
ifTrue: [ self instanceVariables asString ]
ifFalse: [
String streamContents: [ :stream |
Expand Down
2 changes: 1 addition & 1 deletion src/Monticello/Trait.extension.st
Expand Up @@ -2,7 +2,7 @@ Extension { #name : #Trait }

{ #category : #'*Monticello' }
Trait >> asClassDefinition [
self usesSpecialVariables ifFalse: [
self needsSlotClassDefinition ifFalse: [
^ MCTraitDefinition
name: self name
traitComposition: self traitCompositionString
Expand Down
12 changes: 0 additions & 12 deletions src/Slot-Core/String.extension.st
Expand Up @@ -20,15 +20,3 @@ String >> asSlotCollection [
whitespaces := ByteString withAll: { Character space . Character tab . Character cr }.
^(self substrings: whitespaces) collect: [ :substring | substring asSlot ]
]

{ #category : #'*Slot-Core' }
String >> asValidInstVarName [

| validName |

validName := self select: [ :c | c isAlphaNumeric or: [ c == $_ ] ].

^validName first isDigit
ifTrue: [ 'v' , validName ]
ifFalse: [ validName ]
]
5 changes: 1 addition & 4 deletions src/Slot-Core/Symbol.extension.st
Expand Up @@ -2,10 +2,7 @@ Extension { #name : #Symbol }

{ #category : #'*Slot-Core' }
Symbol >> => aVariable [
aVariable isBehavior
ifTrue: [ ^ aVariable named: self].
^ aVariable name: self;
yourself
^ aVariable named: self
]

{ #category : #'*Slot-Core' }
Expand Down
2 changes: 1 addition & 1 deletion src/TraitsV2/TraitedMetaclass.class.st
Expand Up @@ -83,7 +83,7 @@ TraitedMetaclass >> definition [
nextPutAll: 'uses: ';
print: self traitComposition ].

(self usesSpecialSlot or: [ Slot showSlotClassDefinition ])
(self slotsNeedFullDefinition or: [ Slot showSlotClassDefinition ])
ifFalse: [
strm
crtab;
Expand Down

0 comments on commit 4943b21

Please sign in to comment.