From fbd8f91e935a4fcc6f7280777201e84792f3dcb9 Mon Sep 17 00:00:00 2001 From: Marcus Denker Date: Sat, 11 Jul 2020 21:15:18 +0200 Subject: [PATCH] The names of the testing methods for Variables (and VariableNodes) are 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) --- .../OCAbstractLocalVariable.class.st | 6 ---- src/Deprecated90/OCAbstractVariable.class.st | 6 ---- src/Deprecated90/OCLiteralVariable.class.st | 6 ---- src/Deprecated90/OCSlotVariable.class.st | 5 --- src/Kernel/GlobalVariable.class.st | 6 ---- src/Kernel/Slot.class.st | 7 +++- src/Kernel/Variable.class.st | 32 ++++++++++++++++--- src/OpalCompiler-Core/LocalVariable.class.st | 6 ---- .../TemporaryVariable.class.st | 6 ++++ 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Deprecated90/OCAbstractLocalVariable.class.st b/src/Deprecated90/OCAbstractLocalVariable.class.st index d5aa8fdc498..6f2809737bd 100644 --- a/src/Deprecated90/OCAbstractLocalVariable.class.st +++ b/src/Deprecated90/OCAbstractLocalVariable.class.st @@ -25,12 +25,6 @@ OCAbstractLocalVariable >> definingScope [ ^ scope ] -{ #category : #testing } -OCAbstractLocalVariable >> isLocal [ - - ^true -] - { #category : #'read/write usage' } OCAbstractLocalVariable >> isRead [ ^usage = #read diff --git a/src/Deprecated90/OCAbstractVariable.class.st b/src/Deprecated90/OCAbstractVariable.class.st index ffc92a3ced5..48b56a9bb40 100644 --- a/src/Deprecated90/OCAbstractVariable.class.st +++ b/src/Deprecated90/OCAbstractVariable.class.st @@ -28,12 +28,6 @@ OCAbstractVariable >> definingScope [ ^ scope ] -{ #category : #testing } -OCAbstractVariable >> isLocal [ - - ^false -] - { #category : #'read/write usage' } OCAbstractVariable >> isRead [ ^usage = #read diff --git a/src/Deprecated90/OCLiteralVariable.class.st b/src/Deprecated90/OCLiteralVariable.class.st index 09e166630a5..31a941431e3 100644 --- a/src/Deprecated90/OCLiteralVariable.class.st +++ b/src/Deprecated90/OCLiteralVariable.class.st @@ -50,12 +50,6 @@ OCLiteralVariable >> isFromSharedPool [ ifNone: [ false ] ] -{ #category : #testing } -OCLiteralVariable >> isGlobal [ - - ^ true -] - { #category : #testing } OCLiteralVariable >> isGlobalClassNameBinding [ ^ (self value isClass or: [ self value isTrait ]) diff --git a/src/Deprecated90/OCSlotVariable.class.st b/src/Deprecated90/OCSlotVariable.class.st index e16c19a90a7..2258742cf93 100644 --- a/src/Deprecated90/OCSlotVariable.class.st +++ b/src/Deprecated90/OCSlotVariable.class.st @@ -38,11 +38,6 @@ OCSlotVariable >> emitValue: methodBuilder [ slot emitValue: methodBuilder ] -{ #category : #testing } -OCSlotVariable >> isInstance [ - ^ true -] - { #category : #accessing } OCSlotVariable >> name [ ^ slot name diff --git a/src/Kernel/GlobalVariable.class.st b/src/Kernel/GlobalVariable.class.st index 4b01d26404f..fab53ecfc6d 100644 --- a/src/Kernel/GlobalVariable.class.st +++ b/src/Kernel/GlobalVariable.class.st @@ -26,12 +26,6 @@ GlobalVariable >> emitValue: methodBuilder [ methodBuilder pushLiteralVariable: self. ] -{ #category : #testing } -GlobalVariable >> isGlobal [ - - ^ true -] - { #category : #testing } GlobalVariable >> isGlobalVariable [ ^true diff --git a/src/Kernel/Slot.class.st b/src/Kernel/Slot.class.st index 1cc3f63e32d..c8c405f727d 100644 --- a/src/Kernel/Slot.class.st +++ b/src/Kernel/Slot.class.st @@ -218,7 +218,7 @@ Slot >> isDefinedByOwningClass [ ] { #category : #testing } -Slot >> isInstance [ +Slot >> isInstanceVariable [ ^ true ] @@ -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" diff --git a/src/Kernel/Variable.class.st b/src/Kernel/Variable.class.st index bcbf74104a3..f2e96d6f2ce 100644 --- a/src/Kernel/Variable.class.st +++ b/src/Kernel/Variable.class.st @@ -114,8 +114,9 @@ Variable >> isClassVariable [ ] { #category : #testing } -Variable >> isGlobal [ - ^false +Variable >> isGlobal [ + "this will be deprecated" + ^self isGlobalVariable ] { #category : #testing } @@ -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 ] @@ -150,6 +162,7 @@ Variable >> isReferenced [ { #category : #testing } Variable >> isReservedVariable [ + "thisContext, super, self are reserved variables (true, false and nil are literals)" ^false ] @@ -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 @@ -175,6 +194,11 @@ Variable >> isTemp [ ^ false ] +{ #category : #testing } +Variable >> isTemporaryVariable [ + ^false +] + { #category : #testing } Variable >> isThisContext [ ^false diff --git a/src/OpalCompiler-Core/LocalVariable.class.st b/src/OpalCompiler-Core/LocalVariable.class.st index 5a9ddf1c4d6..2c2ef37f1c2 100644 --- a/src/OpalCompiler-Core/LocalVariable.class.st +++ b/src/OpalCompiler-Core/LocalVariable.class.st @@ -115,12 +115,6 @@ LocalVariable >> isEscapingWrite [ ] -{ #category : #testing } -LocalVariable >> isLocal [ - - ^true -] - { #category : #testing } LocalVariable >> isLocalVariable [ diff --git a/src/OpalCompiler-Core/TemporaryVariable.class.st b/src/OpalCompiler-Core/TemporaryVariable.class.st index 15cf987b257..16dc17fee61 100644 --- a/src/OpalCompiler-Core/TemporaryVariable.class.st +++ b/src/OpalCompiler-Core/TemporaryVariable.class.st @@ -18,3 +18,9 @@ TemporaryVariable >> isTemp [ ^ true ] + +{ #category : #testing } +TemporaryVariable >> isTemporaryVariable [ + + ^ true +]