AssignmentNode.st
author claus
Wed, 13 Oct 1993 01:26:26 +0100
changeset 3 b63b8a6b71fb
parent 0 7ad01559b262
child 4 f6fd83437415
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1989-93 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

ParseNode subclass:#AssignmentNode
       instanceVariableNames:'variable expression'
       classVariableNames:''
       poolDictionaries:''
       category:'System-Compiler-Support'
!

AssignmentNode comment:'

COPYRIGHT (c) 1989-93 by Claus Gittinger
              All Rights Reserved

$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.2 1993-10-13 00:25:24 claus Exp $
'!

!AssignmentNode class methodsFor:'instance creation'!

variable:v expression:e
    ^ (self basicNew) variable:v expression:e
! !

!AssignmentNode methodsFor:'evaluating'!

evaluate
    |value|
    value := expression evaluate.
    variable store:value.
    ^ value
! !

!AssignmentNode methodsFor:'accessing'!

variable:v expression:e
    variable := v.
    expression := e
! !

!AssignmentNode methodsFor:'code generation'!

codeForSideEffectOn:aStream inBlock:b
    |sel arg|

    (variable type == #MethodVariable) ifTrue:[
        expression isBinaryMessage ifTrue:[
            sel := expression selector.
            ((sel == #+) or:[sel == #-]) ifTrue:[
                (expression receiver type == #MethodVariable) ifTrue:[
                    (expression receiver index == variable index) ifTrue:[
                        arg := expression arg1.
                        arg isConstant ifTrue:[
                            (arg value == 1) ifTrue:[
                                (sel == #+) ifTrue:[
                                    aStream nextPut:#incMethodVar
                                ] ifFalse:[
                                    aStream nextPut:#decMethodVar
                                ].
                                aStream nextPut:(variable index).
                                ^ self
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ].
    expression codeOn:aStream inBlock:b.
    variable codeStoreOn:aStream inBlock:b valueNeeded:false
!

codeOn:aStream inBlock:b
    expression codeOn:aStream inBlock:b.
    variable codeStoreOn:aStream inBlock:b valueNeeded:true
! !

!AssignmentNode methodsFor:'printing'!

printOn:aStream indent:i
    variable printOn:aStream.
    aStream nextPutAll:' := '.
    expression printOn:aStream
! !