oops - when evaluating in a context, classVars must be
authorClaus Gittinger <cg@exept.de>
Mon, 15 Jun 1998 21:44:03 +0200
changeset 732 c36e5ef1e6ce
parent 731 30ba53c6eb52
child 733 6859b56d5bd2
oops - when evaluating in a context, classVars must be searched in implementing methods class; not in receivers class.
Parser.st
--- a/Parser.st	Mon Jun 15 16:29:32 1998 +0200
+++ b/Parser.st	Mon Jun 15 21:44:03 1998 +0200
@@ -4098,6 +4098,8 @@
 "/                                  index:varIndex
 "/                              selfClass:aClass
 "/                ].
+            ] ifFalse:[
+                "/ self halt:'oops - should not happen'.
             ]
         ].
 
@@ -4109,12 +4111,17 @@
             aClass notNil ifTrue:[
                 parseForCode ifFalse:[self rememberClassVarUsed:varName].
                 ^ VariableNode type:#ClassVariable class:aClass name:varName
-            ]
+            ].
+            "/ self halt:'oops - should not happen'.
         ].
 
         "is it a private-class ?"
 
-        aClass := classToCompileFor.
+        contextToEvaluateIn notNil ifTrue:[
+            aClass := contextToEvaluateIn method who methodClass.
+        ] ifFalse:[
+            aClass := classToCompileFor
+        ].
         aClass isMeta ifTrue:[
             aClass := aClass soleInstance.
         ].
@@ -4147,7 +4154,7 @@
 
     ^ #Error
 
-    "Modified: / 7.5.1998 / 01:40:55 / cg"
+    "Modified: / 15.6.1998 / 20:55:45 / cg"
 ! !
 
 !Parser methodsFor:'private'!
@@ -4264,14 +4271,19 @@
 
     |aClass|
 
-    aClass := classToCompileFor.
+    contextToEvaluateIn notNil ifTrue:[
+        aClass := contextToEvaluateIn method who methodClass.
+    ] ifFalse:[
+        aClass := classToCompileFor
+    ].
+
     [aClass notNil] whileTrue:[
-	(aClass class instVarNames includes:aString) ifTrue:[ ^ aClass].
-	aClass := aClass superclass
+        (aClass class instVarNames includes:aString) ifTrue:[ ^ aClass].
+        aClass := aClass superclass
     ].
     ^ nil
 
-    "Modified: 4.1.1997 / 14:42:15 / cg"
+    "Modified: / 15.6.1998 / 20:53:37 / cg"
 !
 
 inWhichClassIsClassVar:aString
@@ -4280,13 +4292,18 @@
 
     |aClass className baseClass|
 
-    aClass := classToCompileFor.
+    contextToEvaluateIn notNil ifTrue:[
+        aClass := contextToEvaluateIn method who methodClass.
+    ] ifFalse:[
+        aClass := classToCompileFor
+    ].
+
     aClass isMeta ifTrue:[
-	className := aClass name copyWithoutLast:6.
-	baseClass := Smalltalk at:(className asSymbol).
-	baseClass notNil ifTrue:[
-	    aClass := baseClass
-	]
+        className := aClass name copyWithoutLast:6.
+        baseClass := Smalltalk at:(className asSymbol).
+        baseClass notNil ifTrue:[
+            aClass := baseClass
+        ]
     ].
     ^ aClass whichClassDefinesClassVar:aString
 
@@ -4296,8 +4313,8 @@
 "/    ].
 "/    ^ nil
 
-    "Modified: 17.6.1996 / 17:18:41 / stefan"
-    "Modified: 4.1.1997 / 15:57:11 / cg"
+    "Modified: / 17.6.1996 / 17:18:41 / stefan"
+    "Modified: / 15.6.1998 / 20:53:49 / cg"
 ! !
 
 !Parser methodsFor:'queries'!
@@ -4305,36 +4322,49 @@
 classesClassInstVarNames
     "caching allInstVarNames for next compilation saves time ..."
 
-    |names|
+    |names cls|
+
+    contextToEvaluateIn notNil ifTrue:[
+        cls := contextToEvaluateIn method who methodClass.
+    ] ifFalse:[
+        cls := classToCompileFor
+    ].
 
     [
-        (PrevClassInstVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[
+        (PrevClassInstVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[
             PrevClass notNil ifTrue:[
                 PrevClass removeDependent:Parser
             ].
-            PrevClass := classToCompileFor.
-
-            PrevClassInstVarNames := classToCompileFor class allInstVarNames.
+            PrevClass := cls.
+
+            PrevClassInstVarNames := cls class allInstVarNames.
             PrevClass addDependent:Parser.
         ].
         names := PrevClassInstVarNames.
     ] valueUninterruptably.
     ^ names
 
-    "Created: 14.10.1996 / 18:03:35 / cg"
+    "Created: / 14.10.1996 / 18:03:35 / cg"
+    "Modified: / 15.6.1998 / 20:50:10 / cg"
 !
 
 classesClassVarNames
     "caching allClassVarNames for next compilation saves time ..."
 
-    |aClass names|
+    |aClass names cls|
+
+    contextToEvaluateIn notNil ifTrue:[
+        cls := contextToEvaluateIn method who methodClass.
+    ] ifFalse:[
+        cls := classToCompileFor
+    ].
 
     [
-        (PrevClassVarNames isNil or:[PrevClass ~~ classToCompileFor]) ifTrue:[
+        (PrevClassVarNames isNil or:[PrevClass ~~ cls]) ifTrue:[
             PrevClass notNil ifTrue:[
                 PrevClass removeDependent:Parser
             ].
-            aClass := PrevClass := classToCompileFor.
+            aClass := PrevClass := cls.
             aClass isMeta ifTrue:[
                 aClass := aClass soleInstance.
                 aClass isNil ifTrue:[
@@ -4348,9 +4378,9 @@
     ] valueUninterruptably.
     ^ names
 
-    "Modified: 17.6.1996 / 17:15:53 / stefan"
-    "Modified: 21.6.1996 / 15:21:17 / cg"
-    "Created: 14.10.1996 / 18:02:41 / cg"
+    "Modified: / 17.6.1996 / 17:15:53 / stefan"
+    "Created: / 14.10.1996 / 18:02:41 / cg"
+    "Modified: / 15.6.1998 / 20:50:31 / cg"
 !
 
 classesInstVarNames
@@ -4603,6 +4633,6 @@
 !Parser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.177 1998-06-12 18:49:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Parser.st,v 1.178 1998-06-15 19:44:03 cg Exp $'
 ! !
 Parser initialize!