support for workspace variables
authorClaus Gittinger <cg@exept.de>
Sat, 26 Jun 1999 15:46:21 +0200
changeset 871 ada5288239e4
parent 870 1db26e4ce4c4
child 872 7cf38a8125e6
support for workspace variables
AssignNd.st
AssignmentNode.st
--- a/AssignNd.st	Fri Jun 25 18:08:00 1999 +0200
+++ b/AssignNd.st	Sat Jun 26 15:46:21 1999 +0200
@@ -132,7 +132,7 @@
 !
 
 codeNormalOn:aStream valueNeeded:forValue inBlock:b for:aCompiler
-    |isSend|
+    |isSend litIdx selLitIdx|
 
     isSend := expression isMessage.
     (lineNr notNil 
@@ -140,6 +140,44 @@
         self codeLineNumber:lineNr on:aStream for:aCompiler
     ].
 
+    "/ must do workspace variables here, because these
+    "/ need the receiver (the valueHolder) to be pushed first,
+    "/ then the value which is to be stored.
+    "/ finally, a #value: message is generated.
+
+    (variable type == #WorkspaceVariable) ifTrue:[
+        "/ this is done by keeping the valueHolder in the literalArray,
+        "/ and coding a #value: message here.
+
+        litIdx := aCompiler addLiteral:variable value.
+        aStream nextPut:#pushLitS; nextPut:litIdx.
+        expression codeOn:aStream inBlock:b for:aCompiler.
+
+        selLitIdx := aCompiler addLiteral:#value:.
+        selLitIdx <= 255 ifTrue:[
+            aStream nextPut:#sendDrop1; nextPut:(lineNr ? 1); nextPut:selLitIdx.
+        ] ifFalse:[
+            aStream nextPut:#sendDropL; nextPut:(lineNr ? 1); nextPut:selLitIdx; nextPut:0; nextPut:1 "nargs".
+        ].
+
+        forValue ifTrue:[
+            (expression isConstant or:[expression isVariable]) ifTrue:[
+                expression codeOn:aStream inBlock:b for:aCompiler.
+            ] ifFalse:[
+                "/ fetch value from the holder - sigh
+                aStream nextPut:#pushLitS; nextPut:litIdx.
+
+                selLitIdx := aCompiler addLiteral:#value.
+                selLitIdx <= 255 ifTrue:[
+                    aStream nextPut:#send0; nextPut:(lineNr ? 1); nextPut:selLitIdx.
+                ] ifFalse:[
+                    aStream nextPut:#sendL; nextPut:(lineNr ? 1); nextPut:selLitIdx; nextPut:0; nextPut:1 "nargs".
+                ].
+            ]
+        ].
+        ^ self
+    ].
+
     expression codeOn:aStream inBlock:b for:aCompiler.
     expression isBlock ifTrue:[
         variable isLocal ifTrue:[
@@ -213,5 +251,5 @@
 !AssignmentNode class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.27 1999-02-25 14:49:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/AssignNd.st,v 1.28 1999-06-26 13:46:21 cg Exp $'
 ! !
--- a/AssignmentNode.st	Fri Jun 25 18:08:00 1999 +0200
+++ b/AssignmentNode.st	Sat Jun 26 15:46:21 1999 +0200
@@ -132,7 +132,7 @@
 !
 
 codeNormalOn:aStream valueNeeded:forValue inBlock:b for:aCompiler
-    |isSend|
+    |isSend litIdx selLitIdx|
 
     isSend := expression isMessage.
     (lineNr notNil 
@@ -140,6 +140,44 @@
         self codeLineNumber:lineNr on:aStream for:aCompiler
     ].
 
+    "/ must do workspace variables here, because these
+    "/ need the receiver (the valueHolder) to be pushed first,
+    "/ then the value which is to be stored.
+    "/ finally, a #value: message is generated.
+
+    (variable type == #WorkspaceVariable) ifTrue:[
+        "/ this is done by keeping the valueHolder in the literalArray,
+        "/ and coding a #value: message here.
+
+        litIdx := aCompiler addLiteral:variable value.
+        aStream nextPut:#pushLitS; nextPut:litIdx.
+        expression codeOn:aStream inBlock:b for:aCompiler.
+
+        selLitIdx := aCompiler addLiteral:#value:.
+        selLitIdx <= 255 ifTrue:[
+            aStream nextPut:#sendDrop1; nextPut:(lineNr ? 1); nextPut:selLitIdx.
+        ] ifFalse:[
+            aStream nextPut:#sendDropL; nextPut:(lineNr ? 1); nextPut:selLitIdx; nextPut:0; nextPut:1 "nargs".
+        ].
+
+        forValue ifTrue:[
+            (expression isConstant or:[expression isVariable]) ifTrue:[
+                expression codeOn:aStream inBlock:b for:aCompiler.
+            ] ifFalse:[
+                "/ fetch value from the holder - sigh
+                aStream nextPut:#pushLitS; nextPut:litIdx.
+
+                selLitIdx := aCompiler addLiteral:#value.
+                selLitIdx <= 255 ifTrue:[
+                    aStream nextPut:#send0; nextPut:(lineNr ? 1); nextPut:selLitIdx.
+                ] ifFalse:[
+                    aStream nextPut:#sendL; nextPut:(lineNr ? 1); nextPut:selLitIdx; nextPut:0; nextPut:1 "nargs".
+                ].
+            ]
+        ].
+        ^ self
+    ].
+
     expression codeOn:aStream inBlock:b for:aCompiler.
     expression isBlock ifTrue:[
         variable isLocal ifTrue:[
@@ -213,5 +251,5 @@
 !AssignmentNode class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.27 1999-02-25 14:49:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.28 1999-06-26 13:46:21 cg Exp $'
 ! !