author | Claus Gittinger <cg@exept.de> |
Thu, 22 Aug 2019 17:54:53 +0200 | |
changeset 4508 | acdb6bc18328 |
parent 4231 | dd23f58513c0 |
child 4574 | 10a8a23c9953 |
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 |
|
3338 | 199 |
allNodesDo:aBlock |
200 |
"evaluate aBlock for each node in this node and subnodes" |
|
201 |
||
4231 | 202 |
|s| |
3338 | 203 |
|
204 |
s := self. |
|
205 |
[s notNil] whileTrue:[ |
|
206 |
aBlock value:s. |
|
4231 | 207 |
s allSubNodesDo:aBlock. |
3338 | 208 |
s := s nextStatement |
209 |
]. |
|
210 |
! |
|
211 |
||
4231 | 212 |
allSubNodesDo:aBlock |
213 |
"evaluate aBlock for each subnodes" |
|
214 |
||
215 |
|e| |
|
216 |
||
217 |
e := self expression. |
|
218 |
e notNil ifTrue:[e allNodesDo:aBlock]. |
|
219 |
! |
|
220 |
||
4508 | 221 |
childrenDo:aBlock |
222 |
expression notNil ifTrue:[ |
|
223 |
aBlock value:expression |
|
224 |
]. |
|
225 |
! |
|
226 |
||
3044 | 227 |
do:aBlock |
228 |
"in st/x, statements is a linked list (not an ordered collection), |
|
229 |
this provides some dialect compatibility (for st2js)" |
|
230 |
||
231 |
| this | |
|
232 |
||
233 |
"/ too stupid: ST/X statements are linked as a list ... |
|
234 |
||
235 |
this := self. |
|
236 |
[this notNil] whileTrue:[ |
|
237 |
aBlock value:this. |
|
238 |
this := this nextStatement |
|
239 |
]. |
|
240 |
! |
|
241 |
||
3277 | 242 |
messageSelectorsDo:aBlock |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
243 |
"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
|
244 |
|
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
245 |
|s e| |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
246 |
|
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
247 |
s := self. |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
248 |
[s notNil] whileTrue:[ |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
249 |
e := s expression. |
3277 | 250 |
e notNil ifTrue:[e messageSelectorsDo:aBlock]. |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
251 |
s := s nextStatement |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
252 |
]. |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
253 |
! |
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
254 |
|
1504 | 255 |
messagesDo:aBlock |
3314 | 256 |
"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
|
257 |
|
1504 | 258 |
|s e| |
259 |
||
260 |
s := self. |
|
261 |
[s notNil] whileTrue:[ |
|
262 |
e := s expression. |
|
263 |
e notNil ifTrue:[e messagesDo:aBlock]. |
|
264 |
s := s nextStatement |
|
265 |
]. |
|
266 |
! |
|
267 |
||
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
268 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
269 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
270 |
|
1585 | 271 |
|stats this expr| |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
272 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
273 |
"/ 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
|
274 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
275 |
stats := OrderedCollection new. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
276 |
this := self. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
277 |
[this notNil] whileTrue:[ |
1592 | 278 |
this isReturnNode ifTrue:[ |
279 |
stats add:this |
|
280 |
] ifFalse:[ |
|
281 |
expr := this expression. |
|
282 |
stats add:(expr ? this). |
|
283 |
]. |
|
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
284 |
this := this nextStatement |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
285 |
]. |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
286 |
^ anEnumerator doSequence:self temporaries:#() statements:stats |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
287 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
511
diff
changeset
|
288 |
"Created: 19.6.1997 / 16:45:34 / cg" |
542 | 289 |
"Modified: 19.6.1997 / 17:06:47 / cg" |
3314 | 290 |
! |
291 |
||
292 |
variableNodesDo:aBlock |
|
293 |
"evaluate aBlock for each variable-node in this node and subnodes" |
|
294 |
||
295 |
|s e| |
|
296 |
||
297 |
s := self. |
|
298 |
[s notNil] whileTrue:[ |
|
299 |
e := s expression. |
|
300 |
e notNil ifTrue:[e variableNodesDo:aBlock]. |
|
301 |
s := s nextStatement |
|
302 |
]. |
|
539
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 |
|
4508 | 305 |
|
1035 | 306 |
!StatementNode methodsFor:'evaluation'! |
140 | 307 |
|
1384 | 308 |
evaluateAllIn:anEnvironment |
140 | 309 |
|lastValue thisStatement| |
52 | 310 |
|
140 | 311 |
"this could be done more elegant - but with lots of recursion" |
312 |
thisStatement := self. |
|
313 |
[thisStatement notNil] whileTrue:[ |
|
1384 | 314 |
lastValue := thisStatement evaluateExpressionIn:anEnvironment. |
315 |
thisStatement := thisStatement nextStatement |
|
140 | 316 |
]. |
317 |
^ lastValue |
|
318 |
! |
|
319 |
||
1384 | 320 |
evaluateExpressionIn:anEnvironment |
321 |
^ expression evaluateIn:anEnvironment |
|
322 |
! |
|
323 |
||
324 |
evaluateIn:anEnvironment |
|
325 |
^ self evaluateAllIn:anEnvironment. |
|
52 | 326 |
! ! |
327 |
||
1080 | 328 |
!StatementNode methodsFor:'printing & storing'! |
0 | 329 |
|
330 |
printAllOn:aStream |
|
331 |
self printAllOn:aStream indent:4 |
|
332 |
! |
|
333 |
||
334 |
printAllOn:aStream indent:i |
|
335 |
|thisStatement| |
|
336 |
||
337 |
thisStatement := self. |
|
338 |
[thisStatement notNil] whileTrue:[ |
|
1379 | 339 |
aStream spaces:i. |
340 |
thisStatement printOn:aStream indent:i. |
|
341 |
thisStatement nextStatement notNil ifTrue:[ |
|
1633 | 342 |
aStream nextPut:$.. |
1379 | 343 |
aStream cr. |
344 |
]. |
|
345 |
thisStatement := thisStatement nextStatement |
|
0 | 346 |
] |
140 | 347 |
! |
348 |
||
349 |
printOn:aStream indent:i |
|
2168
be3e52955e96
care for nil expression when printing
Claus Gittinger <cg@exept.de>
parents:
2103
diff
changeset
|
350 |
expression notNil ifTrue:[ expression printOn:aStream indent:i ]. |
0 | 351 |
! ! |
140 | 352 |
|
353 |
!StatementNode methodsFor:'queries'! |
|
354 |
||
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
355 |
collectBlocksInto:aCollection |
511
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
356 |
|this ex| |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
357 |
|
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
358 |
this := self. |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
359 |
[this notNil] whileTrue:[ |
511
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
360 |
ex := this expression. |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
361 |
ex notNil ifTrue:[ |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
362 |
ex collectBlocksInto:aCollection. |
c144804051db
handle corrupt expression (nil) in statement
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
363 |
]. |
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
364 |
this := this nextStatement |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
365 |
]. |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
366 |
|
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
367 |
"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
|
368 |
"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
|
369 |
! |
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
370 |
|
2385 | 371 |
containsReturn |
4163 | 372 |
|expr| |
373 |
||
374 |
^ (expr := self expression) notNil and:[expr containsReturn] |
|
375 |
||
376 |
"Modified: / 04-07-2017 / 17:02:52 / cg" |
|
2385 | 377 |
! |
378 |
||
379 |
containsReturnInAnyStatement |
|
380 |
|s| |
|
381 |
||
382 |
s := self. |
|
383 |
[s notNil] whileTrue:[ |
|
2387 | 384 |
s isReturnNode ifTrue:[^ true]. |
2385 | 385 |
s containsReturn ifTrue:[^ true]. |
386 |
s := s nextStatement. |
|
387 |
]. |
|
388 |
^ false |
|
389 |
! |
|
390 |
||
2065 | 391 |
isSimpleConstant |
140 | 392 |
nextStatement notNil ifTrue:[^ false]. |
393 |
^ expression isConstant |
|
332
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
394 |
! |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
395 |
|
2103 | 396 |
isSimpleExpression |
397 |
nextStatement notNil ifTrue:[^ false]. |
|
398 |
^ expression notNil |
|
399 |
! |
|
400 |
||
2065 | 401 |
isSimpleVariable |
402 |
nextStatement notNil ifTrue:[^ false]. |
|
403 |
^ expression isVariable |
|
404 |
! |
|
405 |
||
332
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
406 |
listEndsWithReturn |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
407 |
|thisStatement lastStatement| |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
408 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
409 |
thisStatement := self. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
410 |
[thisStatement notNil] whileTrue:[ |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
411 |
lastStatement := thisStatement. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
412 |
thisStatement := thisStatement nextStatement |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
413 |
]. |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
414 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
415 |
^ lastStatement isReturnNode |
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
416 |
|
7ffd2016cf73
added query if statementList ends in a return
Claus Gittinger <cg@exept.de>
parents:
263
diff
changeset
|
417 |
"Created: 19.8.1996 / 14:32:47 / cg" |
140 | 418 |
! ! |
419 |
||
2503 | 420 |
!StatementNode methodsFor:'testing'! |
421 |
||
422 |
isStatementNode |
|
423 |
||
424 |
^ true |
|
425 |
||
426 |
"Created: / 13-06-2011 / 11:26:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
427 |
"Modified: / 13-06-2011 / 14:05:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
428 |
! ! |
|
429 |
||
2598 | 430 |
!StatementNode methodsFor:'visiting'! |
431 |
||
432 |
acceptVisitor:aVisitor |
|
433 |
"Double dispatch back to the visitor, passing my type encoded in |
|
434 |
the selector (visitor pattern)" |
|
435 |
||
436 |
"stub code automatically generated - please change if required" |
|
437 |
||
438 |
^ aVisitor visitStatementNode:self |
|
439 |
! ! |
|
440 |
||
392
cce48e2f0778
moved lineNr instVar up to here
Claus Gittinger <cg@exept.de>
parents:
332
diff
changeset
|
441 |
!StatementNode class methodsFor:'documentation'! |
148 | 442 |
|
3277 | 443 |
version |
4163 | 444 |
^ '$Header$' |
3277 | 445 |
! |
446 |
||
2503 | 447 |
version_CVS |
4163 | 448 |
^ '$Header$' |
2385 | 449 |
! |
450 |
||
2503 | 451 |
version_SVN |
3273
e637f0ae001c
renamed messagesDo: to messageNodes: do
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
452 |
^ '$ Id $' |
148 | 453 |
! ! |
3044 | 454 |