Skip to content

Commit

Permalink
Push OCAbstractVariable protocol into Variable from Slot.
Browse files Browse the repository at this point in the history
Copy OCUndeclared into UndeclaredVariable
  • Loading branch information
dionisiydk committed Jun 14, 2020
1 parent eb6fa66 commit 01a5322
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 90 deletions.
8 changes: 8 additions & 0 deletions src/Calypso-SystemTools-Core/UndeclaredVariable.extension.st
@@ -0,0 +1,8 @@
Extension { #name : #UndeclaredVariable }

{ #category : #'*Calypso-SystemTools-Core' }
UndeclaredVariable >> asCalypsoVariableOf: declarationClass [

"Undeclared variable behaves like a global. It is shared in all places in system"
^ClyGlobalVariable on: self
]
95 changes: 5 additions & 90 deletions src/Kernel/Slot.class.st
Expand Up @@ -68,6 +68,11 @@ Slot class >> named: aSymbol [
yourself
]

{ #category : #OCVARIABLE }
Slot class >> semanticNodeClass [
^RBInstanceVariableNode
]

{ #category : #settings }
Slot class >> showSlotClassDefinition [
^slotClassDefinition ifNil: [ slotClassDefinition := false ]
Expand Down Expand Up @@ -214,36 +219,16 @@ Slot >> isAccessedIn: aCompiledCode [
anySatisfy: [ :node | node binding slot == self ]
]

{ #category : #OCVARIABLE }
Slot >> isArg [
^false
]

{ #category : #OCVARIABLE }
Slot >> isClassVariable [
^ false
]

{ #category : #testing }
Slot >> isGlobal [
^false
]

{ #category : #OCVARIABLE }
Slot >> isGlobalVariable [
^ false
]

{ #category : #OCVARIABLE }
Slot >> isInstance [
^ true
]

{ #category : #OCVARIABLE }
Slot >> isLiteralVariable [
^false
]

{ #category : #testing }
Slot >> isLocal [

Expand All @@ -261,60 +246,11 @@ Slot >> isReferenced [
^self usingMethods isNotEmpty
]

{ #category : #OCVARIABLE }
Slot >> isRemote [
^false
]

{ #category : #OCVARIABLE }
Slot >> isSelf [
^false
]

{ #category : #testing }
Slot >> isSelfEvaluating [
^true
]

{ #category : #OCVARIABLE }
Slot >> isSelfOrSuper [

^ false
]

{ #category : #OCVARIABLE }
Slot >> isSpecialVariable [
^false
]

{ #category : #OCVARIABLE }
Slot >> isSuper [
^false
]

{ #category : #OCVARIABLE }
Slot >> isTemp [

^ false
]

{ #category : #OCVARIABLE }
Slot >> isThisContext [
^false
]

{ #category : #OCVARIABLE }
Slot >> isUndeclared [

^ false
]

{ #category : #OCVARIABLE }
Slot >> isUninitialized [

^ false
]

{ #category : #testing }
Slot >> isVirtual [
"virtual slots do not take up space in the object and have size = 0"
Expand All @@ -326,11 +262,6 @@ Slot >> isVisible [
^ true
]

{ #category : #OCVARIABLE }
Slot >> isWritable [
^ true
]

{ #category : #testing }
Slot >> isWrittenIn: aCompiledCode [
^aCompiledCode ast instanceVariableWriteNodes
Expand All @@ -349,11 +280,6 @@ Slot >> needsFullDefinition [
^true
]

{ #category : #OCVARIABLE }
Slot >> originalVar [
^ self
]

{ #category : #accessing }
Slot >> owningClass [
"the class that the slot is installed in"
Expand Down Expand Up @@ -384,11 +310,6 @@ Slot >> scope: aScope [
"ignored, subclasses can override to analyze the scope they are to be installed in"
]

{ #category : #OCVARIABLE }
Slot >> semanticNodeClass [
^RBInstanceVariableNode
]

{ #category : #private }
Slot >> sendsInitializeSlots: aClass [
(aClass isTrait or: [ aClass includesSelector: #initialize ])
Expand Down Expand Up @@ -427,12 +348,6 @@ Slot >> usingMethods [
ifNotNil: [:class | class allMethodsAccessingSlot: self].
]

{ #category : #OCVARIABLE }
Slot >> variable [
"I return the first class variable that I model in the case of globals and ivars"
^self
]

{ #category : #'meta-object-protocol' }
Slot >> wantsInitialization [
"if a slot wants to enable instance initalization, return true here"
Expand Down
6 changes: 6 additions & 0 deletions src/Kernel/UndeclaredVariable.class.st
Expand Up @@ -34,3 +34,9 @@ UndeclaredVariable >> isReferenced [
^Smalltalk globals allBehaviors
anySatisfy: [ :behavior | behavior hasSelectorReferringTo: self ]
]

{ #category : #OCVARIABLE }
UndeclaredVariable >> isUndeclared [

^ true
]
100 changes: 100 additions & 0 deletions src/Kernel/Variable.class.st
Expand Up @@ -36,6 +36,11 @@ Variable class >> initialize [
ifNotNil: [ (WeakIdentityKeyDictionary newFrom: Properties) rehash]
]

{ #category : #OCVARIABLE }
Variable class >> semanticNodeClass [
^RBVariableNode
]

{ #category : #comparing }
Variable >> = other [
"Every subclass that adds state must redefine this method"
Expand Down Expand Up @@ -64,11 +69,90 @@ Variable >> hash [
^ self species hash bitXor: self name hash
]

{ #category : #OCVARIABLE }
Variable >> isArg [
^false
]

{ #category : #OCVARIABLE }
Variable >> isClassVariable [
^ false
]

{ #category : #OCVARIABLE }
Variable >> isGlobalVariable [
^ false
]

{ #category : #OCVARIABLE }
Variable >> isInstance [
^ false
]

{ #category : #OCVARIABLE }
Variable >> isLiteralVariable [
^false
]

{ #category : #testing }
Variable >> isReferenced [
^ self subclassResponsibility
]

{ #category : #OCVARIABLE }
Variable >> isRemote [
^false
]

{ #category : #OCVARIABLE }
Variable >> isSelf [
^false
]

{ #category : #OCVARIABLE }
Variable >> isSelfOrSuper [

^ false
]

{ #category : #OCVARIABLE }
Variable >> isSpecialVariable [
^false
]

{ #category : #OCVARIABLE }
Variable >> isSuper [
^false
]

{ #category : #OCVARIABLE }
Variable >> isTemp [

^ false
]

{ #category : #OCVARIABLE }
Variable >> isThisContext [
^false
]

{ #category : #OCVARIABLE }
Variable >> isUndeclared [

^ false
]

{ #category : #OCVARIABLE }
Variable >> isUninitialized [

^ false
]

{ #category : #OCVARIABLE }
Variable >> isWritable [
^ true
]

{ #category : #accessing }
Variable >> name [
^ name
Expand All @@ -79,6 +163,11 @@ Variable >> name: aSymbol [
name := aSymbol
]

{ #category : #OCVARIABLE }
Variable >> originalVar [
^ self
]

{ #category : #properties }
Variable >> properties [
^ Properties at: self ifAbsent: nil
Expand Down Expand Up @@ -140,7 +229,18 @@ Variable >> removeProperty: propName ifAbsent: aBlock [
^ property
]

{ #category : #OCVARIABLE }
Variable >> semanticNodeClass [
^self class semanticNodeClass
]

{ #category : #queries }
Variable >> usingMethods [
self subclassResponsibility
]

{ #category : #OCVARIABLE }
Variable >> variable [
"I return the first class variable that I model in the case of globals and ivars"
^self
]

0 comments on commit 01a5322

Please sign in to comment.