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