author | Claus Gittinger <cg@exept.de> |
Fri, 27 Jun 1997 14:08:18 +0200 | |
changeset 565 | 00673e9d6edc |
parent 562 | 36bd00734940 |
child 569 | 88a1b1d118fd |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 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 |
" |
|
12 |
||
13 |
ParseNode subclass:#BlockNode |
|
168 | 14 |
instanceVariableNames:'blockArgs statements home inlineBlock exitBlock blockVars |
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
15 |
needsHome lineNr endLineNr blockArgAccessedInBlock numTemp |
559 | 16 |
maxNumTemp indexOfFirstTemp' |
168 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'System-Compiler-Support' |
|
0 | 20 |
! |
21 |
||
366 | 22 |
!BlockNode class methodsFor:'documentation'! |
20 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
45 | 27 |
All Rights Reserved |
0 | 28 |
|
20 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
0 | 37 |
|
20 | 38 |
documentation |
39 |
" |
|
40 |
node for parse-trees, representing blocks |
|
261 | 41 |
This is a helper class for the compiler. |
263 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
20 | 45 |
" |
46 |
! ! |
|
0 | 47 |
|
366 | 48 |
!BlockNode class methodsFor:'instance creation'! |
0 | 49 |
|
3 | 50 |
arguments:argList home:h variables:vars |
51 |
^ (self basicNew) setArguments:argList home:h variables:vars |
|
0 | 52 |
! ! |
53 |
||
54 |
!BlockNode methodsFor:'accessing'! |
|
55 |
||
56 |
arguments |
|
57 |
^ blockArgs |
|
58 |
! |
|
59 |
||
26 | 60 |
arguments:argList |
61 |
blockArgs := argList |
|
62 |
! |
|
63 |
||
534 | 64 |
blockArgAccessed |
65 |
"return true if any block argument is accessed in the block" |
|
66 |
||
67 |
^ blockArgAccessedInBlock ? false |
|
68 |
||
69 |
"Modified: 18.6.1997 / 12:06:31 / cg" |
|
70 |
! |
|
71 |
||
72 |
blockArgAccessed:aBoolen |
|
73 |
"set/clear the flag stating if any block argument is accessed in the block" |
|
74 |
||
75 |
blockArgAccessedInBlock := aBoolen |
|
76 |
||
77 |
"Created: 18.6.1997 / 11:35:00 / cg" |
|
78 |
"Modified: 18.6.1997 / 12:06:43 / cg" |
|
79 |
! |
|
80 |
||
394 | 81 |
endLineNumber |
82 |
^ endLineNr |
|
83 |
||
84 |
"Created: 23.10.1996 / 15:51:32 / cg" |
|
85 |
! |
|
86 |
||
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
87 |
endLineNumber:aNumber |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
88 |
endLineNr := aNumber |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
89 |
|
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
90 |
"Created: 21.10.1996 / 14:17:57 / cg" |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
91 |
! |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
92 |
|
140 | 93 |
home |
94 |
^ home |
|
0 | 95 |
! |
96 |
||
97 |
home:aBlock |
|
98 |
home := aBlock |
|
99 |
! |
|
100 |
||
559 | 101 |
indexOfFirstTemp:index |
102 |
indexOfFirstTemp := index |
|
103 |
||
104 |
"Created: 25.6.1997 / 17:24:27 / cg" |
|
105 |
! |
|
106 |
||
555 | 107 |
inlineBlock:aBoolean |
108 |
inlineBlock := aBoolean |
|
0 | 109 |
! |
110 |
||
555 | 111 |
isInlineBlock |
112 |
^ inlineBlock |
|
113 |
||
114 |
"Created: 25.6.1997 / 14:11:33 / cg" |
|
0 | 115 |
! |
116 |
||
394 | 117 |
lineNumber |
118 |
^ lineNr |
|
119 |
||
120 |
"Created: 23.10.1996 / 15:51:50 / cg" |
|
121 |
! |
|
122 |
||
140 | 123 |
lineNumber:aNumber |
124 |
lineNr := aNumber |
|
125 |
! |
|
126 |
||
0 | 127 |
needsHome |
128 |
^ needsHome |
|
129 |
! |
|
130 |
||
131 |
needsHome:aBoolean |
|
132 |
needsHome := aBoolean |
|
6 | 133 |
! |
134 |
||
140 | 135 |
statements |
136 |
^ statements |
|
137 |
! |
|
138 |
||
139 |
statements:s |
|
140 |
statements := s |
|
141 |
! |
|
142 |
||
143 |
variables |
|
144 |
^ blockVars |
|
145 |
! |
|
146 |
||
147 |
variables:varList |
|
148 |
blockVars := varList |
|
149 |
! ! |
|
150 |
||
151 |
!BlockNode methodsFor:'block messages'! |
|
152 |
||
153 |
doesNotUnderstand:aMessage |
|
154 |
|numArgs kludgeBlock| |
|
155 |
||
156 |
(Block implements:(aMessage selector)) ifTrue:[ |
|
212
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
157 |
|
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
158 |
"/ mhmh - a message which I dont understand, but Block implements |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
159 |
"/ send it to a kludgeblock, which will evaluate me again ..." |
ff39051e219f
more constant folding options
Claus Gittinger <cg@exept.de>
parents:
199
diff
changeset
|
160 |
|
140 | 161 |
numArgs := blockArgs size. |
162 |
numArgs == 0 ifTrue:[ |
|
163 |
kludgeBlock := [self value] |
|
164 |
] ifFalse:[ |
|
165 |
numArgs == 1 ifTrue:[ |
|
166 |
kludgeBlock := [:a1 | self value:a1]. |
|
167 |
] ifFalse:[ |
|
168 |
numArgs == 2 ifTrue:[ |
|
169 |
kludgeBlock := [:a1 :a2 | self value:a1 value:a2]. |
|
170 |
] ifFalse:[ |
|
171 |
numArgs == 3 ifTrue:[ |
|
172 |
kludgeBlock := [:a1 :a2 :a3| self value:a1 value:a2 value:a3]. |
|
173 |
] ifFalse:[ |
|
174 |
numArgs == 4 ifTrue:[ |
|
175 |
kludgeBlock := [:a1 :a2 :a3 :a4| self value:a1 value:a2 value:a3 value:a4]. |
|
176 |
] ifFalse:[ |
|
177 |
^ self error:'only support blocks with up-to 4 args' |
|
178 |
] |
|
179 |
] |
|
180 |
] |
|
181 |
] |
|
182 |
]. |
|
183 |
^ kludgeBlock perform:aMessage selector withArguments:aMessage arguments |
|
184 |
]. |
|
185 |
^ super doesNotUnderstand:aMessage |
|
0 | 186 |
! ! |
187 |
||
140 | 188 |
!BlockNode methodsFor:'code generation'! |
189 |
||
190 |
checkForSimpleBlock |
|
191 |
"simple things can be made cheap blocks right now - |
|
192 |
resulting in a simple pushLit instruction ..." |
|
193 |
||
506
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
194 |
|cheapy e val code stackSize| |
140 | 195 |
|
196 |
statements isNil ifTrue:[ |
|
366 | 197 |
"a []-block" |
140 | 198 |
|
366 | 199 |
val := nil |
140 | 200 |
] ifFalse:[ |
366 | 201 |
statements nextStatement notNil ifTrue:[^ nil]. |
202 |
(statements isMemberOf:StatementNode) ifFalse:[^ nil]. |
|
140 | 203 |
|
366 | 204 |
e := statements expression. |
205 |
e isConstant ifFalse:[^ nil]. |
|
140 | 206 |
|
366 | 207 |
val := e value. |
140 | 208 |
]. |
209 |
||
506
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
210 |
stackSize := 0. |
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
211 |
|
140 | 212 |
val == 0 ifTrue:[ |
366 | 213 |
"a [0]-block" |
140 | 214 |
|
366 | 215 |
code := ByteArray with:(ByteCodeCompiler byteCodeFor:#ret0). |
140 | 216 |
]. |
217 |
val == 1 ifTrue:[ |
|
366 | 218 |
"a [1]-block" |
140 | 219 |
|
506
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
220 |
stackSize := 1. |
366 | 221 |
code := ByteArray with:(ByteCodeCompiler byteCodeFor:#push1) |
222 |
with:(ByteCodeCompiler byteCodeFor:#retTop). |
|
140 | 223 |
]. |
224 |
||
225 |
val == true ifTrue:[ |
|
366 | 226 |
"a [true]-block" |
140 | 227 |
|
366 | 228 |
code := ByteArray with:(ByteCodeCompiler byteCodeFor:#retTrue). |
140 | 229 |
]. |
230 |
||
231 |
val == false ifTrue:[ |
|
366 | 232 |
"a [false]-block" |
140 | 233 |
|
366 | 234 |
code := ByteArray with:(ByteCodeCompiler byteCodeFor:#retFalse). |
140 | 235 |
]. |
236 |
||
237 |
val == nil ifTrue:[ |
|
366 | 238 |
"a [nil]-block" |
140 | 239 |
|
366 | 240 |
code := ByteArray with:(ByteCodeCompiler byteCodeFor:#retNil). |
140 | 241 |
]. |
242 |
||
243 |
code notNil ifTrue:[ |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
244 |
cheapy := CheapBlock |
366 | 245 |
byteCode:code |
246 |
numArgs:(blockArgs size) |
|
506
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
247 |
numStack:stackSize |
366 | 248 |
sourcePosition:nil |
249 |
initialPC:nil |
|
250 |
literals:nil. |
|
251 |
^ ConstantNode type:#Block value:cheapy |
|
140 | 252 |
]. |
253 |
||
254 |
^ nil |
|
366 | 255 |
|
506
3dc049d3a2d7
care for stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
256 |
"Modified: 13.4.1997 / 00:05:29 / cg" |
140 | 257 |
! |
258 |
||
259 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
|
260 |
"generate code for this statement - value not needed. |
|
261 |
For blocks, no code is generated at all." |
|
262 |
||
263 |
^ self |
|
264 |
! |
|
265 |
||
266 |
codeInlineOn:aStream inBlock:b for:aCompiler |
|
267 |
self codeInlineOn:aStream inBlock:b valueNeeded:true for:aCompiler |
|
268 |
! |
|
269 |
||
270 |
codeInlineOn:aStream inBlock:b valueNeeded:valueNeeded for:aCompiler |
|
559 | 271 |
|thisStatement nextStatement tmpIndex firstTempIndex codeBlock| |
140 | 272 |
|
273 |
blockVars notNil ifTrue:[ |
|
559 | 274 |
"/ have to move blockvars into surrounding context |
0 | 275 |
|
559 | 276 |
"/ find the first non-inlined block |
277 |
codeBlock := b. |
|
278 |
[codeBlock notNil and:[codeBlock isInlineBlock]] whileTrue:[ |
|
279 |
codeBlock := codeBlock home. |
|
553 | 280 |
]. |
281 |
||
559 | 282 |
blockVars do:[:aBlockVar | |
283 |
codeBlock isNil ifTrue:[ |
|
284 |
"/ in method - add more temps to the method |
|
285 |
tmpIndex := aCompiler addTempVar. |
|
286 |
] ifFalse:[ |
|
287 |
"/ in another block - add more temps to the block |
|
288 |
tmpIndex := codeBlock addTempVar |
|
289 |
]. |
|
290 |
||
291 |
firstTempIndex isNil ifTrue:[ |
|
292 |
firstTempIndex := tmpIndex. |
|
293 |
indexOfFirstTemp isNil ifTrue:[ |
|
294 |
indexOfFirstTemp := tmpIndex |
|
295 |
]. |
|
296 |
]. |
|
297 |
||
298 |
"/ block vars must be nilled |
|
299 |
"/ (in case the previous block left some value there). |
|
300 |
"/ This nilling should be optimized away, if |
|
301 |
"/ the variable gets a value assigned before the first send. |
|
302 |
||
303 |
aStream nextPut:#pushNil. |
|
304 |
codeBlock isNil ifTrue:[ |
|
305 |
"/ in method |
|
306 |
(tmpIndex <= 6) ifTrue:[ |
|
307 |
aStream nextPut:(#(storeMethodVar1 storeMethodVar2 |
|
308 |
storeMethodVar3 storeMethodVar4 |
|
309 |
storeMethodVar5 storeMethodVar6) at:tmpIndex). |
|
310 |
] ifFalse:[ |
|
311 |
aStream nextPut:#storeMethodVar; nextPut:tmpIndex. |
|
312 |
] |
|
313 |
] ifFalse:[ |
|
314 |
"/ in another block |
|
315 |
aStream nextPut:#storeBlockVar; nextPut:tmpIndex. |
|
316 |
] |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
317 |
]. |
140 | 318 |
]. |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
319 |
|
140 | 320 |
inlineBlock := true. |
555 | 321 |
|
140 | 322 |
statements isNil ifTrue:[ |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
323 |
valueNeeded ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
324 |
aStream nextPut:#pushNil |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
325 |
] |
140 | 326 |
] ifFalse:[ |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
327 |
thisStatement := statements. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
328 |
[thisStatement notNil] whileTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
329 |
nextStatement := thisStatement nextStatement. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
330 |
(nextStatement notNil or:[valueNeeded not]) ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
331 |
thisStatement codeForSideEffectOn:aStream inBlock:b for:aCompiler |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
332 |
] ifFalse:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
333 |
thisStatement codeOn:aStream inBlock:b for:aCompiler |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
334 |
]. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
335 |
thisStatement := nextStatement |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
336 |
] |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
337 |
]. |
559 | 338 |
|
386 | 339 |
"/ endLineNr notNil ifTrue:[ |
340 |
"/ ParseNode codeLineNumber:endLineNr on:aStream for:aCompiler |
|
341 |
"/ ]. |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
342 |
|
559 | 343 |
"/ pop off temps (blockVars). |
344 |
"/ also, they are nilled to prevent any temp stuff |
|
345 |
"/ from NOT being garbage collected. |
|
346 |
"/ could optimize here, temps are reused soon. |
|
347 |
||
348 |
blockVars notNil ifTrue:[ |
|
349 |
tmpIndex := firstTempIndex. |
|
350 |
codeBlock isNil ifTrue:[ |
|
351 |
blockVars do:[:dummy | |
|
352 |
aStream nextPut:#pushNil. |
|
353 |
aStream nextPut:#storeMethodVar; nextPut:tmpIndex. |
|
354 |
aCompiler removeTempVar |
|
355 |
] |
|
356 |
] ifFalse:[ |
|
357 |
blockVars do:[:dummy | |
|
358 |
aStream nextPut:#pushNil. |
|
359 |
aStream nextPut:#storeBlockVar; nextPut:tmpIndex. |
|
360 |
codeBlock removeTempVar |
|
361 |
] |
|
362 |
]. |
|
363 |
tmpIndex := tmpIndex + 1. |
|
364 |
]. |
|
365 |
||
366 |
"Modified: 26.6.1997 / 10:39:08 / cg" |
|
140 | 367 |
! |
368 |
||
369 |
codeOn:aStream inBlock:b for:aCompiler |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
370 |
|thisStatement nextStatement lastStatement pos code cheapy p0| |
140 | 371 |
|
372 |
cheapy := self checkForSimpleBlock. |
|
373 |
cheapy notNil ifTrue:[ |
|
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
374 |
cheapy codeOn:aStream inBlock:b for:aCompiler. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
375 |
^ self |
140 | 376 |
]. |
377 |
||
378 |
pos := aStream position. |
|
62 | 379 |
|
555 | 380 |
aStream nextPut:#makeBlock. "+0" |
381 |
aStream nextPut:0. "+1" |
|
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
382 |
aStream nextPut:(blockVars size + maxNumTemp). "+2" |
555 | 383 |
aStream nextPut:(blockArgs size). "+3" |
384 |
"+4" |
|
394 | 385 |
p0 := pos+4. |
386 |
||
140 | 387 |
statements isNil ifTrue:[ |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
388 |
endLineNr notNil ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
389 |
ParseNode codeLineNumber:endLineNr on:aStream for:aCompiler |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
390 |
]. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
391 |
aStream nextPut:#pushNil. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
392 |
aStream nextPut:#retTop. |
140 | 393 |
] ifFalse:[ |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
394 |
thisStatement := statements. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
395 |
[thisStatement notNil] whileTrue:[ |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
396 |
nextStatement := thisStatement nextStatement. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
397 |
nextStatement notNil ifTrue:[ |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
398 |
thisStatement codeForSideEffectOn:aStream inBlock:self for:aCompiler |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
399 |
] ifFalse:[ |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
400 |
lastStatement := thisStatement |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
401 |
]. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
402 |
thisStatement := nextStatement |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
403 |
]. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
404 |
|
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
405 |
lastStatement isPrimary ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
406 |
ReturnNode |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
407 |
codeSimpleReturnFor:lastStatement expression |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
408 |
inBlock:nil |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
409 |
on:aStream |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
410 |
inLine:endLineNr |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
411 |
for:aCompiler |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
412 |
]. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
413 |
lastStatement codeOn:aStream inBlock:self for:aCompiler. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
414 |
endLineNr notNil ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
415 |
ParseNode codeLineNumber:endLineNr on:aStream for:aCompiler |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
416 |
]. |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
417 |
aStream nextPut:#retTop. |
140 | 418 |
]. |
419 |
||
562
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
420 |
code := (aStream contents). |
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
421 |
|
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
422 |
|
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
423 |
"/ sigh - during coding, inlined subBlocks may have added more |
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
424 |
"/ tempVars; patch the nvar byte ... |
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
425 |
|
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
426 |
code at:pos+2 put:(blockVars size + maxNumTemp). |
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
427 |
|
140 | 428 |
"check for [0]-block; |
429 |
these are sometimes used as in ... ifAbsent:[0] |
|
430 |
" |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
431 |
(code at:p0) == #lineno ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
432 |
p0 := p0 + 2 |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
433 |
] ifFalse:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
434 |
(code at:p0) == #lineno16 ifTrue:[ |
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
435 |
p0 := p0 + 3 |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
436 |
] |
140 | 437 |
]. |
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
438 |
|
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
439 |
(code at:p0) == #ret0 ifTrue:[ |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
440 |
aStream position:pos. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
441 |
code grow:pos. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
442 |
aStream nextPut:#mk0Block. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
443 |
^ self |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
444 |
]. |
140 | 445 |
|
446 |
"check for [nil]-block; |
|
447 |
these come to play when code in blocks is commented |
|
448 |
out, or as dummy exception blocks |
|
449 |
" |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
450 |
(code at:p0) == #retNil ifTrue:[ |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
451 |
aStream position:pos. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
452 |
code grow:pos. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
453 |
aStream nextPut:#mkNilBlock. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
454 |
^ self |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
455 |
]. |
140 | 456 |
|
379
24399d5c465c
optionally mark the blocks-end with a lineNr.
Claus Gittinger <cg@exept.de>
parents:
366
diff
changeset
|
457 |
code at:pos+1 put:(aStream position) |
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
458 |
|
562
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
459 |
"Modified: 26.6.1997 / 10:48:56 / cg" |
555 | 460 |
! ! |
461 |
||
462 |
!BlockNode methodsFor:'code generation helpers'! |
|
463 |
||
464 |
addTempVar |
|
465 |
"add a temporary variable; return its position (1-based). |
|
466 |
Used when a block with args/locals is inlined." |
|
467 |
||
559 | 468 |
inlineBlock ifTrue:[self halt:'should not happen']. |
469 |
||
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
470 |
numTemp isNil ifTrue:[numTemp := maxNumTemp := 0]. |
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
471 |
numTemp := numTemp + 1. |
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
472 |
maxNumTemp := maxNumTemp max:numTemp. |
559 | 473 |
^ numTemp + self numVars |
555 | 474 |
|
559 | 475 |
"Modified: 26.6.1997 / 09:52:23 / cg" |
555 | 476 |
! |
477 |
||
478 |
removeTempVar |
|
479 |
"remove a temporary variable" |
|
480 |
||
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
481 |
numTemp := numTemp - 1. |
555 | 482 |
|
483 |
"Created: 25.6.1997 / 14:04:20 / cg" |
|
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
484 |
"Modified: 25.6.1997 / 15:07:07 / cg" |
0 | 485 |
! ! |
486 |
||
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
487 |
!BlockNode methodsFor:'enumeration'! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
488 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
489 |
nodeDo:anEnumerator |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
490 |
"helper for parse tree walking" |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
491 |
|
544
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
492 |
|args| |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
493 |
|
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
494 |
args := blockArgs ? #(). |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
495 |
args := args collect:[:var | |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
496 |
|p| |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
497 |
|
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
498 |
p := ParameterNode new. |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
499 |
p variable:var |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
500 |
]. |
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
501 |
^ anEnumerator doBlock:self arguments:args body:statements |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
502 |
|
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
503 |
"Created: 19.6.1997 / 16:38:30 / cg" |
544
fcfff6f8bc31
more ST80 compatible enumeration
Claus Gittinger <cg@exept.de>
parents:
539
diff
changeset
|
504 |
"Modified: 19.6.1997 / 17:17:57 / cg" |
539
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
505 |
! ! |
69a1cd05c7d6
added node-walk facility (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
534
diff
changeset
|
506 |
|
0 | 507 |
!BlockNode methodsFor:'evaluating'! |
508 |
||
140 | 509 |
evaluate |
510 |
^ self |
|
511 |
! |
|
512 |
||
0 | 513 |
exitWith:something |
514 |
"return via return-statement" |
|
515 |
||
516 |
home notNil ifTrue:[ |
|
45 | 517 |
home exitWith:something |
0 | 518 |
]. |
519 |
exitBlock value:something. |
|
520 |
^ something |
|
521 |
! |
|
522 |
||
523 |
value |
|
524 |
(blockArgs size ~~ 0) ifTrue:[ |
|
45 | 525 |
^ self wrongNumberOfArguments:0 |
0 | 526 |
]. |
527 |
statements isNil ifTrue:[^ nil]. |
|
528 |
exitBlock := [:val | ^ val]. |
|
529 |
^ statements evaluate |
|
530 |
! |
|
531 |
||
532 |
value:anArg |
|
533 |
|oldValue val| |
|
534 |
||
535 |
(blockArgs size ~~ 1) ifTrue:[ |
|
45 | 536 |
^ self wrongNumberOfArguments:1 |
0 | 537 |
]. |
538 |
statements isNil ifTrue:[^ nil]. |
|
539 |
||
540 |
oldValue := (blockArgs at:1) value. |
|
541 |
(blockArgs at:1) value:anArg. |
|
542 |
||
15 | 543 |
exitBlock := [:v | |
45 | 544 |
(blockArgs at:1) value:oldValue. |
545 |
^ v |
|
0 | 546 |
]. |
547 |
||
548 |
val := statements evaluate. |
|
549 |
||
550 |
(blockArgs at:1) value:oldValue. |
|
551 |
^ val |
|
552 |
! |
|
553 |
||
554 |
value:arg1 value:arg2 |
|
555 |
|oldValue1 oldValue2 val| |
|
556 |
||
557 |
(blockArgs size ~~ 2) ifTrue:[ |
|
45 | 558 |
^ self wrongNumberOfArguments:2 |
0 | 559 |
]. |
560 |
statements isNil ifTrue:[^ nil]. |
|
561 |
||
562 |
oldValue1 := (blockArgs at:1) value. |
|
563 |
oldValue2 := (blockArgs at:2) value. |
|
564 |
(blockArgs at:1) value:arg1. |
|
565 |
(blockArgs at:2) value:arg2. |
|
566 |
||
15 | 567 |
exitBlock := [:v | |
45 | 568 |
(blockArgs at:1) value:oldValue1. |
569 |
(blockArgs at:2) value:oldValue2. |
|
570 |
^ v |
|
0 | 571 |
]. |
572 |
||
573 |
val := statements evaluate. |
|
574 |
||
575 |
(blockArgs at:1) value:oldValue1. |
|
576 |
(blockArgs at:2) value:oldValue2. |
|
577 |
^ val |
|
578 |
! |
|
579 |
||
580 |
value:arg1 value:arg2 value:arg3 |
|
581 |
|oldValue1 oldValue2 oldValue3 val| |
|
582 |
||
583 |
(blockArgs size ~~ 3) ifTrue:[ |
|
45 | 584 |
^ self wrongNumberOfArguments:3 |
0 | 585 |
]. |
586 |
statements isNil ifTrue:[^ nil]. |
|
587 |
||
588 |
oldValue1 := (blockArgs at:1) value. |
|
589 |
oldValue2 := (blockArgs at:2) value. |
|
590 |
oldValue3 := (blockArgs at:3) value. |
|
591 |
(blockArgs at:1) value:arg1. |
|
592 |
(blockArgs at:2) value:arg2. |
|
593 |
(blockArgs at:3) value:arg3. |
|
594 |
||
15 | 595 |
exitBlock := [:v | |
45 | 596 |
(blockArgs at:1) value:oldValue1. |
597 |
(blockArgs at:2) value:oldValue2. |
|
598 |
(blockArgs at:3) value:oldValue3. |
|
599 |
^ v |
|
0 | 600 |
]. |
601 |
||
602 |
val := statements evaluate. |
|
603 |
||
604 |
(blockArgs at:1) value:oldValue1. |
|
605 |
(blockArgs at:2) value:oldValue2. |
|
606 |
(blockArgs at:3) value:oldValue3. |
|
607 |
^ val |
|
608 |
! |
|
609 |
||
610 |
value:arg1 value:arg2 value:arg3 value:arg4 |
|
611 |
|oldValue1 oldValue2 oldValue3 oldValue4 val| |
|
612 |
||
613 |
(blockArgs size ~~ 4) ifTrue:[ |
|
45 | 614 |
^ self wrongNumberOfArguments:4 |
0 | 615 |
]. |
616 |
statements isNil ifTrue:[^ nil]. |
|
617 |
||
618 |
oldValue1 := (blockArgs at:1) value. |
|
619 |
oldValue2 := (blockArgs at:2) value. |
|
620 |
oldValue3 := (blockArgs at:3) value. |
|
621 |
oldValue4 := (blockArgs at:4) value. |
|
622 |
(blockArgs at:1) value:arg1. |
|
623 |
(blockArgs at:2) value:arg2. |
|
624 |
(blockArgs at:3) value:arg3. |
|
625 |
(blockArgs at:4) value:arg4. |
|
626 |
||
15 | 627 |
exitBlock := [:v | |
45 | 628 |
(blockArgs at:1) value:oldValue1. |
629 |
(blockArgs at:2) value:oldValue2. |
|
630 |
(blockArgs at:3) value:oldValue3. |
|
631 |
(blockArgs at:4) value:oldValue4. |
|
632 |
^ v |
|
0 | 633 |
]. |
634 |
||
635 |
val := statements evaluate. |
|
636 |
||
637 |
(blockArgs at:1) value:oldValue1. |
|
638 |
(blockArgs at:2) value:oldValue2. |
|
639 |
(blockArgs at:3) value:oldValue3. |
|
640 |
(blockArgs at:4) value:oldValue4. |
|
641 |
^ val |
|
140 | 642 |
! |
3 | 643 |
|
644 |
valueWithArguments:argArray |
|
645 |
|oldValues val| |
|
646 |
||
647 |
(blockArgs size ~~ argArray size) ifTrue:[ |
|
45 | 648 |
^ self wrongNumberOfArguments:argArray size |
3 | 649 |
]. |
650 |
statements isNil ifTrue:[^ nil]. |
|
651 |
||
652 |
oldValues := Array new:(argArray size). |
|
653 |
1 to:argArray size do:[:i | |
|
45 | 654 |
oldValues at:i put:(blockArgs at:i) value. |
655 |
(blockArgs at:i) value:(argArray at:i). |
|
3 | 656 |
]. |
15 | 657 |
exitBlock := [:v | |
45 | 658 |
1 to:argArray size do:[:i | |
659 |
( blockArgs at:i) value:(oldValues at:i) |
|
660 |
]. |
|
661 |
^ v |
|
3 | 662 |
]. |
663 |
||
664 |
val := statements evaluate. |
|
665 |
||
666 |
1 to:argArray size do:[:i | |
|
45 | 667 |
(blockArgs at:i) value:(oldValues at:i) |
3 | 668 |
]. |
669 |
^ val |
|
140 | 670 |
! |
671 |
||
672 |
wrongNumberOfArguments:numberGiven |
|
673 |
Block argumentSignal |
|
674 |
raiseRequestWith:self |
|
675 |
errorString:('block got ' , numberGiven printString , |
|
676 |
' args while ' , blockArgs size printString , ' where expected') |
|
0 | 677 |
! ! |
678 |
||
679 |
!BlockNode methodsFor:'looping'! |
|
680 |
||
681 |
whileFalse:aBlock |
|
26 | 682 |
self value ifTrue:[^ nil]. |
683 |
aBlock value. |
|
684 |
thisContext restart |
|
0 | 685 |
! |
686 |
||
140 | 687 |
whileTrue:aBlock |
688 |
self value ifFalse:[^ nil]. |
|
689 |
aBlock value. |
|
690 |
thisContext restart |
|
0 | 691 |
! ! |
692 |
||
693 |
!BlockNode methodsFor:'printing'! |
|
694 |
||
695 |
printOn:aStream indent:i |
|
98 | 696 |
|n "{Class: SmallInteger }"| |
697 |
||
0 | 698 |
aStream nextPut:$[. |
98 | 699 |
(n := blockArgs size) > 0 ifTrue:[ |
700 |
1 to:n do:[:index | |
|
96 | 701 |
aStream nextPut:$:. |
702 |
aStream nextPutAll:(blockArgs at:index) name. |
|
703 |
aStream space. |
|
704 |
]. |
|
98 | 705 |
aStream nextPut:$|. |
706 |
aStream space. |
|
707 |
]. |
|
708 |
(n := blockVars size) > 0 ifTrue:[ |
|
709 |
aStream nextPut:$|. |
|
710 |
1 to:n do:[:index | |
|
711 |
aStream nextPutAll:(blockVars at:index) name. |
|
712 |
aStream space. |
|
713 |
]. |
|
714 |
aStream nextPut:$|. |
|
0 | 715 |
]. |
716 |
statements notNil ifTrue:[ |
|
45 | 717 |
aStream cr. |
718 |
statements printAllOn:aStream indent:i + 4. |
|
719 |
aStream cr. |
|
720 |
aStream spaces:i. |
|
0 | 721 |
]. |
722 |
aStream nextPut:$] |
|
723 |
! ! |
|
140 | 724 |
|
725 |
!BlockNode methodsFor:'private accessing'! |
|
726 |
||
727 |
setArguments:argList home:h variables:vars |
|
728 |
inlineBlock := false. |
|
729 |
needsHome := false. |
|
730 |
blockArgs := argList. |
|
731 |
home := h. |
|
557
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
732 |
blockVars := vars. |
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
733 |
numTemp := maxNumTemp := 0. |
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
734 |
|
8202a13be88b
preps to move vars of inlined blocks to outer context
Claus Gittinger <cg@exept.de>
parents:
555
diff
changeset
|
735 |
"Modified: 25.6.1997 / 15:07:52 / cg" |
140 | 736 |
! ! |
737 |
||
738 |
!BlockNode methodsFor:'queries'! |
|
739 |
||
394 | 740 |
collectBlocksInto:aCollection |
741 |
aCollection add:self. |
|
458 | 742 |
statements notNil ifTrue:[statements collectBlocksInto:aCollection] |
394 | 743 |
|
744 |
"Created: 23.10.1996 / 15:45:16 / cg" |
|
745 |
"Modified: 23.10.1996 / 16:02:57 / cg" |
|
746 |
! |
|
747 |
||
333
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
748 |
endsWithReturn |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
749 |
statements isNil ifTrue:[ |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
750 |
^ false |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
751 |
]. |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
752 |
^ statements listEndsWithReturn |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
753 |
|
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
754 |
"Created: 19.8.1996 / 14:36:32 / cg" |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
755 |
! |
96bb5c3dab61
added query if blocks statementList ends in a return;
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
756 |
|
559 | 757 |
indexOfFirstTemp |
758 |
^ indexOfFirstTemp |
|
759 |
||
760 |
"Created: 25.6.1997 / 15:39:11 / cg" |
|
761 |
! |
|
762 |
||
140 | 763 |
isBlock |
764 |
"a kludge, to have blocknodes mimic blocks" |
|
765 |
||
766 |
^ true |
|
168 | 767 |
! |
768 |
||
394 | 769 |
numArgs |
522 | 770 |
"return the number of arguments the block represented by myself |
771 |
expects for evaluation" |
|
772 |
||
394 | 773 |
^ blockArgs size |
774 |
||
775 |
"Created: 23.10.1996 / 15:57:04 / cg" |
|
522 | 776 |
"Modified: 7.5.1997 / 15:34:35 / cg" |
394 | 777 |
! |
778 |
||
779 |
numVars |
|
780 |
^ blockVars size |
|
781 |
||
782 |
"Created: 23.10.1996 / 16:17:07 / cg" |
|
783 |
! |
|
784 |
||
169 | 785 |
simpleSendBlockExpression |
786 |
blockVars notNil ifTrue:[^ nil]. |
|
787 |
statements isNil ifTrue:[^ nil]. |
|
788 |
statements nextStatement notNil ifTrue:[^ nil]. |
|
789 |
^ statements expression |
|
790 |
||
791 |
"Created: 13.12.1995 / 20:06:09 / cg" |
|
140 | 792 |
! ! |
793 |
||
366 | 794 |
!BlockNode class methodsFor:'documentation'! |
148 | 795 |
|
796 |
version |
|
562
36bd00734940
care for numVars in makeBlock (inlined blocks add vars)
Claus Gittinger <cg@exept.de>
parents:
559
diff
changeset
|
797 |
^ '$Header: /cvs/stx/stx/libcomp/BlockNode.st,v 1.44 1997-06-26 09:05:30 cg Exp $' |
148 | 798 |
! ! |