author | Stefan Vogel <sv@exept.de> |
Fri, 10 May 2013 15:35:07 +0200 | |
changeset 3163 | a404d6ce2caf |
parent 2609 | 571b92101923 |
child 3447 | fdae5e7e5379 |
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 |
2509 | 129 |
|
2603 | 130 |
variable notNil ifTrue:[variable parent: nil]. |
0 | 131 |
variable := v. |
2603 | 132 |
variable notNil ifTrue:[variable parent: self]. |
133 |
||
134 |
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
|
135 |
expression := e. |
2603 | 136 |
expression notNil ifTrue:[expression parent: self]. |
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
137 |
|
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
|
138 |
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
|
139 |
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
|
140 |
|
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
141 |
"/ 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
|
142 |
"/ cannot be inlined. |
2075
d1a4cd5ab035
changed #variable:expression:
Claus Gittinger <cg@exept.de>
parents:
1806
diff
changeset
|
143 |
(e notNil and:[e isBlockNode]) ifTrue:[ |
882
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
144 |
e possiblyInlined:false |
0bc2a6ecdfad
oops - cannot inline blocks which are assigned or returned.
Claus Gittinger <cg@exept.de>
parents:
876
diff
changeset
|
145 |
] |
2509 | 146 |
|
147 |
"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
|
148 |
"Modified: / 27-07-2011 / 13:50:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0 | 149 |
! ! |
150 |
||
151 |
!AssignmentNode methodsFor:'code generation'! |
|
152 |
||
117 | 153 |
checkIncDecOn:aStream |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
154 |
"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
|
155 |
If so, code it and return true. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
156 |
Otherwise, return false." |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
157 |
|
117 | 158 |
|sel erec arg code| |
0 | 159 |
|
160 |
(variable type == #MethodVariable) ifTrue:[ |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
161 |
expression isBinaryMessage ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
162 |
sel := expression selector. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
163 |
erec := expression receiver. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
164 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
165 |
((sel == #+) or:[sel == #-]) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
166 |
(erec type == #MethodVariable) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
167 |
(erec index == variable index) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
168 |
arg := expression arg1. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
169 |
arg isConstant ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
170 |
(arg value == 1) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
171 |
(sel == #+) ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
172 |
code := #incMethodVar |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
173 |
] ifFalse:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
174 |
code := #decMethodVar |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
175 |
]. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
176 |
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
|
177 |
^ true |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
178 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
179 |
] |
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 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
182 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
183 |
] |
0 | 184 |
]. |
117 | 185 |
^ false |
219
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 |
"Modified: 1.3.1996 / 00:08:02 / cg" |
117 | 188 |
! |
189 |
||
190 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
191 |
(self checkIncDecOn:aStream) ifTrue:[^ self]. |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
192 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
193 |
self codeNormalOn:aStream valueNeeded:false inBlock:b for:aCompiler |
117 | 194 |
|
195 |
"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
|
196 |
"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
|
197 |
! |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
198 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
199 |
codeNormalOn:aStream valueNeeded:forValue inBlock:b for:aCompiler |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
200 |
|isSend litIdx selLitIdx| |
386 | 201 |
|
202 |
isSend := expression isMessage. |
|
203 |
(lineNr notNil |
|
204 |
and:[isSend not]) ifTrue:[ |
|
817 | 205 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
386 | 206 |
]. |
207 |
||
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
208 |
"/ must do workspace variables here, because these |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
209 |
"/ need the receiver (the valueHolder) to be pushed first, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
210 |
"/ then the value which is to be stored. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
211 |
"/ finally, a #value: message is generated. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
212 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
213 |
(variable type == #WorkspaceVariable) ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
214 |
"/ this is done by keeping the valueHolder in the literalArray, |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
215 |
"/ and coding a #value: message here. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
216 |
|
876 | 217 |
litIdx := aCompiler addLiteral:variable token. |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
218 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
219 |
|
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
220 |
expression codeOn:aStream inBlock:b for:aCompiler. |
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 |
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
|
223 |
self emitSendLiteralIndex:selLitIdx numArgs:1 line:(lineNr ? 1) on:aStream for:aCompiler. |
1046 | 224 |
aStream nextPut:#drop. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
225 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
226 |
forValue ifTrue:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
227 |
(expression isConstant or:[expression isVariable]) ifTrue:[ |
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 |
] ifFalse:[ |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
230 |
"/ fetch value from the holder - sigh |
1806
0aeedab88cac
some code savers for common code-emit;
Claus Gittinger <cg@exept.de>
parents:
1589
diff
changeset
|
231 |
self emitPushLiteralIndex:litIdx on:aStream for:aCompiler. |
871
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
232 |
|
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
233 |
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
|
234 |
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
|
235 |
] |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
236 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
237 |
^ self |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
238 |
]. |
ada5288239e4
support for workspace variables
Claus Gittinger <cg@exept.de>
parents:
817
diff
changeset
|
239 |
|
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
240 |
expression codeOn:aStream inBlock:b for:aCompiler. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
241 |
expression isBlock ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
242 |
variable isLocal ifTrue:[ |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
243 |
aStream nextPut:#blockRef |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
244 |
] |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
245 |
]. |
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
246 |
|
386 | 247 |
(lineNr notNil |
248 |
and:[isSend]) ifTrue:[ |
|
817 | 249 |
self codeLineNumber:lineNr on:aStream for:aCompiler |
375 | 250 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
251 |
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
|
252 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
253 |
"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
|
254 |
"Created: 1.3.1996 / 00:41:43 / cg" |
386 | 255 |
"Modified: 21.10.1996 / 16:26:33 / cg" |
0 | 256 |
! |
257 |
||
104 | 258 |
codeOn:aStream inBlock:b for:aCompiler |
117 | 259 |
(self checkIncDecOn:aStream) ifTrue:[ |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
260 |
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
|
261 |
^ self |
117 | 262 |
]. |
219
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
263 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
264 |
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
|
265 |
|
6b977f472cda
care for block-stores into outer contexts
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
266 |
"Modified: 1.3.1996 / 00:42:21 / cg" |
0 | 267 |
! ! |
268 |
||
1035 | 269 |
!AssignmentNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
270 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
271 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
272 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
273 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
274 |
^ anEnumerator doAssignment:self variable:variable value:expression |
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 |
"Modified: 19.6.1997 / 16:37:50 / cg" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
277 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
479
diff
changeset
|
278 |
|
1035 | 279 |
!AssignmentNode methodsFor:'evaluation'! |
140 | 280 |
|
1384 | 281 |
evaluateIn:anEnvironment |
140 | 282 |
|value| |
1384 | 283 |
|
284 |
value := expression evaluateIn:anEnvironment. |
|
140 | 285 |
variable store:value. |
286 |
^ value |
|
287 |
! ! |
|
288 |
||
1079 | 289 |
!AssignmentNode methodsFor:'printing & storing'! |
0 | 290 |
|
291 |
printOn:aStream indent:i |
|
292 |
variable printOn:aStream. |
|
1173 | 293 |
self printOperatorOn:aStream. |
294 |
expression printOn:aStream |
|
295 |
! |
|
296 |
||
297 |
printOperatorOn:aStream |
|
0 | 298 |
aStream nextPutAll:' := '. |
299 |
! ! |
|
140 | 300 |
|
301 |
!AssignmentNode methodsFor:'queries'! |
|
302 |
||
479 | 303 |
collectBlocksInto:aCollection |
304 |
expression collectBlocksInto:aCollection. |
|
305 |
||
306 |
"Created: 11.1.1997 / 20:54:30 / cg" |
|
307 |
! |
|
308 |
||
2267 | 309 |
evaluatesToConstant |
310 |
"return true, if this is a node for an assignment" |
|
311 |
||
312 |
^ expression evaluatesToConstant |
|
313 |
! |
|
314 |
||
1589 | 315 |
precedence |
316 |
^ 0 |
|
317 |
||
318 |
"Created: / 20-04-2005 / 14:11:09 / cg" |
|
2267 | 319 |
! |
320 |
||
321 |
withConstantValueDo:aBlock |
|
322 |
"return true, if this evaluates to a constant value |
|
323 |
and evaluate aBlock with it" |
|
324 |
||
325 |
^ expression withConstantValueDo:aBlock |
|
140 | 326 |
! ! |
327 |
||
2318 | 328 |
!AssignmentNode methodsFor:'testing'! |
329 |
||
330 |
isAssignment |
|
331 |
"return true, if this is a node for an assignment" |
|
332 |
||
333 |
^ true |
|
334 |
! ! |
|
335 |
||
2603 | 336 |
!AssignmentNode methodsFor:'visiting'! |
337 |
||
338 |
acceptVisitor:aVisitor |
|
339 |
"Double dispatch back to the visitor, passing my type encoded in |
|
340 |
the selector (visitor pattern)" |
|
341 |
||
342 |
"stub code automatically generated - please change if required" |
|
343 |
||
344 |
^ aVisitor visitAssignmentNode:self |
|
345 |
! ! |
|
346 |
||
148 | 347 |
!AssignmentNode class methodsFor:'documentation'! |
348 |
||
2509 | 349 |
version_CVS |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
350 |
^ '$Header: /cvs/stx/stx/libcomp/AssignmentNode.st,v 1.44 2013-05-10 13:35:07 stefan Exp $' |
2267 | 351 |
! |
352 |
||
2509 | 353 |
version_SVN |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
354 |
^ '$ Id $' |
148 | 355 |
! ! |
3163
a404d6ce2caf
Emit #lineno16 byte codes only, if line number really changes
Stefan Vogel <sv@exept.de>
parents:
2609
diff
changeset
|
356 |