author | Stefan Vogel <sv@exept.de> |
Mon, 12 Dec 2016 16:38:47 +0100 | |
changeset 4080 | 08869106d07e |
parent 3489 | 6ebe2c95c883 |
child 4226 | 6aa254af709f |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
52 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
1046 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
0 | 14 |
ParseNode subclass:#AssignmentNode |
2509 | 15 |
instanceVariableNames:'variable expression lineNr endLineNr endCharPosition' |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
16 |
classVariableNames:'' |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
17 |
poolDictionaries:'' |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
18 |
category:'System-Compiler-Support' |
0 | 19 |
! |
20 |
||
20 | 21 |
!AssignmentNode class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
52 | 26 |
All Rights Reserved |
20 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
261 | 39 |
node for parse-trees, representing assignments. |
40 |
This is a helper class for the compiler. |
|
263 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
44 |
||
20 | 45 |
" |
46 |
! ! |
|
0 | 47 |
|
48 |
!AssignmentNode class methodsFor:'instance creation'! |
|
49 |
||
50 |
variable:v expression:e |
|
51 |
^ (self basicNew) variable:v expression:e |
|
52 |
! ! |
|
53 |
||
140 | 54 |
!AssignmentNode methodsFor:'accessing'! |
0 | 55 |
|
2509 | 56 |
endCharPosition |
57 |
^ endCharPosition |
|
58 |
! |
|
59 |
||
60 |
endCharPosition:something |
|
61 |
endCharPosition := something. |
|
62 |
! |
|
63 |
||
64 |
endLineNr |
|
65 |
^ endLineNr |
|
66 |
! |
|
67 |
||
68 |
endLineNr:something |
|
69 |
endLineNr := something. |
|
70 |
! |
|
71 |
||
140 | 72 |
expression |
73 |
^ expression |
|
74 |
! |
|
0 | 75 |
|
2509 | 76 |
expression:something |
2603 | 77 |
|
78 |
expression notNil ifTrue:[expression parent: nil]. |
|
2509 | 79 |
expression := something. |
2603 | 80 |
expression notNil ifTrue:[expression parent: self]. |
81 |
||
2609
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
82 |
endPosition := expression endPosition. |
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
83 |
|
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
84 |
"Modified: / 27-07-2011 / 13:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2509 | 85 |
! |
86 |
||
87 |
lineNr |
|
88 |
^ lineNr |
|
89 |
! |
|
90 |
||
91 |
lineNr:something |
|
92 |
lineNr := something. |
|
93 |
! |
|
94 |
||
711 | 95 |
lineNumber |
375 | 96 |
"return lineNr" |
97 |
||
98 |
^ lineNr |
|
99 |
||
711 | 100 |
"Created: / 14.5.1998 / 19:30:49 / cg" |
375 | 101 |
! |
102 |
||
711 | 103 |
lineNumber:something |
375 | 104 |
"set lineNr" |
105 |
||
106 |
lineNr := something. |
|
107 |
||
711 | 108 |
"Created: / 14.5.1998 / 19:30:54 / cg" |
375 | 109 |
! |
110 |
||
542 | 111 |
variable |
112 |
^ variable |
|
113 |
||
114 |
"Created: 19.6.1997 / 17:08:58 / cg" |
|
115 |
! |
|
116 |
||
2509 | 117 |
variable:something |
2603 | 118 |
|
119 |
variable notNil ifTrue:[variable parent: nil]. |
|
2509 | 120 |
variable := something. |
2603 | 121 |
variable notNil ifTrue:[variable parent: self]. |
122 |
||
2609
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
123 |
startPosition := variable startPosition. |
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
124 |
|
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
125 |
"Modified: / 27-07-2011 / 13:50:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2509 | 126 |
! |
127 |
||
0 | 128 |
variable:v expression:e |
2603 | 129 |
variable notNil ifTrue:[variable parent: nil]. |
0 | 130 |
variable := v. |
2603 | 131 |
variable notNil ifTrue:[variable parent: self]. |
132 |
||
3447 | 133 |
e == #Error ifTrue:[ |
134 |
^ self |
|
135 |
]. |
|
136 |
||
2603 | 137 |
expression notNil ifTrue:[expression parent: nil]. |
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
138 |
expression := e. |
3447 | 139 |
expression notNil ifTrue:[ |
140 |
expression parent: self. |
|
141 |
endPosition := expression endPosition. |
|
142 |
]. |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
143 |
|
2609
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
144 |
startPosition := variable startPosition. |
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
145 |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
146 |
"/ any block, which gets assigned to something |
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
147 |
"/ cannot be inlined. |
3489 | 148 |
(e notNil and:[e realNode isBlockNode]) ifTrue:[ |
149 |
e realNode possiblyInlined:false |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
150 |
] |
2509 | 151 |
|
152 |
"Modified: / 22-02-2011 / 12:52:56 / Jakub <zelenja7@fel.cvut.cz>" |
|
2609
571b92101923
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2603
diff
changeset
|
153 |
"Modified: / 27-07-2011 / 13:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 154 |
! ! |
155 |
||
156 |
!AssignmentNode methodsFor:'code generation'! |
|
157 |
||
117 | 158 |
checkIncDecOn:aStream |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
159 |
"check if we can use incMvar / decMvar instruction. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
160 |
If so, code it and return true. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
161 |
Otherwise, return false." |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
162 |
|
117 | 163 |
|sel erec arg code| |
0 | 164 |
|
165 |
(variable type == #MethodVariable) ifTrue:[ |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
166 |
expression isBinaryMessage ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
167 |
sel := expression selector. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
168 |
erec := expression receiver. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
169 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
170 |
((sel == #+) or:[sel == #-]) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
171 |
(erec type == #MethodVariable) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
172 |
(erec index == variable index) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
173 |
arg := expression arg1. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
174 |
arg isConstant ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
175 |
(arg value == 1) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
176 |
(sel == #+) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
177 |
code := #incMethodVar |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
178 |
] ifFalse:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
179 |
code := #decMethodVar |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
180 |
]. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
181 |
aStream nextPut:code; nextPut:(expression lineNumber); nextPut:(variable index). |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
182 |
^ true |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
183 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
184 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
185 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
186 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
187 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
188 |
] |
0 | 189 |
]. |
117 | 190 |
^ false |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
191 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
192 |
"Modified: 1.3.1996 / 00:08:02 / cg" |
117 | 193 |
! |
194 |
||
195 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
196 |
(self checkIncDecOn:aStream) ifTrue:[^ self]. |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
197 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
198 |
self codeNormalOn:aStream valueNeeded:false inBlock:b for:aCompiler |
117 | 199 |
|
200 |
"Modified: 4.9.1995 / 14:38:10 / claus" |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
201 |
"Modified: 1.3.1996 / 00:42:10 / cg" |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
202 |
! |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
203 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
204 |
codeNormalOn:aStream valueNeeded:forValue inBlock:b for:aCompiler |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
205 |
|isSend litIdx selLitIdx| |
386 | 206 |
|
207 |
isSend := expression isMessage. |
|
208 |
(lineNr notNil |
|
209 |
and:[isSend not]) ifTrue:[ |
|
817 | 210 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
386 | 211 |
]. |
212 |
||
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
213 |
"/ must do workspace variables here, because these |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
214 |
"/ need the receiver (the valueHolder) to be pushed first, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
215 |
"/ then the value which is to be stored. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
216 |
"/ finally, a #value: message is generated. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
217 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
218 |
(variable type == #WorkspaceVariable) ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
219 |
"/ this is done by keeping the valueHolder in the literalArray, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
220 |
"/ and coding a #value: message here. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
221 |
|
876 | 222 |
litIdx := aCompiler addLiteral:variable token. |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
223 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
224 |
|
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
225 |
expression codeOn:aStream inBlock:b for:aCompiler. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
226 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
227 |
selLitIdx := aCompiler addLiteral:#value:. |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
228 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:(lineNr ? 1) on:aStream for:aCompiler. |
1046 | 229 |
aStream nextPut:#drop. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
230 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
231 |
forValue ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
232 |
(expression isConstant or:[expression isVariable]) ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
233 |
expression codeOn:aStream inBlock:b for:aCompiler. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
234 |
] ifFalse:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
235 |
"/ fetch value from the holder - sigh |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
236 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
237 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
238 |
selLitIdx := aCompiler addLiteral:#value. |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
239 |
self emitSendLiteralIndex:selLitIdx numArgs:0 line:(lineNr ? 1) on:aStream for:aCompiler. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
240 |
] |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
241 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
242 |
^ self |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
243 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
244 |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
245 |
expression codeOn:aStream inBlock:b for:aCompiler. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
246 |
expression isBlock ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
247 |
variable isLocal ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
248 |
aStream nextPut:#blockRef |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
249 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
250 |
]. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
251 |
|
386 | 252 |
(lineNr notNil |
253 |
and:[isSend]) ifTrue:[ |
|
817 | 254 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
375 | 255 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
256 |
variable codeStoreOn:aStream inBlock:b valueNeeded:forValue for:aCompiler |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
257 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
258 |
"Modified: 4.9.1995 / 14:38:10 / claus" |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
259 |
"Created: 1.3.1996 / 00:41:43 / cg" |
386 | 260 |
"Modified: 21.10.1996 / 16:26:33 / cg" |
0 | 261 |
! |
262 |
||
104 | 263 |
codeOn:aStream inBlock:b for:aCompiler |
117 | 264 |
(self checkIncDecOn:aStream) ifTrue:[ |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
265 |
expression receiver codeOn:aStream inBlock:b for:aCompiler. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
266 |
^ self |
117 | 267 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
268 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
269 |
self codeNormalOn:aStream valueNeeded:true inBlock:b for:aCompiler |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
270 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
271 |
"Modified: 1.3.1996 / 00:42:21 / cg" |
0 | 272 |
! ! |
273 |
||
1035 | 274 |
!AssignmentNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
275 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
276 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
277 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
278 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
279 |
^ anEnumerator doAssignment:self variable:variable value:expression |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
280 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
281 |
"Modified: 19.6.1997 / 16:37:50 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
282 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
283 |
|
1035 | 284 |
!AssignmentNode methodsFor:'evaluation'! |
140 | 285 |
|
1384 | 286 |
evaluateIn:anEnvironment |
140 | 287 |
|value| |
1384 | 288 |
|
289 |
value := expression evaluateIn:anEnvironment. |
|
140 | 290 |
variable store:value. |
291 |
^ value |
|
292 |
! ! |
|
293 |
||
1079 | 294 |
!AssignmentNode methodsFor:'printing & storing'! |
0 | 295 |
|
296 |
printOn:aStream indent:i |
|
297 |
variable printOn:aStream. |
|
1173 | 298 |
self printOperatorOn:aStream. |
299 |
expression printOn:aStream |
|
300 |
! |
|
301 |
||
302 |
printOperatorOn:aStream |
|
0 | 303 |
aStream nextPutAll:' := '. |
304 |
! ! |
|
140 | 305 |
|
306 |
!AssignmentNode methodsFor:'queries'! |
|
307 |
||
479 | 308 |
collectBlocksInto:aCollection |
309 |
expression collectBlocksInto:aCollection. |
|
310 |
||
311 |
"Created: 11.1.1997 / 20:54:30 / cg" |
|
312 |
! |
|
313 |
||
2267 | 314 |
evaluatesToConstant |
315 |
"return true, if this is a node for an assignment" |
|
316 |
||
317 |
^ expression evaluatesToConstant |
|
318 |
! |
|
319 |
||
1589 | 320 |
precedence |
321 |
^ 0 |
|
322 |
||
323 |
"Created: / 20-04-2005 / 14:11:09 / cg" |
|
2267 | 324 |
! |
325 |
||
326 |
withConstantValueDo:aBlock |
|
327 |
"return true, if this evaluates to a constant value |
|
328 |
and evaluate aBlock with it" |
|
329 |
||
330 |
^ expression withConstantValueDo:aBlock |
|
140 | 331 |
! ! |
332 |
||
2318 | 333 |
!AssignmentNode methodsFor:'testing'! |
334 |
||
335 |
isAssignment |
|
336 |
"return true, if this is a node for an assignment" |
|
337 |
||
338 |
^ true |
|
339 |
! ! |
|
340 |
||
2603 | 341 |
!AssignmentNode methodsFor:'visiting'! |
342 |
||
343 |
acceptVisitor:aVisitor |
|
344 |
"Double dispatch back to the visitor, passing my type encoded in |
|
345 |
the selector (visitor pattern)" |
|
346 |
||
347 |
"stub code automatically generated - please change if required" |
|
348 |
||
349 |
^ aVisitor visitAssignmentNode:self |
|
350 |
! ! |
|
351 |
||
148 | 352 |
!AssignmentNode class methodsFor:'documentation'! |
353 |
||
2509 | 354 |
version_CVS |
3489 | 355 |
^ '$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.46 2014-06-13 10:37:56 cg Exp $' |
2267 | 356 |
! |
357 |
||
2509 | 358 |
version_SVN |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
359 |
^ '$ Id $' |
148 | 360 |
! ! |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
361 |