author | Claus Gittinger <cg@exept.de> |
Wed, 29 May 2019 01:10:49 +0200 | |
changeset 24226 | 077779a848b3 |
parent 24126 | ee291d3ee4a5 |
child 24227 | 2c11474e979f |
permissions | -rw-r--r-- |
24226 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
154 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5349 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
17301 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
4299 | 18 |
CompiledCode variableSubclass:#Block |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
19 |
instanceVariableNames:'home nargs sourcePos initialPC' |
21922 | 20 |
classVariableNames:'' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
21 |
poolDictionaries:'' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
22 |
category:'Kernel-Methods' |
1 | 23 |
! |
24 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
25 |
!Block class methodsFor:'documentation'! |
1 | 26 |
|
92 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 30 |
All Rights Reserved |
92 | 31 |
|
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
1 | 41 |
documentation |
42 |
" |
|
67 | 43 |
Blocks are pieces of executable code which can be evaluated by sending |
44 |
them a value-message (''value'', ''value:'', ''value:value:'' etc). |
|
1 | 45 |
|
1265 | 46 |
In smalltalk, Blocks provide the basic (and heavily used) mechanism |
47 |
for looping, enumerating collection elements, visitors, exception |
|
48 |
handling, unwinding, delayed execution and processes. |
|
49 |
||
1254 | 50 |
Blocks are never created explicitely; the only creation |
51 |
is done by the compilers, when some sourceCode is compiled to either |
|
52 |
machine or byteCode. |
|
53 |
||
20621 | 54 |
In the code, blocks are written as: |
55 |
[ |
|
56 |
expression1. |
|
57 |
... |
|
58 |
expressionN |
|
59 |
] |
|
60 |
It represents the computation inside the brackets, |
|
61 |
and can be passed around as argument, assigned to variables or returned from a block or method. |
|
62 |
Creation of a block does NOT evaluate its expressions. You have to give the block to someone, |
|
63 |
who asks it to evaluate itself. This is done by sending #value to the block. |
|
64 |
i.e. |
|
65 |
foo := [ Transcript showCR:'Hello World']. |
|
66 |
... |
|
67 |
foo value |
|
68 |
||
69 |
Blocks are used in many many ways; one particular use is as callback: |
|
70 |
|b| |
|
71 |
||
72 |
b := Button label:'Press me'. |
|
73 |
b action:[ Transcript showCR:'Hello']. |
|
74 |
b open. |
|
75 |
||
67 | 76 |
Blocks with arguments need a message of type ''value:arg1 ... value:argn'' |
77 |
for evaluation; the number of arguments passed when evaluating must match |
|
78 |
the number of arguments the block was declared with otherwise an error is |
|
20621 | 79 |
raised. |
80 |
Blocks without args need a ''value'' message for evaluation. |
|
81 |
||
82 |
another use of blocks is in the enumeration protocols: |
|
83 |
|coll| |
|
84 |
||
85 |
coll := #( 'one' 'two' 'three'). |
|
86 |
coll do:[:eachElement | Transcript showCR:eachElement ]. |
|
87 |
||
88 |
Blocks keep a reference to the context where it was declared - |
|
22363 | 89 |
this allows blocks to access the method's arguments and/or variables. |
154 | 90 |
This is still true after the method has returned - since the |
22363 | 91 |
block keeps this reference, the method's context will NOT die in this case. |
20621 | 92 |
(for experts: Smalltalk blocks are technically lambdas/closures) |
1 | 93 |
|
67 | 94 |
A return (via ^-statement) out of a block will force a return from the |
20621 | 95 |
block's method context (if it is still living). |
96 |
This is effectively a kind of long-jumps out of the method which declared the block |
|
97 |
and makes control structures and loops possible. |
|
98 |
If the method is not alive (i.e. has already returned), a return out of the |
|
99 |
block will trigger an error. |
|
1 | 100 |
|
67 | 101 |
Long-jump is done by defining a catchBlock as ''[^ self]'' |
18252 | 102 |
somewhere up in the calling-tree. Then, to do the long-jump from out of some |
67 | 103 |
deeply nested method, simply do: ''catchBlock value''. |
1 | 104 |
|
1293 | 105 |
[Instance variables:] |
1 | 106 |
|
222 | 107 |
home <Context> the context where this block was created (i.e. defined) |
20621 | 108 |
this may be a blockContext or a methodContext |
222 | 109 |
nargs <SmallInteger> the number of arguments the block expects |
110 |
sourcePos <SmallInteger> the character position of its source, in chars |
|
20621 | 111 |
relative to methods source beginning |
222 | 112 |
initialPC <SmallInteger> the start position within the byteCode |
20621 | 113 |
for compiled blocks, this is nil. |
222 | 114 |
|
115 |
||
1293 | 116 |
[Class variables:] |
222 | 117 |
|
118 |
InvalidNewSignal raised if a Block is tried to be created |
|
20621 | 119 |
with new (which is not allowed). |
120 |
Only the VM is allowed to create Blocks. |
|
1 | 121 |
|
1293 | 122 |
|
67 | 123 |
NOTICE: layout known by runtime system and compiler - do not change |
1293 | 124 |
|
125 |
[author:] |
|
20621 | 126 |
Claus Gittinger |
1293 | 127 |
|
128 |
[see also:] |
|
20621 | 129 |
Process Context |
130 |
Collection |
|
131 |
( contexts. blocks & unwinding : programming/contexts.html) |
|
1 | 132 |
" |
1265 | 133 |
! |
134 |
||
135 |
examples |
|
136 |
" |
|
1293 | 137 |
define a block and evaluate it: |
18252 | 138 |
[exBegin] |
139 |
|b| |
|
140 |
||
141 |
b := [ Transcript showCR:'hello' ]. |
|
142 |
||
143 |
Transcript showCR:'now evaluating the block ...'. |
|
144 |
b value. |
|
145 |
[exEnd] |
|
146 |
||
147 |
||
148 |
||
149 |
even here, blocks are involved: |
|
1265 | 150 |
(although, the compiler optimizes things if possible) |
18252 | 151 |
[exBegin] |
152 |
Transcript showCR:'now evaluating one of two blocks ...'. |
|
153 |
1 > 4 ifTrue:[ |
|
154 |
Transcript showCR:'foo' |
|
155 |
] ifFalse:[ |
|
156 |
Transcript showCR:'bar' |
|
157 |
] |
|
158 |
[exEnd] |
|
1265 | 159 |
|
160 |
||
1293 | 161 |
|
1265 | 162 |
here things become obvious: |
18252 | 163 |
[exBegin] |
164 |
|yesBlock noBlock| |
|
165 |
||
166 |
yesBlock := [ Transcript showCR:'foo' ]. |
|
167 |
noBlock := [ Transcript showCR:'bar' ]. |
|
168 |
||
169 |
Transcript showCR:'now evaluating one of two blocks ...'. |
|
170 |
1 > 4 ifTrue:yesBlock |
|
171 |
ifFalse:noBlock |
|
172 |
[exEnd] |
|
1265 | 173 |
|
174 |
||
1293 | 175 |
|
1265 | 176 |
simple loops: |
177 |
not very objectOriented: |
|
18252 | 178 |
[exBegin] |
179 |
|i| |
|
180 |
||
181 |
i := 1. |
|
182 |
[i < 10] whileTrue:[ |
|
183 |
Transcript showCR:i. |
|
184 |
i := i + 1 |
|
185 |
] |
|
186 |
[exEnd] |
|
1265 | 187 |
|
188 |
||
189 |
using integer protocol: |
|
18252 | 190 |
[exBegin] |
191 |
1 to:10 do:[:i | |
|
192 |
Transcript showCR:i. |
|
193 |
] |
|
194 |
[exEnd] |
|
1265 | 195 |
|
196 |
||
197 |
interval protocol: |
|
18252 | 198 |
[exBegin] |
199 |
(1 to:10) do:[:i | |
|
200 |
Transcript showCR:i. |
|
201 |
] |
|
202 |
[exEnd] |
|
1265 | 203 |
|
204 |
||
1293 | 205 |
|
1265 | 206 |
looping over collections: |
207 |
||
1293 | 208 |
bad code: |
209 |
(only works with numeric-indexable collections) |
|
18252 | 210 |
[exBegin] |
211 |
|i coll| |
|
212 |
||
213 |
coll := #(9 8 7 6 5). |
|
214 |
i := 1. |
|
215 |
[i <= coll size] whileTrue:[ |
|
216 |
Transcript showCR:(coll at:i). |
|
217 |
i := i + 1. |
|
218 |
] |
|
219 |
[exEnd] |
|
1265 | 220 |
|
221 |
||
222 |
||
1293 | 223 |
just as bad (well, marginally better ;-): |
224 |
(only works with numeric-indexable collections) |
|
18252 | 225 |
[exBegin] |
226 |
|coll| |
|
227 |
||
228 |
coll := #(9 8 7 6 5). |
|
229 |
1 to:coll size do:[:i | |
|
230 |
Transcript showCR:(coll at:i). |
|
231 |
] |
|
232 |
[exEnd] |
|
1265 | 233 |
|
234 |
||
235 |
||
1293 | 236 |
the smalltalk way: |
237 |
(works with any collection) |
|
18252 | 238 |
[exBegin] |
239 |
|coll| |
|
240 |
||
241 |
coll := #(9 8 7 6 5). |
|
242 |
coll do:[:element | |
|
243 |
Transcript showCR:element. |
|
244 |
] |
|
245 |
[exEnd] |
|
246 |
||
1265 | 247 |
Rule: use enumeration protocol of the collection instead of |
18252 | 248 |
manually indexing it. [with few exceptions] |
1265 | 249 |
|
250 |
||
251 |
||
252 |
processes: |
|
253 |
||
254 |
forking a lightweight process (thread): |
|
18252 | 255 |
[exBegin] |
256 |
[ |
|
257 |
Transcript showCR:'waiting ...'. |
|
258 |
Delay waitForSeconds:2. |
|
259 |
Transcript showCR:'here I am'. |
|
260 |
] fork |
|
261 |
[exEnd] |
|
262 |
||
263 |
||
264 |
||
1265 | 265 |
some with low prio: |
18252 | 266 |
[exBegin] |
267 |
[ |
|
268 |
Transcript showCR:'computing ...'. |
|
269 |
10000 factorial. |
|
270 |
Transcript showCR:'here I am'. |
|
271 |
] forkAt:(Processor userBackgroundPriority) |
|
272 |
[exEnd] |
|
1265 | 273 |
|
274 |
||
1293 | 275 |
|
276 |
handling exceptions: |
|
18252 | 277 |
[exBegin] |
278 |
Error handle:[:ex | |
|
279 |
Transcript showCR:'exception handler forces return'. |
|
280 |
ex return |
|
281 |
] do:[ |
|
282 |
Transcript showCR:'now, doing something bad ...'. |
|
283 |
1 / 0. |
|
284 |
Transcript showCR:'not reached' |
|
285 |
] |
|
286 |
[exEnd] |
|
1265 | 287 |
|
288 |
||
1293 | 289 |
|
290 |
performing cleanup actions: |
|
18252 | 291 |
[exBegin] |
292 |
Error handle:[:ex | |
|
293 |
Transcript showCR:'exception handler forces return'. |
|
294 |
ex return |
|
295 |
] do:[ |
|
296 |
[ |
|
297 |
Transcript showCR:'doing something bad ...'. |
|
298 |
1 / 0. |
|
299 |
Transcript showCR:'not reached' |
|
300 |
] ifCurtailed:[ |
|
301 |
Transcript showCR:'cleanup' |
|
302 |
] |
|
303 |
] |
|
304 |
[exEnd] |
|
1265 | 305 |
|
306 |
||
1293 | 307 |
delayed execution (visitor pattern): |
18252 | 308 |
(looking carefully into the example, |
1293 | 309 |
C/C++ programmers may raise their eyes ;-) |
18252 | 310 |
[exBegin] |
311 |
|showBlock countBlock |
|
312 |
howMany |
|
313 |
top panel b1 b2| |
|
314 |
||
315 |
howMany := 0. |
|
316 |
||
317 |
showBlock := [ Transcript showCR:howMany ]. |
|
318 |
countBlock := [ howMany := howMany + 1 ]. |
|
319 |
||
320 |
top := StandardSystemView extent:200@200. |
|
321 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
322 |
||
323 |
b1 := Button label:'count up' in:panel. |
|
324 |
b1 action:countBlock. |
|
325 |
||
326 |
b2 := Button label:'show value' in:panel. |
|
327 |
b2 action:showBlock. |
|
328 |
||
329 |
top open. |
|
330 |
||
331 |
Transcript showCR:'new process started;'. |
|
332 |
Transcript showCR:'notice: the blocks can still access the'. |
|
333 |
Transcript showCR:' howMany local variable.'. |
|
334 |
[exEnd] |
|
1265 | 335 |
" |
1 | 336 |
! ! |
337 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
338 |
!Block class methodsFor:'instance creation'! |
1 | 339 |
|
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
340 |
byteCode:bCode numArgs:numArgs numStack:nStack sourcePosition:sourcePos initialPC:initialPC literals:literals |
1 | 341 |
"create a new cheap (homeless) block. |
222 | 342 |
Not for public use - this is a special hook for the compiler." |
1 | 343 |
|
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
344 |
^ self |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
345 |
byteCode:bCode numArgs:numArgs numVars:0 numStack:nStack sourcePosition:sourcePos initialPC:initialPC literals:literals |
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
346 |
! |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
347 |
|
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
348 |
byteCode:bCode numArgs:numArgs numVars:numVars numStack:nStack sourcePosition:sourcePos initialPC:initialPC literals:literals |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
349 |
"create a new cheap (homeless) block. |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
350 |
Not for public use - this is a special hook for the compiler." |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
351 |
|
21922 | 352 |
^ (self basicNew:literals size) |
353 |
byteCode:bCode |
|
354 |
numArgs:numArgs |
|
355 |
numVars:numVars |
|
356 |
numStack:nStack |
|
357 |
sourcePosition:sourcePos |
|
358 |
initialPC:initialPC |
|
359 |
literals:literals; |
|
360 |
yourself. |
|
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
361 |
|
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
362 |
"Modified: 24.6.1996 / 12:36:48 / stefan" |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
363 |
"Created: 13.4.1997 / 00:04:09 / cg" |
1 | 364 |
! |
365 |
||
22 | 366 |
new |
4299 | 367 |
"catch creation of blocks - only the system creates blocks. |
368 |
If you really need a block (assuming, you are some compiler), |
|
369 |
use basicNew and setup the instance carefully" |
|
1 | 370 |
|
21922 | 371 |
^ MethodNotAppropriateError raiseErrorString:'blocks are only created by the system'. |
1 | 372 |
! |
373 |
||
22 | 374 |
new:size |
1 | 375 |
"catch creation of blocks - only the system creates blocks" |
376 |
||
21922 | 377 |
^ MethodNotAppropriateError raiseErrorString:'blocks are only created by the system'. |
1 | 378 |
! ! |
379 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
380 |
!Block class methodsFor:'queries'! |
1 | 381 |
|
623 | 382 |
isBuiltInClass |
1264 | 383 |
"return true if this class is known by the run-time-system. |
384 |
Here, true is returned for myself, false for subclasses." |
|
11 | 385 |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
386 |
^ self == Block |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
387 |
|
1264 | 388 |
"Modified: 23.4.1996 / 15:55:58 / cg" |
1 | 389 |
! ! |
390 |
||
15850 | 391 |
|
7261 | 392 |
!Block methodsFor:'Compatibility-ANSI'! |
5349 | 393 |
|
5944 | 394 |
argumentCount |
7352 | 395 |
"VisualAge/ANSI compatibility: alias for #numArgs. |
5944 | 396 |
return the number of arguments I expect for evaluation" |
397 |
||
398 |
^ nargs |
|
399 |
||
400 |
"Created: 15.11.1996 / 11:22:02 / cg" |
|
401 |
! |
|
402 |
||
5349 | 403 |
ensure:aBlock |
17697 | 404 |
"VisualAge/ANSI compatibility: |
405 |
evaluate the receiver and return its result. |
|
5349 | 406 |
After evaluation, also evaluate aBlock but ignore its result. |
407 |
aBlock is also evaluated in case of abnormal termination. |
|
408 |
(the same as #valueNowOrOnUnwindDo:)" |
|
409 |
||
5666
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
410 |
<exception: #unwind> |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
411 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
412 |
|v| |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
413 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
414 |
v := self value. "the real logic is in Context>>unwind" |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
415 |
thisContext unmarkForUnwind. |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
416 |
aBlock value. |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
417 |
^ v |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
418 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
419 |
"/ the above is the same as in #valueNowOrOnUnwindDo: |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
420 |
"/ (actually, the previous implementation was: |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
421 |
"/ ^ self valueNowOrOnUnwindDo:aBlock |
5349 | 422 |
|
423 |
" |
|
424 |
[ |
|
18252 | 425 |
[ |
426 |
Transcript showCR:'one'. |
|
427 |
Processor activeProcess terminate. |
|
428 |
Transcript showCR:'two'. |
|
429 |
] ensure:[ |
|
430 |
Transcript showCR:'three'. |
|
431 |
]. |
|
5349 | 432 |
] fork. |
433 |
" |
|
434 |
||
435 |
" |
|
436 |
[ |
|
18252 | 437 |
[ |
438 |
Transcript showCR:'one'. |
|
439 |
Transcript showCR:'two'. |
|
440 |
] ensure:[ |
|
441 |
Transcript showCR:'three'. |
|
442 |
]. |
|
5349 | 443 |
] fork. |
444 |
" |
|
5951 | 445 |
! |
446 |
||
447 |
ifCurtailed:aBlock |
|
17697 | 448 |
"VisualAge/ANSI compatibility: |
449 |
evaluate the receiver - when some method sent within unwinds (i.e. does |
|
5951 | 450 |
a long return), evaluate the argument, aBlock. |
451 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
452 |
executed regardless of error actions. |
|
453 |
This is the same as #valueOnUnwindDo:" |
|
454 |
||
455 |
<exception: #unwind> |
|
456 |
||
457 |
|v| |
|
458 |
||
459 |
"/ thisContext markForUnwind. -- same as above pragma |
|
460 |
v := self value. "the real logic is in Context>>unwind" |
|
461 |
thisContext unmarkForUnwind. |
|
462 |
^ v |
|
463 |
||
464 |
" |
|
465 |
|s| |
|
466 |
||
467 |
s := 'Makefile' asFilename readStream. |
|
468 |
[ |
|
18252 | 469 |
^ self |
5951 | 470 |
] ifCurtailed:[ |
18252 | 471 |
Transcript showCR:'closing the stream - even though a return occurred'. |
472 |
s close |
|
5951 | 473 |
] |
474 |
" |
|
475 |
" |
|
476 |
[ |
|
18252 | 477 |
|s| |
478 |
||
479 |
s := 'Makefile' asFilename readStream. |
|
480 |
[ |
|
481 |
Processor activeProcess terminate |
|
482 |
] ifCurtailed:[ |
|
483 |
Transcript showCR:'closing the stream - even though process was terminated'. |
|
484 |
s close |
|
485 |
] |
|
5951 | 486 |
] fork |
487 |
" |
|
5349 | 488 |
! ! |
489 |
||
8440
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
490 |
|
7261 | 491 |
!Block methodsFor:'Compatibility-Squeak'! |
5015 | 492 |
|
18252 | 493 |
cull: optionalFirstArg |
17697 | 494 |
"activate the receiver with one or zero arguments. |
495 |
Squeak compatibility, but also present in VW Smalltalk" |
|
496 |
||
497 |
nargs >= 1 ifTrue:[^ self value:optionalFirstArg]. |
|
15089 | 498 |
^ self value |
499 |
! |
|
500 |
||
17697 | 501 |
cull: optionalFirstArg cull: optionalSecondArg |
502 |
"activate the receiver with two or less arguments. |
|
503 |
Squeak compatibility, but also present in VW Smalltalk" |
|
504 |
||
505 |
nargs >= 2 ifTrue:[^ self value:optionalFirstArg value:optionalSecondArg]. |
|
506 |
nargs = 1 ifTrue:[^ self value:optionalFirstArg]. |
|
15089 | 507 |
^ self value |
508 |
! |
|
509 |
||
17697 | 510 |
cull: optionalFirstArg cull: optionalSecondArg cull: optionalThirdArg |
511 |
"activate the receiver with three or less arguments. |
|
512 |
Squeak compatibility, but also present in VW Smalltalk" |
|
15089 | 513 |
|
514 |
nargs >= 2 ifTrue:[ |
|
18252 | 515 |
nargs >= 3 ifTrue:[ |
516 |
^ self value:optionalFirstArg value:optionalSecondArg value:optionalThirdArg |
|
517 |
]. |
|
518 |
^ self value:optionalFirstArg value:optionalSecondArg |
|
15089 | 519 |
]. |
17697 | 520 |
nargs = 1 ifTrue:[^ self value:optionalFirstArg]. |
15088 | 521 |
^ self value |
522 |
! |
|
523 |
||
5015 | 524 |
ifError:handlerBlock |
15119 | 525 |
"squeak compatibility: |
19450 | 526 |
Evaluate the receiver block and return its value, if no error occurs. |
15119 | 527 |
If an error is raised, return the value from handlerBlock. |
528 |
The handlerBlock may take 0,1 or 2 args. |
|
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
529 |
(1 arg -> the exception; |
20144 | 530 |
2 args -> the errorString and the erroneous receiver)" |
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
531 |
|
11934 | 532 |
|numArgs| |
533 |
||
18434 | 534 |
numArgs := handlerBlock isBlock ifTrue:[handlerBlock argumentCount] ifFalse:[0]. |
21662 | 535 |
numArgs <= 1 ifTrue:[ |
18434 | 536 |
^ self on:Error do:handlerBlock |
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
537 |
]. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
538 |
|
18252 | 539 |
^ self |
18434 | 540 |
on:Error |
541 |
do:[:ex | |
|
21662 | 542 |
ex return:(handlerBlock value:ex description value:ex suspendedContext receiver) |
18434 | 543 |
] |
6142 | 544 |
|
545 |
" |
|
546 |
|a| |
|
547 |
||
548 |
a := 0. |
|
549 |
[ 123 / a ] ifError:[:msg :rec | self halt] |
|
550 |
" |
|
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
551 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
552 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
553 |
|a| |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
554 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
555 |
a := 0. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
556 |
[ 123 / a ] ifError:[:ex | self halt] |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
557 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
558 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
559 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
560 |
|a| |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
561 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
562 |
a := 0. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
563 |
[ 123 / a ] ifError:[self halt] |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
564 |
" |
21662 | 565 |
|
566 |
"Modified: / 18-03-2017 / 18:19:20 / stefan" |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
567 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
568 |
|
15090 | 569 |
timeToRun |
17697 | 570 |
"squeak compatibility: same as millisecondsToRun:" |
571 |
||
15090 | 572 |
^ Time millisecondsToRun:self |
573 |
! |
|
574 |
||
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
575 |
valueWithPossibleArgs:argArray |
17697 | 576 |
"squeak compatibility: same as valueWithOptionalArguments:" |
577 |
||
9602 | 578 |
^ self valueWithOptionalArguments:argArray |
5015 | 579 |
! ! |
580 |
||
7261 | 581 |
!Block methodsFor:'Compatibility-V''Age'! |
1979 | 582 |
|
14139 | 583 |
apply:aCollection from:start to:end |
17697 | 584 |
"VisualAge compatibility: |
18252 | 585 |
Evaluate the receiver for each variable slot of aCollection from start to end. |
14139 | 586 |
Answer aCollection." |
587 |
||
588 |
aCollection from:start to:end do:self. |
|
589 |
^ aCollection |
|
590 |
||
591 |
" |
|
592 |
[:i | Transcript showCR:i ] |
|
18252 | 593 |
apply:#(10 20 30 40 50 60) from:2 to:4 |
14139 | 594 |
" |
595 |
||
596 |
"Created: / 16-05-2012 / 11:20:55 / cg" |
|
597 |
! |
|
598 |
||
599 |
applyWithIndex:aCollection from:start to:end |
|
17697 | 600 |
"VisualAge compatibility: |
18252 | 601 |
Evaluate the receiver for each variable slot and index of aCollection from start to end. |
14139 | 602 |
Answer aCollection." |
603 |
||
604 |
aCollection from:start to:end doWithIndex:self. |
|
605 |
^ aCollection |
|
606 |
||
607 |
" |
|
608 |
[:el :i | Transcript showCR:(i -> el) ] |
|
18252 | 609 |
applyWithIndex:#(10 20 30 40 50 60) from:2 to:4 |
14139 | 610 |
" |
611 |
||
612 |
"Created: / 16-05-2012 / 11:22:01 / cg" |
|
613 |
! |
|
614 |
||
615 |
value:arg1 onReturnDo:aBlock |
|
616 |
"VisualAge compatibility: alias for #ensure: |
|
617 |
evaluate the receiver - when the block returns either a local return |
|
618 |
or an unwind (i.e. does a long return), evaluate the argument, aBlock. |
|
18252 | 619 |
This is used to make certain that cleanup actions |
14139 | 620 |
(for example closing files etc.) are executed regardless of error actions." |
621 |
||
622 |
^ [self value:arg1] ensure:aBlock |
|
623 |
||
624 |
"Created: / 16-05-2012 / 11:29:30 / cg" |
|
625 |
! |
|
626 |
||
627 |
value:arg1 value:arg2 onReturnDo:aBlock |
|
628 |
"VisualAge compatibility: alias for #ensure: |
|
629 |
evaluate the receiver - when the block returns either a local return |
|
630 |
or an unwind (i.e. does a long return), evaluate the argument, aBlock. |
|
18252 | 631 |
This is used to make certain that cleanup actions |
14139 | 632 |
(for example closing files etc.) are executed regardless of error actions." |
633 |
||
634 |
^ [self value:arg1 value:arg2] ensure:aBlock |
|
635 |
||
636 |
"Created: / 16-05-2012 / 11:29:46 / cg" |
|
637 |
! |
|
638 |
||
639 |
value:arg1 value:arg2 value:arg3 onReturnDo:aBlock |
|
640 |
"VisualAge compatibility: alias for #ensure: |
|
641 |
evaluate the receiver - when the block returns either a local return |
|
642 |
or an unwind (i.e. does a long return), evaluate the argument, aBlock. |
|
18252 | 643 |
This is used to make certain that cleanup actions |
14139 | 644 |
(for example closing files etc.) are executed regardless of error actions." |
645 |
||
646 |
^ [self value:arg1 value:arg2 value:arg3] ensure:aBlock |
|
647 |
||
648 |
"Created: / 16-05-2012 / 11:29:59 / cg" |
|
649 |
! |
|
650 |
||
651 |
valueOnReturnDo:aBlock |
|
652 |
"VisualAge compatibility: alias for #ensure: |
|
653 |
evaluate the receiver - when the block returns either a local return |
|
654 |
or an unwind (i.e. does a long return), evaluate the argument, aBlock. |
|
18252 | 655 |
This is used to make certain that cleanup actions |
14139 | 656 |
(for example closing files etc.) are executed regardless of error actions." |
657 |
||
658 |
^ self ensure:aBlock |
|
659 |
||
660 |
"Created: / 15-11-1996 / 11:38:37 / cg" |
|
13054 | 661 |
! |
662 |
||
663 |
when:exceptionClassOrSignal do:handler |
|
17697 | 664 |
"VisualAge compatibility:" |
665 |
||
13054 | 666 |
^ self on:exceptionClassOrSignal do:handler |
667 |
||
668 |
"Created: / 28-08-2010 / 14:41:15 / cg" |
|
1979 | 669 |
! ! |
670 |
||
23715 | 671 |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
672 |
!Block methodsFor:'accessing'! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
673 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
674 |
home |
19450 | 675 |
"return the receiver's home context (the context where it was |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
676 |
created). For cheap blocks, nil is returned" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
677 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
678 |
^ home |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
679 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
680 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
681 |
homeMethod |
19450 | 682 |
"return the receiver's home method. |
683 |
That's the method where the block was created." |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
684 |
|
10473 | 685 |
|m| |
686 |
||
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
687 |
home notNil ifTrue:[ |
19450 | 688 |
m := home method. |
689 |
m notNil ifTrue:[^ m]. |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
690 |
]. |
10473 | 691 |
m := self literalAt:1 ifAbsent:nil. |
692 |
m isMethod ifTrue:[^ m]. |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
693 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
694 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
695 |
"Created: 19.6.1997 / 16:14:57 / cg" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
696 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
697 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
698 |
method |
19450 | 699 |
"return the receiver's method |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
700 |
(the method where the block was created). |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
701 |
Obsolete: use #homeMethod for ST80 compatibility." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
702 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
703 |
<resource: #obsolete> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
704 |
|
21919 | 705 |
self obsoleteMethodWarning:'use #homeMethod'. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
706 |
^ self homeMethod |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
707 |
|
21919 | 708 |
"Modified: / 19-06-1997 / 16:15:24 / cg" |
709 |
"Modified: / 23-06-2017 / 10:47:00 / stefan" |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
710 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
711 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
712 |
methodHome |
15532 | 713 |
"return the receiver's method home context (the context where it was |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
714 |
defined). For cheap blocks, nil is returned" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
715 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
716 |
home notNil ifTrue:[ |
18252 | 717 |
^ home methodHome |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
718 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
719 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
720 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
721 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
722 |
numArgs |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
723 |
"return the number of arguments I expect for evaluation. |
21123 | 724 |
Please use argumentCount for ANSI compatibility" |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
725 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
726 |
"/ <resource: #obsolete> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
727 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
728 |
^ nargs |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
729 |
! ! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
730 |
|
13220
21b4d5e57663
changed: #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
13054
diff
changeset
|
731 |
|
10890 | 732 |
!Block methodsFor:'compatibility-Cola & Pepsi'! |
733 |
||
734 |
arity |
|
18434 | 735 |
^ self argumentCount |
10890 | 736 |
! ! |
5931
9e40d7255c26
check for nil signal in #handle:do:
Claus Gittinger <cg@exept.de>
parents:
5779
diff
changeset
|
737 |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
738 |
!Block methodsFor:'conversion'! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
739 |
|
24126 | 740 |
asBlock |
741 |
^ self |
|
742 |
||
743 |
"Created: / 17-05-2019 / 15:09:21 / Claus Gittinger" |
|
744 |
! |
|
745 |
||
23688 | 746 |
asIterator |
747 |
"return myself as an iterator. |
|
748 |
that is a collection which uses the receiver block to |
|
749 |
generate the elements." |
|
750 |
||
751 |
^ Iterator on:self. |
|
752 |
||
753 |
" |
|
754 |
|coll| |
|
755 |
||
756 |
coll := [:action | 1 to:20 do:action] asIterator. |
|
757 |
coll do:[:each | Transcript showCR:each]. |
|
758 |
" |
|
759 |
||
760 |
"Created: / 09-02-2019 / 15:31:10 / Claus Gittinger" |
|
761 |
! |
|
762 |
||
5349 | 763 |
asVarArgBlock |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
764 |
"convert myself into a varArg block; |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
765 |
this one has 1 formal argument, which gets the list |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
766 |
of actual arguments when evaluated." |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
767 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
768 |
nargs ~~ 1 ifTrue:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
769 |
self error:'vararg blocks must take exactly 1 argument - the arg list'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
770 |
^ nil |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
771 |
]. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
772 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
773 |
self changeClassTo:VarArgBlock. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
774 |
^ self |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
775 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
776 |
" |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
777 |
|b| |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
778 |
|
18252 | 779 |
b := [:argList | Transcript |
780 |
show:'invoked with args:'; |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
781 |
showCR:argList |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
782 |
] asVarArgBlock. |
5349 | 783 |
b value. |
784 |
b value:'arg1'. |
|
785 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4' |
|
786 |
" |
|
787 |
||
788 |
"Created: 23.1.1997 / 13:35:28 / cg" |
|
789 |
"Modified: 23.1.1997 / 13:35:48 / cg" |
|
790 |
! |
|
791 |
||
7151 | 792 |
beCurryingBlock |
793 |
"make myself a currying block; |
|
12920
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
794 |
that's a block which, if invoked with less-than-expected arguments, |
7151 | 795 |
returns another block which provides the provided argument(s) and expects the remaining args. |
12920
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
796 |
Read any book on functional programming, if you don't understand this." |
7151 | 797 |
|
798 |
self changeClassTo:CurryingBlock. |
|
799 |
^ self |
|
12920
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
800 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
801 |
" |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
802 |
|b b1 b2 b3| |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
803 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
804 |
b := [:a :b :c | a + b + c] beCurryingBlock. |
18252 | 805 |
b numArgs. |
12920
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
806 |
b value:1 value:2 value:3. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
807 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
808 |
b1 := b value:10. |
18252 | 809 |
b1 numArgs. |
810 |
b1 value:2 value:3. |
|
12920
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
811 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
812 |
b2 := b value:10 value:20. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
813 |
b2 numArgs. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
814 |
b2 value:3. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
815 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
816 |
b3 := b1 value:20. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
817 |
b3 numArgs. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
818 |
b3 value:3. |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
819 |
" |
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
820 |
|
6f9c1bd017dc
comment/format in: #beCurryingBlock
Claus Gittinger <cg@exept.de>
parents:
12887
diff
changeset
|
821 |
"Modified: / 10-05-2010 / 12:56:20 / cg" |
7151 | 822 |
! |
823 |
||
5349 | 824 |
beVarArg |
825 |
"convert myself into a varArg block; |
|
826 |
this one has 1 formal argument, which gets the list |
|
827 |
of actual arguments when evaluated." |
|
828 |
||
829 |
^ self asVarArgBlock. |
|
830 |
||
831 |
" |
|
832 |
|b| |
|
833 |
||
2241 | 834 |
b := [:argList | argList printCR] beVarArg. |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
835 |
b value. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
836 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4' |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
837 |
" |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
838 |
|
2241 | 839 |
"Created: 23.1.1997 / 13:35:28 / cg" |
840 |
"Modified: 23.1.1997 / 13:35:48 / cg" |
|
23715 | 841 |
! |
842 |
||
843 |
literalArrayEncoding |
|
844 |
"I have none" |
|
845 |
||
846 |
^ nil |
|
847 |
||
848 |
"Created: / 11-02-2019 / 16:50:58 / sr" |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
849 |
! ! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
850 |
|
623 | 851 |
!Block methodsFor:'copying'! |
1 | 852 |
|
10942 | 853 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
854 |
|copyOfHome copyOfMe| |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
855 |
|
8638 | 856 |
home isNil ifTrue:[ |
18252 | 857 |
^ super deepCopyUsing:aDictionary postCopySelector:postCopySelector |
8638 | 858 |
]. |
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
859 |
copyOfHome := home deepCopyUsing:aDictionary. |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
860 |
copyOfMe := self shallowCopy. |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
861 |
copyOfMe setHome:copyOfHome. |
13517
95a2ffba9880
changed: #deepCopyUsing:postCopySelector:
Claus Gittinger <cg@exept.de>
parents:
13220
diff
changeset
|
862 |
copyOfMe perform:postCopySelector withOptionalArgument:self and:aDictionary. |
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
863 |
^ copyOfMe |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
864 |
|
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
865 |
"Created: / 31-03-1998 / 15:46:17 / cg" |
13517
95a2ffba9880
changed: #deepCopyUsing:postCopySelector:
Claus Gittinger <cg@exept.de>
parents:
13220
diff
changeset
|
866 |
"Modified: / 21-07-2011 / 13:30:12 / cg" |
1 | 867 |
! ! |
868 |
||
16871 | 869 |
!Block methodsFor:'debugging'! |
870 |
||
871 |
benchmark:anInfoString |
|
21558 | 872 |
"evaluate myself and show the timing info on Transcript" |
873 |
||
874 |
|startTime endTime startCycles endCycles overhead overheadCycles |
|
20861 | 875 |
micros millis cycles| |
19795 | 876 |
|
21558 | 877 |
"/warmup before executing self |
19795 | 878 |
startTime := OperatingSystem getMicrosecondTime. |
20861 | 879 |
startCycles := OperatingSystem getCPUCycleCount. |
19795 | 880 |
[123] value. |
20861 | 881 |
endCycles := OperatingSystem getCPUCycleCount. |
19795 | 882 |
endTime := OperatingSystem getMicrosecondTime. |
883 |
overhead := endTime - startTime. |
|
20861 | 884 |
"/ just in case, the OS does not support cpu cycles |
21345 | 885 |
startCycles notNil ifTrue:[ overheadCycles := endCycles - startCycles ]. |
21558 | 886 |
|
16871 | 887 |
startTime := OperatingSystem getMicrosecondTime. |
20861 | 888 |
startCycles := OperatingSystem getCPUCycleCount. |
16871 | 889 |
self value. |
20861 | 890 |
endCycles := OperatingSystem getCPUCycleCount. |
16871 | 891 |
endTime := OperatingSystem getMicrosecondTime. |
892 |
||
19795 | 893 |
micros := (endTime - startTime - overhead) max:0. |
21345 | 894 |
"/ just in case, the OS does not support cpu cycles |
895 |
startCycles notNil ifTrue:[ |
|
21558 | 896 |
cycles := (endCycles - startCycles - overheadCycles) max:0. |
21345 | 897 |
]. |
21558 | 898 |
|
16871 | 899 |
Transcript show:anInfoString. |
17338 | 900 |
micros < 1000 ifTrue:[ |
19795 | 901 |
"/ too stupid: many fonts do not have a mu, |
902 |
"/ so I output it as us here. |
|
24226 | 903 |
Transcript show:micros; show:' µs'. |
16871 | 904 |
] ifFalse:[ |
19795 | 905 |
micros < 100000 ifTrue:[ |
906 |
millis := (micros / 1000.0) asFixedPointRoundedToScale:2. |
|
907 |
Transcript show:millis; show:' ms'. |
|
908 |
] ifFalse:[ |
|
909 |
millis := micros // 1000. |
|
910 |
Transcript show:(TimeDuration milliseconds:millis). |
|
911 |
]. |
|
16871 | 912 |
]. |
21345 | 913 |
cycles notNil ifTrue:[ |
20861 | 914 |
Transcript show:' ('; show:cycles; show:' cycles)'. |
915 |
]. |
|
16871 | 916 |
Transcript cr. |
917 |
||
918 |
" |
|
20861 | 919 |
be aware that if you evaluate the following, |
21558 | 920 |
the blocks will be interpreted by the doIt. |
20861 | 921 |
Thus you will get on-realistic values. |
922 |
Better compile those expressions into a method and call that |
|
923 |
for realistic measurements. |
|
21558 | 924 |
|
20861 | 925 |
[] benchmark:'empty block:' - this is a pre-compiled block |
926 |
[123] benchmark:'empty block:' - the rest are interpreted blocks |
|
927 |
[10 factorial] benchmark:'10 factorial:' |
|
928 |
[10 factorial] benchmark:'11 factorial:' |
|
929 |
[100 factorial] benchmark:'100 factorial:' |
|
16871 | 930 |
" |
21558 | 931 |
|
932 |
"Modified (comment): / 23-02-2017 / 21:06:29 / mawalch" |
|
16871 | 933 |
! ! |
934 |
||
1 | 935 |
!Block methodsFor:'error handling'! |
936 |
||
328 | 937 |
invalidCodeObject |
1874 | 938 |
"{ Pragma: +optSpace }" |
939 |
||
67 | 940 |
"this error is triggered by the interpreter when a non-Block object |
941 |
is about to be executed. |
|
942 |
In this case, the VM sends this to the bad method (the receiver). |
|
943 |
Can only happen when the Compiler/runtime system is broken or |
|
944 |
someone played around." |
|
1 | 945 |
|
7602
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
946 |
^ InvalidCodeError |
18252 | 947 |
raiseRequestWith:self |
948 |
errorString:'invalid block - not executable' |
|
1874 | 949 |
|
950 |
"Modified: 4.11.1996 / 22:46:39 / cg" |
|
1 | 951 |
! ! |
952 |
||
953 |
!Block methodsFor:'evaluation'! |
|
954 |
||
955 |
value |
|
18252 | 956 |
"evaluate the receiver with no block args. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
957 |
The receiver must be a block without arguments." |
1 | 958 |
|
959 |
%{ /* NOCONTEXT */ |
|
18252 | 960 |
#ifdef __SCHTEAM__ |
961 |
return context.TAILCALL0( self.asSTCallable() ); |
|
962 |
/* NOTREACHED */ |
|
963 |
#else |
|
1 | 964 |
REGISTER OBJFUNC thecode; |
965 |
OBJ home; |
|
966 |
||
8913 | 967 |
if (__INST(nargs) == __mkSmallInteger(0)) { |
18252 | 968 |
# if defined(THIS_CONTEXT) |
969 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
970 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
971 |
# endif |
|
972 |
||
973 |
thecode = __BlockInstPtr(self)->b_code; |
|
974 |
# ifdef NEW_BLOCK_CALL |
|
975 |
if (thecode != (OBJFUNC)nil) { |
|
976 |
/* compiled machine code */ |
|
977 |
RETURN ( (*thecode)(self) ); |
|
978 |
} |
|
979 |
/* interpreted code */ |
|
980 |
# ifdef PASS_ARG_POINTER |
|
981 |
RETURN ( __interpret(self, 0, nil, nil, nil, nil) ); |
|
982 |
# else |
|
983 |
RETURN ( __interpret(self, 0, nil, nil, nil, nil) ); |
|
984 |
# endif |
|
328 | 985 |
# else |
18252 | 986 |
home = __BlockInstPtr(self)->b_home; |
987 |
if (thecode != (OBJFUNC)nil) { |
|
988 |
/* compiled machine code */ |
|
989 |
RETURN ( (*thecode)(home) ); |
|
990 |
} |
|
991 |
/* interpreted code */ |
|
992 |
# ifdef PASS_ARG_POINTER |
|
993 |
RETURN ( __interpret(self, 0, nil, home, nil, nil) ); |
|
994 |
# else |
|
995 |
RETURN ( __interpret(self, 0, nil, home, nil, nil) ); |
|
996 |
# endif |
|
328 | 997 |
# endif |
1 | 998 |
} |
18252 | 999 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1000 |
%}. |
103 | 1001 |
^ self wrongNumberOfArguments:0 |
1 | 1002 |
! |
1003 |
||
1004 |
value:arg |
|
18252 | 1005 |
"evaluate the receiver with one argument. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1006 |
The receiver must be a 1-arg block." |
1 | 1007 |
|
1008 |
%{ /* NOCONTEXT */ |
|
18252 | 1009 |
#ifdef __SCHTEAM__ |
1010 |
return context.TAILCALL1( self.asSTCallable(), arg ); |
|
1011 |
/* NOTREACHED */ |
|
1012 |
#else |
|
1 | 1013 |
|
1014 |
REGISTER OBJFUNC thecode; |
|
1015 |
OBJ home; |
|
1016 |
||
8913 | 1017 |
if (__INST(nargs) == __mkSmallInteger(1)) { |
18252 | 1018 |
# if defined(THIS_CONTEXT) |
1019 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1020 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1021 |
# endif |
|
1022 |
thecode = __BlockInstPtr(self)->b_code; |
|
1023 |
# ifdef NEW_BLOCK_CALL |
|
1024 |
if (thecode != (OBJFUNC)nil) { |
|
1025 |
RETURN ( (*thecode)(self, arg) ); |
|
1026 |
} |
|
1027 |
/* interpreted code */ |
|
1028 |
# ifdef PASS_ARG_POINTER |
|
1029 |
RETURN ( __interpret(self, 1, nil, nil, nil, nil, &arg) ); |
|
1030 |
# else |
|
1031 |
RETURN ( __interpret(self, 1, nil, nil, nil, nil, arg) ); |
|
1032 |
# endif |
|
328 | 1033 |
# else |
18252 | 1034 |
home = __BlockInstPtr(self)->b_home; |
1035 |
if (thecode != (OBJFUNC)nil) { |
|
1036 |
RETURN ( (*thecode)(home, arg) ); |
|
1037 |
} |
|
1038 |
/* interpreted code */ |
|
1039 |
# ifdef PASS_ARG_POINTER |
|
1040 |
RETURN ( __interpret(self, 1, nil, home, nil, nil, &arg) ); |
|
1041 |
# else |
|
1042 |
RETURN ( __interpret(self, 1, nil, home, nil, nil, arg) ); |
|
1043 |
# endif |
|
328 | 1044 |
# endif |
1 | 1045 |
} |
18252 | 1046 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1047 |
%}. |
103 | 1048 |
^ self wrongNumberOfArguments:1 |
1 | 1049 |
! |
1050 |
||
11998 | 1051 |
value:arg1 optionalArgument:arg2 |
1052 |
"evaluate the receiver. |
|
1053 |
Optionally pass up one or to two arguments (if the receiver is a one/two arg block)." |
|
1054 |
||
1055 |
nargs == 2 ifTrue:[ |
|
18252 | 1056 |
^ self value:arg1 value:arg2 |
11998 | 1057 |
]. |
1058 |
^ self value:arg1 |
|
1059 |
||
1060 |
" |
|
1061 |
|block| |
|
1062 |
||
1063 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1064 |
block value:2 optionalArgument:3. |
11998 | 1065 |
|
1066 |
block := [:arg1 :arg2 | Transcript show:arg1; space; showCR:arg2 ]. |
|
18252 | 1067 |
block value:2 optionalArgument:3. |
11998 | 1068 |
" |
1069 |
! |
|
1070 |
||
1071 |
value:arg1 optionalArgument:arg2 and:arg3 |
|
1072 |
"evaluate the receiver. |
|
1073 |
Optionally pass up one, two or three arguments (if the receiver is a 1/2/3-arg block)." |
|
1074 |
||
1075 |
nargs == 3 ifTrue:[ |
|
18252 | 1076 |
^ self value:arg1 value:arg2 value:arg3 |
11998 | 1077 |
]. |
1078 |
nargs == 2 ifTrue:[ |
|
18252 | 1079 |
^ self value:arg1 value:arg2 |
11998 | 1080 |
]. |
1081 |
^ self value:arg1 |
|
1082 |
||
1083 |
" |
|
1084 |
|block| |
|
1085 |
||
1086 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1087 |
block value:2 optionalArgument:3. |
11998 | 1088 |
|
1089 |
block := [:arg1 :arg2 | Transcript show:arg1; space; showCR:arg2 ]. |
|
18252 | 1090 |
block value:2 optionalArgument:3. |
11998 | 1091 |
" |
1092 |
! |
|
1093 |
||
20623 | 1094 |
value:arg1 optionalArgument:arg2 and:arg3 and:arg4 |
1095 |
"evaluate the receiver. |
|
1096 |
Optionally pass up one, two, three or four arguments |
|
1097 |
(if the receiver is a 1/2/3/4-arg block)." |
|
1098 |
||
1099 |
nargs == 4 ifTrue:[ |
|
1100 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
|
1101 |
]. |
|
1102 |
nargs == 3 ifTrue:[ |
|
1103 |
^ self value:arg1 value:arg2 value:arg3 |
|
1104 |
]. |
|
1105 |
nargs == 2 ifTrue:[ |
|
1106 |
^ self value:arg1 value:arg2 |
|
1107 |
]. |
|
1108 |
^ self value:arg1 |
|
1109 |
||
1110 |
" |
|
1111 |
|block| |
|
1112 |
||
1113 |
block := [:arg | Transcript showCR:arg ]. |
|
1114 |
block value:1 optionalArgument:2 and:3 and:4. |
|
1115 |
||
1116 |
block := [:arg1 :arg2 | Transcript show:arg1; space; showCR:arg2 ]. |
|
1117 |
block value:1 optionalArgument:2 and:3 and:4. |
|
1118 |
||
1119 |
block := [:arg1 :arg2 :arg3 :arg4 | Transcript showCR:{arg1 . arg2 . arg3 . arg4}]. |
|
1120 |
block value:1 optionalArgument:2 and:3 and:4. |
|
1121 |
" |
|
1122 |
! |
|
1123 |
||
1124 |
value:arg1 optionalArgument:arg2 and:arg3 and:arg4 and:arg5 |
|
1125 |
"evaluate the receiver. |
|
1126 |
Optionally pass up five arguments |
|
1127 |
(if the receiver is a 1..5-arg block)." |
|
1128 |
||
1129 |
nargs == 5 ifTrue:[ |
|
1130 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
1131 |
]. |
|
1132 |
nargs == 4 ifTrue:[ |
|
1133 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
|
1134 |
]. |
|
1135 |
nargs == 3 ifTrue:[ |
|
1136 |
^ self value:arg1 value:arg2 value:arg3 |
|
1137 |
]. |
|
1138 |
nargs == 2 ifTrue:[ |
|
1139 |
^ self value:arg1 value:arg2 |
|
1140 |
]. |
|
1141 |
^ self value:arg1 |
|
1142 |
||
1143 |
" |
|
1144 |
|block| |
|
1145 |
||
1146 |
block := [:arg | Transcript showCR:arg ]. |
|
1147 |
block value:1 optionalArgument:2 and:3 and:4 and:5. |
|
1148 |
||
1149 |
block := [:arg1 :arg2 | Transcript show:arg1; space; showCR:arg2 ]. |
|
1150 |
block value:1 optionalArgument:2 and:3 and:4 and:5. |
|
1151 |
||
1152 |
block := [:arg1 :arg2 :arg3 :arg4 :arg5 | Transcript showCR:{arg1 . arg2 . arg3 . arg4 . arg5}]. |
|
1153 |
block value:1 optionalArgument:2 and:3 and:4 and:5. |
|
1154 |
" |
|
1155 |
! |
|
1156 |
||
1157 |
value:arg1 optionalArgument:arg2 and:arg3 and:arg4 and:arg5 and:arg6 |
|
1158 |
"evaluate the receiver. |
|
1159 |
Optionally pass up six arguments |
|
1160 |
(if the receiver is a 1..6-arg block)." |
|
1161 |
||
1162 |
nargs == 6 ifTrue:[ |
|
1163 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
1164 |
]. |
|
1165 |
nargs == 5 ifTrue:[ |
|
1166 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
1167 |
]. |
|
1168 |
nargs == 4 ifTrue:[ |
|
1169 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
|
1170 |
]. |
|
1171 |
nargs == 3 ifTrue:[ |
|
1172 |
^ self value:arg1 value:arg2 value:arg3 |
|
1173 |
]. |
|
1174 |
nargs == 2 ifTrue:[ |
|
1175 |
^ self value:arg1 value:arg2 |
|
1176 |
]. |
|
1177 |
^ self value:arg1 |
|
1178 |
||
1179 |
" |
|
1180 |
|block| |
|
1181 |
||
1182 |
block := [:arg | Transcript showCR:arg ]. |
|
1183 |
block value:1 optionalArgument:2 and:3 and:4 and:5 and:6. |
|
1184 |
||
1185 |
block := [:arg1 :arg2 | Transcript show:arg1; space; showCR:arg2 ]. |
|
1186 |
block value:1 optionalArgument:2 and:3 and:4 and:5 and:6. |
|
1187 |
||
1188 |
block := [:arg1 :arg2 :arg3 :arg4 :arg5 :arg6 | Transcript showCR:{arg1 . arg2 . arg3 . arg4 . arg5 . arg6}]. |
|
1189 |
block value:1 optionalArgument:2 and:3 and:4 and:5 and:6. |
|
1190 |
" |
|
1191 |
! |
|
1192 |
||
1 | 1193 |
value:arg1 value:arg2 |
18252 | 1194 |
"evaluate the receiver with two arguments. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1195 |
The receiver must be a 2-arg block." |
1 | 1196 |
|
1197 |
%{ /* NOCONTEXT */ |
|
18252 | 1198 |
#ifdef __SCHTEAM__ |
1199 |
return context.TAILCALL2( self.asSTCallable(), arg1, arg2 ); |
|
1200 |
/* NOTREACHED */ |
|
1201 |
#else |
|
1 | 1202 |
|
1203 |
REGISTER OBJFUNC thecode; |
|
1204 |
OBJ home; |
|
1205 |
||
8913 | 1206 |
if (__INST(nargs) == __mkSmallInteger(2)) { |
18252 | 1207 |
# if defined(THIS_CONTEXT) |
1208 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1209 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1210 |
# endif |
|
1211 |
thecode = __BlockInstPtr(self)->b_code; |
|
1212 |
# ifdef NEW_BLOCK_CALL |
|
1213 |
if (thecode != (OBJFUNC)nil) { |
|
1214 |
RETURN ( (*thecode)(self, arg1, arg2) ); |
|
1215 |
} |
|
1216 |
# ifdef PASS_ARG_POINTER |
|
1217 |
RETURN ( __interpret(self, 2, nil, nil, nil, nil, &arg1) ); |
|
1218 |
# else |
|
1219 |
RETURN ( __interpret(self, 2, nil, nil, nil, nil, arg1, arg2) ); |
|
1220 |
# endif |
|
328 | 1221 |
# else |
18252 | 1222 |
home = __BlockInstPtr(self)->b_home; |
1223 |
if (thecode != (OBJFUNC)nil) { |
|
1224 |
RETURN ( (*thecode)(home, arg1, arg2) ); |
|
1225 |
} |
|
1226 |
# ifdef PASS_ARG_POINTER |
|
1227 |
RETURN ( __interpret(self, 2, nil, home, nil, nil, &arg1) ); |
|
1228 |
# else |
|
1229 |
RETURN ( __interpret(self, 2, nil, home, nil, nil, arg1, arg2) ); |
|
1230 |
# endif |
|
328 | 1231 |
# endif |
1 | 1232 |
} |
18252 | 1233 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1234 |
%}. |
103 | 1235 |
^ self wrongNumberOfArguments:2 |
1 | 1236 |
! |
1237 |
||
11998 | 1238 |
value:arg1 value:arg2 optionalArgument:arg3 |
1239 |
"evaluate the receiver. |
|
1240 |
Optionally pass two or threearguments (if the receiver is a 2/3-arg block)." |
|
1241 |
||
1242 |
nargs == 3 ifTrue:[ |
|
18252 | 1243 |
^ self value:arg1 value:arg2 value:arg3 |
11998 | 1244 |
]. |
1245 |
^ self value:arg1 value:arg2 |
|
1246 |
! |
|
1247 |
||
1 | 1248 |
value:arg1 value:arg2 value:arg3 |
18252 | 1249 |
"evaluate the receiver with three arguments. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1250 |
The receiver must be a 3-arg block." |
1 | 1251 |
|
1252 |
%{ /* NOCONTEXT */ |
|
18252 | 1253 |
#ifdef __SCHTEAM__ |
1254 |
return context.TAILCALL3( self.asSTCallable(), arg1, arg2, arg3 ); |
|
1255 |
/* NOTREACHED */ |
|
1256 |
#else |
|
1 | 1257 |
|
1258 |
REGISTER OBJFUNC thecode; |
|
1259 |
OBJ home; |
|
1260 |
||
8913 | 1261 |
if (__INST(nargs) == __mkSmallInteger(3)) { |
18252 | 1262 |
# if defined(THIS_CONTEXT) |
1263 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1264 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1265 |
# endif |
|
1266 |
thecode = __BlockInstPtr(self)->b_code; |
|
1267 |
# ifdef NEW_BLOCK_CALL |
|
1268 |
if (thecode != (OBJFUNC)nil) { |
|
1269 |
RETURN ( (*thecode)(self, arg1, arg2, arg3) ); |
|
1270 |
} |
|
1271 |
# ifdef PASS_ARG_POINTER |
|
1272 |
RETURN ( __interpret(self, 3, nil, nil, nil, nil, &arg1) ); |
|
1273 |
# else |
|
1274 |
RETURN ( __interpret(self, 3, nil, nil, nil, nil, arg1, arg2, arg3) ); |
|
1275 |
# endif |
|
328 | 1276 |
# else |
18252 | 1277 |
home = __BlockInstPtr(self)->b_home; |
1278 |
if (thecode != (OBJFUNC)nil) { |
|
1279 |
RETURN ( (*thecode)(home, arg1, arg2, arg3) ); |
|
1280 |
} |
|
1281 |
# ifdef PASS_ARG_POINTER |
|
1282 |
RETURN ( __interpret(self, 3, nil, home, nil, nil, &arg1) ); |
|
1283 |
# else |
|
1284 |
RETURN ( __interpret(self, 3, nil, home, nil, nil, arg1, arg2, arg3) ); |
|
1285 |
# endif |
|
328 | 1286 |
# endif |
1 | 1287 |
} |
18252 | 1288 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1289 |
%}. |
103 | 1290 |
^ self wrongNumberOfArguments:3 |
1 | 1291 |
! |
1292 |
||
20623 | 1293 |
value:arg1 value:arg2 value:arg3 optionalArgument:arg4 |
1294 |
"evaluate the receiver. |
|
1295 |
Optionally pass three or four arguments (if the receiver is a 3/4-arg block)." |
|
1296 |
||
1297 |
nargs == 4 ifTrue:[ |
|
1298 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
|
1299 |
]. |
|
1300 |
^ self value:arg1 value:arg2 value:arg3 |
|
1301 |
! |
|
1302 |
||
1 | 1303 |
value:arg1 value:arg2 value:arg3 value:arg4 |
18252 | 1304 |
"evaluate the receiver with four arguments. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1305 |
The receiver must be a 4-arg block." |
1 | 1306 |
|
1307 |
%{ /* NOCONTEXT */ |
|
18252 | 1308 |
#ifdef __SCHTEAM__ |
1309 |
return context.TAILCALL4( self.asSTCallable(), arg1, arg2, arg3, arg4 ); |
|
1310 |
/* NOTREACHED */ |
|
1311 |
#else |
|
1 | 1312 |
|
1313 |
REGISTER OBJFUNC thecode; |
|
1314 |
OBJ home; |
|
1315 |
||
8913 | 1316 |
if (__INST(nargs) == __mkSmallInteger(4)) { |
18252 | 1317 |
# if defined(THIS_CONTEXT) |
1318 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1319 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1320 |
# endif |
|
1321 |
thecode = __BlockInstPtr(self)->b_code; |
|
1322 |
# ifdef NEW_BLOCK_CALL |
|
1323 |
if (thecode != (OBJFUNC)nil) { |
|
1324 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4) ); |
|
1325 |
} |
|
1326 |
# ifdef PASS_ARG_POINTER |
|
1327 |
RETURN ( __interpret(self, 4, nil, nil, nil, nil, &arg1) ); |
|
1328 |
# else |
|
1329 |
RETURN ( __interpret(self, 4, nil, nil, nil, nil, arg1, arg2, arg3, arg4) ); |
|
1330 |
# endif |
|
328 | 1331 |
# else |
18252 | 1332 |
home = __BlockInstPtr(self)->b_home; |
1333 |
if (thecode != (OBJFUNC)nil) { |
|
1334 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4) ); |
|
1335 |
} |
|
1336 |
# ifdef PASS_ARG_POINTER |
|
1337 |
RETURN ( __interpret(self, 4, nil, home, nil, nil, &arg1) ); |
|
1338 |
# else |
|
1339 |
RETURN ( __interpret(self, 4, nil, home, nil, nil, arg1, arg2, arg3, arg4) ); |
|
1340 |
# endif |
|
328 | 1341 |
# endif |
18252 | 1342 |
} |
1 | 1343 |
#endif |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1344 |
%}. |
103 | 1345 |
^ self wrongNumberOfArguments:4 |
1 | 1346 |
! |
1347 |
||
1348 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
18252 | 1349 |
"evaluate the receiver with five arguments. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1350 |
The receiver must be a 5-arg block." |
1 | 1351 |
|
1352 |
%{ /* NOCONTEXT */ |
|
18252 | 1353 |
#ifdef __SCHTEAM__ |
1354 |
return context.TAILCALL5( self.asSTCallable(), arg1, arg2, arg3, arg4, arg5 ); |
|
1355 |
/* NOTREACHED */ |
|
1356 |
#else |
|
1 | 1357 |
|
1358 |
REGISTER OBJFUNC thecode; |
|
1359 |
OBJ home; |
|
1360 |
||
8913 | 1361 |
if (__INST(nargs) == __mkSmallInteger(5)) { |
18252 | 1362 |
# if defined(THIS_CONTEXT) |
1363 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1364 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1365 |
# endif |
|
1366 |
thecode = __BlockInstPtr(self)->b_code; |
|
1367 |
# ifdef NEW_BLOCK_CALL |
|
1368 |
if (thecode != (OBJFUNC)nil) { |
|
1369 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5) ); |
|
1370 |
} |
|
1371 |
# ifdef PASS_ARG_POINTER |
|
1372 |
RETURN ( __interpret(self, 5, nil, nil, nil, nil, &arg1) ); |
|
1373 |
# else |
|
1374 |
RETURN ( __interpret(self, 5, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5) ); |
|
1375 |
# endif |
|
328 | 1376 |
# else |
18252 | 1377 |
home = __BlockInstPtr(self)->b_home; |
1378 |
if (thecode != (OBJFUNC)nil) { |
|
1379 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5) ); |
|
1380 |
} |
|
1381 |
# ifdef PASS_ARG_POINTER |
|
1382 |
RETURN ( __interpret(self, 5, nil, home, nil, nil, &arg1) ); |
|
1383 |
# else |
|
1384 |
RETURN ( __interpret(self, 5, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5) ); |
|
1385 |
# endif |
|
328 | 1386 |
# endif |
1 | 1387 |
} |
18252 | 1388 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1389 |
%}. |
103 | 1390 |
^ self wrongNumberOfArguments:5 |
1 | 1391 |
! |
1392 |
||
1393 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
18252 | 1394 |
"evaluate the receiver with six arguments. |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1395 |
The receiver must be a 6-arg block." |
1 | 1396 |
|
1397 |
%{ /* NOCONTEXT */ |
|
18252 | 1398 |
#ifdef __SCHTEAM__ |
1399 |
return context.TAILCALL6( self.asSTCallable(), arg1, arg2, arg3, arg4, arg5, arg6 ); |
|
1400 |
/* NOTREACHED */ |
|
1401 |
#else |
|
1 | 1402 |
|
1403 |
REGISTER OBJFUNC thecode; |
|
1404 |
OBJ home; |
|
1405 |
||
8913 | 1406 |
if (__INST(nargs) == __mkSmallInteger(6)) { |
18252 | 1407 |
# if defined(THIS_CONTEXT) |
1408 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1409 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1410 |
# endif |
|
1411 |
thecode = __BlockInstPtr(self)->b_code; |
|
1412 |
# ifdef NEW_BLOCK_CALL |
|
1413 |
if (thecode != (OBJFUNC)nil) { |
|
1414 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
1415 |
} |
|
1416 |
# ifdef PASS_ARG_POINTER |
|
1417 |
RETURN ( __interpret(self, 6, nil, nil, nil, nil, &arg1) ); |
|
1418 |
# else |
|
1419 |
RETURN ( __interpret(self, 6, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
1420 |
# endif |
|
328 | 1421 |
# else |
18252 | 1422 |
home = __BlockInstPtr(self)->b_home; |
1423 |
if (thecode != (OBJFUNC)nil) { |
|
1424 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
1425 |
} |
|
1426 |
# ifdef PASS_ARG_POINTER |
|
1427 |
RETURN ( __interpret(self, 6, nil, home, nil, nil, &arg1) ); |
|
1428 |
# else |
|
1429 |
RETURN ( __interpret(self, 6, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
1430 |
# endif |
|
328 | 1431 |
# endif |
1 | 1432 |
} |
18252 | 1433 |
#endif /* not SCHTEAM */ |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1434 |
%}. |
103 | 1435 |
^ self wrongNumberOfArguments:6 |
1 | 1436 |
! |
1437 |
||
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1438 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1439 |
"evaluate the receiver with seven arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1440 |
The receiver must be a 7-arg block." |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1441 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1442 |
%{ /* NOCONTEXT */ |
18252 | 1443 |
#ifdef __SCHTEAM__ |
1444 |
return context.TAILCALL7( self.asSTCallable(), arg1, arg2, arg3, arg4, arg5, arg6, arg7 ); |
|
1445 |
/* NOTREACHED */ |
|
1446 |
#else |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1447 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1448 |
REGISTER OBJFUNC thecode; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1449 |
OBJ home; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1450 |
|
8913 | 1451 |
if (__INST(nargs) == __mkSmallInteger(7)) { |
18252 | 1452 |
# if defined(THIS_CONTEXT) |
1453 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1454 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1455 |
# endif |
|
1456 |
thecode = __BlockInstPtr(self)->b_code; |
|
1457 |
# ifdef NEW_BLOCK_CALL |
|
1458 |
if (thecode != (OBJFUNC)nil) { |
|
1459 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1460 |
} |
|
1461 |
# ifdef PASS_ARG_POINTER |
|
1462 |
RETURN ( __interpret(self, 7, nil, nil, nil, nil, &arg1) ); |
|
1463 |
# else |
|
1464 |
RETURN ( __interpret(self, 7, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1465 |
# endif |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1466 |
# else |
18252 | 1467 |
home = __BlockInstPtr(self)->b_home; |
1468 |
if (thecode != (OBJFUNC)nil) { |
|
1469 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1470 |
} |
|
1471 |
# ifdef PASS_ARG_POINTER |
|
1472 |
RETURN ( __interpret(self, 7, nil, home, nil, nil, &arg1) ); |
|
1473 |
# else |
|
1474 |
RETURN ( __interpret(self, 7, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1475 |
# endif |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1476 |
# endif |
18252 | 1477 |
} |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1478 |
#endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1479 |
%}. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1480 |
^ self wrongNumberOfArguments:7 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1481 |
! |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1482 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1483 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1484 |
"evaluate the receiver with eight arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1485 |
The receiver must be a 8-arg block." |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1486 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1487 |
%{ /* NOCONTEXT */ |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1488 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1489 |
REGISTER OBJFUNC thecode; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1490 |
OBJ home; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1491 |
|
8913 | 1492 |
if (__INST(nargs) == __mkSmallInteger(8)) { |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1493 |
#if defined(THIS_CONTEXT) |
18252 | 1494 |
if (__ISVALID_ILC_LNO(__pilc)) |
1495 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1496 |
#endif |
18252 | 1497 |
thecode = __BlockInstPtr(self)->b_code; |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1498 |
#ifdef NEW_BLOCK_CALL |
18252 | 1499 |
if (thecode != (OBJFUNC)nil) { |
1500 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
|
1501 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1502 |
# ifdef PASS_ARG_POINTER |
18252 | 1503 |
RETURN ( __interpret(self, 8, nil, nil, nil, nil, &arg1) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1504 |
# else |
18252 | 1505 |
RETURN ( __interpret(self, 8, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1506 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1507 |
#else |
18252 | 1508 |
home = __BlockInstPtr(self)->b_home; |
1509 |
if (thecode != (OBJFUNC)nil) { |
|
1510 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
|
1511 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1512 |
# ifdef PASS_ARG_POINTER |
18252 | 1513 |
RETURN ( __interpret(self, 8, nil, home, nil, nil, &arg1) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1514 |
# else |
18252 | 1515 |
RETURN ( __interpret(self, 8, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1516 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1517 |
#endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1518 |
} |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1519 |
%}. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1520 |
^ self wrongNumberOfArguments:8 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1521 |
! |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1522 |
|
11588 | 1523 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 |
11603 | 1524 |
"evaluate the receiver with 9 arguments. |
1525 |
The receiver must be a 9-arg block." |
|
11588 | 1526 |
|
1527 |
%{ /* NOCONTEXT */ |
|
1528 |
||
1529 |
REGISTER OBJFUNC thecode; |
|
1530 |
OBJ home; |
|
1531 |
||
1532 |
if (__INST(nargs) == __mkSmallInteger(9)) { |
|
1533 |
#if defined(THIS_CONTEXT) |
|
18252 | 1534 |
if (__ISVALID_ILC_LNO(__pilc)) |
1535 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
11588 | 1536 |
#endif |
18252 | 1537 |
thecode = __BlockInstPtr(self)->b_code; |
11588 | 1538 |
#ifdef NEW_BLOCK_CALL |
18252 | 1539 |
if (thecode != (OBJFUNC)nil) { |
1540 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1541 |
} |
|
11588 | 1542 |
# ifdef PASS_ARG_POINTER |
18252 | 1543 |
RETURN ( __interpret(self, 9, nil, nil, nil, nil, &arg1) ); |
11588 | 1544 |
# else |
18252 | 1545 |
RETURN ( __interpret(self, 9, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
11588 | 1546 |
# endif |
1547 |
#else |
|
18252 | 1548 |
home = __BlockInstPtr(self)->b_home; |
1549 |
if (thecode != (OBJFUNC)nil) { |
|
1550 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1551 |
} |
|
11588 | 1552 |
# ifdef PASS_ARG_POINTER |
18252 | 1553 |
RETURN ( __interpret(self, 9, nil, home, nil, nil, &arg1) ); |
11588 | 1554 |
# else |
18252 | 1555 |
RETURN ( __interpret(self, 9, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
11588 | 1556 |
# endif |
1557 |
#endif |
|
1558 |
} |
|
1559 |
%}. |
|
1560 |
^ self wrongNumberOfArguments:9 |
|
1561 |
! |
|
1562 |
||
1563 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 |
|
11603 | 1564 |
"evaluate the receiver with 10 arguments. |
11588 | 1565 |
The receiver must be a 10-arg block." |
1566 |
||
1567 |
%{ /* NOCONTEXT */ |
|
1568 |
||
1569 |
REGISTER OBJFUNC thecode; |
|
1570 |
OBJ home; |
|
1571 |
||
1572 |
if (__INST(nargs) == __mkSmallInteger(10)) { |
|
1573 |
#if defined(THIS_CONTEXT) |
|
18252 | 1574 |
if (__ISVALID_ILC_LNO(__pilc)) |
1575 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
11588 | 1576 |
#endif |
18252 | 1577 |
thecode = __BlockInstPtr(self)->b_code; |
11588 | 1578 |
#ifdef NEW_BLOCK_CALL |
18252 | 1579 |
if (thecode != (OBJFUNC)nil) { |
1580 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1581 |
} |
|
11588 | 1582 |
# ifdef PASS_ARG_POINTER |
18252 | 1583 |
RETURN ( __interpret(self, 10, nil, nil, nil, nil, &arg1) ); |
11588 | 1584 |
# else |
18252 | 1585 |
RETURN ( __interpret(self, 10, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
11588 | 1586 |
# endif |
1587 |
#else |
|
18252 | 1588 |
home = __BlockInstPtr(self)->b_home; |
1589 |
if (thecode != (OBJFUNC)nil) { |
|
1590 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1591 |
} |
|
11588 | 1592 |
# ifdef PASS_ARG_POINTER |
18252 | 1593 |
RETURN ( __interpret(self, 10, nil, home, nil, nil, &arg1) ); |
11588 | 1594 |
# else |
18252 | 1595 |
RETURN ( __interpret(self, 10, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
11588 | 1596 |
# endif |
1597 |
#endif |
|
1598 |
} |
|
1599 |
%}. |
|
1600 |
^ self wrongNumberOfArguments:10 |
|
1601 |
! |
|
1602 |
||
1603 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 value:arg11 |
|
11603 | 1604 |
"evaluate the receiver with 11 arguments. |
1605 |
The receiver must be a 11-arg block." |
|
11588 | 1606 |
|
1607 |
%{ /* NOCONTEXT */ |
|
1608 |
||
1609 |
REGISTER OBJFUNC thecode; |
|
1610 |
OBJ home; |
|
1611 |
||
1612 |
if (__INST(nargs) == __mkSmallInteger(11)) { |
|
1613 |
#if defined(THIS_CONTEXT) |
|
18252 | 1614 |
if (__ISVALID_ILC_LNO(__pilc)) |
1615 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
11588 | 1616 |
#endif |
18252 | 1617 |
thecode = __BlockInstPtr(self)->b_code; |
11588 | 1618 |
#ifdef NEW_BLOCK_CALL |
18252 | 1619 |
if (thecode != (OBJFUNC)nil) { |
1620 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1621 |
} |
|
11588 | 1622 |
# ifdef PASS_ARG_POINTER |
18252 | 1623 |
RETURN ( __interpret(self, 11, nil, nil, nil, nil, &arg1) ); |
11588 | 1624 |
# else |
18252 | 1625 |
RETURN ( __interpret(self, 11, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
11588 | 1626 |
# endif |
1627 |
#else |
|
18252 | 1628 |
home = __BlockInstPtr(self)->b_home; |
1629 |
if (thecode != (OBJFUNC)nil) { |
|
1630 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1631 |
} |
|
11588 | 1632 |
# ifdef PASS_ARG_POINTER |
18252 | 1633 |
RETURN ( __interpret(self, 11, nil, home, nil, nil, &arg1) ); |
11588 | 1634 |
# else |
18252 | 1635 |
RETURN ( __interpret(self, 11, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
11588 | 1636 |
# endif |
1637 |
#endif |
|
1638 |
} |
|
1639 |
%}. |
|
1640 |
^ self wrongNumberOfArguments:11 |
|
1641 |
! |
|
1642 |
||
11603 | 1643 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 value:arg11 value:arg12 |
1644 |
"evaluate the receiver with 12 arguments. |
|
1645 |
The receiver must be a 12-arg block." |
|
1646 |
||
1647 |
%{ /* NOCONTEXT */ |
|
1648 |
||
1649 |
REGISTER OBJFUNC thecode; |
|
1650 |
OBJ home; |
|
1651 |
||
1652 |
if (__INST(nargs) == __mkSmallInteger(12)) { |
|
1653 |
#if defined(THIS_CONTEXT) |
|
18252 | 1654 |
if (__ISVALID_ILC_LNO(__pilc)) |
1655 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
11603 | 1656 |
#endif |
18252 | 1657 |
thecode = __BlockInstPtr(self)->b_code; |
11603 | 1658 |
#ifdef NEW_BLOCK_CALL |
18252 | 1659 |
if (thecode != (OBJFUNC)nil) { |
1660 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1661 |
} |
|
11603 | 1662 |
# ifdef PASS_ARG_POINTER |
18252 | 1663 |
RETURN ( __interpret(self, 12, nil, nil, nil, nil, &arg1) ); |
11603 | 1664 |
# else |
18252 | 1665 |
RETURN ( __interpret(self, 12, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
11603 | 1666 |
# endif |
1667 |
#else |
|
18252 | 1668 |
home = __BlockInstPtr(self)->b_home; |
1669 |
if (thecode != (OBJFUNC)nil) { |
|
1670 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1671 |
} |
|
11603 | 1672 |
# ifdef PASS_ARG_POINTER |
18252 | 1673 |
RETURN ( __interpret(self, 12, nil, home, nil, nil, &arg1) ); |
11603 | 1674 |
# else |
18252 | 1675 |
RETURN ( __interpret(self, 12, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
11603 | 1676 |
# endif |
1677 |
#endif |
|
1678 |
} |
|
1679 |
%}. |
|
1680 |
^ self wrongNumberOfArguments:12 |
|
1681 |
! |
|
1682 |
||
3688 | 1683 |
valueAt:priority |
1684 |
"evaluate the receiver, at the given prioriy; |
|
11998 | 1685 |
i.e. change the priority for the execution of the receiver. |
1686 |
Bad name: should be called evaluateWithPriority: or similar" |
|
3688 | 1687 |
|
21921 | 1688 |
|oldPrio activeProcess| |
9042 | 1689 |
|
1690 |
activeProcess := Processor activeProcess. |
|
3688 | 1691 |
oldPrio := Processor activePriority. |
21921 | 1692 |
^ [ |
1693 |
activeProcess priority:priority. |
|
1694 |
self value. |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
1695 |
] ensure:[ |
21921 | 1696 |
activeProcess priority:oldPrio |
3688 | 1697 |
]. |
1698 |
||
1699 |
" |
|
1700 |
[ |
|
21921 | 1701 |
1000 timesRepeat:[ |
1702 |
1000 factorial |
|
1703 |
] |
|
3688 | 1704 |
] valueAt:3 |
1705 |
" |
|
1706 |
||
21921 | 1707 |
"Created: / 29-07-1998 / 19:19:48 / cg" |
1708 |
"Modified: / 23-06-2017 / 11:13:30 / stefan" |
|
3688 | 1709 |
! |
1710 |
||
18993 | 1711 |
valueWithArguments:argArrayIn |
1 | 1712 |
"evaluate the receiver with arguments taken from argArray. |
313 | 1713 |
ArgArray must be either an Array or nil. |
1 | 1714 |
The size of the argArray must match the number of arguments the receiver expects." |
1715 |
||
18993 | 1716 |
|argArray a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1717 |
||
1718 |
argArray := argArrayIn. |
|
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1719 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
20551 | 1720 |
argArray isCollection ifFalse:[ |
18993 | 1721 |
^ self badArgumentArray:argArray |
1722 |
]. |
|
20551 | 1723 |
argArray := argArray asArray. |
1 | 1724 |
]. |
18993 | 1725 |
(argArray size ~~ nargs) ifTrue:[ |
1726 |
^ self wrongNumberOfArguments:argArray size |
|
1 | 1727 |
]. |
18993 | 1728 |
|
1 | 1729 |
%{ |
1730 |
REGISTER OBJFUNC thecode; |
|
1731 |
OBJ home; |
|
67 | 1732 |
REGISTER OBJ *ap; |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1733 |
OBJ nA; |
1 | 1734 |
|
1735 |
#if defined(THIS_CONTEXT) |
|
328 | 1736 |
if (__ISVALID_ILC_LNO(__pilc)) |
18993 | 1737 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
1 | 1738 |
#endif |
1133 | 1739 |
thecode = __BlockInstPtr(self)->b_code; |
1037 | 1740 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
1741 |
nA = __INST(nargs); |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
1742 |
|
1037 | 1743 |
#ifndef NEW_BLOCK_CALL |
1133 | 1744 |
home = __BlockInstPtr(self)->b_home; |
1037 | 1745 |
if (thecode != (OBJFUNC)nil) { |
18993 | 1746 |
/* the most common case (0 args) here (without a switch) */ |
1747 |
||
1748 |
if (nA == __mkSmallInteger(0)) { |
|
1749 |
RETURN ( (*thecode)(home) ); |
|
1750 |
} |
|
1751 |
||
1752 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
|
1753 |
switch ((INT)(nA)) { |
|
1754 |
default: |
|
1755 |
goto error; |
|
1756 |
case (INT)__mkSmallInteger(15): |
|
1757 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) ); |
|
1758 |
case (INT)__mkSmallInteger(14): |
|
1759 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]) ); |
|
1760 |
case (INT)__mkSmallInteger(13): |
|
1761 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]) ); |
|
1762 |
case (INT)__mkSmallInteger(12): |
|
1763 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11]) ); |
|
1764 |
case (INT)__mkSmallInteger(11): |
|
1765 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10]) ); |
|
1766 |
case (INT)__mkSmallInteger(10): |
|
1767 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) ); |
|
1768 |
case (INT)__mkSmallInteger(9): |
|
1769 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) ); |
|
1770 |
case (INT)__mkSmallInteger(8): |
|
1771 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) ); |
|
1772 |
case (INT)__mkSmallInteger(7): |
|
1773 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) ); |
|
1774 |
case (INT)__mkSmallInteger(6): |
|
1775 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) ); |
|
1776 |
case (INT)__mkSmallInteger(5): |
|
1777 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) ); |
|
1778 |
case (INT)__mkSmallInteger(4): |
|
1779 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) ); |
|
1780 |
case (INT)__mkSmallInteger(3): |
|
1781 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) ); |
|
1782 |
case (INT)__mkSmallInteger(2): |
|
1783 |
RETURN ( (*thecode)(home, ap[0], ap[1]) ); |
|
1784 |
case (INT)__mkSmallInteger(1): |
|
1785 |
RETURN ( (*thecode)(home, ap[0]) ); |
|
1786 |
case (INT)__mkSmallInteger(0): |
|
1787 |
RETURN ( (*thecode)(home) ); |
|
1788 |
break; |
|
1789 |
} |
|
1037 | 1790 |
} |
1791 |
#endif |
|
1792 |
||
8913 | 1793 |
if (nA != __mkSmallInteger(0)) { |
18993 | 1794 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
1795 |
switch ((INT)nA) { |
|
1796 |
default: |
|
1797 |
goto error; |
|
1798 |
case (INT)__mkSmallInteger(15): |
|
1799 |
a15 = ap[14]; |
|
1800 |
case (INT)__mkSmallInteger(14): |
|
1801 |
a14 = ap[13]; |
|
1802 |
case (INT)__mkSmallInteger(13): |
|
1803 |
a13 = ap[12]; |
|
1804 |
case (INT)__mkSmallInteger(12): |
|
1805 |
a12 = ap[11]; |
|
1806 |
case (INT)__mkSmallInteger(11): |
|
1807 |
a11 = ap[10]; |
|
1808 |
case (INT)__mkSmallInteger(10): |
|
1809 |
a10 = ap[9]; |
|
1810 |
case (INT)__mkSmallInteger(9): |
|
1811 |
a9 = ap[8]; |
|
1812 |
case (INT)__mkSmallInteger(8): |
|
1813 |
a8 = ap[7]; |
|
1814 |
case (INT)__mkSmallInteger(7): |
|
1815 |
a7 = ap[6]; |
|
1816 |
case (INT)__mkSmallInteger(6): |
|
1817 |
a6 = ap[5]; |
|
1818 |
case (INT)__mkSmallInteger(5): |
|
1819 |
a5 = ap[4]; |
|
1820 |
case (INT)__mkSmallInteger(4): |
|
1821 |
a4 = ap[3]; |
|
1822 |
case (INT)__mkSmallInteger(3): |
|
1823 |
a3 = ap[2]; |
|
1824 |
case (INT)__mkSmallInteger(2): |
|
1825 |
a2 = ap[1]; |
|
1826 |
case (INT)__mkSmallInteger(1): |
|
1827 |
a1 = ap[0]; |
|
1828 |
case (INT)__mkSmallInteger(0): |
|
1829 |
break; |
|
1830 |
} |
|
1 | 1831 |
} |
1133 | 1832 |
|
11 | 1833 |
#ifdef NEW_BLOCK_CALL |
1 | 1834 |
if (thecode != (OBJFUNC)nil) { |
18993 | 1835 |
RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
11 | 1836 |
} |
328 | 1837 |
# ifdef PASS_ARG_POINTER |
6553
ce4ca4df3415
oops - last modification created a little bug.
Claus Gittinger <cg@exept.de>
parents:
6512
diff
changeset
|
1838 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
328 | 1839 |
# else |
8009 | 1840 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
328 | 1841 |
# endif |
1037 | 1842 |
|
1 | 1843 |
#else |
1037 | 1844 |
|
328 | 1845 |
# ifdef PASS_ARG_POINTER |
6553
ce4ca4df3415
oops - last modification created a little bug.
Claus Gittinger <cg@exept.de>
parents:
6512
diff
changeset
|
1846 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
328 | 1847 |
# else |
8009 | 1848 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
328 | 1849 |
# endif |
1037 | 1850 |
|
1 | 1851 |
#endif |
67 | 1852 |
|
11 | 1853 |
error: ; |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1854 |
%}. |
138 | 1855 |
" |
8009 | 1856 |
the above code only supports up-to 15 arguments |
138 | 1857 |
" |
7602
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
1858 |
^ ArgumentError |
18993 | 1859 |
raiseRequestWith:self |
1860 |
errorString:'only blocks with up-to 15 arguments supported' |
|
1861 |
||
1862 |
" |
|
1863 |
[:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithArguments:#(1 2 3). |
|
1864 |
[:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithArguments:#(1 2 3) asOrderedCollection. |
|
1865 |
" |
|
6317 | 1866 |
! |
1867 |
||
1868 |
valueWithOptionalArgument:arg |
|
1869 |
"evaluate the receiver. |
|
6318 | 1870 |
Optionally pass an argument (if the receiver is a one arg block)." |
6317 | 1871 |
|
6628
4d693c525443
#handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
6611
diff
changeset
|
1872 |
nargs == 1 ifTrue:[ |
18252 | 1873 |
^ self value:arg |
6317 | 1874 |
]. |
1875 |
^ self value |
|
6320 | 1876 |
|
1877 |
" |
|
1878 |
|block| |
|
1879 |
||
1880 |
block := [ Transcript showCR:'hello' ]. |
|
18252 | 1881 |
block valueWithOptionalArgument:2. |
6320 | 1882 |
|
1883 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1884 |
block valueWithOptionalArgument:2. |
6320 | 1885 |
" |
6785 | 1886 |
! |
1887 |
||
1888 |
valueWithOptionalArgument:arg1 and:arg2 |
|
1889 |
"evaluate the receiver. |
|
1890 |
Optionally pass up to two arguments (if the receiver is a one/two arg block)." |
|
1891 |
||
1892 |
nargs == 2 ifTrue:[ |
|
18252 | 1893 |
^ self value:arg1 value:arg2 |
6785 | 1894 |
]. |
1895 |
nargs == 1 ifTrue:[ |
|
18252 | 1896 |
^ self value:arg1 |
6785 | 1897 |
]. |
1898 |
^ self value |
|
1899 |
||
1900 |
" |
|
1901 |
|block| |
|
1902 |
||
1903 |
block := [ Transcript showCR:'hello' ]. |
|
18252 | 1904 |
block valueWithOptionalArgument:2. |
6785 | 1905 |
|
1906 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1907 |
block valueWithOptionalArgument:2. |
6785 | 1908 |
|
1909 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
18252 | 1910 |
block valueWithOptionalArgument:10 and:20. |
6785 | 1911 |
" |
9010 | 1912 |
! |
1913 |
||
1914 |
valueWithOptionalArgument:arg1 and:arg2 and:arg3 |
|
1915 |
"evaluate the receiver. |
|
1916 |
Optionally pass up to three arguments (if the receiver is a one/two/three arg block)." |
|
1917 |
||
1918 |
nargs == 3 ifTrue:[ |
|
18252 | 1919 |
^ self value:arg1 value:arg2 value:arg3 |
9010 | 1920 |
]. |
1921 |
nargs == 2 ifTrue:[ |
|
18252 | 1922 |
^ self value:arg1 value:arg2 |
9010 | 1923 |
]. |
1924 |
nargs == 1 ifTrue:[ |
|
18252 | 1925 |
^ self value:arg1 |
9010 | 1926 |
]. |
1927 |
^ self value |
|
1928 |
||
1929 |
" |
|
1930 |
|block| |
|
1931 |
||
1932 |
block := [ Transcript showCR:'hello' ]. |
|
18252 | 1933 |
block valueWithOptionalArgument:2. |
9010 | 1934 |
|
1935 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1936 |
block valueWithOptionalArgument:2. |
9010 | 1937 |
|
1938 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
18252 | 1939 |
block valueWithOptionalArgument:10 and:20. |
9010 | 1940 |
" |
1941 |
! |
|
1942 |
||
1943 |
valueWithOptionalArgument:arg1 and:arg2 and:arg3 and:arg4 |
|
1944 |
"evaluate the receiver. |
|
1945 |
Optionally pass up to four arguments (if the receiver is a one/two/three/four arg block)." |
|
1946 |
||
1947 |
nargs == 4 ifTrue:[ |
|
18252 | 1948 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
9010 | 1949 |
]. |
1950 |
nargs == 3 ifTrue:[ |
|
18252 | 1951 |
^ self value:arg1 value:arg2 value:arg3 |
9010 | 1952 |
]. |
1953 |
nargs == 2 ifTrue:[ |
|
18252 | 1954 |
^ self value:arg1 value:arg2 |
9010 | 1955 |
]. |
1956 |
nargs == 1 ifTrue:[ |
|
18252 | 1957 |
^ self value:arg1 |
9010 | 1958 |
]. |
1959 |
^ self value |
|
1960 |
||
1961 |
" |
|
1962 |
|block| |
|
1963 |
||
1964 |
block := [ Transcript showCR:'hello' ]. |
|
18252 | 1965 |
block valueWithOptionalArgument:2. |
9010 | 1966 |
|
1967 |
block := [:arg | Transcript showCR:arg ]. |
|
18252 | 1968 |
block valueWithOptionalArgument:2. |
9010 | 1969 |
|
1970 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
18252 | 1971 |
block valueWithOptionalArgument:10 and:20. |
9010 | 1972 |
" |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1973 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1974 |
|
18992 | 1975 |
valueWithOptionalArguments:argArrayIn |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1976 |
"evaluate the receiver with arguments as required taken from argArray. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1977 |
Only the required number of arguments is taken from argArray or nil; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1978 |
(i.e. argArray may be larger than the required number). |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1979 |
If the size of the argArray is smaller than the number of arguments, an error is raised." |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1980 |
|
18992 | 1981 |
|argArray numArgsProvided a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1982 |
||
1983 |
argArray := argArrayIn. |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1984 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
20551 | 1985 |
argArray isCollection ifFalse:[ |
18992 | 1986 |
^ self badArgumentArray:argArray |
1987 |
]. |
|
20551 | 1988 |
argArray := argArray asArray. |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1989 |
]. |
18992 | 1990 |
|
1991 |
(argArray size < nargs) ifTrue:[ |
|
1992 |
^ self wrongNumberOfArguments:argArray size |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1993 |
]. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1994 |
%{ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1995 |
REGISTER OBJFUNC thecode; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1996 |
OBJ home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1997 |
REGISTER OBJ *ap; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1998 |
OBJ nA; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1999 |
int __numArgsProvided = __intVal(numArgsProvided); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2000 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2001 |
#if defined(THIS_CONTEXT) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2002 |
if (__ISVALID_ILC_LNO(__pilc)) |
18992 | 2003 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2004 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2005 |
thecode = __BlockInstPtr(self)->b_code; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2006 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2007 |
nA = __INST(nargs); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2008 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2009 |
if (argArray == nil) { |
18992 | 2010 |
ap = 0; |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2011 |
} else { |
18992 | 2012 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2013 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2014 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2015 |
#ifndef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2016 |
home = __BlockInstPtr(self)->b_home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2017 |
if (thecode != (OBJFUNC)nil) { |
18992 | 2018 |
/* the most common case (0 args) here (without a switch) */ |
2019 |
||
2020 |
if (nA == __mkSmallInteger(0)) { |
|
2021 |
RETURN ( (*thecode)(home) ); |
|
2022 |
} |
|
2023 |
||
2024 |
switch ((INT)(nA)) { |
|
2025 |
default: |
|
2026 |
goto error; |
|
2027 |
case (INT)__mkSmallInteger(15): |
|
2028 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13], ap[14]) ); |
|
2029 |
case (INT)__mkSmallInteger(14): |
|
2030 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12], ap[13]) ); |
|
2031 |
case (INT)__mkSmallInteger(13): |
|
2032 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11], ap[12]) ); |
|
2033 |
case (INT)__mkSmallInteger(12): |
|
2034 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10], ap[11]) ); |
|
2035 |
case (INT)__mkSmallInteger(11): |
|
2036 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9], ap[10]) ); |
|
2037 |
case (INT)__mkSmallInteger(10): |
|
2038 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) ); |
|
2039 |
case (INT)__mkSmallInteger(9): |
|
2040 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) ); |
|
2041 |
case (INT)__mkSmallInteger(8): |
|
2042 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) ); |
|
2043 |
case (INT)__mkSmallInteger(7): |
|
2044 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) ); |
|
2045 |
case (INT)__mkSmallInteger(6): |
|
2046 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) ); |
|
2047 |
case (INT)__mkSmallInteger(5): |
|
2048 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) ); |
|
2049 |
case (INT)__mkSmallInteger(4): |
|
2050 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) ); |
|
2051 |
case (INT)__mkSmallInteger(3): |
|
2052 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) ); |
|
2053 |
case (INT)__mkSmallInteger(2): |
|
2054 |
RETURN ( (*thecode)(home, ap[0], ap[1]) ); |
|
2055 |
case (INT)__mkSmallInteger(1): |
|
2056 |
RETURN ( (*thecode)(home, ap[0]) ); |
|
2057 |
case (INT)__mkSmallInteger(0): |
|
2058 |
RETURN ( (*thecode)(home) ); |
|
2059 |
break; |
|
2060 |
} |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2061 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2062 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2063 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2064 |
if (nA != __mkSmallInteger(0)) { |
18992 | 2065 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
2066 |
switch ((INT)nA) { |
|
2067 |
default: |
|
2068 |
goto error; |
|
2069 |
case (INT)__mkSmallInteger(15): |
|
2070 |
a15 = ap[14]; |
|
2071 |
case (INT)__mkSmallInteger(14): |
|
2072 |
a14 = ap[13]; |
|
2073 |
case (INT)__mkSmallInteger(13): |
|
2074 |
a13 = ap[12]; |
|
2075 |
case (INT)__mkSmallInteger(12): |
|
2076 |
a12 = ap[11]; |
|
2077 |
case (INT)__mkSmallInteger(11): |
|
2078 |
a11 = ap[10]; |
|
2079 |
case (INT)__mkSmallInteger(10): |
|
2080 |
a10 = ap[9]; |
|
2081 |
case (INT)__mkSmallInteger(9): |
|
2082 |
a9 = ap[8]; |
|
2083 |
case (INT)__mkSmallInteger(8): |
|
2084 |
a8 = ap[7]; |
|
2085 |
case (INT)__mkSmallInteger(7): |
|
2086 |
a7 = ap[6]; |
|
2087 |
case (INT)__mkSmallInteger(6): |
|
2088 |
a6 = ap[5]; |
|
2089 |
case (INT)__mkSmallInteger(5): |
|
2090 |
a5 = ap[4]; |
|
2091 |
case (INT)__mkSmallInteger(4): |
|
2092 |
a4 = ap[3]; |
|
2093 |
case (INT)__mkSmallInteger(3): |
|
2094 |
a3 = ap[2]; |
|
2095 |
case (INT)__mkSmallInteger(2): |
|
2096 |
a2 = ap[1]; |
|
2097 |
case (INT)__mkSmallInteger(1): |
|
2098 |
a1 = ap[0]; |
|
2099 |
case (INT)__mkSmallInteger(0): |
|
2100 |
break; |
|
2101 |
} |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2102 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2103 |
#ifdef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2104 |
if (thecode != (OBJFUNC)nil) { |
18992 | 2105 |
RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2106 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2107 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2108 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2109 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2110 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2111 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2112 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2113 |
#else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2114 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2115 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2116 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2117 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2118 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2119 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2120 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2121 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2122 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2123 |
error: ; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2124 |
%}. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2125 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2126 |
the above code only supports up-to 15 arguments |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2127 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2128 |
^ ArgumentError |
18992 | 2129 |
raiseRequestWith:self |
2130 |
errorString:'only blocks with up-to 15 arguments supported' |
|
2131 |
||
2132 |
||
2133 |
" |
|
2134 |
[:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithOptionalArguments:#(1 2 3 4). |
|
2135 |
[:a :b :c | Transcript showCR:a; showCR:b; showCR:c] valueWithOptionalArguments:#(1 2 3 4) asOrderedCollection. |
|
2136 |
" |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2137 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2138 |
|
18992 | 2139 |
valueWithPossibleArguments:argArrayIn |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2140 |
"evaluate the receiver with arguments as required taken from argArray. |
18252 | 2141 |
If argArray provides less than the required number of arguments, |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2142 |
nil is assumed for any remaining argument. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2143 |
(i.e. argArray may be smaller than the required number). |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2144 |
Only the required number of arguments is taken from argArray or nil; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2145 |
(i.e. argArray may be larger than the required number)." |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2146 |
|
18992 | 2147 |
|argArray numArgsProvided a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
2148 |
||
2149 |
argArray := argArrayIn. |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2150 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
20551 | 2151 |
argArray isCollection ifFalse:[ |
18992 | 2152 |
^ self badArgumentArray:argArray |
2153 |
]. |
|
20551 | 2154 |
argArray := argArray asArray. |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2155 |
]. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2156 |
numArgsProvided := argArray size. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2157 |
%{ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2158 |
REGISTER OBJFUNC thecode; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2159 |
OBJ home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2160 |
REGISTER OBJ *ap; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2161 |
OBJ nA; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2162 |
int __numArgsProvided = __intVal(numArgsProvided); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2163 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2164 |
#if defined(THIS_CONTEXT) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2165 |
if (__ISVALID_ILC_LNO(__pilc)) |
18992 | 2166 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2167 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2168 |
thecode = __BlockInstPtr(self)->b_code; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2169 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2170 |
nA = __INST(nargs); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2171 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2172 |
if (argArray == nil) { |
18992 | 2173 |
ap = 0; |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2174 |
} else { |
18992 | 2175 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2176 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2177 |
switch (__numArgsProvided) { |
18992 | 2178 |
default: |
2179 |
case 15: a15 = ap[14]; |
|
2180 |
case 14: a14 = ap[13]; |
|
2181 |
case 13: a13 = ap[12]; |
|
2182 |
case 12: a12 = ap[11]; |
|
2183 |
case 11: a11 = ap[10]; |
|
2184 |
case 10: a10 = ap[9]; |
|
2185 |
case 9: a9 = ap[8]; |
|
2186 |
case 8: a8 = ap[7]; |
|
2187 |
case 7: a7 = ap[6]; |
|
2188 |
case 6: a6 = ap[5]; |
|
2189 |
case 5: a5 = ap[4]; |
|
2190 |
case 4: a4 = ap[3]; |
|
2191 |
case 3: a3 = ap[2]; |
|
2192 |
case 2: a2 = ap[1]; |
|
2193 |
case 1: a1 = ap[0]; |
|
2194 |
case 0: ; |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2195 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2196 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2197 |
#ifndef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2198 |
home = __BlockInstPtr(self)->b_home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2199 |
if (thecode != (OBJFUNC)nil) { |
18992 | 2200 |
/* the most common case (0 args) here (without a switch) */ |
2201 |
||
2202 |
if (nA == __mkSmallInteger(0)) { |
|
2203 |
RETURN ( (*thecode)(home) ); |
|
2204 |
} |
|
2205 |
||
2206 |
switch ((INT)(nA)) { |
|
2207 |
default: |
|
2208 |
goto error; |
|
2209 |
case (INT)__mkSmallInteger(15): |
|
2210 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
|
2211 |
case (INT)__mkSmallInteger(14): |
|
2212 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) ); |
|
2213 |
case (INT)__mkSmallInteger(13): |
|
2214 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) ); |
|
2215 |
case (INT)__mkSmallInteger(12): |
|
2216 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) ); |
|
2217 |
case (INT)__mkSmallInteger(11): |
|
2218 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) ); |
|
2219 |
case (INT)__mkSmallInteger(10): |
|
2220 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) ); |
|
2221 |
case (INT)__mkSmallInteger(9): |
|
2222 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9) ); |
|
2223 |
case (INT)__mkSmallInteger(8): |
|
2224 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8) ); |
|
2225 |
case (INT)__mkSmallInteger(7): |
|
2226 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7) ); |
|
2227 |
case (INT)__mkSmallInteger(6): |
|
2228 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6) ); |
|
2229 |
case (INT)__mkSmallInteger(5): |
|
2230 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5) ); |
|
2231 |
case (INT)__mkSmallInteger(4): |
|
2232 |
RETURN ( (*thecode)(home, a1, a2, a3, a4) ); |
|
2233 |
case (INT)__mkSmallInteger(3): |
|
2234 |
RETURN ( (*thecode)(home, a1, a2, a3) ); |
|
2235 |
case (INT)__mkSmallInteger(2): |
|
2236 |
RETURN ( (*thecode)(home, a1, a2) ); |
|
2237 |
case (INT)__mkSmallInteger(1): |
|
2238 |
RETURN ( (*thecode)(home, a1) ); |
|
2239 |
case (INT)__mkSmallInteger(0): |
|
2240 |
RETURN ( (*thecode)(home) ); |
|
2241 |
break; |
|
2242 |
} |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2243 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2244 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2245 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2246 |
#ifdef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2247 |
if (thecode != (OBJFUNC)nil) { |
18992 | 2248 |
RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2249 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2250 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2251 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2252 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2253 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2254 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2255 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2256 |
#else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2257 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2258 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2259 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2260 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2261 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2262 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2263 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2264 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2265 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2266 |
error: ; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2267 |
%}. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2268 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2269 |
the above code only supports up-to 15 arguments |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2270 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
2271 |
^ ArgumentError |
18992 | 2272 |
raiseRequestWith:self |
2273 |
errorString:'only blocks with up-to 15 arguments supported' |
|
2274 |
||
2275 |
" |
|
2276 |
[:a :b :c :d| Transcript showCR:a; showCR:b; showCR:c; showCR:d] valueWithPossibleArguments:#(1 2 3). |
|
20178 | 2277 |
[:a :b :c :d| Transcript showCR:a; showCR:b; showCR:c; showCR:d] valueWithPossibleArguments:#(1 2 3 4 5). |
18992 | 2278 |
[:a :b :c :d| Transcript showCR:a; showCR:b; showCR:c; showCR:d] valueWithPossibleArguments:#(1 2 3) asOrderedCollection. |
2279 |
" |
|
154 | 2280 |
! ! |
2281 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2282 |
!Block methodsFor:'exception handling'! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2283 |
|
6512 | 2284 |
on:aSignalOrSignalSetOrException do:exceptionBlock |
2285 |
"added for ANSI compatibility; evaluate the receiver, |
|
18252 | 2286 |
handling aSignalOrSignalSetOrException. |
18316 | 2287 |
If the signal is raised during evaluation, |
2288 |
the 2nd argument, exceptionBlock is evaluated (and its value returned" |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2289 |
|
4542
5dc47816cf68
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4513
diff
changeset
|
2290 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2291 |
<exception: #handle> |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2292 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2293 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2294 |
^ self value. "the real logic is in Exception>>doRaise" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2295 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2296 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2297 |
[ |
18316 | 2298 |
1 foo |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2299 |
] on:MessageNotUnderstood do:[:ex | self halt] |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2300 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2301 |
[ |
18316 | 2302 |
1 foo |
6512 | 2303 |
] on:(MessageNotUnderstood , AbortOperationRequest) do:[:ex | self halt] |
2304 |
||
2305 |
[ |
|
18316 | 2306 |
1 foo |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2307 |
] on:SignalSet anySignal do:[:ex| 2 bar. self halt] |
18316 | 2308 |
|
2309 |
[ |
|
2310 |
1 foo |
|
2311 |
] on:Error do:[:ex| 2 ] |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2312 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2313 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2314 |
"Modified: / 26.7.1999 / 15:30:48 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2315 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2316 |
|
11338 | 2317 |
on:aSignalOrSignalSetOrException do:exceptionBlock ensure:ensureBlock |
2318 |
"added for ANSI compatibility; evaluate the receiver, |
|
18252 | 2319 |
handling aSignalOrSignalSetOrException. |
11338 | 2320 |
The 2nd argument, exceptionBlock is evaluated |
2321 |
if the signal is raised during evaluation. |
|
2322 |
The 3rd argument, ensureBlock is evaluated in any case - even if the activity |
|
2323 |
was unwound due to an unhandled exception." |
|
2324 |
||
2325 |
<context: #return> |
|
2326 |
<exception: #handle> |
|
2327 |
<exception: #unwind> |
|
2328 |
||
2329 |
|v| |
|
2330 |
||
2331 |
v := self value. "the real logic is in Context>>unwind and Exception>>doRaise" |
|
2332 |
thisContext unmarkForUnwind. |
|
2333 |
ensureBlock value. |
|
2334 |
^ v |
|
2335 |
||
2336 |
" |
|
2337 |
|e| |
|
2338 |
||
2339 |
e := 0. |
|
2340 |
[ |
|
23040 | 2341 |
1 foo |
2342 |
] on:MessageNotUnderstood do:[:ex | |
|
2343 |
self halt |
|
2344 |
] ensure:[ |
|
2345 |
e := 1 |
|
2346 |
]. |
|
11338 | 2347 |
self assert:(e == 1). |
2348 |
" |
|
2349 |
||
2350 |
" |
|
23432 | 2351 |
[ |
2352 |
1 foo |
|
2353 |
] on:MessageNotUnderstood do:[:ex | |
|
2354 |
^ self |
|
2355 |
] ensure:[ |
|
2356 |
Transcript showCR:'ensure ensured' |
|
2357 |
]. |
|
2358 |
" |
|
2359 |
||
2360 |
" |
|
11338 | 2361 |
|e| |
2362 |
||
2363 |
e := 0. |
|
2364 |
[ |
|
23040 | 2365 |
1 negated |
2366 |
] on:MessageNotUnderstood do:[:ex | |
|
2367 |
self halt |
|
2368 |
] ensure:[ |
|
2369 |
e := 1 |
|
2370 |
]. |
|
11338 | 2371 |
self assert:(e == 1). |
2372 |
" |
|
23040 | 2373 |
|
2374 |
"Modified (comment): / 30-05-2018 / 21:20:14 / Claus Gittinger" |
|
11338 | 2375 |
! |
2376 |
||
18959 | 2377 |
on:aSignalOrSignalSetOrException do:exceptionBlock ifCurtailed:curtailBlock |
2378 |
"evaluate the receiver, |
|
2379 |
handling aSignalOrSignalSetOrException. |
|
2380 |
The 2nd argument, exceptionBlock is evaluated |
|
2381 |
if the signal is raised during evaluation. |
|
2382 |
The 3rd argument, curtailBlock is evaluated if the activity |
|
2383 |
was unwound due to an unhandled exception in the receiver block |
|
2384 |
(but not in the exceptionBlock)." |
|
2385 |
||
2386 |
<context: #return> |
|
2387 |
<exception: #handle> |
|
2388 |
<exception: #unwind> |
|
2389 |
||
2390 |
|v| |
|
2391 |
||
2392 |
v := self value. "the real logic is in Context>>unwind and Exception>>doRaise" |
|
2393 |
thisContext unmarkForUnwind. |
|
2394 |
^ v |
|
2395 |
||
2396 |
" |
|
2397 |
|e| |
|
2398 |
||
2399 |
e := 0. |
|
2400 |
[ |
|
2401 |
1 foo |
|
2402 |
] on:MessageNotUnderstood |
|
2403 |
do:[:ex | e := 1] |
|
2404 |
ifCurtailed:[ e := 2 ]. |
|
2405 |
self assert:(e == 1). |
|
2406 |
" |
|
2407 |
||
2408 |
" |
|
2409 |
abort the debugger to perform the ifCurtailedBlock... |
|
2410 |
continue the debugger to go to the end |
|
2411 |
||
2412 |
|e| |
|
2413 |
||
2414 |
e := 0. |
|
2415 |
[ |
|
2416 |
#[] at:2 |
|
2417 |
] on:MessageNotUnderstood |
|
2418 |
do:[:ex | e := 1] |
|
2419 |
ifCurtailed:[ e := 2. e inspect ]. |
|
2420 |
self assert:(e == 0). |
|
2421 |
" |
|
2422 |
||
2423 |
" |
|
2424 |
|e| |
|
2425 |
||
2426 |
e := 0. |
|
2427 |
[ |
|
2428 |
1 negated |
|
2429 |
] on:MessageNotUnderstood |
|
2430 |
do:[:ex | self halt] |
|
2431 |
ifCurtailed:[ e := 1 ]. |
|
2432 |
self assert:(e == 0). |
|
2433 |
" |
|
21669 | 2434 |
|
2435 |
||
2436 |
" |
|
2437 |
|e| |
|
2438 |
||
2439 |
e := 0. |
|
2440 |
[ |
|
2441 |
1 foo |
|
2442 |
] on:MessageNotUnderstood do:[:ex | 2 bla] |
|
2443 |
ifCurtailed:[ e := 1 ]. |
|
2444 |
self assert:(e == 0). |
|
2445 |
" |
|
2446 |
||
2447 |
"Modified (comment): / 23-03-2017 / 19:10:31 / stefan" |
|
18959 | 2448 |
! |
2449 |
||
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2450 |
on:anExceptionHandler do:exceptionBlock on:anExceptionHandler2 do:anExceptionBlock2 |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2451 |
"added for ANSI compatibility; evaluate the receiver, |
18252 | 2452 |
handling aSignalOrSignalSetOrException. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2453 |
The 2nd argument, exceptionBlock is evaluated |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2454 |
if the signal is raised during evaluation." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2455 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2456 |
<context: #return> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2457 |
<exception: #handle> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2458 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2459 |
"/ thisContext markForHandle. -- same as above pragma |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2460 |
^ self value. "the real logic is in Exception>>doRaise" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2461 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2462 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2463 |
[ |
18252 | 2464 |
1 foo |
2465 |
] on:MessageNotUnderstood do:[:ex | self halt:'Got MessageNotUnderstood'] |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2466 |
on:Error do:[:ex| self halt:'Got Error'] |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2467 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2468 |
[ |
18252 | 2469 |
1 // 0 |
2470 |
] on:MessageNotUnderstood do:[:ex | self halt:'Got MessageNotUnderstood'] |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2471 |
on:Error do:[:ex| self halt:'Got Error'] |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2472 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2473 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2474 |
"Modified: / 26.7.1999 / 15:30:48 / stefan" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2475 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2476 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2477 |
valueWithExceptionHandler:handler |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2478 |
"evaluate myself. If any of the signals in handler is raised, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2479 |
evaluate the corresponding handler block." |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2480 |
|
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4542
diff
changeset
|
2481 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2482 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2483 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2484 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2485 |
^ self value. "the real logic is in Exception>>doRaise" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2486 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2487 |
"Created: / 26.7.1999 / 11:23:45 / stefan" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2488 |
"Modified: / 26.7.1999 / 11:24:06 / stefan" |
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2489 |
! |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2490 |
|
19237 | 2491 |
valueWithTimeout:aTimeDurationOrIntegerSeconds |
14803 | 2492 |
"execute the receiver, but abort the evaluation after aTimeDuration if still running. |
16076 | 2493 |
Return the receiver's value, or nil if aborted." |
14803 | 2494 |
|
19237 | 2495 |
|milliseconds| |
2496 |
||
2497 |
milliseconds := aTimeDurationOrIntegerSeconds isTimeDuration |
|
2498 |
ifTrue:[ aTimeDurationOrIntegerSeconds asMilliseconds ] |
|
2499 |
ifFalse:[ (aTimeDurationOrIntegerSeconds * 1000) truncated]. |
|
2500 |
^ self valueWithWatchDog:[^ nil] afterMilliseconds:milliseconds |
|
14803 | 2501 |
|
2502 |
" |
|
2503 |
[ |
|
19237 | 2504 |
1 to:15 do:[:round | |
2505 |
Transcript showCR:round. |
|
2506 |
Delay waitForMilliseconds:20. |
|
2507 |
]. |
|
2508 |
true |
|
18252 | 2509 |
] valueWithTimeout:(TimeDuration seconds:1) |
14803 | 2510 |
" |
2511 |
||
2512 |
" |
|
2513 |
[ |
|
19237 | 2514 |
1 to:100 do:[:round | |
2515 |
Transcript showCR:round. |
|
2516 |
Delay waitForMilliseconds:20. |
|
2517 |
]. |
|
2518 |
true |
|
18252 | 2519 |
] valueWithTimeout:(TimeDuration seconds:1) |
14803 | 2520 |
" |
2521 |
! |
|
2522 |
||
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2523 |
valueWithWatchDog:exceptionBlock afterMilliseconds:aTimeLimit |
11803 | 2524 |
"a watchdog on a block's execution. If the block does not finish its |
2525 |
evaluation after aTimeLimit milliseconds, it is interrupted (aborted) and |
|
24226 | 2526 |
exceptionBlock's value is returned. |
2527 |
The receiver's code must be prepared |
|
2528 |
for premature returning (by adding ensure blocks, as required). |
|
2529 |
The timeout is not raised, if the process is currently being debugged |
|
2530 |
(to prevent the debugger from being closed prematurely)" |
|
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2531 |
|
22518 | 2532 |
|inError| |
21921 | 2533 |
|
2534 |
inError := false. |
|
13030
9b9f51659b4a
changed: #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
12931
diff
changeset
|
2535 |
|
22518 | 2536 |
^ TimeoutNotification handle:[:ex | |
21667 | 2537 |
inError ifTrue:[ |
2538 |
ex proceed |
|
2539 |
]. |
|
22996 | 2540 |
exceptionBlock valueWithOptionalArgument:ex. |
10700
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
2541 |
] do:[ |
21667 | 2542 |
NoHandlerError handle:[:ex | |
2543 |
inError := true. |
|
2544 |
ex reject. |
|
2545 |
] do:[ |
|
21921 | 2546 |
|showStopper me done| |
2547 |
||
2548 |
done := false. |
|
2549 |
me := Processor activeProcess. |
|
22518 | 2550 |
showStopper := [ |
21921 | 2551 |
done ifFalse:[ |
2552 |
me interruptWith:[ |
|
24226 | 2553 |
(done not and:[me isDebugged not]) ifTrue:[ |
22518 | 2554 |
TimeoutNotification raiseRequest. |
21921 | 2555 |
] |
2556 |
] |
|
2557 |
] |
|
2558 |
]. |
|
2559 |
||
21667 | 2560 |
[ |
22518 | 2561 |
|retVal| |
2562 |
||
21667 | 2563 |
Processor |
2564 |
addTimedBlock:showStopper |
|
2565 |
for:me |
|
2566 |
afterMilliseconds:aTimeLimit. |
|
2567 |
||
2568 |
retVal := self value. |
|
2569 |
done := true. |
|
22518 | 2570 |
retVal |
21667 | 2571 |
] ensure:[ |
2572 |
Processor removeTimedBlock:showStopper |
|
2573 |
]. |
|
2574 |
] |
|
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2575 |
]. |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2576 |
|
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2577 |
" |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2578 |
[ |
21667 | 2579 |
Delay waitForSeconds:5. |
2580 |
true |
|
18252 | 2581 |
] valueWithWatchDog:[false] afterMilliseconds:2000 |
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
2582 |
" |
10678
5cd10f301f94
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10473
diff
changeset
|
2583 |
|
12928 | 2584 |
"Modified: / 21-05-2010 / 12:19:57 / sr" |
21667 | 2585 |
"Modified: / 19-03-2017 / 18:13:07 / cg" |
22518 | 2586 |
"Modified: / 31-01-2018 / 08:34:51 / stefan" |
22996 | 2587 |
"Modified: / 23-05-2018 / 12:47:00 / Maren" |
24226 | 2588 |
"Modified (comment): / 29-05-2019 / 01:09:36 / Claus Gittinger" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2589 |
! ! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
2590 |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2591 |
!Block methodsFor:'exception handling private'! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2592 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2593 |
exceptionHandlerFor:anException in:aContext |
11338 | 2594 |
"answer the exceptionHandler (the Error or signal) for anException from aContext." |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2595 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2596 |
aContext selector == #on:do:on:do: ifTrue:[ |
22642 | 2597 |
|exceptionCreator exceptionHandlerInContext| |
2598 |
||
2599 |
exceptionCreator := anException creator. |
|
2600 |
exceptionHandlerInContext := aContext argAt:1. |
|
2601 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
|
2602 |
GenericException printBadExceptionHandler:exceptionHandlerInContext in:aContext. |
|
2603 |
^ nil. |
|
2604 |
]. |
|
2605 |
(exceptionHandlerInContext accepts:exceptionCreator) ifTrue:[ |
|
2606 |
^ exceptionHandlerInContext. |
|
2607 |
]. |
|
2608 |
||
2609 |
exceptionHandlerInContext := aContext argAt:3. |
|
2610 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
|
2611 |
GenericException printBadExceptionHandler:exceptionHandlerInContext in:aContext. |
|
2612 |
^ nil. |
|
2613 |
]. |
|
2614 |
(exceptionHandlerInContext accepts:exceptionCreator) ifTrue:[ |
|
2615 |
^ exceptionHandlerInContext. |
|
2616 |
]. |
|
2617 |
^ nil. |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2618 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2619 |
|
11338 | 2620 |
"aContext selector must be #on:do: , #on:do:ensure: or #valueWithExceptionHandler:" |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2621 |
^ aContext argAt:1. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2622 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2623 |
|
22642 | 2624 |
handlerForSignal:exceptionCreator context:aContext originator:originator |
18959 | 2625 |
"answer the handler block for the exceptionCreator from originator. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2626 |
The handler block is retrieved from aContext. |
18959 | 2627 |
Answer nil if the exceptionCreator is not handled." |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2628 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2629 |
|selector exceptionHandlerInContext| |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2630 |
|
22642 | 2631 |
selector := aContext selector. |
11338 | 2632 |
|
2633 |
(selector == #on:do: |
|
18959 | 2634 |
or:[ selector == #on:do:ensure: |
2635 |
or:[ selector == #on:do:ifCurtailed: ]] |
|
2636 |
) ifTrue:[ |
|
22642 | 2637 |
exceptionHandlerInContext := aContext argAt:1. |
18959 | 2638 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
22642 | 2639 |
GenericException printBadExceptionHandler:exceptionHandlerInContext in:aContext. |
18959 | 2640 |
^ nil. |
2641 |
]. |
|
2642 |
(exceptionHandlerInContext == exceptionCreator |
|
2643 |
or:[exceptionHandlerInContext accepts:exceptionCreator]) ifTrue:[ |
|
2644 |
selector == #on:do:ifCurtailed: ifTrue:[ |
|
22642 | 2645 |
aContext unmarkForUnwind. "if there is a handler, no unwind block has to be performed" |
18959 | 2646 |
]. |
22642 | 2647 |
^ (aContext argAt:2) ? [nil]. |
18959 | 2648 |
]. |
2649 |
^ nil |
|
11338 | 2650 |
]. |
2651 |
||
2652 |
selector == #on:do:on:do: ifTrue:[ |
|
22642 | 2653 |
exceptionHandlerInContext := aContext argAt:1. |
18959 | 2654 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
22642 | 2655 |
GenericException printBadExceptionHandler:exceptionHandlerInContext in:aContext. |
18959 | 2656 |
^ nil. |
2657 |
]. |
|
2658 |
(exceptionHandlerInContext == exceptionCreator |
|
2659 |
or:[exceptionHandlerInContext accepts:exceptionCreator]) ifTrue:[ |
|
22642 | 2660 |
^ (aContext argAt:2) ? [nil]. |
18959 | 2661 |
]. |
2662 |
||
22642 | 2663 |
exceptionHandlerInContext := aContext argAt:3. |
18959 | 2664 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
22642 | 2665 |
GenericException printBadExceptionHandler:exceptionHandlerInContext in:aContext. |
18959 | 2666 |
^ nil. |
2667 |
]. |
|
2668 |
(exceptionHandlerInContext == exceptionCreator |
|
2669 |
or:[exceptionHandlerInContext accepts:exceptionCreator]) ifTrue:[ |
|
22642 | 2670 |
^ (aContext argAt:4) ? [nil]. |
18959 | 2671 |
]. |
2672 |
^ nil |
|
11338 | 2673 |
]. |
2674 |
||
2675 |
selector == #valueWithExceptionHandler: ifTrue:[ |
|
22642 | 2676 |
^ (aContext argAt:1) handlerForSignal:exceptionCreator. |
11338 | 2677 |
]. |
2678 |
||
2679 |
"/ mhmh - should not arrive here |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2680 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2681 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2682 |
"Created: / 25.7.1999 / 19:52:58 / stefan" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2683 |
"Modified: / 26.7.1999 / 14:30:42 / stefan" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2684 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2685 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2686 |
handlerProtectedBlock:doBlock inContext:context |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2687 |
"set the block that is protected by an exception handler in context. |
11338 | 2688 |
This is the receiver of the #on:do: or #valueWithExceptionHandler:. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2689 |
Needed for #restartDo:" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2690 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2691 |
context receiver:doBlock |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2692 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2693 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2694 |
[1/0] on:Error do:[:ex| ex restartDo:[55]] |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2695 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2696 |
! ! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2697 |
|
14139 | 2698 |
|
623 | 2699 |
!Block methodsFor:'looping'! |
325 | 2700 |
|
623 | 2701 |
doUntil:aBlock |
2702 |
"repeat the receiver block until aBlock evaluates to true. |
|
2703 |
The receiver is evaluated at least once. |
|
2704 |
This is the same as '... doWhile:[... not]' " |
|
325 | 2705 |
|
623 | 2706 |
"this implementation is for purists ... :-)" |
2707 |
||
2708 |
self value. |
|
2709 |
aBlock value ifTrue:[^ nil]. |
|
2710 |
thisContext restart |
|
325 | 2711 |
|
2712 |
" |
|
623 | 2713 |
|n| |
154 | 2714 |
|
623 | 2715 |
n := 1. |
8602 | 2716 |
[n printCR] doUntil:[ (n := n + 1) > 5 ] |
154 | 2717 |
" |
1 | 2718 |
! |
2719 |
||
623 | 2720 |
doWhile:aBlock |
2721 |
"repeat the receiver block until aBlock evaluates to false. |
|
2722 |
The receiver is evaluated at least once." |
|
67 | 2723 |
|
154 | 2724 |
"this implementation is for purists ... :-)" |
2725 |
||
623 | 2726 |
self value. |
2727 |
aBlock value ifFalse:[^ nil]. |
|
2728 |
thisContext restart |
|
2729 |
||
2730 |
" |
|
2731 |
|n| |
|
2732 |
||
2733 |
n := 1. |
|
8602 | 2734 |
[n printCR] doWhile:[ (n := n + 1) <= 5 ] |
623 | 2735 |
" |
2736 |
! |
|
2737 |
||
2738 |
loop |
|
18252 | 2739 |
"repeat the receiver forever |
1211 | 2740 |
(the receiver block should contain a return somewhere). |
2741 |
The implementation below was inspired by a corresponding Self method." |
|
623 | 2742 |
|
2743 |
self value. |
|
67 | 2744 |
thisContext restart |
2745 |
||
2746 |
" |
|
2747 |
|n| |
|
2748 |
||
2749 |
n := 1. |
|
623 | 2750 |
[ |
18252 | 2751 |
n printCR. |
2752 |
n >= 10 ifTrue:[^ nil]. |
|
2753 |
n := n + 1 |
|
623 | 2754 |
] loop |
2755 |
" |
|
1211 | 2756 |
|
2757 |
"Modified: 18.4.1996 / 13:50:40 / cg" |
|
623 | 2758 |
! |
2759 |
||
2760 |
loopWithExit |
|
18252 | 2761 |
"the receiver must be a block of one argument. It is evaluated in a loop forever, |
2762 |
and is passed a block, which, if sent a value:-message, will exit the receiver block, |
|
623 | 2763 |
returning the parameter of the value:-message. Used for loops with exit in the middle. |
2764 |
Inspired by a corresponding Self method." |
|
2765 |
||
2766 |
|exitBlock| |
|
2767 |
||
2768 |
exitBlock := [:exitValue | ^ exitValue]. |
|
16239 | 2769 |
[self value:exitBlock] loop. |
623 | 2770 |
|
2771 |
" |
|
2772 |
|i| |
|
2773 |
i := 1. |
|
2774 |
[:exit | |
|
18252 | 2775 |
Transcript showCR:i. |
2776 |
i == 5 ifTrue:[exit value:'thats it']. |
|
2777 |
i := i + 1 |
|
623 | 2778 |
] loopWithExit |
2779 |
" |
|
2780 |
! |
|
2781 |
||
2782 |
repeat |
|
1211 | 2783 |
"repeat the receiver forever - same as loop, for ST-80 compatibility. |
2784 |
(the receiver block should contain a return somewhere)." |
|
623 | 2785 |
|
2786 |
self value. |
|
2787 |
thisContext restart |
|
1211 | 2788 |
|
2789 |
"Modified: 18.4.1996 / 13:50:55 / cg" |
|
623 | 2790 |
! |
2791 |
||
16162 | 2792 |
repeat:n |
18252 | 2793 |
"repeat the receiver n times - similar to timesRepeat, but optionally passes the |
16162 | 2794 |
loop counter as argument" |
2795 |
||
18434 | 2796 |
self argumentCount == 0 ifTrue:[ |
2797 |
n timesRepeat:self |
|
16162 | 2798 |
] ifFalse:[ |
18434 | 2799 |
1 to:n do:self |
16162 | 2800 |
]. |
2801 |
||
2802 |
" |
|
2803 |
[ Transcript showCR:'hello' ] repeat:3 |
|
2804 |
[:i | Transcript showCR:'hello',i printString ] repeat:3 |
|
2805 |
" |
|
2806 |
! |
|
2807 |
||
623 | 2808 |
valueWithExit |
2809 |
"the receiver must be a block of one argument. It is evaluated, and is passed a block, |
|
18252 | 2810 |
which, if sent a value:-message, will exit the receiver block, returning the parameter of the |
623 | 2811 |
value:-message. Used for premature returns to the caller. |
2812 |
Taken from a manchester goody (a similar construct also appears in Self)." |
|
2813 |
||
1211 | 2814 |
^ self value:[:exitValue | ^exitValue] |
623 | 2815 |
|
2816 |
" |
|
2817 |
[:exit | |
|
2238 | 2818 |
1 to:10 do:[:i | |
2819 |
Transcript showCR:i. |
|
2820 |
i == 5 ifTrue:[exit value:'thats it'] |
|
2821 |
]. |
|
2822 |
'regular block-value; never returned' |
|
623 | 2823 |
] valueWithExit |
2824 |
" |
|
1211 | 2825 |
|
2826 |
"Modified: 18.4.1996 / 13:51:38 / cg" |
|
623 | 2827 |
! |
2828 |
||
5215 | 2829 |
valueWithRestart |
14683 | 2830 |
"the receiver must be a block of one argument. It is evaluated, and is passed a block, |
15244 | 2831 |
which, if sent a value-message, will restart the receiver block from the beginning" |
2832 |
||
15316 | 2833 |
|myContext restartAction| |
5215 | 2834 |
|
2835 |
myContext := thisContext. |
|
15320 | 2836 |
restartAction := [ myContext unwindAndRestart ]. |
15316 | 2837 |
^ self value:restartAction. |
5215 | 2838 |
|
2839 |
" |
|
2840 |
[:restart | |
|
18252 | 2841 |
(self confirm:'try again ?') ifTrue:[ |
2842 |
restart value. |
|
2843 |
] |
|
5215 | 2844 |
] valueWithRestart |
2845 |
" |
|
2846 |
||
2847 |
"Modified: / 25.1.2000 / 21:47:50 / cg" |
|
2848 |
! |
|
2849 |
||
14683 | 2850 |
valueWithRestartAndExit |
2851 |
"the receiver must be a block of two arguments, a restart and an exit block. |
|
2852 |
See description of valueWithExit and valueWithRestart for their use" |
|
2853 |
||
15316 | 2854 |
|myContext restartAction| |
14683 | 2855 |
|
2856 |
myContext := thisContext. |
|
15320 | 2857 |
restartAction := [ myContext unwindAndRestart ]. |
15316 | 2858 |
^ self value:restartAction value:[:exitValue | ^exitValue]. |
14683 | 2859 |
|
2860 |
" |
|
2861 |
[:restart :exit | |
|
18252 | 2862 |
|i| |
2863 |
||
2864 |
i := 0. |
|
2865 |
[ |
|
2866 |
i := i + 1. |
|
2867 |
(self confirm:('i is ',i printString,'; start over ?')) ifTrue:[ |
|
2868 |
restart value. |
|
2869 |
]. |
|
2870 |
(self confirm:'enough ?') ifTrue:[ |
|
2871 |
exit value:nil. |
|
2872 |
]. |
|
2873 |
] loop |
|
14683 | 2874 |
] valueWithRestartAndExit |
2875 |
" |
|
2876 |
! |
|
2877 |
||
623 | 2878 |
whileFalse |
2879 |
"evaluate the receiver while it evaluates to false (ST80 compatibility)" |
|
2880 |
||
2881 |
"this implementation is for purists ... :-)" |
|
2882 |
||
2883 |
self value ifTrue:[^ nil]. |
|
2884 |
thisContext restart |
|
2885 |
||
2886 |
" |
|
2887 |
|n| |
|
2888 |
||
2889 |
n := 1. |
|
8602 | 2890 |
[n printCR. (n := n + 1) > 10] whileFalse |
67 | 2891 |
" |
2892 |
! |
|
1 | 2893 |
|
67 | 2894 |
whileFalse:aBlock |
2895 |
"evaluate the argument, aBlock while the receiver evaluates to false. |
|
18252 | 2896 |
- usually open coded by compilers, but needed here for #perform |
67 | 2897 |
and expression evaluation." |
2898 |
||
154 | 2899 |
"this implementation is for purists ... :-)" |
2900 |
||
67 | 2901 |
self value ifTrue:[^ nil]. |
2902 |
aBlock value. |
|
2903 |
thisContext restart |
|
2904 |
||
2905 |
" |
|
2906 |
|n| |
|
2907 |
||
2908 |
n := 1. |
|
2909 |
[n > 10] whileFalse:[ |
|
18252 | 2910 |
n printCR. |
2911 |
n := n + 1 |
|
67 | 2912 |
] |
2913 |
" |
|
1 | 2914 |
! |
2915 |
||
2916 |
whileTrue |
|
67 | 2917 |
"evaluate the receiver while it evaluates to true (ST80 compatibility)" |
1 | 2918 |
|
154 | 2919 |
"this implementation is for purists ... :-)" |
2920 |
||
67 | 2921 |
self value ifFalse:[^ nil]. |
2922 |
thisContext restart |
|
1 | 2923 |
|
67 | 2924 |
" |
2925 |
|n| |
|
1 | 2926 |
|
67 | 2927 |
n := 1. |
8602 | 2928 |
[n printCR. (n := n + 1) <= 10] whileTrue |
67 | 2929 |
" |
1 | 2930 |
! |
2931 |
||
623 | 2932 |
whileTrue:aBlock |
2933 |
"evaluate the argument, aBlock while the receiver evaluates to true. |
|
18252 | 2934 |
- usually open coded by compilers, but needed here for #perform |
623 | 2935 |
and expression evaluation." |
1 | 2936 |
|
154 | 2937 |
"this implementation is for purists ... :-)" |
2938 |
||
623 | 2939 |
self value ifFalse:[^ nil]. |
2940 |
aBlock value. |
|
67 | 2941 |
thisContext restart |
2942 |
||
2943 |
" |
|
2944 |
|n| |
|
1 | 2945 |
|
67 | 2946 |
n := 1. |
623 | 2947 |
[n <= 10] whileTrue:[ |
18252 | 2948 |
n printCR. |
2949 |
n := n + 1 |
|
623 | 2950 |
] |
68 | 2951 |
" |
67 | 2952 |
! ! |
2953 |
||
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2954 |
|
92 | 2955 |
!Block methodsFor:'printing & storing'! |
1 | 2956 |
|
7151 | 2957 |
printBlockBracketsOn:aStream |
18252 | 2958 |
aStream nextPutAll:'[]'. |
7151 | 2959 |
! |
2960 |
||
1 | 2961 |
printOn:aStream |
44 | 2962 |
"append a a printed representation of the block to aStream" |
2963 |
||
6633 | 2964 |
|h sel methodClass| |
54 | 2965 |
|
2966 |
"cheap blocks have no home context, but a method instead" |
|
2967 |
||
2968 |
(home isNil or:[home isContext not]) ifTrue:[ |
|
18252 | 2969 |
aStream nextPutAll:'[] in '. |
2970 |
||
2971 |
" |
|
2972 |
currently, some cheap blocks don't know where they have been created |
|
2973 |
" |
|
2974 |
aStream nextPutAll:' ??? (optimized)'. |
|
2975 |
^ self |
|
54 | 2976 |
]. |
2977 |
||
2978 |
"a full blown block (with home, but without method)" |
|
7151 | 2979 |
self printBlockBracketsOn:aStream. |
18252 | 2980 |
aStream nextPutAll:' in '. |
154 | 2981 |
h := self methodHome. |
2982 |
sel := h selector. |
|
2983 |
"/ old: |
|
2984 |
"/ home receiver class name printOn:aStream. |
|
2985 |
"/ new: |
|
212 | 2986 |
"/ (h searchClass whichClassImplements:sel) name printOn:aStream. |
213 | 2987 |
methodClass := h methodClass. |
2988 |
methodClass isNil ifTrue:[ |
|
18252 | 2989 |
'UnboundMethod' printOn:aStream. |
213 | 2990 |
] ifFalse:[ |
18252 | 2991 |
methodClass name printOn:aStream. |
213 | 2992 |
]. |
7157
935eaabbe6dc
printString now "... in className >> sel"
Claus Gittinger <cg@exept.de>
parents:
7151
diff
changeset
|
2993 |
aStream nextPutAll:'>>'. |
154 | 2994 |
sel printOn:aStream. |
54 | 2995 |
|
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2996 |
"/ |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2997 |
"/ aStream nextPutAll:'[] in '. |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2998 |
"/ homeClass := home containingClass. |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2999 |
"/ homeClass notNil ifTrue:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3000 |
"/ homeClass name printOn:aStream. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3001 |
"/ aStream space. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3002 |
"/ (homeClass selectorForMethod:home) printOn:aStream |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
3003 |
"/ ] ifFalse:[ |
18252 | 3004 |
"/ aStream nextPutAll:' ???' |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
3005 |
"/ ] |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
3006 |
"/ |
9253 | 3007 |
! |
3008 |
||
3009 |
storeOn:aStream |
|
15850 | 3010 |
MethodNotAppropriateError raiseRequestErrorString:'Blocks cannot be stored (yet)'. |
9287 | 3011 |
self printOn:aStream. |
1 | 3012 |
! ! |
623 | 3013 |
|
7257 | 3014 |
!Block methodsFor:'private-accessing'! |
623 | 3015 |
|
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
3016 |
byteCode:bCode numArgs:numArgs numVars:numVars numStack:numStack sourcePosition:srcPos initialPC:iPC literals:lits |
1265 | 3017 |
"set all relevant internals. |
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
3018 |
DANGER ALERT: this interface is strictly private." |
623 | 3019 |
|
3020 |
byteCode := bCode. |
|
3021 |
nargs := numArgs. |
|
3022 |
sourcePos := srcPos. |
|
3023 |
initialPC := iPC. |
|
1777 | 3024 |
flags := 0. |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
3025 |
self stackSize:numStack. |
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3026 |
self literals:lits. |
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
3027 |
self numberOfArgs:numArgs. "/ must set the compiledCode flags as well |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
3028 |
self numberOfVars:numVars. "/ must set the compiledCode flags as well |
1265 | 3029 |
|
3030 |
"Modified: 23.4.1996 / 16:05:30 / cg" |
|
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
3031 |
"Modified: 24.6.1996 / 12:37:37 / stefan" |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
3032 |
"Created: 13.4.1997 / 00:00:57 / cg" |
623 | 3033 |
! |
3034 |
||
18252 | 3035 |
initialPC |
5779 | 3036 |
"return the initial pc for evaluation." |
3037 |
||
3038 |
^ initialPC |
|
3039 |
! |
|
3040 |
||
18252 | 3041 |
initialPC:initial |
1265 | 3042 |
"set the initial pc for evaluation. |
3043 |
DANGER ALERT: this interface is for the compiler only." |
|
623 | 3044 |
|
3045 |
initialPC := initial |
|
1265 | 3046 |
|
3047 |
"Modified: 23.4.1996 / 16:05:39 / cg" |
|
623 | 3048 |
! |
3049 |
||
3050 |
numArgs:numArgs |
|
1265 | 3051 |
"set the number of arguments the receiver expects for evaluation. |
3052 |
DANGER ALERT: this interface is for the compiler only." |
|
623 | 3053 |
|
3054 |
nargs := numArgs |
|
1265 | 3055 |
|
3056 |
"Modified: 23.4.1996 / 16:05:52 / cg" |
|
623 | 3057 |
! |
3058 |
||
5744 | 3059 |
setHome:aContext |
3060 |
home := aContext |
|
3061 |
! |
|
3062 |
||
18252 | 3063 |
source |
7323 | 3064 |
|m| |
3065 |
||
3066 |
sourcePos isString ifTrue:[ "/ misuses the sourcePosition slot |
|
21678 | 3067 |
^ sourcePos |
7323 | 3068 |
]. |
21678 | 3069 |
m := self homeMethod. |
7323 | 3070 |
m notNil ifTrue:[ |
21678 | 3071 |
^ m source |
7323 | 3072 |
]. |
3073 |
^ nil |
|
21678 | 3074 |
|
3075 |
"Modified: / 31-03-2017 / 17:26:52 / stefan" |
|
7323 | 3076 |
! |
3077 |
||
18252 | 3078 |
source:aString |
6981 | 3079 |
"set the source - only to be used, if the block is not contained in a method. |
3080 |
This interface is for knowledgable users only." |
|
3081 |
||
3082 |
sourcePos := aString "/ misuse the sourcePosition slot |
|
3083 |
! |
|
3084 |
||
18252 | 3085 |
sourcePosition:position |
1265 | 3086 |
"set the position of the source within my method. |
3087 |
This interface is for the compiler only." |
|
623 | 3088 |
|
3089 |
sourcePos := position |
|
1265 | 3090 |
|
3091 |
"Modified: 23.4.1996 / 16:06:19 / cg" |
|
623 | 3092 |
! ! |
3093 |
||
3094 |
!Block methodsFor:'privileged evaluation'! |
|
3095 |
||
3096 |
valueUninterruptably |
|
3097 |
"evaluate the receiver with interrupts blocked. |
|
3098 |
This does not prevent preemption by a higher priority processes |
|
3099 |
if any becomes runnable due to the evaluation of the receiver |
|
3100 |
(i.e. if a semaphore is signalled)." |
|
3101 |
||
2301 | 3102 |
"we must keep track of blocking-state if this is called nested" |
3103 |
(OperatingSystem blockInterrupts) ifTrue:[ |
|
22083 | 3104 |
"/ already blocked. |
3105 |
^ self value |
|
2301 | 3106 |
]. |
22083 | 3107 |
|
3108 |
"/ was not blocked |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3109 |
^ self ensure:[OperatingSystem unblockInterrupts]. |
22083 | 3110 |
|
3111 |
"Modified (comment): / 24-07-2017 / 18:03:04 / cg" |
|
623 | 3112 |
! |
3113 |
||
3114 |
valueUnpreemptively |
|
3115 |
"evaluate the receiver without the possiblity of preemption |
|
3116 |
(i.e. at a very high priority)" |
|
3117 |
||
3118 |
|oldPrio activeProcess| |
|
3119 |
||
3120 |
activeProcess := Processor activeProcess. |
|
3121 |
oldPrio := activeProcess changePriority:(Processor highestPriority). |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3122 |
^ self ensure:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3123 |
activeProcess priority:oldPrio |
623 | 3124 |
] |
3125 |
! ! |
|
3126 |
||
3127 |
!Block methodsFor:'process creation'! |
|
3128 |
||
3129 |
fork |
|
3130 |
"create a new process executing the receiver at the current priority." |
|
3131 |
||
3132 |
^ self newProcess resume |
|
3133 |
! |
|
3134 |
||
3135 |
forkAt:priority |
|
3136 |
"create a new process executing the receiver at a different priority." |
|
3137 |
||
3138 |
^ (self newProcess priority:priority) resume |
|
3139 |
! |
|
3140 |
||
6609 | 3141 |
forkNamed:aString |
18252 | 3142 |
"create a new process, give it a name and let it start |
6609 | 3143 |
executing the receiver at the current priority." |
3144 |
||
21314 | 3145 |
^ self newProcess |
3146 |
name:aString; |
|
3147 |
resume; |
|
3148 |
yourself. |
|
3149 |
||
3150 |
"Modified: / 27-01-2017 / 18:10:16 / stefan" |
|
6609 | 3151 |
! |
3152 |
||
623 | 3153 |
forkWith:argArray |
3154 |
"create a new process executing the receiver, |
|
3155 |
passing elements in argArray as arguments to the receiver block." |
|
3156 |
||
3157 |
^ [self valueWithArguments:argArray] fork. |
|
3158 |
! |
|
3159 |
||
3160 |
newProcess |
|
3161 |
"create a new (unscheduled) process executing the receiver" |
|
3162 |
||
3163 |
^ Process for:self priority:(Processor activePriority) |
|
3164 |
! |
|
3165 |
||
3166 |
newProcessWithArguments:argArray |
|
3167 |
"create a new (unscheduled) process executing the receiver, |
|
3168 |
passing the elements in argArray as arguments to the receiver block." |
|
3169 |
||
3170 |
^ [self valueWithArguments:argArray] newProcess |
|
3171 |
! ! |
|
3172 |
||
22010 | 3173 |
!Block methodsFor:'splitting & joining'! |
3174 |
||
3175 |
split: aSequenceableCollection indicesDo: aBlock |
|
3176 |
"let me split aSequenceableCollection and evaluate aBlock for each fragment's |
|
3177 |
start- and end-position" |
|
3178 |
||
3179 |
| position | |
|
3180 |
||
3181 |
position := 1. |
|
3182 |
aSequenceableCollection withIndexDo:[:element :idx | |
|
3183 |
(self value: element) ifTrue:[ |
|
3184 |
aBlock value: position value: idx - 1. |
|
3185 |
position := idx + 1 |
|
3186 |
] |
|
3187 |
]. |
|
3188 |
aBlock value: position value: aSequenceableCollection size |
|
3189 |
||
3190 |
" |
|
3191 |
[ :char| char isSeparator ] split: 'aa bb cc dd' |
|
3192 |
||
3193 |
[ :char| char isSeparator ] split: 'aa bb cc dd' do:[:fragment | Transcript showCR:fragment ] |
|
3194 |
||
3195 |
[ :char| char isSeparator ] split: 'aa bb cc dd' indicesDo:[:start :end | Transcript show:start; show:' to '; showCR:end ] |
|
3196 |
" |
|
3197 |
||
3198 |
"Created: / 13-07-2017 / 18:32:09 / cg" |
|
3199 |
! ! |
|
3200 |
||
623 | 3201 |
!Block methodsFor:'testing'! |
3202 |
||
3203 |
isBlock |
|
3204 |
"return true, if this is a block - yes I am" |
|
3205 |
||
3206 |
^ true |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3207 |
! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3208 |
|
21662 | 3209 |
isBlockWithArgumentCount:count |
3210 |
"return true, if this is a block with count args" |
|
3211 |
||
3212 |
^ nargs == count |
|
3213 |
||
3214 |
"Created: / 18-03-2017 / 18:07:03 / stefan" |
|
3215 |
! |
|
3216 |
||
16276 | 3217 |
isCheapBlock |
3218 |
^ false |
|
3219 |
! |
|
3220 |
||
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3221 |
isVarArgBlock |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3222 |
"return true, if this block accepts a variable number of arguments" |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3223 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3224 |
^ false |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3225 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
3226 |
"Created: 23.1.1997 / 04:59:51 / cg" |
623 | 3227 |
! ! |
3228 |
||
3229 |
!Block methodsFor:'unwinding'! |
|
3230 |
||
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3231 |
unwindHandlerInContext:aContext |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3232 |
"given a context which has been marked for unwind, |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3233 |
retrieve the handler block. |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3234 |
This avoids hardwiring access to the first argument in |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3235 |
#unwind methods (and theoretically allows for other unwinding |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3236 |
methods to be added)" |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3237 |
|
11338 | 3238 |
|selector| |
3239 |
||
3240 |
selector := aContext selector. |
|
3241 |
selector == #'value:onUnwindDo:' ifTrue:[ |
|
18959 | 3242 |
^ aContext argAt:2 |
4896 | 3243 |
]. |
18959 | 3244 |
(selector == #'on:do:ensure:' |
3245 |
or:[selector == #'on:do:ifCurtailed:'])ifTrue:[ |
|
3246 |
^ aContext argAt:3 |
|
11338 | 3247 |
]. |
4896 | 3248 |
|
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3249 |
"/ for now, only #valueNowOrOnUnwindDo: |
4896 | 3250 |
"/ or #valueOnUnwindDo: |
5666
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
3251 |
"/ or #ensure: |
6608 | 3252 |
"/ or #ifCurtailed: |
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3253 |
|
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3254 |
^ aContext argAt:1 |
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3255 |
! ! |
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3256 |
|
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3257 |
!Block methodsFor:'unwinding-old'! |
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
3258 |
|
4896 | 3259 |
value:arg onUnwindDo:aBlock |
3260 |
"evaluate the receiver, passing it one argument |
|
3261 |
- when some method sent within unwinds (i.e. does |
|
3262 |
a long return), evaluate the argument, aBlock. |
|
3263 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
3264 |
executed regardless of error actions" |
|
3265 |
||
3266 |
<exception: #unwind> |
|
3267 |
||
3268 |
|v| |
|
3269 |
||
3270 |
"/ thisContext markForUnwind. -- same as above pragma |
|
3271 |
v := self value:arg. "the real logic is in Context>>unwind" |
|
3272 |
thisContext unmarkForUnwind. |
|
3273 |
^ v |
|
3274 |
||
3275 |
" |
|
3276 |
|s| |
|
3277 |
||
3278 |
s := 'Makefile' asFilename readStream. |
|
3279 |
[:arg | |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3280 |
^ self |
4896 | 3281 |
] value:12345 onUnwindDo:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3282 |
Transcript showCR:'closing the stream - even though a return occurred'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3283 |
s close |
4896 | 3284 |
] |
3285 |
" |
|
3286 |
" |
|
3287 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3288 |
|s| |
4896 | 3289 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3290 |
s := 'Makefile' asFilename readStream. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3291 |
[:arg | |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3292 |
Processor activeProcess terminate |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3293 |
] value:12345 onUnwindDo:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3294 |
Transcript showCR:'closing the stream - even though process was terminated'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3295 |
s close |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
3296 |
] |
4896 | 3297 |
] fork |
3298 |
" |
|
3299 |
||
3300 |
! |
|
3301 |
||
623 | 3302 |
valueNowOrOnUnwindDo:aBlock |
3303 |
"evaluate the receiver - after that, or when some method sent within unwinds (i.e. does |
|
3304 |
a long return), evaluate the argument, aBlock. |
|
3305 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
3306 |
executed regardless of error actions. |
20773 | 3307 |
Same as the more modern, ANSI standardized #ensure:, |
3308 |
which should be used instead for portability." |
|
623 | 3309 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3310 |
<exception: #unwind> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3311 |
|
623 | 3312 |
|v| |
3313 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3314 |
"/ thisContext markForUnwind. -- same as above pragma |
623 | 3315 |
v := self value. "the real logic is in Context>>unwind" |
1187
619ff79bc665
valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents:
1181
diff
changeset
|
3316 |
thisContext unmarkForUnwind. |
623 | 3317 |
aBlock value. |
3318 |
^ v |
|
3319 |
||
3320 |
" |
|
3321 |
in the following example, f will be closed even if the block |
|
3322 |
returns with 'oops'. There are many more applications of this kind |
|
3323 |
found in the system. |
|
3324 |
" |
|
3325 |
" |
|
3326 |
|f| |
|
3327 |
||
3328 |
f := 'Makefile' asFilename readStream. |
|
3329 |
[ |
|
20773 | 3330 |
l := f nextLine. |
3331 |
l isNil ifTrue:[^ 'oops'] |
|
623 | 3332 |
] valueNowOrOnUnwindDo:[ |
20773 | 3333 |
f close |
623 | 3334 |
] |
3335 |
" |
|
1187
619ff79bc665
valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents:
1181
diff
changeset
|
3336 |
|
619ff79bc665
valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents:
1181
diff
changeset
|
3337 |
"Modified: 16.4.1996 / 11:05:26 / stefan" |
623 | 3338 |
! |
3339 |
||
3340 |
valueOnUnwindDo:aBlock |
|
3341 |
"evaluate the receiver - when some method sent within unwinds (i.e. does |
|
3342 |
a long return), evaluate the argument, aBlock. |
|
3343 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
20773 | 3344 |
executed regardless of error actions. |
3345 |
Same as the more modern, ANSI standardized #ifCurtailed:, |
|
3346 |
which should be used instead for portability." |
|
623 | 3347 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3348 |
<exception: #unwind> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3349 |
|
2286 | 3350 |
|v| |
3351 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
3352 |
"/ thisContext markForUnwind. -- same as above pragma |
2286 | 3353 |
v := self value. "the real logic is in Context>>unwind" |
3354 |
thisContext unmarkForUnwind. |
|
3355 |
^ v |
|
3356 |
||
4896 | 3357 |
" |
3358 |
|s| |
|
3359 |
||
3360 |
s := 'Makefile' asFilename readStream. |
|
3361 |
[ |
|
20773 | 3362 |
^ self |
4896 | 3363 |
] valueOnUnwindDo:[ |
20773 | 3364 |
Transcript showCR:'closing the stream - even though a return occurred'. |
3365 |
s close |
|
4896 | 3366 |
] |
3367 |
" |
|
3368 |
" |
|
3369 |
[ |
|
20773 | 3370 |
|s| |
3371 |
||
3372 |
s := 'Makefile' asFilename readStream. |
|
3373 |
[ |
|
3374 |
Processor activeProcess terminate |
|
3375 |
] valueOnUnwindDo:[ |
|
3376 |
Transcript showCR:'closing the stream - even though process was terminated'. |
|
3377 |
s close |
|
3378 |
] |
|
4896 | 3379 |
] fork |
3380 |
" |
|
623 | 3381 |
! ! |
3382 |
||
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3383 |
!Block methodsFor:'visiting'! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3384 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3385 |
acceptVisitor:aVisitor with:aParameter |
16730 | 3386 |
"dispatch for visitor pattern; send #visitBlock:with: to aVisitor" |
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3387 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3388 |
^ aVisitor visitBlock:self with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3389 |
! ! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
3390 |
|
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
3391 |
!Block class methodsFor:'documentation'! |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
3392 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
3393 |
version |
18959 | 3394 |
^ '$Header$' |
12118
41ee8ff1908e
comment/format in: #deferredValue
Claus Gittinger <cg@exept.de>
parents:
11998
diff
changeset
|
3395 |
! |
41ee8ff1908e
comment/format in: #deferredValue
Claus Gittinger <cg@exept.de>
parents:
11998
diff
changeset
|
3396 |
|
41ee8ff1908e
comment/format in: #deferredValue
Claus Gittinger <cg@exept.de>
parents:
11998
diff
changeset
|
3397 |
version_CVS |
18959 | 3398 |
^ '$Header$' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
3399 |
! ! |
6785 | 3400 |