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