author | Jan Vrany <jan.vrany@labware.com> |
Thu, 27 Oct 2022 14:53:59 +0100 | |
branch | jv |
changeset 4735 | 3b11fb3ede98 |
parent 4723 | 524785227024 |
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 |
" |
|
1080 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
4163 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
0 | 16 |
ParseNode subclass:#StatementNode |
2503 | 17 |
instanceVariableNames:'expression nextStatement lineNr' |
261 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler-Support' |
|
0 | 21 |
! |
22 |
||
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
23 |
!StatementNode class methodsFor:'documentation'! |
20 | 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 |
" |
|
41 |
node for parse-trees, representing statements |
|
261 | 42 |
This is a helper class for the compiler. |
263 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
20 | 46 |
" |
47 |
! ! |
|
0 | 48 |
|
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
49 |
!StatementNode class methodsFor:'instance creation'! |
0 | 50 |
|
51 |
expression:e |
|
52 |
^ (self basicNew) expression:e |
|
53 |
! ! |
|
54 |
||
140 | 55 |
!StatementNode methodsFor:'accessing'! |
0 | 56 |
|
140 | 57 |
expression |
58 |
^ expression |
|
0 | 59 |
! |
60 |
||
2598 | 61 |
expression:something |
62 |
||
63 |
expression notNil ifTrue:[expression parent: nil]. |
|
64 |
expression := something. |
|
2667 | 65 |
expression notNil ifTrue:[ |
66 |
expression parent: self. |
|
67 |
startPosition := expression startPosition. |
|
68 |
endPosition := expression endPosition. |
|
69 |
]. |
|
2613
4e1f7de0d215
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2598
diff
changeset
|
70 |
|
4e1f7de0d215
More fixes to keep node position in the source. Not yet fully implemented
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2598
diff
changeset
|
71 |
"Modified: / 27-07-2011 / 13:51:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2667 | 72 |
"Modified: / 20-08-2011 / 20:00:56 / cg" |
0 | 73 |
! |
74 |
||
2503 | 75 |
isStatement |
76 |
^true. |
|
77 |
||
78 |
"Created: / 22-02-2011 / 15:04:36 / Jakub <zelenja7@fel.cvut.cz>" |
|
79 |
! |
|
80 |
||
0 | 81 |
last |
82 |
"return the last statement in a list" |
|
83 |
||
84 |
|last this| |
|
85 |
||
86 |
"this could be done more elegant - but with lots of recursion" |
|
87 |
last := self. |
|
88 |
this := self. |
|
89 |
[this notNil] whileTrue:[ |
|
52 | 90 |
last := this. |
91 |
this := this nextStatement |
|
0 | 92 |
]. |
93 |
^ last |
|
94 |
! |
|
95 |
||
711 | 96 |
lineNumber |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
97 |
"return lineNr" |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
98 |
|
1504 | 99 |
lineNr notNil ifTrue:[^ lineNr]. |
100 |
expression notNil ifTrue:[ ^ expression lineNumber ]. |
|
101 |
nextStatement notNil ifTrue:[^ nextStatement lineNumber]. |
|
102 |
^ nil |
|
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
103 |
|
711 | 104 |
"Created: / 14.5.1998 / 19:31:06 / cg" |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
105 |
! |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
106 |
|
711 | 107 |
lineNumber:something |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
108 |
"set lineNr" |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
109 |
|
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
110 |
lineNr := something. |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
111 |
|
711 | 112 |
"Created: / 14.5.1998 / 19:31:11 / cg" |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
113 |
! |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
114 |
|
1504 | 115 |
lineNumberOfFirstMessage |
116 |
|lno| |
|
117 |
||
118 |
lno := self lineNumber. |
|
3277 | 119 |
self messagesDo:[:m | lno := lno min:(m lineNumber)]. |
1504 | 120 |
^ lno |
121 |
! |
|
122 |
||
0 | 123 |
nextStatement |
124 |
^ nextStatement |
|
125 |
! |
|
126 |
||
140 | 127 |
nextStatement:s |
2598 | 128 |
|
129 |
nextStatement notNil ifTrue:[nextStatement parent: nil]. |
|
130 |
nextStatement := s. |
|
131 |
nextStatement notNil ifTrue:[nextStatement parent: parent]. |
|
132 |
||
133 |
"Modified: / 20-07-2011 / 21:42:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
134 |
! |
|
135 |
||
136 |
parent: aParseNode |
|
137 |
||
138 |
super parent: aParseNode. |
|
139 |
nextStatement notNil ifTrue:[nextStatement parent: aParseNode]. |
|
140 |
||
141 |
"Created: / 20-07-2011 / 19:52:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 | 142 |
! ! |
143 |
||
144 |
!StatementNode methodsFor:'code generation'! |
|
145 |
||
1379 | 146 |
codeAllForSideEffectOn:aStream inBlock:b for:aCompiler |
147 |
|thisStatement| |
|
148 |
||
149 |
thisStatement := self. |
|
150 |
[thisStatement notNil] whileTrue:[ |
|
151 |
thisStatement codeForSideEffectOn:aStream inBlock:b for:aCompiler. |
|
152 |
thisStatement := thisStatement nextStatement |
|
153 |
]. |
|
154 |
! |
|
155 |
||
140 | 156 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
157 |
"generate code for this statement - value not needed" |
|
158 |
||
985 | 159 |
expression notNil ifTrue:[ |
160 |
expression codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
161 |
] |
|
0 | 162 |
! |
163 |
||
140 | 164 |
codeOn:aStream inBlock:b for:aCompiler |
165 |
"generate code for this statement" |
|
166 |
||
1313 | 167 |
expression notNil ifTrue:[ |
168 |
expression codeOn:aStream inBlock:b for:aCompiler |
|
169 |
] |
|
0 | 170 |
! ! |
171 |
||
1209 | 172 |
!StatementNode methodsFor:'converting'! |
173 |
||
174 |
asCollectionOfStatements |
|
175 |
"returns a orderedCollection of statements, |
|
176 |
representing the list of which the receiver is the head" |
|
177 |
||
178 |
|coll stat| |
|
179 |
||
180 |
coll := OrderedCollection new. |
|
181 |
stat := self. |
|
182 |
[stat notNil] whileTrue:[ |
|
2695
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
183 |
stat expression isNil ifTrue:[ |
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
184 |
] ifFalse:[ |
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
185 |
coll add:stat. |
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
186 |
]. |
1209 | 187 |
stat := stat nextStatement. |
188 |
]. |
|
189 |
^ coll |
|
2695
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
190 |
|
28c485e5738e
changed: #asCollectionOfStatements
Claus Gittinger <cg@exept.de>
parents:
2667
diff
changeset
|
191 |
"Modified: / 12-09-2011 / 10:02:47 / cg" |
1209 | 192 |
! ! |
193 |
||
1035 | 194 |
!StatementNode methodsFor:'enumerating'! |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
195 |
|
4574 | 196 |
allMessageSelectorsDo:aBlock |
197 |
"evaluate aBlock for each message-selector sent by this statement and all followup statements" |
|
198 |
||
199 |
|s| |
|
200 |
||
201 |
s := self. |
|
202 |
[s notNil] whileTrue:[ |
|
203 |
s messageSelectorsDo:aBlock. |
|
204 |
s := s nextStatement |
|
205 |
]. |
|
206 |
! |
|
207 |
||
208 |
allMessagesDo:aBlock |
|
209 |
"evaluate aBlock for each message-node sent by this statement and all followup statements" |
|
210 |
||
211 |
|s| |
|
212 |
||
213 |
s := self. |
|
214 |
[s notNil] whileTrue:[ |
|
215 |
s messagesDo:aBlock. |
|
216 |
s := s nextStatement |
|
217 |
]. |
|
218 |
! |
|
219 |
||
3338 | 220 |
allNodesDo:aBlock |
221 |
"evaluate aBlock for each node in this node and subnodes" |
|
222 |
||
4231 | 223 |
|s| |
3338 | 224 |
|
225 |
s := self. |
|
226 |
[s notNil] whileTrue:[ |
|
227 |
aBlock value:s. |
|
4231 | 228 |
s allSubNodesDo:aBlock. |
3338 | 229 |
s := s nextStatement |
230 |
]. |
|
231 |
! |
|
232 |
||
4231 | 233 |
allSubNodesDo:aBlock |
234 |
"evaluate aBlock for each subnodes" |
|
235 |
||
236 |
|e| |
|
237 |
||
238 |
e := self expression. |
|
239 |
e notNil ifTrue:[e allNodesDo:aBlock]. |
|
240 |
! |
|
241 |
||
4384
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
242 |
blockNodesDo:aBlock recursively: aBoolean |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
243 |
|
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
244 |
|s e| |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
245 |
|
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
246 |
s := self. |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
247 |
[s notNil] whileTrue:[ |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
248 |
e := s expression. |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
249 |
e notNil ifTrue:[e blockNodesDo:aBlock recursively: aBoolean]. |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
250 |
s := s nextStatement |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
251 |
]. |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
252 |
|
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
253 |
"Created: / 15-07-2018 / 10:34:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
254 |
! |
aee25576d864
DBG: teach `ByteCodeCompiler` to generate Smalltalk/X debug info
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4231
diff
changeset
|
255 |
|
4508 | 256 |
childrenDo:aBlock |
257 |
expression notNil ifTrue:[ |
|
258 |
aBlock value:expression |
|
259 |
]. |
|
260 |
! |
|
261 |
||
3044 | 262 |
do:aBlock |
263 |
"in st/x, statements is a linked list (not an ordered collection), |
|
264 |
this provides some dialect compatibility (for st2js)" |
|
265 |
||
266 |
| this | |
|
267 |
||
268 |
"/ too stupid: ST/X statements are linked as a list ... |
|
269 |
||
270 |
this := self. |
|
271 |
[this notNil] whileTrue:[ |
|
272 |
aBlock value:this. |
|
273 |
this := this nextStatement |
|
274 |
]. |
|
275 |
! |
|
276 |
||
3277 | 277 |
messageSelectorsDo:aBlock |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
278 |
"evaluate aBlock for each message-selector sent by this node and subnodes" |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
279 |
|
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
280 |
|s e| |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
281 |
|
4574 | 282 |
e := self expression. |
283 |
e notNil ifTrue:[e messageSelectorsDo:aBlock]. |
|
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
284 |
! |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
285 |
|
1504 | 286 |
messagesDo:aBlock |
3314 | 287 |
"evaluate aBlock for each message-node sent by this node and subnodes" |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
288 |
|
4574 | 289 |
|e| |
1504 | 290 |
|
4574 | 291 |
e := self expression. |
292 |
e notNil ifTrue:[e messagesDo:aBlock]. |
|
1504 | 293 |
! |
294 |
||
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
295 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
296 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
297 |
|
1585 | 298 |
|stats this expr| |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
299 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
300 |
"/ too stupid: ST/X statements are linked as a list ... |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
301 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
302 |
stats := OrderedCollection new. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
303 |
this := self. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
304 |
[this notNil] whileTrue:[ |
1592 | 305 |
this isReturnNode ifTrue:[ |
306 |
stats add:this |
|
307 |
] ifFalse:[ |
|
308 |
expr := this expression. |
|
309 |
stats add:(expr ? this). |
|
310 |
]. |
|
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
311 |
this := this nextStatement |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
312 |
]. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
313 |
^ anEnumerator doSequence:self temporaries:#() statements:stats |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
314 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
315 |
"Created: 19.6.1997 / 16:45:34 / cg" |
542 | 316 |
"Modified: 19.6.1997 / 17:06:47 / cg" |
3314 | 317 |
! |
318 |
||
319 |
variableNodesDo:aBlock |
|
320 |
"evaluate aBlock for each variable-node in this node and subnodes" |
|
321 |
||
322 |
|s e| |
|
323 |
||
324 |
s := self. |
|
325 |
[s notNil] whileTrue:[ |
|
326 |
e := s expression. |
|
327 |
e notNil ifTrue:[e variableNodesDo:aBlock]. |
|
328 |
s := s nextStatement |
|
329 |
]. |
|
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
330 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
331 |
|
1035 | 332 |
!StatementNode methodsFor:'evaluation'! |
140 | 333 |
|
1384 | 334 |
evaluateAllIn:anEnvironment |
140 | 335 |
|lastValue thisStatement| |
52 | 336 |
|
140 | 337 |
"this could be done more elegant - but with lots of recursion" |
338 |
thisStatement := self. |
|
339 |
[thisStatement notNil] whileTrue:[ |
|
1384 | 340 |
lastValue := thisStatement evaluateExpressionIn:anEnvironment. |
341 |
thisStatement := thisStatement nextStatement |
|
140 | 342 |
]. |
343 |
^ lastValue |
|
344 |
! |
|
345 |
||
1384 | 346 |
evaluateExpressionIn:anEnvironment |
347 |
^ expression evaluateIn:anEnvironment |
|
348 |
! |
|
349 |
||
350 |
evaluateIn:anEnvironment |
|
351 |
^ self evaluateAllIn:anEnvironment. |
|
52 | 352 |
! ! |
353 |
||
1080 | 354 |
!StatementNode methodsFor:'printing & storing'! |
0 | 355 |
|
356 |
printAllOn:aStream |
|
357 |
self printAllOn:aStream indent:4 |
|
358 |
! |
|
359 |
||
360 |
printAllOn:aStream indent:i |
|
361 |
|thisStatement| |
|
362 |
||
363 |
thisStatement := self. |
|
364 |
[thisStatement notNil] whileTrue:[ |
|
1379 | 365 |
aStream spaces:i. |
366 |
thisStatement printOn:aStream indent:i. |
|
367 |
thisStatement nextStatement notNil ifTrue:[ |
|
1633 | 368 |
aStream nextPut:$.. |
1379 | 369 |
aStream cr. |
370 |
]. |
|
371 |
thisStatement := thisStatement nextStatement |
|
0 | 372 |
] |
140 | 373 |
! |
374 |
||
375 |
printOn:aStream indent:i |
|
2168
be3e52955e96
care for nil expression when printing
Claus Gittinger <cg@exept.de>
parents:
2103
diff
changeset
|
376 |
expression notNil ifTrue:[ expression printOn:aStream indent:i ]. |
0 | 377 |
! ! |
140 | 378 |
|
379 |
!StatementNode methodsFor:'queries'! |
|
380 |
||
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
381 |
collectBlocksInto:aCollection |
511
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
382 |
|this ex| |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
383 |
|
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
384 |
this := self. |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
385 |
[this notNil] whileTrue:[ |
511
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
386 |
ex := this expression. |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
387 |
ex notNil ifTrue:[ |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
388 |
ex collectBlocksInto:aCollection. |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
389 |
]. |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
390 |
this := this nextStatement |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
391 |
]. |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
392 |
|
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
393 |
"Created: 23.10.1996 / 15:44:13 / cg" |
511
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
394 |
"Modified: 20.4.1997 / 12:10:18 / cg" |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
395 |
! |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
396 |
|
2385 | 397 |
containsReturn |
4163 | 398 |
|expr| |
399 |
||
400 |
^ (expr := self expression) notNil and:[expr containsReturn] |
|
401 |
||
402 |
"Modified: / 04-07-2017 / 17:02:52 / cg" |
|
2385 | 403 |
! |
404 |
||
405 |
containsReturnInAnyStatement |
|
406 |
|s| |
|
407 |
||
408 |
s := self. |
|
409 |
[s notNil] whileTrue:[ |
|
2387 | 410 |
s isReturnNode ifTrue:[^ true]. |
2385 | 411 |
s containsReturn ifTrue:[^ true]. |
412 |
s := s nextStatement. |
|
413 |
]. |
|
414 |
^ false |
|
415 |
! |
|
416 |
||
2065 | 417 |
isSimpleConstant |
140 | 418 |
nextStatement notNil ifTrue:[^ false]. |
419 |
^ expression isConstant |
|
332
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
420 |
! |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
421 |
|
2103 | 422 |
isSimpleExpression |
423 |
nextStatement notNil ifTrue:[^ false]. |
|
424 |
^ expression notNil |
|
425 |
! |
|
426 |
||
2065 | 427 |
isSimpleVariable |
428 |
nextStatement notNil ifTrue:[^ false]. |
|
429 |
^ expression isVariable |
|
430 |
! |
|
431 |
||
332
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
432 |
listEndsWithReturn |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
433 |
|thisStatement lastStatement| |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
434 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
435 |
thisStatement := self. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
436 |
[thisStatement notNil] whileTrue:[ |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
437 |
lastStatement := thisStatement. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
438 |
thisStatement := thisStatement nextStatement |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
439 |
]. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
440 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
441 |
^ lastStatement isReturnNode |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
442 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
443 |
"Created: 19.8.1996 / 14:32:47 / cg" |
140 | 444 |
! ! |
445 |
||
2503 | 446 |
!StatementNode methodsFor:'testing'! |
447 |
||
448 |
isStatementNode |
|
449 |
||
450 |
^ true |
|
451 |
||
452 |
"Created: / 13-06-2011 / 11:26:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
453 |
"Modified: / 13-06-2011 / 14:05:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
454 |
! ! |
|
455 |
||
2598 | 456 |
!StatementNode methodsFor:'visiting'! |
457 |
||
458 |
acceptVisitor:aVisitor |
|
459 |
"Double dispatch back to the visitor, passing my type encoded in |
|
460 |
the selector (visitor pattern)" |
|
461 |
||
462 |
"stub code automatically generated - please change if required" |
|
463 |
||
464 |
^ aVisitor visitStatementNode:self |
|
465 |
! ! |
|
466 |
||
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
467 |
!StatementNode class methodsFor:'documentation'! |
148 | 468 |
|
3277 | 469 |
version |
4163 | 470 |
^ '$Header$' |
3277 | 471 |
! |
472 |
||
2503 | 473 |
version_CVS |
4163 | 474 |
^ '$Header$' |
2385 | 475 |
! |
476 |
||
2503 | 477 |
version_SVN |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
478 |
^ '$ Id $' |
148 | 479 |
! ! |
3044 | 480 |