0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
ParseNode subclass:#AssignmentNode
|
|
14 |
instanceVariableNames:'variable expression'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Compiler-Support'
|
|
18 |
!
|
|
19 |
|
|
20 |
AssignmentNode comment:'
|
4
|
21 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
22 |
All Rights Reserved
|
20
|
23 |
'!
|
0
|
24 |
|
20
|
25 |
!AssignmentNode class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
version
|
|
42 |
"
|
|
43 |
$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.6 1994-06-02 20:25:45 claus Exp $
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
|
47 |
documentation
|
|
48 |
"
|
|
49 |
node for parse-trees, representing assignments
|
|
50 |
"
|
|
51 |
! !
|
0
|
52 |
|
|
53 |
!AssignmentNode class methodsFor:'instance creation'!
|
|
54 |
|
|
55 |
variable:v expression:e
|
|
56 |
^ (self basicNew) variable:v expression:e
|
|
57 |
! !
|
|
58 |
|
|
59 |
!AssignmentNode methodsFor:'evaluating'!
|
|
60 |
|
|
61 |
evaluate
|
|
62 |
|value|
|
|
63 |
value := expression evaluate.
|
|
64 |
variable store:value.
|
|
65 |
^ value
|
|
66 |
! !
|
|
67 |
|
17
|
68 |
!AssignmentNode methodsFor:'queries'!
|
|
69 |
|
|
70 |
isAssignment
|
|
71 |
"return true, if this is a node for an assignment"
|
|
72 |
|
|
73 |
^ true
|
|
74 |
! !
|
|
75 |
|
0
|
76 |
!AssignmentNode methodsFor:'accessing'!
|
|
77 |
|
|
78 |
variable:v expression:e
|
|
79 |
variable := v.
|
|
80 |
expression := e
|
17
|
81 |
!
|
|
82 |
|
|
83 |
expression
|
|
84 |
^ expression
|
0
|
85 |
! !
|
|
86 |
|
|
87 |
!AssignmentNode methodsFor:'code generation'!
|
|
88 |
|
|
89 |
codeForSideEffectOn:aStream inBlock:b
|
|
90 |
|sel arg|
|
|
91 |
|
|
92 |
(variable type == #MethodVariable) ifTrue:[
|
|
93 |
expression isBinaryMessage ifTrue:[
|
|
94 |
sel := expression selector.
|
|
95 |
((sel == #+) or:[sel == #-]) ifTrue:[
|
|
96 |
(expression receiver type == #MethodVariable) ifTrue:[
|
|
97 |
(expression receiver index == variable index) ifTrue:[
|
|
98 |
arg := expression arg1.
|
|
99 |
arg isConstant ifTrue:[
|
|
100 |
(arg value == 1) ifTrue:[
|
|
101 |
(sel == #+) ifTrue:[
|
|
102 |
aStream nextPut:#incMethodVar
|
|
103 |
] ifFalse:[
|
|
104 |
aStream nextPut:#decMethodVar
|
|
105 |
].
|
6
|
106 |
aStream nextPut:(expression lineNumber).
|
0
|
107 |
aStream nextPut:(variable index).
|
|
108 |
^ self
|
|
109 |
]
|
|
110 |
]
|
|
111 |
]
|
|
112 |
]
|
|
113 |
]
|
|
114 |
]
|
|
115 |
].
|
|
116 |
expression codeOn:aStream inBlock:b.
|
|
117 |
variable codeStoreOn:aStream inBlock:b valueNeeded:false
|
|
118 |
!
|
|
119 |
|
|
120 |
codeOn:aStream inBlock:b
|
|
121 |
expression codeOn:aStream inBlock:b.
|
|
122 |
variable codeStoreOn:aStream inBlock:b valueNeeded:true
|
|
123 |
! !
|
|
124 |
|
|
125 |
!AssignmentNode methodsFor:'printing'!
|
|
126 |
|
|
127 |
printOn:aStream indent:i
|
|
128 |
variable printOn:aStream.
|
|
129 |
aStream nextPutAll:' := '.
|
|
130 |
expression printOn:aStream
|
|
131 |
! !
|