Skip to content

Commit

Permalink
The names of the testing methods for Variables (and VariableNodes) ar…
Browse files Browse the repository at this point in the history
…e not good. #isGlobal works, but it breakes down with #isInstance...

As one step, this PR just makes sure that all the "nice" variable check methos exist on the Variable hierarchy

- add missing (e.g. isTemporaryVariable)
- the short versions forward to the new and have a comment that they will be deprecated
- add comments to the version on Variable for those that are not obvious (eg isLiteralVariable, the term is not nice but that is what they are called on the Bytecode level)

This PR does *not*
- change any senders
- modify the AST level
- isSelf/isSuper are skiped for now (they should be isSelfVariable, too)
  • Loading branch information
MarcusDenker committed Jul 11, 2020
1 parent ab58204 commit fbd8f91
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 40 deletions.
6 changes: 0 additions & 6 deletions src/Deprecated90/OCAbstractLocalVariable.class.st
Expand Up @@ -25,12 +25,6 @@ OCAbstractLocalVariable >> definingScope [
^ scope
]

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

^true
]

{ #category : #'read/write usage' }
OCAbstractLocalVariable >> isRead [
^usage = #read
Expand Down
6 changes: 0 additions & 6 deletions src/Deprecated90/OCAbstractVariable.class.st
Expand Up @@ -28,12 +28,6 @@ OCAbstractVariable >> definingScope [
^ scope
]

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

^false
]

{ #category : #'read/write usage' }
OCAbstractVariable >> isRead [
^usage = #read
Expand Down
6 changes: 0 additions & 6 deletions src/Deprecated90/OCLiteralVariable.class.st
Expand Up @@ -50,12 +50,6 @@ OCLiteralVariable >> isFromSharedPool [
ifNone: [ false ]
]

{ #category : #testing }
OCLiteralVariable >> isGlobal [

^ true
]

{ #category : #testing }
OCLiteralVariable >> isGlobalClassNameBinding [
^ (self value isClass or: [ self value isTrait ])
Expand Down
5 changes: 0 additions & 5 deletions src/Deprecated90/OCSlotVariable.class.st
Expand Up @@ -38,11 +38,6 @@ OCSlotVariable >> emitValue: methodBuilder [
slot emitValue: methodBuilder
]

{ #category : #testing }
OCSlotVariable >> isInstance [
^ true
]

{ #category : #accessing }
OCSlotVariable >> name [
^ slot name
Expand Down
6 changes: 0 additions & 6 deletions src/Kernel/GlobalVariable.class.st
Expand Up @@ -26,12 +26,6 @@ GlobalVariable >> emitValue: methodBuilder [
methodBuilder pushLiteralVariable: self.
]

{ #category : #testing }
GlobalVariable >> isGlobal [

^ true
]

{ #category : #testing }
GlobalVariable >> isGlobalVariable [
^true
Expand Down
7 changes: 6 additions & 1 deletion src/Kernel/Slot.class.st
Expand Up @@ -218,7 +218,7 @@ Slot >> isDefinedByOwningClass [
]

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

Expand All @@ -233,6 +233,11 @@ Slot >> isSelfEvaluating [
^true
]

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

{ #category : #testing }
Slot >> isVirtual [
"virtual slots do not take up space in the object and have size = 0"
Expand Down
32 changes: 28 additions & 4 deletions src/Kernel/Variable.class.st
Expand Up @@ -114,8 +114,9 @@ Variable >> isClassVariable [
]

{ #category : #testing }
Variable >> isGlobal [
^false
Variable >> isGlobal [
"this will be deprecated"
^self isGlobalVariable
]

{ #category : #testing }
Expand All @@ -125,21 +126,32 @@ Variable >> isGlobalVariable [

{ #category : #testing }
Variable >> isInstance [
^ false
"this will be deprecated"
^ self isInstanceVariable
]

{ #category : #testing }
Variable >> isInstanceVariable [
"check if the var is an instance variable (a Slot)"
^false
]

{ #category : #testing }
Variable >> isLiteralVariable [
"returns true for Global Variables, Class Variables and some others
(e.g. Workspace bindings and Undeclared variables, see subclasses)"
^false
]

{ #category : #testing }
Variable >> isLocal [
^false
"this will be deprecated"
^self isLocalVariable
]

{ #category : #testing }
Variable >> isLocalVariable [
"temporary variables and arguments are local variables"
^false
]

Expand All @@ -150,6 +162,7 @@ Variable >> isReferenced [

{ #category : #testing }
Variable >> isReservedVariable [
"thisContext, super, self are reserved variables (true, false and nil are literals)"
^false
]

Expand All @@ -164,6 +177,12 @@ Variable >> isSelfOrSuper [
^ self isSelf or: [ self isSuper ]
]

{ #category : #testing }
Variable >> isSlot [
"check if the var is an instance variable (a Slot)"
^false
]

{ #category : #testing }
Variable >> isSuper [
^false
Expand All @@ -175,6 +194,11 @@ Variable >> isTemp [
^ false
]

{ #category : #testing }
Variable >> isTemporaryVariable [
^false
]

{ #category : #testing }
Variable >> isThisContext [
^false
Expand Down
6 changes: 0 additions & 6 deletions src/OpalCompiler-Core/LocalVariable.class.st
Expand Up @@ -115,12 +115,6 @@ LocalVariable >> isEscapingWrite [

]

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

^true
]

{ #category : #testing }
LocalVariable >> isLocalVariable [

Expand Down
6 changes: 6 additions & 0 deletions src/OpalCompiler-Core/TemporaryVariable.class.st
Expand Up @@ -18,3 +18,9 @@ TemporaryVariable >> isTemp [

^ true
]

{ #category : #testing }
TemporaryVariable >> isTemporaryVariable [

^ true
]

0 comments on commit fbd8f91

Please sign in to comment.