ConstantNode.st
changeset 104 2016bfa4cd45
parent 103 f4a69d7dd387
child 106 2653f74569d1
equal deleted inserted replaced
103:f4a69d7dd387 104:2016bfa4cd45
    20 
    20 
    21 ConstantNode comment:'
    21 ConstantNode comment:'
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    22 COPYRIGHT (c) 1989 by Claus Gittinger
    23 	      All Rights Reserved
    23 	      All Rights Reserved
    24 
    24 
    25 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.14 1995-08-11 16:02:58 claus Exp $
    25 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.15 1995-08-11 20:27:54 claus Exp $
    26 '!
    26 '!
    27 
    27 
    28 !ConstantNode class methodsFor:'documentation'!
    28 !ConstantNode class methodsFor:'documentation'!
    29 
    29 
    30 copyright
    30 copyright
    41 "
    41 "
    42 !
    42 !
    43 
    43 
    44 version
    44 version
    45 "
    45 "
    46 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.14 1995-08-11 16:02:58 claus Exp $
    46 $Header: /cvs/stx/stx/libcomp/ConstantNode.st,v 1.15 1995-08-11 20:27:54 claus Exp $
    47 "
    47 "
    48 !
    48 !
    49 
    49 
    50 documentation
    50 documentation
    51 "
    51 "
   163     ^ aValue
   163     ^ aValue
   164 ! !
   164 ! !
   165 
   165 
   166 !ConstantNode methodsFor:'code generation'!
   166 !ConstantNode methodsFor:'code generation'!
   167 
   167 
   168 codeOn:aStream inBlock:b
   168 codeOn:aStream inBlock:b for:aCompiler
   169     "generated code for the constant"
   169     "generated code for the constant"
   170 
   170 
   171     |code|
   171     |code index|
   172 
   172 
   173     (type == #Integer) ifTrue:[
   173     (type == #Integer) ifTrue:[
   174 	(value between: -128 and:127) ifTrue:[
   174 	(value between: -128 and:127) ifTrue:[
   175 	    (value == 0) ifTrue:[
   175 	    (value == 0) ifTrue:[
   176 		code := #push0
   176 		code := #push0
   206 	code := #pushFalse.
   206 	code := #pushFalse.
   207     ].
   207     ].
   208     code notNil ifTrue:[
   208     code notNil ifTrue:[
   209 	aStream nextPut:code. ^ self
   209 	aStream nextPut:code. ^ self
   210     ].
   210     ].
   211     aStream nextPut:#pushLit; nextPut:value
   211     index := aCompiler addLiteral:value.
   212 !
   212     index <= 8 ifTrue:[
   213 
   213 	aStream nextPut:(#(pushLit1 pushLit2 pushLit3 pushLit4
   214 codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded
   214 			   pushLit5 pushLit6 pushLit7 pushLit8) at:index).
       
   215     ] ifFalse:[
       
   216 	aStream nextPut:#pushLit; nextPut:value
       
   217     ].
       
   218 !
       
   219 
       
   220 codeStoreOn:aStream inBlock:codeBlock valueNeeded:valueNeeded for:aCompiler
   215     "not sent - parser checks for this"
   221     "not sent - parser checks for this"
   216 
   222 
   217     ^ self error:'assignment to literals not allowed'
   223     ^ self error:'assignment to literals not allowed'
   218 ! !
   224 ! !
   219 
   225