author | Stefan Vogel <sv@exept.de> |
Tue, 17 Mar 2009 17:22:03 +0100 | |
changeset 11638 | 20a63a6bf2fb |
parent 11603 | 67c94d57ca7a |
child 11704 | a47fdf0a638d |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
154 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5349 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
4299 | 14 |
CompiledCode variableSubclass:#Block |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
15 |
instanceVariableNames:'home nargs sourcePos initialPC' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
16 |
classVariableNames:'InvalidNewSignal' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
17 |
poolDictionaries:'' |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
18 |
category:'Kernel-Methods' |
1 | 19 |
! |
20 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
21 |
!Block class methodsFor:'documentation'! |
1 | 22 |
|
92 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
154 | 26 |
All Rights Reserved |
92 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
1 | 37 |
documentation |
38 |
" |
|
67 | 39 |
Blocks are pieces of executable code which can be evaluated by sending |
40 |
them a value-message (''value'', ''value:'', ''value:value:'' etc). |
|
1 | 41 |
|
1265 | 42 |
In smalltalk, Blocks provide the basic (and heavily used) mechanism |
43 |
for looping, enumerating collection elements, visitors, exception |
|
44 |
handling, unwinding, delayed execution and processes. |
|
45 |
||
1254 | 46 |
Blocks are never created explicitely; the only creation |
47 |
is done by the compilers, when some sourceCode is compiled to either |
|
48 |
machine or byteCode. |
|
49 |
||
67 | 50 |
Blocks with arguments need a message of type ''value:arg1 ... value:argn'' |
51 |
for evaluation; the number of arguments passed when evaluating must match |
|
52 |
the number of arguments the block was declared with otherwise an error is |
|
53 |
raised. Blocks without args need a ''value'' message for evaluation. |
|
1 | 54 |
|
154 | 55 |
Blocks keep a reference to the context where the block was declared - |
67 | 56 |
this allows blocks to access the methods arguments and/or variables. |
154 | 57 |
This is still true after the method has returned - since the |
67 | 58 |
block keeps this reference, the methods context will NOT die in this case. |
222 | 59 |
(i.e. Blocks are closures in Smalltalk/X) |
1 | 60 |
|
67 | 61 |
A return (via ^-statement) out of a block will force a return from the |
62 |
blocks method context (if it is still living) - this make the implementation |
|
63 |
of long-jumps and control structures possible. |
|
154 | 64 |
(If the method is not alive (i.e. has already returned), a return out of the |
65 |
block will trigger an error) |
|
1 | 66 |
|
67 | 67 |
Long-jump is done by defining a catchBlock as ''[^ self]'' |
68 |
somewhere up in the calling-tree. Then, to do the long-jump from out of some |
|
69 |
deeply nested method, simply do: ''catchBlock value''. |
|
1 | 70 |
|
1293 | 71 |
[Instance variables:] |
1 | 72 |
|
222 | 73 |
home <Context> the context where this block was created (i.e. defined) |
2238 | 74 |
this may be a blockContext or a methodContext |
222 | 75 |
nargs <SmallInteger> the number of arguments the block expects |
76 |
sourcePos <SmallInteger> the character position of its source, in chars |
|
2238 | 77 |
relative to methods source beginning |
222 | 78 |
initialPC <SmallInteger> the start position within the byteCode |
2238 | 79 |
for compiled blocks, this is nil. |
222 | 80 |
|
81 |
||
1293 | 82 |
[Class variables:] |
222 | 83 |
|
84 |
InvalidNewSignal raised if a Block is tried to be created |
|
2238 | 85 |
with new (which is not allowed). |
86 |
Only the VM is allowed to create Blocks. |
|
1 | 87 |
|
1293 | 88 |
|
67 | 89 |
NOTICE: layout known by runtime system and compiler - do not change |
1293 | 90 |
|
91 |
[author:] |
|
2238 | 92 |
Claus Gittinger |
1293 | 93 |
|
94 |
[see also:] |
|
2238 | 95 |
Process Context |
96 |
Collection |
|
97 |
( contexts. blocks & unwinding : programming/contexts.html) |
|
1 | 98 |
" |
1265 | 99 |
! |
100 |
||
101 |
examples |
|
102 |
" |
|
1293 | 103 |
define a block and evaluate it: |
2238 | 104 |
[exBegin] |
105 |
|b| |
|
1265 | 106 |
|
2238 | 107 |
b := [ Transcript showCR:'hello' ]. |
1293 | 108 |
|
2238 | 109 |
Transcript showCR:'now evaluating the block ...'. |
110 |
b value. |
|
111 |
[exEnd] |
|
1265 | 112 |
|
113 |
||
1293 | 114 |
|
1265 | 115 |
even here, blocks are involved: |
116 |
(although, the compiler optimizes things if possible) |
|
2238 | 117 |
[exBegin] |
118 |
Transcript showCR:'now evaluating one of two blocks ...'. |
|
119 |
1 > 4 ifTrue:[ |
|
120 |
Transcript showCR:'foo' |
|
121 |
] ifFalse:[ |
|
122 |
Transcript showCR:'bar' |
|
123 |
] |
|
124 |
[exEnd] |
|
1265 | 125 |
|
126 |
||
1293 | 127 |
|
1265 | 128 |
here things become obvious: |
2238 | 129 |
[exBegin] |
130 |
|yesBlock noBlock| |
|
1265 | 131 |
|
2238 | 132 |
yesBlock := [ Transcript showCR:'foo' ]. |
133 |
noBlock := [ Transcript showCR:'bar' ]. |
|
1265 | 134 |
|
2238 | 135 |
Transcript showCR:'now evaluating one of two blocks ...'. |
136 |
1 > 4 ifTrue:yesBlock |
|
137 |
ifFalse:noBlock |
|
138 |
[exEnd] |
|
1265 | 139 |
|
140 |
||
1293 | 141 |
|
1265 | 142 |
simple loops: |
143 |
not very objectOriented: |
|
2238 | 144 |
[exBegin] |
145 |
|i| |
|
1265 | 146 |
|
2238 | 147 |
i := 1. |
148 |
[i < 10] whileTrue:[ |
|
149 |
Transcript showCR:i. |
|
150 |
i := i + 1 |
|
151 |
] |
|
152 |
[exEnd] |
|
1265 | 153 |
|
154 |
||
155 |
using integer protocol: |
|
2238 | 156 |
[exBegin] |
157 |
1 to:10 do:[:i | |
|
158 |
Transcript showCR:i. |
|
159 |
] |
|
160 |
[exEnd] |
|
1265 | 161 |
|
162 |
||
163 |
interval protocol: |
|
2238 | 164 |
[exBegin] |
165 |
(1 to:10) do:[:i | |
|
166 |
Transcript showCR:i. |
|
167 |
] |
|
168 |
[exEnd] |
|
1265 | 169 |
|
170 |
||
1293 | 171 |
|
1265 | 172 |
looping over collections: |
173 |
||
1293 | 174 |
bad code: |
175 |
(only works with numeric-indexable collections) |
|
2238 | 176 |
[exBegin] |
177 |
|i coll| |
|
1265 | 178 |
|
2238 | 179 |
coll := #(9 8 7 6 5). |
180 |
i := 1. |
|
181 |
[i <= coll size] whileTrue:[ |
|
182 |
Transcript showCR:(coll at:i). |
|
183 |
i := i + 1. |
|
184 |
] |
|
185 |
[exEnd] |
|
1265 | 186 |
|
187 |
||
188 |
||
1293 | 189 |
just as bad (well, marginally better ;-): |
190 |
(only works with numeric-indexable collections) |
|
2238 | 191 |
[exBegin] |
192 |
|coll| |
|
1265 | 193 |
|
2238 | 194 |
coll := #(9 8 7 6 5). |
195 |
1 to:coll size do:[:i | |
|
196 |
Transcript showCR:(coll at:i). |
|
197 |
] |
|
198 |
[exEnd] |
|
1265 | 199 |
|
200 |
||
201 |
||
1293 | 202 |
the smalltalk way: |
203 |
(works with any collection) |
|
2238 | 204 |
[exBegin] |
205 |
|coll| |
|
1265 | 206 |
|
2238 | 207 |
coll := #(9 8 7 6 5). |
208 |
coll do:[:element | |
|
209 |
Transcript showCR:element. |
|
210 |
] |
|
211 |
[exEnd] |
|
1265 | 212 |
|
213 |
Rule: use enumeration protocol of the collection instead of |
|
2238 | 214 |
manually indexing it. [with few exceptions] |
1265 | 215 |
|
216 |
||
217 |
||
218 |
processes: |
|
219 |
||
220 |
forking a lightweight process (thread): |
|
2238 | 221 |
[exBegin] |
222 |
[ |
|
223 |
Transcript showCR:'waiting ...'. |
|
224 |
Delay waitForSeconds:2. |
|
225 |
Transcript showCR:'here I am'. |
|
226 |
] fork |
|
227 |
[exEnd] |
|
1265 | 228 |
|
229 |
||
230 |
||
231 |
some with low prio: |
|
2238 | 232 |
[exBegin] |
233 |
[ |
|
234 |
Transcript showCR:'computing ...'. |
|
235 |
10000 factorial. |
|
236 |
Transcript showCR:'here I am'. |
|
237 |
] forkAt:(Processor userBackgroundPriority) |
|
238 |
[exEnd] |
|
1265 | 239 |
|
240 |
||
1293 | 241 |
|
242 |
handling exceptions: |
|
2238 | 243 |
[exBegin] |
244 |
Object errorSignal handle:[:ex | |
|
245 |
Transcript showCR:'exception handler forces return'. |
|
246 |
ex return |
|
247 |
] do:[ |
|
248 |
Transcript showCR:'now, doing something bad ...'. |
|
249 |
1 / 0. |
|
250 |
Transcript showCR:'not reached' |
|
251 |
] |
|
252 |
[exEnd] |
|
1265 | 253 |
|
254 |
||
1293 | 255 |
|
256 |
performing cleanup actions: |
|
2238 | 257 |
[exBegin] |
258 |
Object errorSignal handle:[:ex | |
|
259 |
Transcript showCR:'exception handler forces return'. |
|
260 |
ex return |
|
261 |
] do:[ |
|
262 |
[ |
|
263 |
Transcript showCR:'doing something bad ...'. |
|
264 |
1 / 0. |
|
265 |
Transcript showCR:'not reached' |
|
266 |
] valueOnUnwindDo:[ |
|
267 |
Transcript showCR:'cleanup' |
|
268 |
] |
|
269 |
] |
|
270 |
[exEnd] |
|
1265 | 271 |
|
272 |
||
1293 | 273 |
delayed execution (visitor pattern): |
274 |
(looking carefully into the example, |
|
275 |
C/C++ programmers may raise their eyes ;-) |
|
2238 | 276 |
[exBegin] |
277 |
|showBlock countBlock |
|
278 |
howMany |
|
279 |
top panel b1 b2| |
|
1265 | 280 |
|
2238 | 281 |
howMany := 0. |
1265 | 282 |
|
2238 | 283 |
showBlock := [ Transcript showCR:howMany ]. |
284 |
countBlock := [ howMany := howMany + 1 ]. |
|
1265 | 285 |
|
2238 | 286 |
top := StandardSystemView extent:200@200. |
287 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
1265 | 288 |
|
2238 | 289 |
b1 := Button label:'count up' in:panel. |
290 |
b1 action:countBlock. |
|
1265 | 291 |
|
2238 | 292 |
b2 := Button label:'show value' in:panel. |
293 |
b2 action:showBlock. |
|
1265 | 294 |
|
2238 | 295 |
top open. |
1265 | 296 |
|
2238 | 297 |
Transcript showCR:'new process started;'. |
298 |
Transcript showCR:'notice: the blocks can still access the'. |
|
299 |
Transcript showCR:' howMany local variable.'. |
|
300 |
[exEnd] |
|
1265 | 301 |
" |
1 | 302 |
! ! |
303 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
304 |
!Block class methodsFor:'initialization'! |
1 | 305 |
|
306 |
initialize |
|
1254 | 307 |
"create signals raised by various errors" |
1 | 308 |
|
48 | 309 |
InvalidNewSignal isNil ifTrue:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6981
diff
changeset
|
310 |
InvalidNewSignal := Error newSignalMayProceed:false. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6981
diff
changeset
|
311 |
InvalidNewSignal nameClass:self message:#invalidNewSignal. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6981
diff
changeset
|
312 |
InvalidNewSignal notifierString:'blocks are only created by the system'. |
48 | 313 |
] |
1254 | 314 |
|
315 |
"Modified: 22.4.1996 / 16:34:20 / cg" |
|
1 | 316 |
! ! |
317 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
318 |
!Block class methodsFor:'instance creation'! |
1 | 319 |
|
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
320 |
byteCode:bCode numArgs:numArgs numStack:nStack sourcePosition:sourcePos initialPC:initialPC literals:literals |
1 | 321 |
"create a new cheap (homeless) block. |
222 | 322 |
Not for public use - this is a special hook for the compiler." |
1 | 323 |
|
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
324 |
^ self |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
325 |
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
|
326 |
! |
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
327 |
|
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
328 |
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
|
329 |
"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
|
330 |
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
|
331 |
|
1 | 332 |
|newBlock| |
333 |
||
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
334 |
newBlock := (super basicNew:(literals size)) |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
335 |
byteCode:bCode |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
336 |
numArgs:numArgs |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
337 |
numVars:numVars |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
338 |
numStack:nStack |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
339 |
sourcePosition:sourcePos |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
340 |
initialPC:initialPC |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
341 |
literals:literals. |
1 | 342 |
^ newBlock |
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
343 |
|
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
344 |
"Modified: 24.6.1996 / 12:36:48 / stefan" |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
345 |
"Created: 13.4.1997 / 00:04:09 / cg" |
1 | 346 |
! |
347 |
||
22 | 348 |
new |
4299 | 349 |
"catch creation of blocks - only the system creates blocks. |
350 |
If you really need a block (assuming, you are some compiler), |
|
351 |
use basicNew and setup the instance carefully" |
|
1 | 352 |
|
128 | 353 |
^ InvalidNewSignal raise. |
1 | 354 |
! |
355 |
||
22 | 356 |
new:size |
1 | 357 |
"catch creation of blocks - only the system creates blocks" |
358 |
||
128 | 359 |
^ InvalidNewSignal raise. |
1 | 360 |
! ! |
361 |
||
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
362 |
!Block class methodsFor:'queries'! |
1 | 363 |
|
623 | 364 |
isBuiltInClass |
1264 | 365 |
"return true if this class is known by the run-time-system. |
366 |
Here, true is returned for myself, false for subclasses." |
|
11 | 367 |
|
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
368 |
^ self == Block |
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
369 |
|
1264 | 370 |
"Modified: 23.4.1996 / 15:55:58 / cg" |
1 | 371 |
! ! |
372 |
||
7261 | 373 |
!Block methodsFor:'Compatibility-ANSI'! |
5349 | 374 |
|
5944 | 375 |
argumentCount |
7352 | 376 |
"VisualAge/ANSI compatibility: alias for #numArgs. |
5944 | 377 |
return the number of arguments I expect for evaluation" |
378 |
||
379 |
^ nargs |
|
380 |
||
381 |
"Created: 15.11.1996 / 11:22:02 / cg" |
|
382 |
! |
|
383 |
||
5349 | 384 |
ensure:aBlock |
385 |
"evaluate the receiver and return its result. |
|
386 |
After evaluation, also evaluate aBlock but ignore its result. |
|
387 |
aBlock is also evaluated in case of abnormal termination. |
|
388 |
(the same as #valueNowOrOnUnwindDo:)" |
|
389 |
||
5666
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
390 |
<exception: #unwind> |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
391 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
392 |
|v| |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
393 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
394 |
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
|
395 |
thisContext unmarkForUnwind. |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
396 |
aBlock value. |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
397 |
^ v |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
398 |
|
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
399 |
"/ the above is the same as in #valueNowOrOnUnwindDo: |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
400 |
"/ (actually, the previous implementation was: |
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
401 |
"/ ^ self valueNowOrOnUnwindDo:aBlock |
5349 | 402 |
|
403 |
" |
|
404 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
405 |
[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
406 |
Transcript showCR:'one'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
407 |
Processor activeProcess terminate. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
408 |
Transcript showCR:'two'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
409 |
] ensure:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
410 |
Transcript showCR:'three'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
411 |
]. |
5349 | 412 |
] fork. |
413 |
" |
|
414 |
||
415 |
" |
|
416 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
417 |
[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
418 |
Transcript showCR:'one'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
419 |
Transcript showCR:'two'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
420 |
] ensure:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
421 |
Transcript showCR:'three'. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
422 |
]. |
5349 | 423 |
] fork. |
424 |
" |
|
5951 | 425 |
! |
426 |
||
427 |
ifCurtailed:aBlock |
|
428 |
"evaluate the receiver - when some method sent within unwinds (i.e. does |
|
429 |
a long return), evaluate the argument, aBlock. |
|
430 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
431 |
executed regardless of error actions. |
|
432 |
This is the same as #valueOnUnwindDo:" |
|
433 |
||
434 |
<exception: #unwind> |
|
435 |
||
436 |
|v| |
|
437 |
||
438 |
"/ thisContext markForUnwind. -- same as above pragma |
|
439 |
v := self value. "the real logic is in Context>>unwind" |
|
440 |
thisContext unmarkForUnwind. |
|
441 |
^ v |
|
442 |
||
443 |
" |
|
444 |
|s| |
|
445 |
||
446 |
s := 'Makefile' asFilename readStream. |
|
447 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
448 |
^ self |
5951 | 449 |
] ifCurtailed:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
450 |
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
|
451 |
s close |
5951 | 452 |
] |
453 |
" |
|
454 |
" |
|
455 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
456 |
|s| |
5951 | 457 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
458 |
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
|
459 |
[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
460 |
Processor activeProcess terminate |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
461 |
] ifCurtailed:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
462 |
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
|
463 |
s close |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
464 |
] |
5951 | 465 |
] fork |
466 |
" |
|
5349 | 467 |
! ! |
468 |
||
8440
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
469 |
!Block methodsFor:'Compatibility-Dolphin'! |
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
470 |
|
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
471 |
deferredValue |
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
472 |
"doplphin's alias for futureValue" |
8440
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
473 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
474 |
^ self futureValue |
8440
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
475 |
! ! |
66d126056d3d
Dolphin compatibility: #deferredValue
Stefan Vogel <sv@exept.de>
parents:
8394
diff
changeset
|
476 |
|
7261 | 477 |
!Block methodsFor:'Compatibility-Squeak'! |
5015 | 478 |
|
479 |
ifError:handlerBlock |
|
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
480 |
"same as onError: - for squeak compatibility. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
481 |
Notice, that the handlerBlock may take 0,1 or 2 args. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
482 |
(1 arg -> the exception; |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
483 |
2 args -> the errorString and the erronous receiver)" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
484 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
485 |
handlerBlock numArgs == 1 ifTrue:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
486 |
^ 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
|
487 |
]. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
488 |
|
6142 | 489 |
^ self |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
490 |
on:Error |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
491 |
do:[:ex | |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
492 |
|errString errReceiver| |
6142 | 493 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
494 |
handlerBlock numArgs == 0 ifTrue:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
495 |
ex return:handlerBlock value |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
496 |
]. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
497 |
errString := ex description. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
498 |
errReceiver := ex suspendedContext receiver. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
499 |
ex return:(handlerBlock value:errString value:errReceiver) |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
500 |
] |
6142 | 501 |
|
502 |
" |
|
503 |
|a| |
|
504 |
||
505 |
a := 0. |
|
506 |
[ 123 / a ] ifError:[:msg :rec | self halt] |
|
507 |
" |
|
6159
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
508 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
509 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
510 |
|a| |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
511 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
512 |
a := 0. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
513 |
[ 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
|
514 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
515 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
516 |
" |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
517 |
|a| |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
518 |
|
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
519 |
a := 0. |
33d75f51cf24
support 0, 1 or 2-arg handler blocks in #ifError:
Claus Gittinger <cg@exept.de>
parents:
6142
diff
changeset
|
520 |
[ 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
|
521 |
" |
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
522 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
523 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
524 |
valueWithPossibleArgs:argArray |
9602 | 525 |
^ self valueWithOptionalArguments:argArray |
5015 | 526 |
! ! |
527 |
||
7261 | 528 |
!Block methodsFor:'Compatibility-V''Age'! |
1979 | 529 |
|
530 |
valueOnReturnDo:aBlock |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
531 |
"VisualAge compatibility: alias for #ifCurtailed: |
1979 | 532 |
evaluate the receiver - when some method sent within unwinds |
533 |
(i.e. does a long return), evaluate the argument, aBlock. |
|
534 |
This is used to make certain that cleanup actions |
|
535 |
(for example closing files etc.) are executed regardless of error actions. |
|
536 |
||
537 |
Q: is this the exact semantics of V'Ages method ? |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
538 |
the documentation is unclean; it could be a valueNowOrOnUnwindDo: ..." |
1979 | 539 |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
540 |
^ self ifCurtailed:aBlock |
1979 | 541 |
|
542 |
"Created: 15.11.1996 / 11:38:37 / cg" |
|
543 |
! ! |
|
544 |
||
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
545 |
!Block methodsFor:'accessing'! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
546 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
547 |
home |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
548 |
"return the receivers home context (the context where it was |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
549 |
created). For cheap blocks, nil is returned" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
550 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
551 |
^ home |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
552 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
553 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
554 |
homeMethod |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
555 |
"return the receivers home method. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
556 |
Thats the method where the block was created." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
557 |
|
10473 | 558 |
|m| |
559 |
||
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
560 |
home notNil ifTrue:[ |
10473 | 561 |
m := home method. |
562 |
m notNil ifTrue:[^ m]. |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
563 |
]. |
10473 | 564 |
m := self literalAt:1 ifAbsent:nil. |
565 |
m isMethod ifTrue:[^ m]. |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
566 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
567 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
568 |
"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
|
569 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
570 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
571 |
method |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
572 |
"return the receivers method |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
573 |
(the method where the block was created). |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
574 |
Obsolete: use #homeMethod for ST80 compatibility." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
575 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
576 |
<resource: #obsolete> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
577 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
578 |
^ self homeMethod |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
579 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
580 |
"Modified: 19.6.1997 / 16:15:24 / cg" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
581 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
582 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
583 |
methodHome |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
584 |
"return the receivers method home context (the context where it was |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
585 |
defined). For cheap blocks, nil is returned" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
586 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
587 |
home notNil ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
588 |
^ home methodHome |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
589 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
590 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
591 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
592 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
593 |
numArgs |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
594 |
"return the number of arguments I expect for evaluation. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
595 |
Please use argumentCount, which is ANSI" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
596 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
597 |
"/ <resource: #obsolete> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
598 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
599 |
^ nargs |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
600 |
! ! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
601 |
|
11588 | 602 |
|
10890 | 603 |
!Block methodsFor:'compatibility-Cola & Pepsi'! |
604 |
||
605 |
arity |
|
606 |
^ self numArgs |
|
607 |
! ! |
|
5931
9e40d7255c26
check for nil signal in #handle:do:
Claus Gittinger <cg@exept.de>
parents:
5779
diff
changeset
|
608 |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
609 |
!Block methodsFor:'conversion'! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
610 |
|
5349 | 611 |
asVarArgBlock |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
612 |
"convert myself into a varArg block; |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
613 |
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
|
614 |
of actual arguments when evaluated." |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
615 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
616 |
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
|
617 |
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
|
618 |
^ nil |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
619 |
]. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
620 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
621 |
self changeClassTo:VarArgBlock. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
622 |
^ self |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
623 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
624 |
" |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
625 |
|b| |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
626 |
|
5349 | 627 |
b := [:argList | Transcript |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
628 |
show:'invoked with args:'; |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
629 |
showCR:argList |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
630 |
] asVarArgBlock. |
5349 | 631 |
b value. |
632 |
b value:'arg1'. |
|
633 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4' |
|
634 |
" |
|
635 |
||
636 |
"Created: 23.1.1997 / 13:35:28 / cg" |
|
637 |
"Modified: 23.1.1997 / 13:35:48 / cg" |
|
638 |
! |
|
639 |
||
7151 | 640 |
beCurryingBlock |
641 |
"make myself a currying block; |
|
642 |
thats a block which, if invoked with less-than-expected arguments, |
|
643 |
returns another block which provides the provided argument(s) and expects the remaining args. |
|
644 |
Read any book on functional programming, if you dont understand this." |
|
645 |
||
646 |
self changeClassTo:CurryingBlock. |
|
647 |
^ self |
|
648 |
! |
|
649 |
||
5349 | 650 |
beVarArg |
651 |
"convert myself into a varArg block; |
|
652 |
this one has 1 formal argument, which gets the list |
|
653 |
of actual arguments when evaluated." |
|
654 |
||
655 |
^ self asVarArgBlock. |
|
656 |
||
657 |
" |
|
658 |
|b| |
|
659 |
||
2241 | 660 |
b := [:argList | argList printCR] beVarArg. |
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
661 |
b value. |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
662 |
b value:'arg1' value:'arg2' value:'arg3' value:'arg4' |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
663 |
" |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
664 |
|
2241 | 665 |
"Created: 23.1.1997 / 13:35:28 / cg" |
666 |
"Modified: 23.1.1997 / 13:35:48 / cg" |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
667 |
! ! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
668 |
|
623 | 669 |
!Block methodsFor:'copying'! |
1 | 670 |
|
10942 | 671 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
623 | 672 |
"raise an error - deepCopy is not allowed for blocks" |
1 | 673 |
|
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
674 |
|copyOfHome copyOfMe| |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
675 |
|
8638 | 676 |
home isNil ifTrue:[ |
10942 | 677 |
^ super deepCopyUsing:aDictionary postCopySelector:postCopySelector |
8638 | 678 |
]. |
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
679 |
copyOfHome := home deepCopyUsing:aDictionary. |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
680 |
copyOfMe := self shallowCopy. |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
681 |
copyOfMe setHome:copyOfHome. |
10942 | 682 |
copyOfMe perform:postCopySelector with:self. |
10135
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
683 |
^ copyOfMe |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
684 |
|
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
685 |
"Created: / 31-03-1998 / 15:46:17 / cg" |
66ba0830449b
partial support for copying (ok, if my context is not active)
fm
parents:
9646
diff
changeset
|
686 |
"Modified: / 20-10-2006 / 14:53:34 / User" |
1 | 687 |
! ! |
688 |
||
689 |
!Block methodsFor:'error handling'! |
|
690 |
||
328 | 691 |
invalidCodeObject |
1874 | 692 |
"{ Pragma: +optSpace }" |
693 |
||
67 | 694 |
"this error is triggered by the interpreter when a non-Block object |
695 |
is about to be executed. |
|
696 |
In this case, the VM sends this to the bad method (the receiver). |
|
697 |
Can only happen when the Compiler/runtime system is broken or |
|
698 |
someone played around." |
|
1 | 699 |
|
7602
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
700 |
^ InvalidCodeError |
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
701 |
raiseRequestWith:self |
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
702 |
errorString:'invalid block - not executable' |
1874 | 703 |
|
704 |
"Modified: 4.11.1996 / 22:46:39 / cg" |
|
1 | 705 |
! ! |
706 |
||
707 |
!Block methodsFor:'evaluation'! |
|
708 |
||
709 |
value |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
710 |
"evaluate the receiver with no block args. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
711 |
The receiver must be a block without arguments." |
1 | 712 |
|
713 |
%{ /* NOCONTEXT */ |
|
714 |
||
715 |
REGISTER OBJFUNC thecode; |
|
716 |
OBJ home; |
|
717 |
||
8913 | 718 |
if (__INST(nargs) == __mkSmallInteger(0)) { |
1 | 719 |
#if defined(THIS_CONTEXT) |
7149 | 720 |
if (__ISVALID_ILC_LNO(__pilc)) |
721 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 722 |
#endif |
328 | 723 |
|
7149 | 724 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 725 |
#ifdef NEW_BLOCK_CALL |
7149 | 726 |
if (thecode != (OBJFUNC)nil) { |
727 |
/* compiled machine code */ |
|
728 |
RETURN ( (*thecode)(self) ); |
|
729 |
} |
|
730 |
/* interpreted code */ |
|
328 | 731 |
# ifdef PASS_ARG_POINTER |
7149 | 732 |
RETURN ( __interpret(self, 0, nil, nil, nil, nil) ); |
328 | 733 |
# else |
7149 | 734 |
RETURN ( __interpret(self, 0, nil, nil, nil, nil) ); |
328 | 735 |
# endif |
11 | 736 |
#else |
7149 | 737 |
home = __BlockInstPtr(self)->b_home; |
738 |
if (thecode != (OBJFUNC)nil) { |
|
739 |
/* compiled machine code */ |
|
740 |
RETURN ( (*thecode)(home) ); |
|
741 |
} |
|
742 |
/* interpreted code */ |
|
328 | 743 |
# ifdef PASS_ARG_POINTER |
7149 | 744 |
RETURN ( __interpret(self, 0, nil, home, nil, nil) ); |
328 | 745 |
# else |
7149 | 746 |
RETURN ( __interpret(self, 0, nil, home, nil, nil) ); |
328 | 747 |
# endif |
11 | 748 |
#endif |
1 | 749 |
} |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
750 |
%}. |
103 | 751 |
^ self wrongNumberOfArguments:0 |
1 | 752 |
! |
753 |
||
754 |
value:arg |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
755 |
"evaluate the receiver with one argument. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
756 |
The receiver must be a 1-arg block." |
1 | 757 |
|
758 |
%{ /* NOCONTEXT */ |
|
759 |
||
760 |
REGISTER OBJFUNC thecode; |
|
761 |
OBJ home; |
|
762 |
||
8913 | 763 |
if (__INST(nargs) == __mkSmallInteger(1)) { |
1 | 764 |
#if defined(THIS_CONTEXT) |
7149 | 765 |
if (__ISVALID_ILC_LNO(__pilc)) |
766 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 767 |
#endif |
7149 | 768 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 769 |
#ifdef NEW_BLOCK_CALL |
7149 | 770 |
if (thecode != (OBJFUNC)nil) { |
771 |
RETURN ( (*thecode)(self, arg) ); |
|
772 |
} |
|
773 |
/* interpreted code */ |
|
328 | 774 |
# ifdef PASS_ARG_POINTER |
7149 | 775 |
RETURN ( __interpret(self, 1, nil, nil, nil, nil, &arg) ); |
328 | 776 |
# else |
7149 | 777 |
RETURN ( __interpret(self, 1, nil, nil, nil, nil, arg) ); |
328 | 778 |
# endif |
1 | 779 |
#else |
7149 | 780 |
home = __BlockInstPtr(self)->b_home; |
781 |
if (thecode != (OBJFUNC)nil) { |
|
782 |
RETURN ( (*thecode)(home, arg) ); |
|
783 |
} |
|
784 |
/* interpreted code */ |
|
328 | 785 |
# ifdef PASS_ARG_POINTER |
7149 | 786 |
RETURN ( __interpret(self, 1, nil, home, nil, nil, &arg) ); |
328 | 787 |
# else |
7149 | 788 |
RETURN ( __interpret(self, 1, nil, home, nil, nil, arg) ); |
328 | 789 |
# endif |
1 | 790 |
#endif |
791 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
792 |
%}. |
103 | 793 |
^ self wrongNumberOfArguments:1 |
1 | 794 |
! |
795 |
||
796 |
value:arg1 value:arg2 |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
797 |
"evaluate the receiver with two arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
798 |
The receiver must be a 2-arg block." |
1 | 799 |
|
800 |
%{ /* NOCONTEXT */ |
|
801 |
||
802 |
REGISTER OBJFUNC thecode; |
|
803 |
OBJ home; |
|
804 |
||
8913 | 805 |
if (__INST(nargs) == __mkSmallInteger(2)) { |
1 | 806 |
#if defined(THIS_CONTEXT) |
7149 | 807 |
if (__ISVALID_ILC_LNO(__pilc)) |
808 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 809 |
#endif |
7149 | 810 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 811 |
#ifdef NEW_BLOCK_CALL |
7149 | 812 |
if (thecode != (OBJFUNC)nil) { |
813 |
RETURN ( (*thecode)(self, arg1, arg2) ); |
|
814 |
} |
|
328 | 815 |
# ifdef PASS_ARG_POINTER |
7149 | 816 |
RETURN ( __interpret(self, 2, nil, nil, nil, nil, &arg1) ); |
328 | 817 |
# else |
7149 | 818 |
RETURN ( __interpret(self, 2, nil, nil, nil, nil, arg1, arg2) ); |
328 | 819 |
# endif |
1 | 820 |
#else |
7149 | 821 |
home = __BlockInstPtr(self)->b_home; |
822 |
if (thecode != (OBJFUNC)nil) { |
|
823 |
RETURN ( (*thecode)(home, arg1, arg2) ); |
|
824 |
} |
|
328 | 825 |
# ifdef PASS_ARG_POINTER |
7149 | 826 |
RETURN ( __interpret(self, 2, nil, home, nil, nil, &arg1) ); |
328 | 827 |
# else |
7149 | 828 |
RETURN ( __interpret(self, 2, nil, home, nil, nil, arg1, arg2) ); |
328 | 829 |
# endif |
1 | 830 |
#endif |
831 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
832 |
%}. |
103 | 833 |
^ self wrongNumberOfArguments:2 |
1 | 834 |
! |
835 |
||
836 |
value:arg1 value:arg2 value:arg3 |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
837 |
"evaluate the receiver with three arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
838 |
The receiver must be a 3-arg block." |
1 | 839 |
|
840 |
%{ /* NOCONTEXT */ |
|
841 |
||
842 |
REGISTER OBJFUNC thecode; |
|
843 |
OBJ home; |
|
844 |
||
8913 | 845 |
if (__INST(nargs) == __mkSmallInteger(3)) { |
1 | 846 |
#if defined(THIS_CONTEXT) |
7149 | 847 |
if (__ISVALID_ILC_LNO(__pilc)) |
848 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 849 |
#endif |
7149 | 850 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 851 |
#ifdef NEW_BLOCK_CALL |
7149 | 852 |
if (thecode != (OBJFUNC)nil) { |
853 |
RETURN ( (*thecode)(self, arg1, arg2, arg3) ); |
|
854 |
} |
|
328 | 855 |
# ifdef PASS_ARG_POINTER |
7149 | 856 |
RETURN ( __interpret(self, 3, nil, nil, nil, nil, &arg1) ); |
328 | 857 |
# else |
7149 | 858 |
RETURN ( __interpret(self, 3, nil, nil, nil, nil, arg1, arg2, arg3) ); |
328 | 859 |
# endif |
1 | 860 |
#else |
7149 | 861 |
home = __BlockInstPtr(self)->b_home; |
862 |
if (thecode != (OBJFUNC)nil) { |
|
863 |
RETURN ( (*thecode)(home, arg1, arg2, arg3) ); |
|
864 |
} |
|
328 | 865 |
# ifdef PASS_ARG_POINTER |
7149 | 866 |
RETURN ( __interpret(self, 3, nil, home, nil, nil, &arg1) ); |
328 | 867 |
# else |
7149 | 868 |
RETURN ( __interpret(self, 3, nil, home, nil, nil, arg1, arg2, arg3) ); |
328 | 869 |
# endif |
1 | 870 |
#endif |
871 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
872 |
%}. |
103 | 873 |
^ self wrongNumberOfArguments:3 |
1 | 874 |
! |
875 |
||
876 |
value:arg1 value:arg2 value:arg3 value:arg4 |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
877 |
"evaluate the receiver with four arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
878 |
The receiver must be a 4-arg block." |
1 | 879 |
|
880 |
%{ /* NOCONTEXT */ |
|
881 |
||
882 |
REGISTER OBJFUNC thecode; |
|
883 |
OBJ home; |
|
884 |
||
8913 | 885 |
if (__INST(nargs) == __mkSmallInteger(4)) { |
1 | 886 |
#if defined(THIS_CONTEXT) |
7149 | 887 |
if (__ISVALID_ILC_LNO(__pilc)) |
888 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 889 |
#endif |
7149 | 890 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 891 |
#ifdef NEW_BLOCK_CALL |
7149 | 892 |
if (thecode != (OBJFUNC)nil) { |
893 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4) ); |
|
894 |
} |
|
328 | 895 |
# ifdef PASS_ARG_POINTER |
7149 | 896 |
RETURN ( __interpret(self, 4, nil, nil, nil, nil, &arg1) ); |
328 | 897 |
# else |
7149 | 898 |
RETURN ( __interpret(self, 4, nil, nil, nil, nil, arg1, arg2, arg3, arg4) ); |
328 | 899 |
# endif |
1 | 900 |
#else |
7149 | 901 |
home = __BlockInstPtr(self)->b_home; |
902 |
if (thecode != (OBJFUNC)nil) { |
|
903 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4) ); |
|
904 |
} |
|
328 | 905 |
# ifdef PASS_ARG_POINTER |
7149 | 906 |
RETURN ( __interpret(self, 4, nil, home, nil, nil, &arg1) ); |
328 | 907 |
# else |
7149 | 908 |
RETURN ( __interpret(self, 4, nil, home, nil, nil, arg1, arg2, arg3, arg4) ); |
328 | 909 |
# endif |
1 | 910 |
#endif |
911 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
912 |
%}. |
103 | 913 |
^ self wrongNumberOfArguments:4 |
1 | 914 |
! |
915 |
||
916 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
917 |
"evaluate the receiver with five arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
918 |
The receiver must be a 5-arg block." |
1 | 919 |
|
920 |
%{ /* NOCONTEXT */ |
|
921 |
||
922 |
REGISTER OBJFUNC thecode; |
|
923 |
OBJ home; |
|
924 |
||
8913 | 925 |
if (__INST(nargs) == __mkSmallInteger(5)) { |
1 | 926 |
#if defined(THIS_CONTEXT) |
7149 | 927 |
if (__ISVALID_ILC_LNO(__pilc)) |
928 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 929 |
#endif |
7149 | 930 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 931 |
#ifdef NEW_BLOCK_CALL |
7149 | 932 |
if (thecode != (OBJFUNC)nil) { |
933 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5) ); |
|
934 |
} |
|
328 | 935 |
# ifdef PASS_ARG_POINTER |
7149 | 936 |
RETURN ( __interpret(self, 5, nil, nil, nil, nil, &arg1) ); |
328 | 937 |
# else |
7149 | 938 |
RETURN ( __interpret(self, 5, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5) ); |
328 | 939 |
# endif |
1 | 940 |
#else |
7149 | 941 |
home = __BlockInstPtr(self)->b_home; |
942 |
if (thecode != (OBJFUNC)nil) { |
|
943 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5) ); |
|
944 |
} |
|
328 | 945 |
# ifdef PASS_ARG_POINTER |
7149 | 946 |
RETURN ( __interpret(self, 5, nil, home, nil, nil, &arg1) ); |
328 | 947 |
# else |
7149 | 948 |
RETURN ( __interpret(self, 5, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5) ); |
328 | 949 |
# endif |
1 | 950 |
#endif |
951 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
952 |
%}. |
103 | 953 |
^ self wrongNumberOfArguments:5 |
1 | 954 |
! |
955 |
||
956 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
957 |
"evaluate the receiver with six arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
958 |
The receiver must be a 6-arg block." |
1 | 959 |
|
960 |
%{ /* NOCONTEXT */ |
|
961 |
||
962 |
REGISTER OBJFUNC thecode; |
|
963 |
OBJ home; |
|
964 |
||
8913 | 965 |
if (__INST(nargs) == __mkSmallInteger(6)) { |
1 | 966 |
#if defined(THIS_CONTEXT) |
7149 | 967 |
if (__ISVALID_ILC_LNO(__pilc)) |
968 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1 | 969 |
#endif |
7149 | 970 |
thecode = __BlockInstPtr(self)->b_code; |
11 | 971 |
#ifdef NEW_BLOCK_CALL |
7149 | 972 |
if (thecode != (OBJFUNC)nil) { |
973 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
974 |
} |
|
328 | 975 |
# ifdef PASS_ARG_POINTER |
7149 | 976 |
RETURN ( __interpret(self, 6, nil, nil, nil, nil, &arg1) ); |
328 | 977 |
# else |
7149 | 978 |
RETURN ( __interpret(self, 6, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6) ); |
328 | 979 |
# endif |
1 | 980 |
#else |
7149 | 981 |
home = __BlockInstPtr(self)->b_home; |
982 |
if (thecode != (OBJFUNC)nil) { |
|
983 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6) ); |
|
984 |
} |
|
328 | 985 |
# ifdef PASS_ARG_POINTER |
7149 | 986 |
RETURN ( __interpret(self, 6, nil, home, nil, nil, &arg1) ); |
328 | 987 |
# else |
7149 | 988 |
RETURN ( __interpret(self, 6, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6) ); |
328 | 989 |
# endif |
1 | 990 |
#endif |
991 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
992 |
%}. |
103 | 993 |
^ self wrongNumberOfArguments:6 |
1 | 994 |
! |
995 |
||
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
996 |
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
|
997 |
"evaluate the receiver with seven arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
998 |
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
|
999 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1000 |
%{ /* NOCONTEXT */ |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1001 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1002 |
REGISTER OBJFUNC thecode; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1003 |
OBJ home; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1004 |
|
8913 | 1005 |
if (__INST(nargs) == __mkSmallInteger(7)) { |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1006 |
#if defined(THIS_CONTEXT) |
7149 | 1007 |
if (__ISVALID_ILC_LNO(__pilc)) |
1008 |
__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
|
1009 |
#endif |
7149 | 1010 |
thecode = __BlockInstPtr(self)->b_code; |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1011 |
#ifdef NEW_BLOCK_CALL |
7149 | 1012 |
if (thecode != (OBJFUNC)nil) { |
1013 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1014 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1015 |
# ifdef PASS_ARG_POINTER |
7149 | 1016 |
RETURN ( __interpret(self, 7, nil, nil, nil, nil, &arg1) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1017 |
# else |
7149 | 1018 |
RETURN ( __interpret(self, 7, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1019 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1020 |
#else |
7149 | 1021 |
home = __BlockInstPtr(self)->b_home; |
1022 |
if (thecode != (OBJFUNC)nil) { |
|
1023 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
|
1024 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1025 |
# ifdef PASS_ARG_POINTER |
7149 | 1026 |
RETURN ( __interpret(self, 7, nil, home, nil, nil, &arg1) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1027 |
# else |
7149 | 1028 |
RETURN ( __interpret(self, 7, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7) ); |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1029 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1030 |
#endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1031 |
} |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1032 |
%}. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1033 |
^ self wrongNumberOfArguments:7 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1034 |
! |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1035 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1036 |
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
|
1037 |
"evaluate the receiver with eight arguments. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1038 |
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
|
1039 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1040 |
%{ /* NOCONTEXT */ |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1041 |
|
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1042 |
REGISTER OBJFUNC thecode; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1043 |
OBJ home; |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1044 |
|
8913 | 1045 |
if (__INST(nargs) == __mkSmallInteger(8)) { |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1046 |
#if defined(THIS_CONTEXT) |
7149 | 1047 |
if (__ISVALID_ILC_LNO(__pilc)) |
1048 |
__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
|
1049 |
#endif |
7149 | 1050 |
thecode = __BlockInstPtr(self)->b_code; |
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1051 |
#ifdef NEW_BLOCK_CALL |
7149 | 1052 |
if (thecode != (OBJFUNC)nil) { |
1053 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
|
1054 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1055 |
# ifdef PASS_ARG_POINTER |
7149 | 1056 |
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
|
1057 |
# else |
7149 | 1058 |
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
|
1059 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1060 |
#else |
7149 | 1061 |
home = __BlockInstPtr(self)->b_home; |
1062 |
if (thecode != (OBJFUNC)nil) { |
|
1063 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ); |
|
1064 |
} |
|
1605
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1065 |
# ifdef PASS_ARG_POINTER |
7149 | 1066 |
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
|
1067 |
# else |
7149 | 1068 |
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
|
1069 |
# endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1070 |
#endif |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1071 |
} |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1072 |
%}. |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1073 |
^ self wrongNumberOfArguments:8 |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1074 |
! |
61def0ffbdd6
added value:...value: with 7 and 8 args
Claus Gittinger <cg@exept.de>
parents:
1493
diff
changeset
|
1075 |
|
11588 | 1076 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 |
11603 | 1077 |
"evaluate the receiver with 9 arguments. |
1078 |
The receiver must be a 9-arg block." |
|
11588 | 1079 |
|
1080 |
%{ /* NOCONTEXT */ |
|
1081 |
||
1082 |
REGISTER OBJFUNC thecode; |
|
1083 |
OBJ home; |
|
1084 |
||
1085 |
if (__INST(nargs) == __mkSmallInteger(9)) { |
|
1086 |
#if defined(THIS_CONTEXT) |
|
1087 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1088 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1089 |
#endif |
|
1090 |
thecode = __BlockInstPtr(self)->b_code; |
|
1091 |
#ifdef NEW_BLOCK_CALL |
|
1092 |
if (thecode != (OBJFUNC)nil) { |
|
1093 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1094 |
} |
|
1095 |
# ifdef PASS_ARG_POINTER |
|
1096 |
RETURN ( __interpret(self, 9, nil, nil, nil, nil, &arg1) ); |
|
1097 |
# else |
|
1098 |
RETURN ( __interpret(self, 9, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1099 |
# endif |
|
1100 |
#else |
|
1101 |
home = __BlockInstPtr(self)->b_home; |
|
1102 |
if (thecode != (OBJFUNC)nil) { |
|
1103 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1104 |
} |
|
1105 |
# ifdef PASS_ARG_POINTER |
|
1106 |
RETURN ( __interpret(self, 9, nil, home, nil, nil, &arg1) ); |
|
1107 |
# else |
|
1108 |
RETURN ( __interpret(self, 9, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) ); |
|
1109 |
# endif |
|
1110 |
#endif |
|
1111 |
} |
|
1112 |
%}. |
|
1113 |
^ self wrongNumberOfArguments:9 |
|
1114 |
! |
|
1115 |
||
1116 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 |
|
11603 | 1117 |
"evaluate the receiver with 10 arguments. |
11588 | 1118 |
The receiver must be a 10-arg block." |
1119 |
||
1120 |
%{ /* NOCONTEXT */ |
|
1121 |
||
1122 |
REGISTER OBJFUNC thecode; |
|
1123 |
OBJ home; |
|
1124 |
||
1125 |
if (__INST(nargs) == __mkSmallInteger(10)) { |
|
1126 |
#if defined(THIS_CONTEXT) |
|
1127 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1128 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1129 |
#endif |
|
1130 |
thecode = __BlockInstPtr(self)->b_code; |
|
1131 |
#ifdef NEW_BLOCK_CALL |
|
1132 |
if (thecode != (OBJFUNC)nil) { |
|
1133 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1134 |
} |
|
1135 |
# ifdef PASS_ARG_POINTER |
|
1136 |
RETURN ( __interpret(self, 10, nil, nil, nil, nil, &arg1) ); |
|
1137 |
# else |
|
1138 |
RETURN ( __interpret(self, 10, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1139 |
# endif |
|
1140 |
#else |
|
1141 |
home = __BlockInstPtr(self)->b_home; |
|
1142 |
if (thecode != (OBJFUNC)nil) { |
|
1143 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1144 |
} |
|
1145 |
# ifdef PASS_ARG_POINTER |
|
1146 |
RETURN ( __interpret(self, 10, nil, home, nil, nil, &arg1) ); |
|
1147 |
# else |
|
1148 |
RETURN ( __interpret(self, 10, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) ); |
|
1149 |
# endif |
|
1150 |
#endif |
|
1151 |
} |
|
1152 |
%}. |
|
1153 |
^ self wrongNumberOfArguments:10 |
|
1154 |
! |
|
1155 |
||
1156 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 value:arg11 |
|
11603 | 1157 |
"evaluate the receiver with 11 arguments. |
1158 |
The receiver must be a 11-arg block." |
|
11588 | 1159 |
|
1160 |
%{ /* NOCONTEXT */ |
|
1161 |
||
1162 |
REGISTER OBJFUNC thecode; |
|
1163 |
OBJ home; |
|
1164 |
||
1165 |
if (__INST(nargs) == __mkSmallInteger(11)) { |
|
1166 |
#if defined(THIS_CONTEXT) |
|
1167 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1168 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1169 |
#endif |
|
1170 |
thecode = __BlockInstPtr(self)->b_code; |
|
1171 |
#ifdef NEW_BLOCK_CALL |
|
1172 |
if (thecode != (OBJFUNC)nil) { |
|
1173 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1174 |
} |
|
1175 |
# ifdef PASS_ARG_POINTER |
|
1176 |
RETURN ( __interpret(self, 11, nil, nil, nil, nil, &arg1) ); |
|
1177 |
# else |
|
1178 |
RETURN ( __interpret(self, 11, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1179 |
# endif |
|
1180 |
#else |
|
1181 |
home = __BlockInstPtr(self)->b_home; |
|
1182 |
if (thecode != (OBJFUNC)nil) { |
|
1183 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1184 |
} |
|
1185 |
# ifdef PASS_ARG_POINTER |
|
1186 |
RETURN ( __interpret(self, 11, nil, home, nil, nil, &arg1) ); |
|
1187 |
# else |
|
1188 |
RETURN ( __interpret(self, 11, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11) ); |
|
1189 |
# endif |
|
1190 |
#endif |
|
1191 |
} |
|
1192 |
%}. |
|
1193 |
^ self wrongNumberOfArguments:11 |
|
1194 |
! |
|
1195 |
||
11603 | 1196 |
value:arg1 value:arg2 value:arg3 value:arg4 value:arg5 value:arg6 value:arg7 value:arg8 value:arg9 value:arg10 value:arg11 value:arg12 |
1197 |
"evaluate the receiver with 12 arguments. |
|
1198 |
The receiver must be a 12-arg block." |
|
1199 |
||
1200 |
%{ /* NOCONTEXT */ |
|
1201 |
||
1202 |
REGISTER OBJFUNC thecode; |
|
1203 |
OBJ home; |
|
1204 |
||
1205 |
if (__INST(nargs) == __mkSmallInteger(12)) { |
|
1206 |
#if defined(THIS_CONTEXT) |
|
1207 |
if (__ISVALID_ILC_LNO(__pilc)) |
|
1208 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
|
1209 |
#endif |
|
1210 |
thecode = __BlockInstPtr(self)->b_code; |
|
1211 |
#ifdef NEW_BLOCK_CALL |
|
1212 |
if (thecode != (OBJFUNC)nil) { |
|
1213 |
RETURN ( (*thecode)(self, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1214 |
} |
|
1215 |
# ifdef PASS_ARG_POINTER |
|
1216 |
RETURN ( __interpret(self, 12, nil, nil, nil, nil, &arg1) ); |
|
1217 |
# else |
|
1218 |
RETURN ( __interpret(self, 12, nil, nil, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1219 |
# endif |
|
1220 |
#else |
|
1221 |
home = __BlockInstPtr(self)->b_home; |
|
1222 |
if (thecode != (OBJFUNC)nil) { |
|
1223 |
RETURN ( (*thecode)(home, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1224 |
} |
|
1225 |
# ifdef PASS_ARG_POINTER |
|
1226 |
RETURN ( __interpret(self, 12, nil, home, nil, nil, &arg1) ); |
|
1227 |
# else |
|
1228 |
RETURN ( __interpret(self, 12, nil, home, nil, nil, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) ); |
|
1229 |
# endif |
|
1230 |
#endif |
|
1231 |
} |
|
1232 |
%}. |
|
1233 |
^ self wrongNumberOfArguments:12 |
|
1234 |
! |
|
1235 |
||
3688 | 1236 |
valueAt:priority |
1237 |
"evaluate the receiver, at the given prioriy; |
|
1238 |
i.e. change the priority for the execution of the receiver." |
|
1239 |
||
9042 | 1240 |
|oldPrio retVal activeProcess| |
1241 |
||
1242 |
activeProcess := Processor activeProcess. |
|
3688 | 1243 |
oldPrio := Processor activePriority. |
1244 |
[ |
|
9042 | 1245 |
activeProcess priority:priority. |
1246 |
retVal := self value. |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
1247 |
] ensure:[ |
9042 | 1248 |
activeProcess priority:oldPrio |
3688 | 1249 |
]. |
1250 |
^ retVal |
|
1251 |
||
1252 |
" |
|
1253 |
[ |
|
9042 | 1254 |
1000 timesRepeat:[ |
1255 |
1000 factorial |
|
1256 |
] |
|
3688 | 1257 |
] valueAt:3 |
1258 |
" |
|
1259 |
||
1260 |
"Created: / 29.7.1998 / 19:19:48 / cg" |
|
1261 |
! |
|
1262 |
||
1 | 1263 |
valueWithArguments:argArray |
1264 |
"evaluate the receiver with arguments taken from argArray. |
|
313 | 1265 |
ArgArray must be either an Array or nil. |
1 | 1266 |
The size of the argArray must match the number of arguments the receiver expects." |
1267 |
||
8009 | 1268 |
|a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15| |
1 | 1269 |
|
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1270 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
7149 | 1271 |
^ self badArgumentArray:argArray |
1 | 1272 |
]. |
1273 |
(argArray size == nargs) ifFalse:[ |
|
7149 | 1274 |
^ self wrongNumberOfArguments:argArray size |
1 | 1275 |
]. |
1276 |
%{ |
|
1277 |
||
1278 |
REGISTER OBJFUNC thecode; |
|
1279 |
OBJ home; |
|
67 | 1280 |
REGISTER OBJ *ap; |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1281 |
OBJ nA; |
1 | 1282 |
|
1283 |
#if defined(THIS_CONTEXT) |
|
328 | 1284 |
if (__ISVALID_ILC_LNO(__pilc)) |
7149 | 1285 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
1 | 1286 |
#endif |
1133 | 1287 |
thecode = __BlockInstPtr(self)->b_code; |
1037 | 1288 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
1289 |
nA = __INST(nargs); |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
1290 |
|
1037 | 1291 |
#ifndef NEW_BLOCK_CALL |
1133 | 1292 |
home = __BlockInstPtr(self)->b_home; |
1037 | 1293 |
if (thecode != (OBJFUNC)nil) { |
7149 | 1294 |
/* the most common case (0 args) here (without a switch) */ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
1295 |
|
8913 | 1296 |
if (nA == __mkSmallInteger(0)) { |
7149 | 1297 |
RETURN ( (*thecode)(home) ); |
1298 |
} |
|
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1299 |
|
7149 | 1300 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
1301 |
switch ((INT)(nA)) { |
|
1302 |
default: |
|
1303 |
goto error; |
|
8913 | 1304 |
case (INT)__mkSmallInteger(15): |
8009 | 1305 |
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]) ); |
8913 | 1306 |
case (INT)__mkSmallInteger(14): |
8009 | 1307 |
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]) ); |
8913 | 1308 |
case (INT)__mkSmallInteger(13): |
8009 | 1309 |
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]) ); |
8913 | 1310 |
case (INT)__mkSmallInteger(12): |
7149 | 1311 |
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]) ); |
8913 | 1312 |
case (INT)__mkSmallInteger(11): |
7149 | 1313 |
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]) ); |
8913 | 1314 |
case (INT)__mkSmallInteger(10): |
7149 | 1315 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) ); |
8913 | 1316 |
case (INT)__mkSmallInteger(9): |
7149 | 1317 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) ); |
8913 | 1318 |
case (INT)__mkSmallInteger(8): |
7149 | 1319 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) ); |
8913 | 1320 |
case (INT)__mkSmallInteger(7): |
7149 | 1321 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) ); |
8913 | 1322 |
case (INT)__mkSmallInteger(6): |
7149 | 1323 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) ); |
8913 | 1324 |
case (INT)__mkSmallInteger(5): |
7149 | 1325 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) ); |
8913 | 1326 |
case (INT)__mkSmallInteger(4): |
7149 | 1327 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) ); |
8913 | 1328 |
case (INT)__mkSmallInteger(3): |
7149 | 1329 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) ); |
8913 | 1330 |
case (INT)__mkSmallInteger(2): |
7149 | 1331 |
RETURN ( (*thecode)(home, ap[0], ap[1]) ); |
8913 | 1332 |
case (INT)__mkSmallInteger(1): |
7149 | 1333 |
RETURN ( (*thecode)(home, ap[0]) ); |
8913 | 1334 |
case (INT)__mkSmallInteger(0): |
7149 | 1335 |
RETURN ( (*thecode)(home) ); |
1336 |
break; |
|
1337 |
} |
|
1037 | 1338 |
} |
1339 |
#endif |
|
1340 |
||
8913 | 1341 |
if (nA != __mkSmallInteger(0)) { |
7149 | 1342 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
1343 |
switch ((INT)nA) { |
|
1344 |
default: |
|
1345 |
goto error; |
|
8913 | 1346 |
case (INT)__mkSmallInteger(15): |
8009 | 1347 |
a15 = ap[14]; |
8913 | 1348 |
case (INT)__mkSmallInteger(14): |
8009 | 1349 |
a14 = ap[13]; |
8913 | 1350 |
case (INT)__mkSmallInteger(13): |
8009 | 1351 |
a13 = ap[12]; |
8913 | 1352 |
case (INT)__mkSmallInteger(12): |
7149 | 1353 |
a12 = ap[11]; |
8913 | 1354 |
case (INT)__mkSmallInteger(11): |
7149 | 1355 |
a11 = ap[10]; |
8913 | 1356 |
case (INT)__mkSmallInteger(10): |
7149 | 1357 |
a10 = ap[9]; |
8913 | 1358 |
case (INT)__mkSmallInteger(9): |
7149 | 1359 |
a9 = ap[8]; |
8913 | 1360 |
case (INT)__mkSmallInteger(8): |
7149 | 1361 |
a8 = ap[7]; |
8913 | 1362 |
case (INT)__mkSmallInteger(7): |
7149 | 1363 |
a7 = ap[6]; |
8913 | 1364 |
case (INT)__mkSmallInteger(6): |
7149 | 1365 |
a6 = ap[5]; |
8913 | 1366 |
case (INT)__mkSmallInteger(5): |
7149 | 1367 |
a5 = ap[4]; |
8913 | 1368 |
case (INT)__mkSmallInteger(4): |
7149 | 1369 |
a4 = ap[3]; |
8913 | 1370 |
case (INT)__mkSmallInteger(3): |
7149 | 1371 |
a3 = ap[2]; |
8913 | 1372 |
case (INT)__mkSmallInteger(2): |
7149 | 1373 |
a2 = ap[1]; |
8913 | 1374 |
case (INT)__mkSmallInteger(1): |
7149 | 1375 |
a1 = ap[0]; |
8913 | 1376 |
case (INT)__mkSmallInteger(0): |
7149 | 1377 |
break; |
1378 |
} |
|
1 | 1379 |
} |
1133 | 1380 |
|
11 | 1381 |
#ifdef NEW_BLOCK_CALL |
1 | 1382 |
if (thecode != (OBJFUNC)nil) { |
8009 | 1383 |
RETURN ( (*thecode)(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) ); |
11 | 1384 |
} |
328 | 1385 |
# ifdef PASS_ARG_POINTER |
6553
ce4ca4df3415
oops - last modification created a little bug.
Claus Gittinger <cg@exept.de>
parents:
6512
diff
changeset
|
1386 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
328 | 1387 |
# else |
8009 | 1388 |
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 | 1389 |
# endif |
1037 | 1390 |
|
1 | 1391 |
#else |
1037 | 1392 |
|
328 | 1393 |
# ifdef PASS_ARG_POINTER |
6553
ce4ca4df3415
oops - last modification created a little bug.
Claus Gittinger <cg@exept.de>
parents:
6512
diff
changeset
|
1394 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
328 | 1395 |
# else |
8009 | 1396 |
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 | 1397 |
# endif |
1037 | 1398 |
|
1 | 1399 |
#endif |
67 | 1400 |
|
11 | 1401 |
error: ; |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
1402 |
%}. |
138 | 1403 |
" |
8009 | 1404 |
the above code only supports up-to 15 arguments |
138 | 1405 |
" |
7602
d048f13cd50a
Exception classes initialize themself.
Stefan Vogel <sv@exept.de>
parents:
7352
diff
changeset
|
1406 |
^ ArgumentError |
7149 | 1407 |
raiseRequestWith:self |
8009 | 1408 |
errorString:'only blocks with up-to 15 arguments supported' |
6317 | 1409 |
! |
1410 |
||
1411 |
valueWithOptionalArgument:arg |
|
1412 |
"evaluate the receiver. |
|
6318 | 1413 |
Optionally pass an argument (if the receiver is a one arg block)." |
6317 | 1414 |
|
6628
4d693c525443
#handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
6611
diff
changeset
|
1415 |
nargs == 1 ifTrue:[ |
4d693c525443
#handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
6611
diff
changeset
|
1416 |
^ self value:arg |
6317 | 1417 |
]. |
1418 |
^ self value |
|
6320 | 1419 |
|
1420 |
" |
|
1421 |
|block| |
|
1422 |
||
1423 |
block := [ Transcript showCR:'hello' ]. |
|
1424 |
block valueWithOptionalArgument:2. |
|
1425 |
||
1426 |
block := [:arg | Transcript showCR:arg ]. |
|
1427 |
block valueWithOptionalArgument:2. |
|
1428 |
" |
|
6785 | 1429 |
! |
1430 |
||
1431 |
valueWithOptionalArgument:arg1 and:arg2 |
|
1432 |
"evaluate the receiver. |
|
1433 |
Optionally pass up to two arguments (if the receiver is a one/two arg block)." |
|
1434 |
||
1435 |
nargs == 2 ifTrue:[ |
|
1436 |
^ self value:arg1 value:arg2 |
|
1437 |
]. |
|
1438 |
nargs == 1 ifTrue:[ |
|
1439 |
^ self value:arg1 |
|
1440 |
]. |
|
1441 |
^ self value |
|
1442 |
||
1443 |
" |
|
1444 |
|block| |
|
1445 |
||
1446 |
block := [ Transcript showCR:'hello' ]. |
|
1447 |
block valueWithOptionalArgument:2. |
|
1448 |
||
1449 |
block := [:arg | Transcript showCR:arg ]. |
|
1450 |
block valueWithOptionalArgument:2. |
|
1451 |
||
1452 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
1453 |
block valueWithOptionalArgument:10 and:20. |
|
1454 |
" |
|
9010 | 1455 |
! |
1456 |
||
1457 |
valueWithOptionalArgument:arg1 and:arg2 and:arg3 |
|
1458 |
"evaluate the receiver. |
|
1459 |
Optionally pass up to three arguments (if the receiver is a one/two/three arg block)." |
|
1460 |
||
1461 |
nargs == 3 ifTrue:[ |
|
1462 |
^ self value:arg1 value:arg2 value:arg3 |
|
1463 |
]. |
|
1464 |
nargs == 2 ifTrue:[ |
|
1465 |
^ self value:arg1 value:arg2 |
|
1466 |
]. |
|
1467 |
nargs == 1 ifTrue:[ |
|
1468 |
^ self value:arg1 |
|
1469 |
]. |
|
1470 |
^ self value |
|
1471 |
||
1472 |
" |
|
1473 |
|block| |
|
1474 |
||
1475 |
block := [ Transcript showCR:'hello' ]. |
|
1476 |
block valueWithOptionalArgument:2. |
|
1477 |
||
1478 |
block := [:arg | Transcript showCR:arg ]. |
|
1479 |
block valueWithOptionalArgument:2. |
|
1480 |
||
1481 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
1482 |
block valueWithOptionalArgument:10 and:20. |
|
1483 |
" |
|
1484 |
! |
|
1485 |
||
1486 |
valueWithOptionalArgument:arg1 and:arg2 and:arg3 and:arg4 |
|
1487 |
"evaluate the receiver. |
|
1488 |
Optionally pass up to four arguments (if the receiver is a one/two/three/four arg block)." |
|
1489 |
||
1490 |
nargs == 4 ifTrue:[ |
|
1491 |
^ self value:arg1 value:arg2 value:arg3 value:arg4 |
|
1492 |
]. |
|
1493 |
nargs == 3 ifTrue:[ |
|
1494 |
^ self value:arg1 value:arg2 value:arg3 |
|
1495 |
]. |
|
1496 |
nargs == 2 ifTrue:[ |
|
1497 |
^ self value:arg1 value:arg2 |
|
1498 |
]. |
|
1499 |
nargs == 1 ifTrue:[ |
|
1500 |
^ self value:arg1 |
|
1501 |
]. |
|
1502 |
^ self value |
|
1503 |
||
1504 |
" |
|
1505 |
|block| |
|
1506 |
||
1507 |
block := [ Transcript showCR:'hello' ]. |
|
1508 |
block valueWithOptionalArgument:2. |
|
1509 |
||
1510 |
block := [:arg | Transcript showCR:arg ]. |
|
1511 |
block valueWithOptionalArgument:2. |
|
1512 |
||
1513 |
block := [:arg1 :arg2 | Transcript showCR:arg1. Transcript showCR:arg2 ]. |
|
1514 |
block valueWithOptionalArgument:10 and:20. |
|
1515 |
" |
|
9145
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1516 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1517 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1518 |
valueWithOptionalArguments:argArray |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1519 |
"evaluate the receiver with arguments as required taken from argArray. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1520 |
Only the required number of arguments is taken from argArray or nil; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1521 |
(i.e. argArray may be larger than the required number). |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1522 |
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
|
1523 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1524 |
|numArgsProvided 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
|
1525 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1526 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1527 |
^ self badArgumentArray:argArray |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1528 |
]. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1529 |
(argArray size >= nargs) ifFalse:[ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1530 |
^ self wrongNumberOfArguments:argArray size |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1531 |
]. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1532 |
%{ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1533 |
REGISTER OBJFUNC thecode; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1534 |
OBJ home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1535 |
REGISTER OBJ *ap; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1536 |
OBJ nA; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1537 |
int __numArgsProvided = __intVal(numArgsProvided); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1538 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1539 |
#if defined(THIS_CONTEXT) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1540 |
if (__ISVALID_ILC_LNO(__pilc)) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1541 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1542 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1543 |
thecode = __BlockInstPtr(self)->b_code; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1544 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1545 |
nA = __INST(nargs); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1546 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1547 |
if (argArray == nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1548 |
ap = 0; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1549 |
} else { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1550 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1551 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1552 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1553 |
#ifndef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1554 |
home = __BlockInstPtr(self)->b_home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1555 |
if (thecode != (OBJFUNC)nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1556 |
/* the most common case (0 args) here (without a switch) */ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1557 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1558 |
if (nA == __mkSmallInteger(0)) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1559 |
RETURN ( (*thecode)(home) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1560 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1561 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1562 |
switch ((INT)(nA)) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1563 |
default: |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1564 |
goto error; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1565 |
case (INT)__mkSmallInteger(15): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1566 |
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]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1567 |
case (INT)__mkSmallInteger(14): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1568 |
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]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1569 |
case (INT)__mkSmallInteger(13): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1570 |
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]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1571 |
case (INT)__mkSmallInteger(12): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1572 |
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]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1573 |
case (INT)__mkSmallInteger(11): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1574 |
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]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1575 |
case (INT)__mkSmallInteger(10): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1576 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8], ap[9]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1577 |
case (INT)__mkSmallInteger(9): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1578 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7], ap[8]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1579 |
case (INT)__mkSmallInteger(8): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1580 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6], ap[7]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1581 |
case (INT)__mkSmallInteger(7): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1582 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5], ap[6]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1583 |
case (INT)__mkSmallInteger(6): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1584 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4], ap[5]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1585 |
case (INT)__mkSmallInteger(5): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1586 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3], ap[4]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1587 |
case (INT)__mkSmallInteger(4): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1588 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2], ap[3]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1589 |
case (INT)__mkSmallInteger(3): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1590 |
RETURN ( (*thecode)(home, ap[0], ap[1], ap[2]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1591 |
case (INT)__mkSmallInteger(2): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1592 |
RETURN ( (*thecode)(home, ap[0], ap[1]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1593 |
case (INT)__mkSmallInteger(1): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1594 |
RETURN ( (*thecode)(home, ap[0]) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1595 |
case (INT)__mkSmallInteger(0): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1596 |
RETURN ( (*thecode)(home) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1597 |
break; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1598 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1599 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1600 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1601 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1602 |
if (nA != __mkSmallInteger(0)) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1603 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1604 |
switch ((INT)nA) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1605 |
default: |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1606 |
goto error; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1607 |
case (INT)__mkSmallInteger(15): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1608 |
a15 = ap[14]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1609 |
case (INT)__mkSmallInteger(14): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1610 |
a14 = ap[13]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1611 |
case (INT)__mkSmallInteger(13): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1612 |
a13 = ap[12]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1613 |
case (INT)__mkSmallInteger(12): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1614 |
a12 = ap[11]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1615 |
case (INT)__mkSmallInteger(11): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1616 |
a11 = ap[10]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1617 |
case (INT)__mkSmallInteger(10): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1618 |
a10 = ap[9]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1619 |
case (INT)__mkSmallInteger(9): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1620 |
a9 = ap[8]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1621 |
case (INT)__mkSmallInteger(8): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1622 |
a8 = ap[7]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1623 |
case (INT)__mkSmallInteger(7): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1624 |
a7 = ap[6]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1625 |
case (INT)__mkSmallInteger(6): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1626 |
a6 = ap[5]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1627 |
case (INT)__mkSmallInteger(5): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1628 |
a5 = ap[4]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1629 |
case (INT)__mkSmallInteger(4): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1630 |
a4 = ap[3]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1631 |
case (INT)__mkSmallInteger(3): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1632 |
a3 = ap[2]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1633 |
case (INT)__mkSmallInteger(2): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1634 |
a2 = ap[1]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1635 |
case (INT)__mkSmallInteger(1): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1636 |
a1 = ap[0]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1637 |
case (INT)__mkSmallInteger(0): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1638 |
break; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1639 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1640 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1641 |
#ifdef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1642 |
if (thecode != (OBJFUNC)nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1643 |
RETURN ( (*thecode)(self, 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
|
1644 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1645 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1646 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1647 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1648 |
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
|
1649 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1650 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1651 |
#else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1652 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1653 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1654 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1655 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1656 |
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
|
1657 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1658 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1659 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1660 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1661 |
error: ; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1662 |
%}. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1663 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1664 |
the above code only supports up-to 15 arguments |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1665 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1666 |
^ ArgumentError |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1667 |
raiseRequestWith:self |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1668 |
errorString:'only blocks with up-to 15 arguments supported' |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1669 |
! |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1670 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1671 |
valueWithPossibleArguments:argArray |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1672 |
"evaluate the receiver with arguments as required taken from argArray. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1673 |
If argArray provides less than the required number of arguments, |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1674 |
nil is assumed for any remaining argument. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1675 |
(i.e. argArray may be smaller than the required number). |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1676 |
Only the required number of arguments is taken from argArray or nil; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1677 |
(i.e. argArray may be larger than the required number)." |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1678 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1679 |
|numArgsProvided 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
|
1680 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1681 |
(argArray notNil and:[(argArray class ~~ Array) and:[argArray isArray not]]) ifTrue:[ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1682 |
^ self badArgumentArray:argArray |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1683 |
]. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1684 |
numArgsProvided := argArray size. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1685 |
%{ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1686 |
REGISTER OBJFUNC thecode; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1687 |
OBJ home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1688 |
REGISTER OBJ *ap; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1689 |
OBJ nA; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1690 |
int __numArgsProvided = __intVal(numArgsProvided); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1691 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1692 |
#if defined(THIS_CONTEXT) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1693 |
if (__ISVALID_ILC_LNO(__pilc)) |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1694 |
__ContextInstPtr(__thisContext)->c_lineno = __ILC_LNO_AS_OBJ(__pilc); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1695 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1696 |
thecode = __BlockInstPtr(self)->b_code; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1697 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1698 |
nA = __INST(nargs); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1699 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1700 |
if (argArray == nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1701 |
ap = 0; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1702 |
} else { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1703 |
ap = __arrayVal(argArray); /* nonNil after above test (size is known to be ok) */ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1704 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1705 |
switch (__numArgsProvided) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1706 |
default: |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1707 |
case 15: a15 = ap[14]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1708 |
case 14: a14 = ap[13]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1709 |
case 13: a13 = ap[12]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1710 |
case 12: a12 = ap[11]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1711 |
case 11: a11 = ap[10]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1712 |
case 10: a10 = ap[9]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1713 |
case 9: a9 = ap[8]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1714 |
case 8: a8 = ap[7]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1715 |
case 7: a7 = ap[6]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1716 |
case 6: a6 = ap[5]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1717 |
case 5: a5 = ap[4]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1718 |
case 4: a4 = ap[3]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1719 |
case 3: a3 = ap[2]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1720 |
case 2: a2 = ap[1]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1721 |
case 1: a1 = ap[0]; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1722 |
case 0: ; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1723 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1724 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1725 |
#ifndef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1726 |
home = __BlockInstPtr(self)->b_home; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1727 |
if (thecode != (OBJFUNC)nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1728 |
/* the most common case (0 args) here (without a switch) */ |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1729 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1730 |
if (nA == __mkSmallInteger(0)) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1731 |
RETURN ( (*thecode)(home) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1732 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1733 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1734 |
switch ((INT)(nA)) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1735 |
default: |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1736 |
goto error; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1737 |
case (INT)__mkSmallInteger(15): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1738 |
RETURN ( (*thecode)(home, 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
|
1739 |
case (INT)__mkSmallInteger(14): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1740 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1741 |
case (INT)__mkSmallInteger(13): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1742 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1743 |
case (INT)__mkSmallInteger(12): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1744 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1745 |
case (INT)__mkSmallInteger(11): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1746 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1747 |
case (INT)__mkSmallInteger(10): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1748 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1749 |
case (INT)__mkSmallInteger(9): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1750 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8, a9) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1751 |
case (INT)__mkSmallInteger(8): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1752 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7, a8) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1753 |
case (INT)__mkSmallInteger(7): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1754 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6, a7) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1755 |
case (INT)__mkSmallInteger(6): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1756 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5, a6) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1757 |
case (INT)__mkSmallInteger(5): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1758 |
RETURN ( (*thecode)(home, a1, a2, a3, a4, a5) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1759 |
case (INT)__mkSmallInteger(4): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1760 |
RETURN ( (*thecode)(home, a1, a2, a3, a4) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1761 |
case (INT)__mkSmallInteger(3): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1762 |
RETURN ( (*thecode)(home, a1, a2, a3) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1763 |
case (INT)__mkSmallInteger(2): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1764 |
RETURN ( (*thecode)(home, a1, a2) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1765 |
case (INT)__mkSmallInteger(1): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1766 |
RETURN ( (*thecode)(home, a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1767 |
case (INT)__mkSmallInteger(0): |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1768 |
RETURN ( (*thecode)(home) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1769 |
break; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1770 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1771 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1772 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1773 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1774 |
#ifdef NEW_BLOCK_CALL |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1775 |
if (thecode != (OBJFUNC)nil) { |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1776 |
RETURN ( (*thecode)(self, 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
|
1777 |
} |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1778 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1779 |
RETURN ( __interpret(self, __intVal(nA), nil, nil, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1780 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1781 |
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
|
1782 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1783 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1784 |
#else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1785 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1786 |
# ifdef PASS_ARG_POINTER |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1787 |
RETURN ( __interpret(self, __intVal(nA), nil, home, nil, nil, &a1) ); |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1788 |
# else |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1789 |
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
|
1790 |
# endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1791 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1792 |
#endif |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1793 |
|
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1794 |
error: ; |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1795 |
%}. |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1796 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1797 |
the above code only supports up-to 15 arguments |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1798 |
" |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1799 |
^ ArgumentError |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1800 |
raiseRequestWith:self |
c0ccf0f361ba
+valueWithPossibleArguments:
Claus Gittinger <cg@exept.de>
parents:
9042
diff
changeset
|
1801 |
errorString:'only blocks with up-to 15 arguments supported' |
154 | 1802 |
! ! |
1803 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1804 |
!Block methodsFor:'exception handling'! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1805 |
|
6512 | 1806 |
on:aSignalOrSignalSetOrException do:exceptionBlock |
1807 |
"added for ANSI compatibility; evaluate the receiver, |
|
1808 |
handling aSignalOrSignalSetOrException. |
|
1809 |
The 2nd argument, exceptionBlock is evaluated |
|
1810 |
if the signal is raised during evaluation." |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1811 |
|
4542
5dc47816cf68
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4513
diff
changeset
|
1812 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1813 |
<exception: #handle> |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1814 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1815 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1816 |
^ 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
|
1817 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1818 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1819 |
[ |
6512 | 1820 |
1 foo |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1821 |
] 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
|
1822 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1823 |
[ |
6512 | 1824 |
1 foo |
1825 |
] on:(MessageNotUnderstood , AbortOperationRequest) do:[:ex | self halt] |
|
1826 |
||
1827 |
[ |
|
1828 |
1 foo |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1829 |
] on:SignalSet anySignal do:[:ex| 2 bar. self halt] |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1830 |
" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1831 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1832 |
"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
|
1833 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1834 |
|
11338 | 1835 |
on:aSignalOrSignalSetOrException do:exceptionBlock ensure:ensureBlock |
1836 |
"added for ANSI compatibility; evaluate the receiver, |
|
1837 |
handling aSignalOrSignalSetOrException. |
|
1838 |
The 2nd argument, exceptionBlock is evaluated |
|
1839 |
if the signal is raised during evaluation. |
|
1840 |
The 3rd argument, ensureBlock is evaluated in any case - even if the activity |
|
1841 |
was unwound due to an unhandled exception." |
|
1842 |
||
1843 |
<context: #return> |
|
1844 |
<exception: #handle> |
|
1845 |
<exception: #unwind> |
|
1846 |
||
1847 |
|v| |
|
1848 |
||
1849 |
v := self value. "the real logic is in Context>>unwind and Exception>>doRaise" |
|
1850 |
thisContext unmarkForUnwind. |
|
1851 |
ensureBlock value. |
|
1852 |
^ v |
|
1853 |
||
1854 |
" |
|
1855 |
|e| |
|
1856 |
||
1857 |
e := 0. |
|
1858 |
[ |
|
1859 |
1 foo |
|
1860 |
] on:MessageNotUnderstood |
|
1861 |
do:[:ex | self halt] |
|
1862 |
ensure:[ e := 1 ]. |
|
1863 |
self assert:(e == 1). |
|
1864 |
" |
|
1865 |
||
1866 |
" |
|
1867 |
|e| |
|
1868 |
||
1869 |
e := 0. |
|
1870 |
[ |
|
1871 |
1 negated |
|
1872 |
] on:MessageNotUnderstood |
|
1873 |
do:[:ex | self halt] |
|
1874 |
ensure:[ e := 1 ]. |
|
1875 |
self assert:(e == 1). |
|
1876 |
" |
|
1877 |
! |
|
1878 |
||
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1879 |
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
|
1880 |
"added for ANSI compatibility; evaluate the receiver, |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1881 |
handling aSignalOrSignalSetOrException. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1882 |
The 2nd argument, exceptionBlock is evaluated |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1883 |
if the signal is raised during evaluation." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1884 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1885 |
<context: #return> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1886 |
<exception: #handle> |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1887 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1888 |
"/ thisContext markForHandle. -- same as above pragma |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1889 |
^ 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
|
1890 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1891 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1892 |
[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1893 |
1 foo |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1894 |
] on:MessageNotUnderstood do:[:ex | self halt:'Got MessageNotUnderstood'] |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1895 |
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
|
1896 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1897 |
[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1898 |
1 // 0 |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1899 |
] on:MessageNotUnderstood do:[:ex | self halt:'Got MessageNotUnderstood'] |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1900 |
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
|
1901 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1902 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1903 |
"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
|
1904 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1905 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1906 |
valueWithExceptionHandler:handler |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1907 |
"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
|
1908 |
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
|
1909 |
|
4547
082a2f7d9d8e
Add #handlerProtectedBlock:inContext
Stefan Vogel <sv@exept.de>
parents:
4542
diff
changeset
|
1910 |
<context: #return> |
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1911 |
<exception: #handle> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1912 |
|
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1913 |
"/ thisContext markForHandle. -- same as above pragma |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
1914 |
^ 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
|
1915 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1916 |
"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
|
1917 |
"Modified: / 26.7.1999 / 11:24:06 / stefan" |
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1918 |
! |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1919 |
|
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1920 |
valueWithWatchDog:exceptionBlock afterMilliseconds:aTimeLimit |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1921 |
"a watchdog on a blocks execution" |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1922 |
|
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1923 |
|showStopper me signal retVal| |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1924 |
|
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1925 |
me := Processor activeProcess. |
10678
5cd10f301f94
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10473
diff
changeset
|
1926 |
signal := Signal new notifierString:'timeout'. |
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1927 |
showStopper := [me interruptWith:signal raise]. |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1928 |
|
10700
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1929 |
signal handle:[:ex | |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1930 |
retVal := exceptionBlock value. |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1931 |
] do:[ |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1932 |
Processor |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1933 |
addTimedBlock:showStopper |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1934 |
for:me |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1935 |
afterMilliseconds:aTimeLimit. |
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1936 |
|
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1937 |
retVal := self ensure:[ Processor removeTimedBlock:showStopper ]. |
9485
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1938 |
]. |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1939 |
^ retVal |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1940 |
|
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1941 |
" |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1942 |
[ |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1943 |
Delay waitForSeconds:5. |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1944 |
true |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1945 |
] valueWithWatchDog:[false] afterMilliseconds:2000 |
dab6bd4e2a81
added evaluation with watchdog
Claus Gittinger <cg@exept.de>
parents:
9287
diff
changeset
|
1946 |
" |
10678
5cd10f301f94
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10473
diff
changeset
|
1947 |
|
10700
0436b2f40e4c
changed #valueWithWatchDog:afterMilliseconds:
Claus Gittinger <cg@exept.de>
parents:
10678
diff
changeset
|
1948 |
"Modified: / 09-09-2007 / 15:18:22 / cg" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1949 |
! ! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4419
diff
changeset
|
1950 |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1951 |
!Block methodsFor:'exception handling private'! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1952 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1953 |
exceptionHandlerFor:anException in:aContext |
11338 | 1954 |
"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
|
1955 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1956 |
aContext selector == #on:do:on:do: ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1957 |
|exceptionCreator exceptionHandlerInContext| |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1958 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1959 |
exceptionCreator := anException creator. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1960 |
exceptionHandlerInContext := aContext argAt:1. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1961 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1962 |
exceptionHandlerInContext isNil ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1963 |
'Block [warning]: nil ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1964 |
] ifFalse:[(exceptionHandlerInContext isBehavior |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1965 |
and:[exceptionHandlerInContext isLoaded not]) ifTrue:[ |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1966 |
"If the exception class is still autoloaded, |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1967 |
it does not accept our exception. Raising the exception would load the class" |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1968 |
^ nil |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1969 |
] ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1970 |
'Block [warning]: non-ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1971 |
]]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1972 |
aContext fullPrint. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1973 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1974 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1975 |
(exceptionHandlerInContext accepts:exceptionCreator) ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1976 |
^ exceptionHandlerInContext. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1977 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1978 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1979 |
exceptionHandlerInContext := aContext argAt:3. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1980 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1981 |
exceptionHandlerInContext isNil ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1982 |
'Block [warning]: nil ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1983 |
] ifFalse:[(exceptionHandlerInContext isBehavior |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1984 |
and:[exceptionHandlerInContext isLoaded not]) ifTrue:[ |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1985 |
"If the exception class is still autoloaded, |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1986 |
it does not accept our exception. Raising the exception would load the class" |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1987 |
^ nil |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1988 |
] ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1989 |
'Block [warning]: non-ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
1990 |
]]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1991 |
aContext fullPrint. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1992 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1993 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1994 |
(exceptionHandlerInContext accepts:exceptionCreator) ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1995 |
^ exceptionHandlerInContext. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1996 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1997 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1998 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
1999 |
|
11338 | 2000 |
"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
|
2001 |
^ aContext argAt:1. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2002 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2003 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2004 |
handlerForSignal:exceptionHandler context:theContext originator:originator |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2005 |
"answer the handler block for the exceptionHandler from originator. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2006 |
The handler block is retrieved from aContext. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2007 |
Answer nil if the exceptionHandler is not handled." |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2008 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2009 |
|selector exceptionHandlerInContext| |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2010 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2011 |
selector := theContext selector. |
11338 | 2012 |
|
2013 |
(selector == #on:do: |
|
2014 |
or:[ selector == #on:do:ensure: ]) ifTrue:[ |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2015 |
exceptionHandlerInContext := theContext argAt:1. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2016 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2017 |
exceptionHandlerInContext isNil ifTrue:[ |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2018 |
'Block [warning]: nil ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2019 |
] ifFalse:[(exceptionHandlerInContext isBehavior |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2020 |
and:[exceptionHandlerInContext isLoaded not]) ifTrue:[ |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2021 |
"If the exception class is still autoloaded, |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2022 |
it does not accept our exception. Raising the exception would load the class" |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2023 |
^ nil |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2024 |
] ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2025 |
'Block [warning]: non-ExceptionHandler in on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2026 |
]]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2027 |
theContext fullPrint. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2028 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2029 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2030 |
(exceptionHandlerInContext == exceptionHandler |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2031 |
or:[exceptionHandlerInContext accepts:exceptionHandler]) ifTrue:[ |
11638
20a63a6bf2fb
changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
11603
diff
changeset
|
2032 |
^ (theContext argAt:2) ? [nil]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2033 |
]. |
11338 | 2034 |
^ nil |
2035 |
]. |
|
2036 |
||
2037 |
selector == #on:do:on:do: ifTrue:[ |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2038 |
exceptionHandlerInContext := theContext argAt:1. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2039 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2040 |
exceptionHandlerInContext isNil ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2041 |
'Block [warning]: nil ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2042 |
] ifFalse:[(exceptionHandlerInContext isBehavior |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2043 |
and:[exceptionHandlerInContext isLoaded not]) ifTrue:[ |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2044 |
"If the exception class is still autoloaded, |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2045 |
it does not accept our exception. Raising the exception would load the class" |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2046 |
^ nil |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2047 |
] ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2048 |
'Block [warning]: non-ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2049 |
]]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2050 |
theContext fullPrint. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2051 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2052 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2053 |
(exceptionHandlerInContext == exceptionHandler |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2054 |
or:[exceptionHandlerInContext accepts:exceptionHandler]) ifTrue:[ |
11638
20a63a6bf2fb
changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
11603
diff
changeset
|
2055 |
^ (theContext argAt:2) ? [nil]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2056 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2057 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2058 |
exceptionHandlerInContext := theContext argAt:3. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2059 |
exceptionHandlerInContext isExceptionHandler ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2060 |
exceptionHandlerInContext isNil ifTrue:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2061 |
'Block [warning]: nil ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2062 |
] ifFalse:[(exceptionHandlerInContext isBehavior |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2063 |
and:[exceptionHandlerInContext isLoaded not]) ifTrue:[ |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2064 |
"If the exception class is still autoloaded, |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2065 |
it does not accept our exception. Raising the exception would load the class" |
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2066 |
^ nil |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2067 |
] ifFalse:[ |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2068 |
'Block [warning]: non-ExceptionHandler in on:do:on:do:-context' errorPrintCR. |
8723
ff9b4eb01fae
#on:do: handle autoloaded exception classes
Stefan Vogel <sv@exept.de>
parents:
8708
diff
changeset
|
2069 |
]]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2070 |
theContext fullPrint. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2071 |
^ nil. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2072 |
]. |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2073 |
(exceptionHandlerInContext == exceptionHandler |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2074 |
or:[exceptionHandlerInContext accepts:exceptionHandler]) ifTrue:[ |
11638
20a63a6bf2fb
changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
11603
diff
changeset
|
2075 |
^ (theContext argAt:4) ? [nil]. |
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2076 |
]. |
11338 | 2077 |
^ nil |
2078 |
]. |
|
2079 |
||
2080 |
selector == #valueWithExceptionHandler: ifTrue:[ |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2081 |
^ (theContext argAt:1) handlerForSignal:exceptionHandler. |
11338 | 2082 |
]. |
2083 |
||
2084 |
"/ mhmh - should not arrive here |
|
8682
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2085 |
^ nil |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2086 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2087 |
"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
|
2088 |
"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
|
2089 |
! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2090 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2091 |
handlerProtectedBlock:doBlock inContext:context |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2092 |
"set the block that is protected by an exception handler in context. |
11338 | 2093 |
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
|
2094 |
Needed for #restartDo:" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2095 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2096 |
context receiver:doBlock |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2097 |
|
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2098 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2099 |
[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
|
2100 |
" |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2101 |
! ! |
3bbf34191ca2
Support for Block>>#on:do:on:do:
Stefan Vogel <sv@exept.de>
parents:
8638
diff
changeset
|
2102 |
|
623 | 2103 |
!Block methodsFor:'looping'! |
325 | 2104 |
|
623 | 2105 |
doUntil:aBlock |
2106 |
"repeat the receiver block until aBlock evaluates to true. |
|
2107 |
The receiver is evaluated at least once. |
|
2108 |
This is the same as '... doWhile:[... not]' " |
|
325 | 2109 |
|
623 | 2110 |
"this implementation is for purists ... :-)" |
2111 |
||
2112 |
self value. |
|
2113 |
aBlock value ifTrue:[^ nil]. |
|
2114 |
thisContext restart |
|
325 | 2115 |
|
2116 |
" |
|
623 | 2117 |
|n| |
154 | 2118 |
|
623 | 2119 |
n := 1. |
8602 | 2120 |
[n printCR] doUntil:[ (n := n + 1) > 5 ] |
154 | 2121 |
" |
1 | 2122 |
! |
2123 |
||
623 | 2124 |
doWhile:aBlock |
2125 |
"repeat the receiver block until aBlock evaluates to false. |
|
2126 |
The receiver is evaluated at least once." |
|
67 | 2127 |
|
154 | 2128 |
"this implementation is for purists ... :-)" |
2129 |
||
623 | 2130 |
self value. |
2131 |
aBlock value ifFalse:[^ nil]. |
|
2132 |
thisContext restart |
|
2133 |
||
2134 |
" |
|
2135 |
|n| |
|
2136 |
||
2137 |
n := 1. |
|
8602 | 2138 |
[n printCR] doWhile:[ (n := n + 1) <= 5 ] |
623 | 2139 |
" |
2140 |
! |
|
2141 |
||
2142 |
loop |
|
1211 | 2143 |
"repeat the receiver forever |
2144 |
(the receiver block should contain a return somewhere). |
|
2145 |
The implementation below was inspired by a corresponding Self method." |
|
623 | 2146 |
|
2147 |
self value. |
|
67 | 2148 |
thisContext restart |
2149 |
||
2150 |
" |
|
2151 |
|n| |
|
2152 |
||
2153 |
n := 1. |
|
623 | 2154 |
[ |
8602 | 2155 |
n printCR. |
2156 |
n >= 10 ifTrue:[^ nil]. |
|
2157 |
n := n + 1 |
|
623 | 2158 |
] loop |
2159 |
" |
|
1211 | 2160 |
|
2161 |
"Modified: 18.4.1996 / 13:50:40 / cg" |
|
623 | 2162 |
! |
2163 |
||
2164 |
loopWithExit |
|
2165 |
"the receiver must be a block of one argument. It is evaluated in a loop forever, |
|
2166 |
and is passed a block, which, if sent a value:-message, will exit the receiver block, |
|
2167 |
returning the parameter of the value:-message. Used for loops with exit in the middle. |
|
2168 |
Inspired by a corresponding Self method." |
|
2169 |
||
2170 |
|exitBlock| |
|
2171 |
||
2172 |
exitBlock := [:exitValue | ^ exitValue]. |
|
2173 |
[true] whileTrue:[self value:exitBlock] |
|
2174 |
||
2175 |
" |
|
2176 |
|i| |
|
2177 |
i := 1. |
|
2178 |
[:exit | |
|
1422 | 2179 |
Transcript showCR:i. |
623 | 2180 |
i == 5 ifTrue:[exit value:'thats it']. |
2181 |
i := i + 1 |
|
2182 |
] loopWithExit |
|
2183 |
" |
|
2184 |
! |
|
2185 |
||
2186 |
repeat |
|
1211 | 2187 |
"repeat the receiver forever - same as loop, for ST-80 compatibility. |
2188 |
(the receiver block should contain a return somewhere)." |
|
623 | 2189 |
|
2190 |
self value. |
|
2191 |
thisContext restart |
|
1211 | 2192 |
|
2193 |
"Modified: 18.4.1996 / 13:50:55 / cg" |
|
623 | 2194 |
! |
2195 |
||
2196 |
valueWithExit |
|
2197 |
"the receiver must be a block of one argument. It is evaluated, and is passed a block, |
|
2198 |
which, if sent a value:-message, will exit the receiver block, returning the parameter of the |
|
2199 |
value:-message. Used for premature returns to the caller. |
|
2200 |
Taken from a manchester goody (a similar construct also appears in Self)." |
|
2201 |
||
1211 | 2202 |
^ self value:[:exitValue | ^exitValue] |
623 | 2203 |
|
2204 |
" |
|
2205 |
[:exit | |
|
2238 | 2206 |
1 to:10 do:[:i | |
2207 |
Transcript showCR:i. |
|
2208 |
i == 5 ifTrue:[exit value:'thats it'] |
|
2209 |
]. |
|
2210 |
'regular block-value; never returned' |
|
623 | 2211 |
] valueWithExit |
2212 |
" |
|
1211 | 2213 |
|
2214 |
"Modified: 18.4.1996 / 13:51:38 / cg" |
|
623 | 2215 |
! |
2216 |
||
5215 | 2217 |
valueWithRestart |
2218 |
|myContext restartAction| |
|
2219 |
||
2220 |
myContext := thisContext. |
|
2221 |
restartAction := [ myContext restart ]. |
|
2222 |
^ self value:restartAction. |
|
2223 |
||
2224 |
" |
|
2225 |
[:restart | |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2226 |
(self confirm:'try again ?') ifTrue:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2227 |
restart value. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2228 |
] |
5215 | 2229 |
] valueWithRestart |
2230 |
" |
|
2231 |
||
2232 |
"Modified: / 25.1.2000 / 21:47:50 / cg" |
|
2233 |
! |
|
2234 |
||
623 | 2235 |
whileFalse |
2236 |
"evaluate the receiver while it evaluates to false (ST80 compatibility)" |
|
2237 |
||
2238 |
"this implementation is for purists ... :-)" |
|
2239 |
||
2240 |
self value ifTrue:[^ nil]. |
|
2241 |
thisContext restart |
|
2242 |
||
2243 |
" |
|
2244 |
|n| |
|
2245 |
||
2246 |
n := 1. |
|
8602 | 2247 |
[n printCR. (n := n + 1) > 10] whileFalse |
67 | 2248 |
" |
2249 |
! |
|
1 | 2250 |
|
67 | 2251 |
whileFalse:aBlock |
2252 |
"evaluate the argument, aBlock while the receiver evaluates to false. |
|
2253 |
- usually open coded by compilers, but needed here for #perform |
|
2254 |
and expression evaluation." |
|
2255 |
||
154 | 2256 |
"this implementation is for purists ... :-)" |
2257 |
||
67 | 2258 |
self value ifTrue:[^ nil]. |
2259 |
aBlock value. |
|
2260 |
thisContext restart |
|
2261 |
||
2262 |
" |
|
2263 |
|n| |
|
2264 |
||
2265 |
n := 1. |
|
2266 |
[n > 10] whileFalse:[ |
|
8602 | 2267 |
n printCR. |
2268 |
n := n + 1 |
|
67 | 2269 |
] |
2270 |
" |
|
1 | 2271 |
! |
2272 |
||
2273 |
whileTrue |
|
67 | 2274 |
"evaluate the receiver while it evaluates to true (ST80 compatibility)" |
1 | 2275 |
|
154 | 2276 |
"this implementation is for purists ... :-)" |
2277 |
||
67 | 2278 |
self value ifFalse:[^ nil]. |
2279 |
thisContext restart |
|
1 | 2280 |
|
67 | 2281 |
" |
2282 |
|n| |
|
1 | 2283 |
|
67 | 2284 |
n := 1. |
8602 | 2285 |
[n printCR. (n := n + 1) <= 10] whileTrue |
67 | 2286 |
" |
1 | 2287 |
! |
2288 |
||
623 | 2289 |
whileTrue:aBlock |
2290 |
"evaluate the argument, aBlock while the receiver evaluates to true. |
|
2291 |
- usually open coded by compilers, but needed here for #perform |
|
2292 |
and expression evaluation." |
|
1 | 2293 |
|
154 | 2294 |
"this implementation is for purists ... :-)" |
2295 |
||
623 | 2296 |
self value ifFalse:[^ nil]. |
2297 |
aBlock value. |
|
67 | 2298 |
thisContext restart |
2299 |
||
2300 |
" |
|
2301 |
|n| |
|
1 | 2302 |
|
67 | 2303 |
n := 1. |
623 | 2304 |
[n <= 10] whileTrue:[ |
8602 | 2305 |
n printCR. |
2306 |
n := n + 1 |
|
623 | 2307 |
] |
68 | 2308 |
" |
67 | 2309 |
! ! |
2310 |
||
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2311 |
!Block methodsFor:'parallel evaluation'! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2312 |
|
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2313 |
futureValue |
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2314 |
"Fork a synchronised evaluation of myself. |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2315 |
Starts the evaluation in parallel now, but synchronizes |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2316 |
any access to wait until the result is computed." |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2317 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2318 |
^ Future new block:self |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2319 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2320 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2321 |
futureValue:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2322 |
"Fork a synchronised evaluation of myself. |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2323 |
Starts the evaluation in parallel now, but synchronizes |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2324 |
any access to wait until the result is computed." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2325 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2326 |
^ Future new block:self value:aValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2327 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2328 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2329 |
futureValue:aValue value:anotherValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2330 |
"Fork a synchronised evaluation of myself. |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2331 |
Starts the evaluation in parallel now, but synchronizes |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2332 |
any access to wait until the result is computed." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2333 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2334 |
^ Future new |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2335 |
block:self |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2336 |
value:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2337 |
value:anotherValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2338 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2339 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2340 |
futureValue:aValue value:anotherValue value:bValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2341 |
"Fork a synchronised evaluation of myself. |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2342 |
Starts the evaluation in parallel now, but synchronizes |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2343 |
any access to wait until the result is computed." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2344 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2345 |
^ Future new |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2346 |
block:self |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2347 |
value:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2348 |
value:anotherValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2349 |
value:bValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2350 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2351 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2352 |
futureValueWithArguments:anArray |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2353 |
"Fork a synchronised evaluation of myself. |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2354 |
Starts the evaluation in parallel now, but synchronizes |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2355 |
any access to wait until the result is computed." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2356 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2357 |
^ Future new block:self valueWithArguments:anArray |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2358 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2359 |
|
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2360 |
lazyValue |
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2361 |
"Fork a synchronised evaluation of myself. Only starts |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2362 |
the evaluation when the result is requested." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2363 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2364 |
^ Lazy new block:self |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2365 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2366 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2367 |
lazyValue:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2368 |
"Fork a synchronised evaluation of myself. Only starts |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2369 |
the evaluation when the result is requested." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2370 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2371 |
^ Lazy new block:self value:aValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2372 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2373 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2374 |
lazyValue:aValue value:anotherValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2375 |
"Fork a synchronised evaluation of myself. Only starts |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2376 |
the evaluation when the result is requested." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2377 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2378 |
^ Lazy new |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2379 |
block:self |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2380 |
value:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2381 |
value:anotherValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2382 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2383 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2384 |
lazyValue:aValue value:anotherValue value:bValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2385 |
"Fork a synchronised evaluation of myself. Only starts |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2386 |
the evaluation when the result is requested." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2387 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2388 |
^ Lazy new |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2389 |
block:self |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2390 |
value:aValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2391 |
value:anotherValue |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2392 |
value:bValue |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2393 |
! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2394 |
|
8708
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2395 |
lazyValueWithArguments:anArray |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2396 |
"Fork a synchronised evaluation of myself. Only starts |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2397 |
the evaluation when the result is requested." |
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2398 |
|
fd7eba3420e1
Dolphin compat: #deferredValue is the same as #futureValue
Stefan Vogel <sv@exept.de>
parents:
8682
diff
changeset
|
2399 |
^ Lazy new block:self valueWithArguments:anArray |
7660
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2400 |
! ! |
1f3792fd3d37
lazy and future value moved to libbasic.
Claus Gittinger <cg@exept.de>
parents:
7602
diff
changeset
|
2401 |
|
92 | 2402 |
!Block methodsFor:'printing & storing'! |
1 | 2403 |
|
7151 | 2404 |
printBlockBracketsOn:aStream |
2405 |
aStream nextPutAll:'[]'. |
|
2406 |
! |
|
2407 |
||
1 | 2408 |
printOn:aStream |
44 | 2409 |
"append a a printed representation of the block to aStream" |
2410 |
||
6633 | 2411 |
|h sel methodClass| |
54 | 2412 |
|
2413 |
"cheap blocks have no home context, but a method instead" |
|
2414 |
||
2415 |
(home isNil or:[home isContext not]) ifTrue:[ |
|
6633 | 2416 |
aStream nextPutAll:'[] in '. |
1 | 2417 |
|
6633 | 2418 |
" |
2419 |
currently, some cheap blocks don't know where they have been created |
|
2420 |
" |
|
2421 |
aStream nextPutAll:' ??? (optimized)'. |
|
2422 |
^ self |
|
54 | 2423 |
]. |
2424 |
||
2425 |
"a full blown block (with home, but without method)" |
|
7151 | 2426 |
self printBlockBracketsOn:aStream. |
2427 |
aStream nextPutAll:' in '. |
|
154 | 2428 |
h := self methodHome. |
2429 |
sel := h selector. |
|
2430 |
"/ old: |
|
2431 |
"/ home receiver class name printOn:aStream. |
|
2432 |
"/ new: |
|
212 | 2433 |
"/ (h searchClass whichClassImplements:sel) name printOn:aStream. |
213 | 2434 |
methodClass := h methodClass. |
2435 |
methodClass isNil ifTrue:[ |
|
6633 | 2436 |
'UnboundMethod' printOn:aStream. |
213 | 2437 |
] ifFalse:[ |
6633 | 2438 |
methodClass name printOn:aStream. |
213 | 2439 |
]. |
7157
935eaabbe6dc
printString now "... in className >> sel"
Claus Gittinger <cg@exept.de>
parents:
7151
diff
changeset
|
2440 |
aStream nextPutAll:'>>'. |
154 | 2441 |
sel printOn:aStream. |
54 | 2442 |
|
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2443 |
"/ |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2444 |
"/ aStream nextPutAll:'[] in '. |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2445 |
"/ homeClass := home containingClass. |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2446 |
"/ 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
|
2447 |
"/ 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
|
2448 |
"/ aStream space. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2449 |
"/ (homeClass selectorForMethod:home) printOn:aStream |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2450 |
"/ ] ifFalse:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2451 |
"/ aStream nextPutAll:' ???' |
2841
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2452 |
"/ ] |
d3cab7c7d334
allow non-array in valueWithArguments
Claus Gittinger <cg@exept.de>
parents:
2828
diff
changeset
|
2453 |
"/ |
9253 | 2454 |
! |
2455 |
||
2456 |
storeOn:aStream |
|
9287 | 2457 |
self error:'Blocks cannot be stored (yet)' mayProceed:true. |
2458 |
self printOn:aStream. |
|
1 | 2459 |
! ! |
623 | 2460 |
|
7257 | 2461 |
!Block methodsFor:'private-accessing'! |
623 | 2462 |
|
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
2463 |
byteCode:bCode numArgs:numArgs numVars:numVars numStack:numStack sourcePosition:srcPos initialPC:iPC literals:lits |
1265 | 2464 |
"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
|
2465 |
DANGER ALERT: this interface is strictly private." |
623 | 2466 |
|
2467 |
byteCode := bCode. |
|
2468 |
nargs := numArgs. |
|
2469 |
sourcePos := srcPos. |
|
2470 |
initialPC := iPC. |
|
1777 | 2471 |
flags := 0. |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
2472 |
self stackSize:numStack. |
1493
33e226c7d187
Move method's literals form literalArray to indexed instvars.
Stefan Vogel <sv@exept.de>
parents:
1422
diff
changeset
|
2473 |
self literals:lits. |
5766
64d22218e98b
must ensure that nArgs and nVar flag setting is correct
Claus Gittinger <cg@exept.de>
parents:
5744
diff
changeset
|
2474 |
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
|
2475 |
self numberOfVars:numVars. "/ must set the compiledCode flags as well |
1265 | 2476 |
|
2477 |
"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
|
2478 |
"Modified: 24.6.1996 / 12:37:37 / stefan" |
2542
555749f035f4
need stackSize when creating blocks.
Claus Gittinger <cg@exept.de>
parents:
2301
diff
changeset
|
2479 |
"Created: 13.4.1997 / 00:00:57 / cg" |
623 | 2480 |
! |
2481 |
||
5779 | 2482 |
initialPC |
2483 |
"return the initial pc for evaluation." |
|
2484 |
||
2485 |
^ initialPC |
|
2486 |
! |
|
2487 |
||
623 | 2488 |
initialPC:initial |
1265 | 2489 |
"set the initial pc for evaluation. |
2490 |
DANGER ALERT: this interface is for the compiler only." |
|
623 | 2491 |
|
2492 |
initialPC := initial |
|
1265 | 2493 |
|
2494 |
"Modified: 23.4.1996 / 16:05:39 / cg" |
|
623 | 2495 |
! |
2496 |
||
2497 |
numArgs:numArgs |
|
1265 | 2498 |
"set the number of arguments the receiver expects for evaluation. |
2499 |
DANGER ALERT: this interface is for the compiler only." |
|
623 | 2500 |
|
2501 |
nargs := numArgs |
|
1265 | 2502 |
|
2503 |
"Modified: 23.4.1996 / 16:05:52 / cg" |
|
623 | 2504 |
! |
2505 |
||
5744 | 2506 |
setHome:aContext |
2507 |
home := aContext |
|
2508 |
! |
|
2509 |
||
7323 | 2510 |
source |
2511 |
|m| |
|
2512 |
||
2513 |
sourcePos isString ifTrue:[ "/ misuses the sourcePosition slot |
|
2514 |
^ sourcePos |
|
2515 |
]. |
|
2516 |
m := self method. |
|
2517 |
m notNil ifTrue:[ |
|
2518 |
^ m source |
|
2519 |
]. |
|
2520 |
^ nil |
|
2521 |
! |
|
2522 |
||
6981 | 2523 |
source:aString |
2524 |
"set the source - only to be used, if the block is not contained in a method. |
|
2525 |
This interface is for knowledgable users only." |
|
2526 |
||
2527 |
sourcePos := aString "/ misuse the sourcePosition slot |
|
2528 |
! |
|
2529 |
||
623 | 2530 |
sourcePosition:position |
1265 | 2531 |
"set the position of the source within my method. |
2532 |
This interface is for the compiler only." |
|
623 | 2533 |
|
2534 |
sourcePos := position |
|
1265 | 2535 |
|
2536 |
"Modified: 23.4.1996 / 16:06:19 / cg" |
|
623 | 2537 |
! ! |
2538 |
||
2539 |
!Block methodsFor:'privileged evaluation'! |
|
2540 |
||
2541 |
valueUninterruptably |
|
2542 |
"evaluate the receiver with interrupts blocked. |
|
2543 |
This does not prevent preemption by a higher priority processes |
|
2544 |
if any becomes runnable due to the evaluation of the receiver |
|
2545 |
(i.e. if a semaphore is signalled)." |
|
2546 |
||
2301 | 2547 |
"we must keep track of blocking-state if this is called nested" |
2548 |
(OperatingSystem blockInterrupts) ifTrue:[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2549 |
"/ already blocked. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2550 |
^ self value |
2301 | 2551 |
]. |
864 | 2552 |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2553 |
^ self ensure:[OperatingSystem unblockInterrupts]. |
623 | 2554 |
! |
2555 |
||
2556 |
valueUnpreemptively |
|
2557 |
"evaluate the receiver without the possiblity of preemption |
|
2558 |
(i.e. at a very high priority)" |
|
2559 |
||
2560 |
|oldPrio activeProcess| |
|
2561 |
||
2562 |
activeProcess := Processor activeProcess. |
|
2563 |
oldPrio := activeProcess changePriority:(Processor highestPriority). |
|
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2564 |
^ self ensure:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2565 |
activeProcess priority:oldPrio |
623 | 2566 |
] |
2567 |
! ! |
|
2568 |
||
2569 |
!Block methodsFor:'process creation'! |
|
2570 |
||
2571 |
fork |
|
2572 |
"create a new process executing the receiver at the current priority." |
|
2573 |
||
2574 |
^ self newProcess resume |
|
2575 |
! |
|
2576 |
||
2577 |
forkAt:priority |
|
2578 |
"create a new process executing the receiver at a different priority." |
|
2579 |
||
2580 |
^ (self newProcess priority:priority) resume |
|
2581 |
! |
|
2582 |
||
6609 | 2583 |
forkNamed:aString |
2584 |
"create a new process, give it a name and let it start |
|
2585 |
executing the receiver at the current priority." |
|
2586 |
||
2587 |
|newProcess| |
|
2588 |
||
2589 |
newProcess := self newProcess. |
|
2590 |
newProcess name:aString. |
|
2591 |
newProcess resume. |
|
2592 |
^ newProcess. |
|
2593 |
! |
|
2594 |
||
623 | 2595 |
forkWith:argArray |
2596 |
"create a new process executing the receiver, |
|
2597 |
passing elements in argArray as arguments to the receiver block." |
|
2598 |
||
2599 |
^ [self valueWithArguments:argArray] fork. |
|
2600 |
! |
|
2601 |
||
2602 |
newProcess |
|
2603 |
"create a new (unscheduled) process executing the receiver" |
|
2604 |
||
2605 |
^ Process for:self priority:(Processor activePriority) |
|
2606 |
! |
|
2607 |
||
2608 |
newProcessWithArguments:argArray |
|
2609 |
"create a new (unscheduled) process executing the receiver, |
|
2610 |
passing the elements in argArray as arguments to the receiver block." |
|
2611 |
||
2612 |
^ [self valueWithArguments:argArray] newProcess |
|
2613 |
! |
|
2614 |
||
2615 |
promise |
|
2616 |
"create a promise on the receiver. The promise will evaluate the |
|
2617 |
receiver and promise to return the value with the #value message. |
|
2618 |
The evaluation will be performed as a separate process. |
|
2619 |
Asking the promise for its value will either block the asking process |
|
2620 |
(if the evaluation has not yet been finished) or return the value |
|
2621 |
immediately." |
|
2622 |
||
2623 |
^ Promise value:self |
|
2624 |
||
2625 |
" |
|
2626 |
|p| |
|
2627 |
||
2628 |
p := [1000 factorial] promise. |
|
2629 |
'do something else ...'. |
|
2630 |
p value |
|
2631 |
" |
|
2632 |
! |
|
2633 |
||
2634 |
promiseAt:prio |
|
2635 |
"create a promise on the receiver. The promise will evaluate the |
|
2636 |
receiver and promise to return the value with the #value message. |
|
2637 |
The evaluation will be performed as a separate process running at prio. |
|
2638 |
Asking the promise for its value will either block the asking process |
|
2639 |
(if the evaluation has not yet been finished) or return the value |
|
2640 |
immediately." |
|
2641 |
||
2642 |
^ Promise value:self priority:prio |
|
2643 |
! ! |
|
2644 |
||
2645 |
!Block methodsFor:'testing'! |
|
2646 |
||
2647 |
isBlock |
|
2648 |
"return true, if this is a block - yes I am" |
|
2649 |
||
2650 |
^ true |
|
2237
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2651 |
! |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2652 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2653 |
isVarArgBlock |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2654 |
"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
|
2655 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2656 |
^ false |
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2657 |
|
d54ee88b8106
VarArgBlock as a private subclass
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
2658 |
"Created: 23.1.1997 / 04:59:51 / cg" |
623 | 2659 |
! ! |
2660 |
||
2661 |
!Block methodsFor:'unwinding'! |
|
2662 |
||
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2663 |
unwindHandlerInContext:aContext |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2664 |
"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
|
2665 |
retrieve the handler block. |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2666 |
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
|
2667 |
#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
|
2668 |
methods to be added)" |
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2669 |
|
11338 | 2670 |
|selector| |
2671 |
||
2672 |
selector := aContext selector. |
|
2673 |
selector == #'value:onUnwindDo:' ifTrue:[ |
|
6608 | 2674 |
^ aContext argAt:2 |
4896 | 2675 |
]. |
11338 | 2676 |
selector == #'on:do:ensure:' ifTrue:[ |
2677 |
^ aContext argAt:3 |
|
2678 |
]. |
|
4896 | 2679 |
|
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2680 |
"/ for now, only #valueNowOrOnUnwindDo: |
4896 | 2681 |
"/ or #valueOnUnwindDo: |
5666
de56e39714da
inlined unwind setup into #ensure:
Claus Gittinger <cg@exept.de>
parents:
5349
diff
changeset
|
2682 |
"/ or #ensure: |
6608 | 2683 |
"/ or #ifCurtailed: |
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2684 |
|
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2685 |
^ aContext argAt:1 |
6257
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2686 |
! ! |
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2687 |
|
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2688 |
!Block methodsFor:'unwinding-old'! |
4479
6915eb8eeeff
added query for unwindHandler (like contexts ask for handler)
Claus Gittinger <cg@exept.de>
parents:
4476
diff
changeset
|
2689 |
|
4896 | 2690 |
value:arg onUnwindDo:aBlock |
2691 |
"evaluate the receiver, passing it one argument |
|
2692 |
- when some method sent within unwinds (i.e. does |
|
2693 |
a long return), evaluate the argument, aBlock. |
|
2694 |
This is used to make certain that cleanup actions (for example closing files etc.) are |
|
2695 |
executed regardless of error actions" |
|
2696 |
||
2697 |
<exception: #unwind> |
|
2698 |
||
2699 |
|v| |
|
2700 |
||
2701 |
"/ thisContext markForUnwind. -- same as above pragma |
|
2702 |
v := self value:arg. "the real logic is in Context>>unwind" |
|
2703 |
thisContext unmarkForUnwind. |
|
2704 |
^ v |
|
2705 |
||
2706 |
" |
|
2707 |
|s| |
|
2708 |
||
2709 |
s := 'Makefile' asFilename readStream. |
|
2710 |
[:arg | |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2711 |
^ self |
4896 | 2712 |
] 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
|
2713 |
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
|
2714 |
s close |
4896 | 2715 |
] |
2716 |
" |
|
2717 |
" |
|
2718 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2719 |
|s| |
4896 | 2720 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2721 |
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
|
2722 |
[:arg | |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2723 |
Processor activeProcess terminate |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2724 |
] value:12345 onUnwindDo:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2725 |
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
|
2726 |
s close |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2727 |
] |
4896 | 2728 |
] fork |
2729 |
" |
|
2730 |
||
2731 |
! |
|
2732 |
||
623 | 2733 |
valueNowOrOnUnwindDo:aBlock |
2734 |
"evaluate the receiver - after that, or when some method sent within unwinds (i.e. does |
|
2735 |
a long return), evaluate the argument, aBlock. |
|
2736 |
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
|
2737 |
executed regardless of error actions. |
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2738 |
Same as the more modern #ensure:" |
623 | 2739 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2740 |
<exception: #unwind> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2741 |
|
623 | 2742 |
|v| |
2743 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2744 |
"/ thisContext markForUnwind. -- same as above pragma |
623 | 2745 |
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
|
2746 |
thisContext unmarkForUnwind. |
623 | 2747 |
aBlock value. |
2748 |
^ v |
|
2749 |
||
2750 |
" |
|
2751 |
in the following example, f will be closed even if the block |
|
2752 |
returns with 'oops'. There are many more applications of this kind |
|
2753 |
found in the system. |
|
2754 |
" |
|
2755 |
" |
|
2756 |
|f| |
|
2757 |
||
2758 |
f := 'Makefile' asFilename readStream. |
|
2759 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2760 |
l := f nextLine. |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2761 |
l isNil ifTrue:[^ 'oops'] |
623 | 2762 |
] valueNowOrOnUnwindDo:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2763 |
f close |
623 | 2764 |
] |
2765 |
" |
|
1187
619ff79bc665
valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents:
1181
diff
changeset
|
2766 |
|
619ff79bc665
valueNowOrOnUnwindDo: don't execute unwind block when block is currently executed 'now'.
Stefan Vogel <sv@exept.de>
parents:
1181
diff
changeset
|
2767 |
"Modified: 16.4.1996 / 11:05:26 / stefan" |
623 | 2768 |
! |
2769 |
||
2770 |
valueOnUnwindDo:aBlock |
|
2771 |
"evaluate the receiver - when some method sent within unwinds (i.e. does |
|
2772 |
a long return), evaluate the argument, aBlock. |
|
2773 |
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
|
2774 |
executed regardless of error actions |
f77941a61a12
Fix comments. Use #ensure: instead of #valueNowOrOnUnwindDo:
Stefan Vogel <sv@exept.de>
parents:
6236
diff
changeset
|
2775 |
Same as the more modern #ifCurtailed:" |
623 | 2776 |
|
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2777 |
<exception: #unwind> |
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2778 |
|
2286 | 2779 |
|v| |
2780 |
||
4491
5041cae5651c
use new pragma to flag exception frames.
Claus Gittinger <cg@exept.de>
parents:
4479
diff
changeset
|
2781 |
"/ thisContext markForUnwind. -- same as above pragma |
2286 | 2782 |
v := self value. "the real logic is in Context>>unwind" |
2783 |
thisContext unmarkForUnwind. |
|
2784 |
^ v |
|
2785 |
||
4896 | 2786 |
" |
2787 |
|s| |
|
2788 |
||
2789 |
s := 'Makefile' asFilename readStream. |
|
2790 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2791 |
^ self |
4896 | 2792 |
] valueOnUnwindDo:[ |
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2793 |
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
|
2794 |
s close |
4896 | 2795 |
] |
2796 |
" |
|
2797 |
" |
|
2798 |
[ |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2799 |
|s| |
4896 | 2800 |
|
6498
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2801 |
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
|
2802 |
[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2803 |
Processor activeProcess terminate |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2804 |
] valueOnUnwindDo:[ |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2805 |
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
|
2806 |
s close |
3db82d6e6146
use arrayVal macro; slightly shorter code for value (switch on MKSMALLINT)
Claus Gittinger <cg@exept.de>
parents:
6320
diff
changeset
|
2807 |
] |
4896 | 2808 |
] fork |
2809 |
" |
|
623 | 2810 |
! ! |
2811 |
||
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2812 |
!Block methodsFor:'visiting'! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2813 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2814 |
acceptVisitor:aVisitor with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2815 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2816 |
^ aVisitor visitBlock:self with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2817 |
! ! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8009
diff
changeset
|
2818 |
|
1773
442d1b73ecb9
no longer allow Blocks with a dynamic-bit to be created
Claus Gittinger <cg@exept.de>
parents:
1672
diff
changeset
|
2819 |
!Block class methodsFor:'documentation'! |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2820 |
|
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2821 |
version |
11638
20a63a6bf2fb
changed #handlerForSignal:context:originator:
Stefan Vogel <sv@exept.de>
parents:
11603
diff
changeset
|
2822 |
^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.164 2009-03-17 16:22:03 stefan Exp $' |
1181
6637fee79d7b
only Block & CheapBlock are fixed - subclasses may look different
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
2823 |
! ! |
6785 | 2824 |
|
623 | 2825 |
Block initialize! |