allow access to class-instVars from doIts;
dont warn about unimplemented selectors in a send to
an undefined variable.
--- a/Parser.st Wed May 06 16:19:57 1998 +0200
+++ b/Parser.st Thu May 07 19:37:27 1998 +0200
@@ -2192,7 +2192,7 @@
or:[((names := self classesInstVarNames) notNil and:[names includes:aSelectorString])
or:[((names := self classesClassInstVarNames) notNil and:[names includes:aSelectorString])
or:[((names := self classesClassVarNames) notNil and:[names includes:aSelectorString])]]]]) ifTrue:[
- err := ' is currently nowhere implemented ..
+ err := ' is currently nowhere implemented ..
.. but a variable with that name is defined.
Missing ''.'' after the previous expression
@@ -2206,113 +2206,118 @@
ok := false.
sym := aSelectorString asSymbolIfInterned.
sym notNil ifTrue:[
- ok := true.
- receiver notNil ifTrue:[
- "
- if the receiver is a constant, we can check if it responds
- to this selector
- "
- receiver isConstant ifTrue:[
- rec := receiver evaluate.
- ok := rec respondsTo:sym.
- err := ' will not be understood here (message to ' , rec classNameWithArticle , ')'.
- ] ifFalse:[
- receiver isBlock ifTrue:[
- "/ this should help with typos, sending #ifTrue to blocks ...
- ok := [] respondsTo:sym.
- err := ' will not be understood here (message to a Block)'.
- ] ifFalse:[
- "
- if the receiver is a global, we check it too ...
- "
- (((recType := receiver type) == #GlobalVariable)
- or:[recType == #PrivateClass]) ifTrue:[
- "/ dont check autoloaded classes
- "/ - it may work after loading"
-
- rec := receiver evaluate.
- (rec notNil
- and:[rec isBehavior
- and:[rec isLoaded not]]) ifTrue:[
- ^ aSelectorString
- ].
-
- ok := rec respondsTo:sym.
- ok ifFalse:[
- "if it implements #doesNotUnderstand, assume its ok"
- (rec class implements:#doesNotUnderstand:) ifTrue:[
- ^ aSelectorString
- ]
- ].
-
- err := ' may not be understood here (is currently ' , rec classNameWithArticle , ')'.
- ] ifFalse:[
- "if its a super send, we can do more checking"
- receiver isSuper ifTrue:[
- receiver isHere ifFalse:[
- ((superCls := classToCompileFor superclass) notNil
- and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[
- err := ' is currently not implemented in any superclass'.
- ok := false
- ]
- ] ifTrue:[
- (classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[
- err := ' is currently not implemented in this class'.
- ok := false
- ]
- ]
- ].
-
- (receiver isUnaryMessage
- and:[receiver selector == #class
- and:[receiver receiver type == #Self]]) ifTrue:[
- "its a message to self class - can check this too ..."
- (classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[
- ok := false.
- classToCompileFor allSubclasses do:[:subclass |
- (subclass class implements:sym) ifTrue:[
- ok := true
- ]
- ].
- err := ' is currently not implemented in the class'.
- ]
- ]
- ]
- ]
- ]
- ]
+ ok := true.
+ receiver notNil ifTrue:[
+ "
+ if the receiver is a constant, we can check if it responds
+ to this selector
+ "
+ receiver isConstant ifTrue:[
+ rec := receiver evaluate.
+ ok := rec respondsTo:sym.
+ err := ' will not be understood here (message to ' , rec classNameWithArticle , ')'.
+ ] ifFalse:[
+ receiver isBlock ifTrue:[
+ "/ this should help with typos, sending #ifTrue to blocks ...
+ ok := [] respondsTo:sym.
+ err := ' will not be understood here (message to a Block)'.
+ ] ifFalse:[
+ "
+ if the receiver is a global, we check it too ...
+ "
+ (((recType := receiver type) == #GlobalVariable)
+ or:[recType == #PrivateClass]) ifTrue:[
+ "/ dont check autoloaded classes
+ "/ - it may work after loading"
+
+ rec := receiver evaluate.
+ (rec notNil
+ and:[rec isBehavior
+ and:[rec isLoaded not]]) ifTrue:[
+ ^ aSelectorString
+ ].
+
+ ok := rec respondsTo:sym.
+ ok ifFalse:[
+ "if it implements #doesNotUnderstand, assume its ok"
+ (rec class implements:#doesNotUnderstand:) ifTrue:[
+ ^ aSelectorString
+ ]
+ ].
+
+ err := ' may not be understood here (is currently ' , rec classNameWithArticle , ')'.
+ ] ifFalse:[
+ "if its a super send, we can do more checking"
+ receiver isSuper ifTrue:[
+ receiver isHere ifFalse:[
+ ((superCls := classToCompileFor superclass) notNil
+ and:[(superCls whichClassIncludesSelector:sym) isNil]) ifTrue:[
+ err := ' is currently not implemented in any superclass'.
+ ok := false
+ ]
+ ] ifTrue:[
+ (classToCompileFor whichClassIncludesSelector:sym) isNil ifTrue:[
+ err := ' is currently not implemented in this class'.
+ ok := false
+ ]
+ ]
+ ].
+
+ (receiver isUnaryMessage
+ and:[receiver selector == #class
+ and:[receiver receiver type == #Self]]) ifTrue:[
+ "its a message to self class - can check this too ..."
+ (classToCompileFor class whichClassIncludesSelector:sym) isNil ifTrue:[
+ ok := false.
+ classToCompileFor allSubclasses do:[:subclass |
+ (subclass class implements:sym) ifTrue:[
+ ok := true
+ ]
+ ].
+ err := ' is currently not implemented in the class'.
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
].
ok ifFalse:[
- (receiver notNil
- and:[((recType := receiver type) == #GlobalVariable)
- or:[recType == #PrivateClass]]) ifTrue:[
- "/ dont check autoloaded classes
- "/ - it may work after loading
-
- rec := receiver evaluate.
- (rec notNil
- and:[rec isBehavior
- and:[rec isLoaded not]]) ifTrue:[
- ^ aSelectorString
- ].
- ].
+ (receiver notNil
+ and:[((recType := receiver type) == #GlobalVariable)
+ or:[recType == #PrivateClass]]) ifTrue:[
+ "/ dont check autoloaded classes
+ "/ - it may work after loading
+
+ rec := receiver evaluate.
+ (rec notNil
+ and:[rec isBehavior
+ and:[rec isLoaded not]]) ifTrue:[
+ ^ aSelectorString
+ ].
+ rec class == UndefinedVariable ifTrue:[
+ "/ dont check undefined vars;
+ "/ it may work after loading/defining
+ ^ aSelectorString
+ ].
+ ].
"OLD: "
- self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2
+ self warning:('#' , aSelectorString , '\\' , err) withCRs position:pos1 to:pos2
" "
"NEW: - not finished - need more interfaces
(currently produces warning output on Transcript while filing in
- ^ self correctSelector:aSelectorString message:('#' , aSelectorString , err) position:pos1 to:pos2
+ ^ self correctSelector:aSelectorString message:('#' , aSelectorString , err) position:pos1 to:pos2
"
].
^ aSelectorString
- "Modified: 5.9.1995 / 17:02:11 / claus"
- "Modified: 5.1.1997 / 16:50:36 / cg"
+ "Modified: / 5.9.1995 / 17:02:11 / claus"
+ "Modified: / 7.5.1998 / 11:28:03 / cg"
! !
!Parser methodsFor:'error handling'!
@@ -4159,7 +4164,16 @@
aClass notNil ifTrue:[
classToCompileFor isMeta ifFalse:[
classVarIndex == 0 ifTrue:[
- "/ there is no corresponding classVar
+ "/ there is no corresponding classVar;
+ "/ wants to access classInstVar ?
+ contextToEvaluateIn notNil ifTrue:[
+ "/ allow it in a doIt ...
+
+ ^ VariableNode type:#ClassInstanceVariable
+ name:varName
+ index:varIndex
+ selfClass:aClass
+ ].
self parseError:'access to class-inst-var from inst method is not allowed'.
^ #Error.
] ifFalse:[
@@ -4226,7 +4240,7 @@
^ #Error
- "Modified: / 19.4.1998 / 12:24:35 / cg"
+ "Modified: / 7.5.1998 / 01:40:55 / cg"
! !
!Parser methodsFor:'private'!
@@ -4640,6 +4654,6 @@
!Parser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.170 1998-04-25 14:04:42 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.171 1998-05-07 17:37:27 cg Exp $'
! !
Parser initialize!