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