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