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