--- a/ParseNode.st Wed Aug 09 13:54:18 2006 +0200
+++ b/ParseNode.st Wed Aug 09 13:58:24 2006 +0200
@@ -144,6 +144,110 @@
self class codeLineNumber:nr on:aStream for:aCompiler
! !
+!ParseNode methodsFor:'code generation helpers'!
+
+emitPushGlobalWithLiteralIndex:litIndex on:aTokenCodeStream for:aCompiler
+ litIndex <= 255 ifTrue:[
+ aTokenCodeStream nextPut:#pushGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ litIndex <= 16rFFFF ifTrue:[
+ aTokenCodeStream nextPut:#pushGlobalL; nextPut:litIndex; nextPut:0
+ ] ifFalse:[
+ aTokenCodeStream nextPut:#pushGlobalVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0
+ ].
+ ].
+!
+
+emitPushLiteral:value on:aTokenCodeStream for:aCompiler
+ |index|
+
+ index := aCompiler addLiteral:value.
+ self emitPushLiteralIndex:index on:aTokenCodeStream for:aCompiler
+!
+
+emitPushLiteralIndex:index on:aTokenCodeStream for:aCompiler
+ index <= 8 ifTrue:[
+ aTokenCodeStream
+ nextPut:(#(pushLit1 pushLit2 pushLit3 pushLit4
+ pushLit5 pushLit6 pushLit7 pushLit8) at:index).
+ ] ifFalse:[
+ index <= 255 ifTrue:[
+ aTokenCodeStream nextPut:#pushLitS; nextPut:index
+ ] ifFalse:[
+ index <= 16rFFFF ifTrue:[
+ aTokenCodeStream nextPut:#pushLitL; nextPut:index; nextPut:0
+ ] ifFalse:[
+ aTokenCodeStream nextPut:#pushLitVL; nextPut:0; nextPut:index; nextPut:0; nextPut:0; nextPut:0
+ ]
+ ].
+ ].
+!
+
+emitSendLiteralIndex:litIndex numArgs:nargs line:lineNr on:aStream
+ (litIndex <= 255) ifTrue:[
+ nargs <= 3 ifTrue:[
+ aStream
+ nextPut:(#(send0 send1 send2 send3) at:(nargs+1)); nextPut:lineNr;
+ nextPut:litIndex.
+ ^ self.
+ ].
+ aStream
+ nextPut:#send; nextPut:lineNr;
+ nextPut:litIndex;
+ nextPut:nargs.
+ ^ self.
+ ].
+
+ (litIndex <= 16rFFFF) ifTrue:[
+ aStream
+ nextPut:#sendL; nextPut:lineNr;
+ nextPut:litIndex; nextPut:0;
+ nextPut:nargs.
+ ^ self.
+ ].
+
+ aStream
+ nextPut:#sendVL; nextPut:0; nextPut:lineNr;
+ nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0;
+ nextPut:nargs.
+!
+
+emitStoreGlobalWithLiteralIndex:litIndex on:aTokenCodeStream for:aCompiler
+ litIndex <= 255 ifTrue:[
+ aTokenCodeStream nextPut:#storeGlobalS; nextPut:litIndex
+ ] ifFalse:[
+ litIndex <= 16rFFFF ifTrue:[
+ aTokenCodeStream nextPut:#storeGlobalL; nextPut:litIndex; nextPut:0
+ ] ifFalse:[
+ aTokenCodeStream nextPut:#storeGlobalVL; nextPut:0; nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0; nextPut:0
+ ].
+ ].
+!
+
+emitSuperSendLiteralIndex:litIndex classLiteralIndex:clsLitIndex numArgs:nargs line:lineNr on:aStream
+ (litIndex <= 255 and:[clsLitIndex <= 255]) ifTrue:[
+ aStream
+ nextPut:#superSend; nextPut:lineNr;
+ nextPut:litIndex;
+ nextPut:nargs;
+ nextPut:clsLitIndex.
+ ] ifFalse:[
+ (litIndex <= 16rFFFF and:[clsLitIndex <= 16rFFFF]) ifTrue:[
+ aStream
+ nextPut:#superSendL; nextPut:lineNr;
+ nextPut:litIndex; nextPut:0;
+ nextPut:nargs;
+ nextPut:clsLitIndex; nextPut:0.
+ ] ifFalse:[
+ aStream
+ nextPut:#superSendVL; nextPut:0; nextPut:lineNr;
+ nextPut:litIndex; nextPut:0; nextPut:0; nextPut:0;
+ nextPut:nargs;
+ nextPut:clsLitIndex; nextPut:0; nextPut:0; nextPut:0.
+ ].
+ ].
+! !
+
!ParseNode methodsFor:'enumeration'!
messagesDo:aBlock
@@ -344,5 +448,5 @@
!ParseNode class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libcomp/ParseNode.st,v 1.41 2006-03-16 14:24:57 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libcomp/ParseNode.st,v 1.42 2006-08-09 11:58:24 cg Exp $'
! !