# HG changeset patch # User Claus Gittinger # Date 930404781 -7200 # Node ID ada5288239e4dbc8c5ebe2c6ba9c635039dec3ce # Parent 1db26e4ce4c4c6a5d6a61d5cdd7206b77c93f3df support for workspace variables diff -r 1db26e4ce4c4 -r ada5288239e4 AssignNd.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 $' ! ! diff -r 1db26e4ce4c4 -r ada5288239e4 AssignmentNode.st --- 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 $' ! !