Skip to content

Commit

Permalink
OCLiteralVariable protocol is copied into LiteralVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
dionisiydk committed Jun 14, 2020
1 parent 9fbef42 commit 1e14d8c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Calypso-SystemTools-Core/LiteralVariable.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Extension { #name : #LiteralVariable }

{ #category : #'*Calypso-SystemTools-Core' }
LiteralVariable >> asCalypsoVariableOf: declarationClass [
"it is variable compatible object. Generally variable objects should have declaring class.
Then it will be not needed and simplified"
self isGlobalVariable ifTrue: [ ^ClyGlobalVariable on: self ].

^ClyClassVariable on: self visibleFrom: declarationClass "scope getClass"
]
30 changes: 28 additions & 2 deletions src/Kernel/LiteralVariable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ LiteralVariable class >> key: newKey value: newValue [
^self basicNew key: newKey value: newValue
]

{ #category : #OCVARIABLE }
LiteralVariable class >> semanticNodeClass [

^RBGlobalNode
]

{ #category : #comparing }
LiteralVariable >> = anAssociation [

Expand Down Expand Up @@ -118,16 +124,28 @@ LiteralVariable >> isClassVariable [
^false
]

{ #category : #testing }
{ #category : #OCVARIABLE }
LiteralVariable >> isGlobal [
^true

^ true
]

{ #category : #OCVARIABLE }
LiteralVariable >> isGlobalClassNameBinding [
^ (self value isClass or: [ self value isTrait ])
and: [ name == self value name ]
]

{ #category : #testing }
LiteralVariable >> isGlobalVariable [
^false
]

{ #category : #OCVARIABLE }
LiteralVariable >> isLiteralVariable [
^true
]

{ #category : #testing }
LiteralVariable >> isReadIn: aCompiledCode [
^aCompiledCode readsRef: self
Expand Down Expand Up @@ -155,6 +173,14 @@ LiteralVariable >> isVariableBinding [
^true
]

{ #category : #OCVARIABLE }
LiteralVariable >> isWritable [
"Literal variables are writable, if they aren't global bindings for class names, like
#Object -> Object "

^ (self isGlobalVariable and: [ self isGlobalClassNameBinding ]) not
]

{ #category : #testing }
LiteralVariable >> isWrittenIn: aCompiledCode [
^aCompiledCode writesRef: self
Expand Down
6 changes: 6 additions & 0 deletions src/Kernel/UndeclaredVariable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ UndeclaredVariable class >> registeredWithName: aString [
yourself
]

{ #category : #OCVARIABLE }
UndeclaredVariable class >> semanticNodeClass [

^RBVariableNode
]

{ #category : #queries }
UndeclaredVariable >> definingClass [
"Nobody defines undeclared variable"
Expand Down
5 changes: 5 additions & 0 deletions src/Kernel/Variable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ Variable >> isClassVariable [
^ false
]

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

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

0 comments on commit 1e14d8c

Please sign in to comment.