author | Claus Gittinger <cg@exept.de> |
Sun, 17 Jun 2018 08:31:51 +0200 | |
changeset 4278 | d756ed6a7120 |
parent 4233 | 03bacf52b5b7 |
child 4315 | 734f7d2b6efe |
child 4384 | aee25576d864 |
child 4463 | 37e65d2ffde2 |
permissions | -rw-r--r-- |
4226 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
4 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
52 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1046 | 14 |
"{ Package: 'stx:libcomp' }" |
15 |
||
4226 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
ParseNode subclass:#AssignmentNode |
2509 | 19 |
instanceVariableNames:'variable expression lineNr endLineNr endCharPosition' |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
20 |
classVariableNames:'' |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
21 |
poolDictionaries:'' |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
22 |
category:'System-Compiler-Support' |
0 | 23 |
! |
24 |
||
20 | 25 |
!AssignmentNode class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
52 | 30 |
All Rights Reserved |
20 | 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 |
documentation |
|
42 |
" |
|
261 | 43 |
node for parse-trees, representing assignments. |
44 |
This is a helper class for the compiler. |
|
263 | 45 |
|
46 |
[author:] |
|
47 |
Claus Gittinger |
|
48 |
||
20 | 49 |
" |
50 |
! ! |
|
0 | 51 |
|
52 |
!AssignmentNode class methodsFor:'instance creation'! |
|
53 |
||
54 |
variable:v expression:e |
|
55 |
^ (self basicNew) variable:v expression:e |
|
56 |
! ! |
|
57 |
||
140 | 58 |
!AssignmentNode methodsFor:'accessing'! |
0 | 59 |
|
2509 | 60 |
endCharPosition |
61 |
^ endCharPosition |
|
62 |
! |
|
63 |
||
64 |
endCharPosition:something |
|
65 |
endCharPosition := something. |
|
66 |
! |
|
67 |
||
68 |
endLineNr |
|
69 |
^ endLineNr |
|
70 |
! |
|
71 |
||
72 |
endLineNr:something |
|
73 |
endLineNr := something. |
|
74 |
! |
|
75 |
||
140 | 76 |
expression |
77 |
^ expression |
|
78 |
! |
|
0 | 79 |
|
2509 | 80 |
expression:something |
2603 | 81 |
|
82 |
expression notNil ifTrue:[expression parent: nil]. |
|
2509 | 83 |
expression := something. |
2603 | 84 |
expression notNil ifTrue:[expression parent: self]. |
85 |
||
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
|
86 |
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
|
87 |
|
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
|
88 |
"Modified: / 27-07-2011 / 13:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2509 | 89 |
! |
90 |
||
91 |
lineNr |
|
92 |
^ lineNr |
|
93 |
! |
|
94 |
||
95 |
lineNr:something |
|
96 |
lineNr := something. |
|
97 |
! |
|
98 |
||
711 | 99 |
lineNumber |
375 | 100 |
"return lineNr" |
101 |
||
102 |
^ lineNr |
|
103 |
||
711 | 104 |
"Created: / 14.5.1998 / 19:30:49 / cg" |
375 | 105 |
! |
106 |
||
711 | 107 |
lineNumber:something |
375 | 108 |
"set lineNr" |
109 |
||
110 |
lineNr := something. |
|
111 |
||
711 | 112 |
"Created: / 14.5.1998 / 19:30:54 / cg" |
375 | 113 |
! |
114 |
||
542 | 115 |
variable |
116 |
^ variable |
|
117 |
||
118 |
"Created: 19.6.1997 / 17:08:58 / cg" |
|
119 |
! |
|
120 |
||
2509 | 121 |
variable:something |
2603 | 122 |
|
123 |
variable notNil ifTrue:[variable parent: nil]. |
|
2509 | 124 |
variable := something. |
2603 | 125 |
variable notNil ifTrue:[variable parent: self]. |
126 |
||
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
|
127 |
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
|
128 |
|
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
|
129 |
"Modified: / 27-07-2011 / 13:50:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2509 | 130 |
! |
131 |
||
0 | 132 |
variable:v expression:e |
2603 | 133 |
variable notNil ifTrue:[variable parent: nil]. |
0 | 134 |
variable := v. |
2603 | 135 |
variable notNil ifTrue:[variable parent: self]. |
136 |
||
3447 | 137 |
e == #Error ifTrue:[ |
138 |
^ self |
|
139 |
]. |
|
140 |
||
2603 | 141 |
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
|
142 |
expression := e. |
3447 | 143 |
expression notNil ifTrue:[ |
144 |
expression parent: self. |
|
145 |
endPosition := expression endPosition. |
|
146 |
]. |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
147 |
|
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
|
148 |
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
|
149 |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
150 |
"/ 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
|
151 |
"/ cannot be inlined. |
3489 | 152 |
(e notNil and:[e realNode isBlockNode]) ifTrue:[ |
153 |
e realNode possiblyInlined:false |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
154 |
] |
2509 | 155 |
|
156 |
"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
|
157 |
"Modified: / 27-07-2011 / 13:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 158 |
! ! |
159 |
||
160 |
!AssignmentNode methodsFor:'code generation'! |
|
161 |
||
117 | 162 |
checkIncDecOn:aStream |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
163 |
"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
|
164 |
If so, code it and return true. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
165 |
Otherwise, return false." |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
166 |
|
117 | 167 |
|sel erec arg code| |
0 | 168 |
|
169 |
(variable type == #MethodVariable) ifTrue:[ |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
170 |
expression isBinaryMessage ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
171 |
sel := expression selector. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
172 |
erec := expression receiver. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
173 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
174 |
((sel == #+) or:[sel == #-]) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
175 |
(erec type == #MethodVariable) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
176 |
(erec index == variable index) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
177 |
arg := expression arg1. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
178 |
arg isConstant ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
179 |
(arg value == 1) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
180 |
(sel == #+) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
181 |
code := #incMethodVar |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
182 |
] ifFalse:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
183 |
code := #decMethodVar |
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 |
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
|
186 |
^ true |
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 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
192 |
] |
0 | 193 |
]. |
117 | 194 |
^ false |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
195 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
196 |
"Modified: 1.3.1996 / 00:08:02 / cg" |
117 | 197 |
! |
198 |
||
199 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
200 |
(self checkIncDecOn:aStream) ifTrue:[^ self]. |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
201 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
202 |
self codeNormalOn:aStream valueNeeded:false inBlock:b for:aCompiler |
117 | 203 |
|
204 |
"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
|
205 |
"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
|
206 |
! |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
207 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
208 |
codeNormalOn:aStream valueNeeded:forValue inBlock:b for:aCompiler |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
209 |
|isSend litIdx selLitIdx| |
386 | 210 |
|
211 |
isSend := expression isMessage. |
|
212 |
(lineNr notNil |
|
213 |
and:[isSend not]) ifTrue:[ |
|
817 | 214 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
386 | 215 |
]. |
216 |
||
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
217 |
"/ must do workspace variables here, because these |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
218 |
"/ need the receiver (the valueHolder) to be pushed first, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
219 |
"/ then the value which is to be stored. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
220 |
"/ finally, a #value: message is generated. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
221 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
222 |
(variable type == #WorkspaceVariable) ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
223 |
"/ this is done by keeping the valueHolder in the literalArray, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
224 |
"/ and coding a #value: message here. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
225 |
|
876 | 226 |
litIdx := aCompiler addLiteral:variable token. |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
227 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
228 |
|
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
229 |
expression codeOn:aStream inBlock:b for:aCompiler. |
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 |
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
|
232 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:(lineNr ? 1) on:aStream for:aCompiler. |
1046 | 233 |
aStream nextPut:#drop. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
234 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
235 |
forValue ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
236 |
(expression isConstant or:[expression isVariable]) ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
237 |
expression codeOn:aStream inBlock:b for:aCompiler. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
238 |
] ifFalse:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
239 |
"/ fetch value from the holder - sigh |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
240 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
871
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 |
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
|
243 |
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
|
244 |
] |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
245 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
246 |
^ self |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
247 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
248 |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
249 |
expression codeOn:aStream inBlock:b for:aCompiler. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
250 |
expression isBlock ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
251 |
variable isLocal ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
252 |
aStream nextPut:#blockRef |
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 |
]. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
255 |
|
386 | 256 |
(lineNr notNil |
257 |
and:[isSend]) ifTrue:[ |
|
817 | 258 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
375 | 259 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
260 |
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
|
261 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
262 |
"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
|
263 |
"Created: 1.3.1996 / 00:41:43 / cg" |
386 | 264 |
"Modified: 21.10.1996 / 16:26:33 / cg" |
0 | 265 |
! |
266 |
||
104 | 267 |
codeOn:aStream inBlock:b for:aCompiler |
117 | 268 |
(self checkIncDecOn:aStream) ifTrue:[ |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
269 |
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
|
270 |
^ self |
117 | 271 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
272 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
273 |
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
|
274 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
275 |
"Modified: 1.3.1996 / 00:42:21 / cg" |
0 | 276 |
! ! |
277 |
||
1035 | 278 |
!AssignmentNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
279 |
|
4233 | 280 |
allSubNodesDo:aBlock |
281 |
aBlock value:variable. |
|
282 |
expression allNodesDo:aBlock |
|
283 |
! |
|
284 |
||
4226 | 285 |
messagesDo:aBlock |
286 |
"evaluate aBlock for each message-node here and in subnodes" |
|
287 |
||
288 |
expression messagesDo:aBlock. |
|
289 |
! |
|
290 |
||
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
291 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
292 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
293 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
294 |
^ anEnumerator doAssignment:self variable:variable value:expression |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
295 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
296 |
"Modified: 19.6.1997 / 16:37:50 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
297 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
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 |