author | Jan Vrany <jan.vrany@labware.com> |
Mon, 15 Jun 2020 11:33:35 +0100 | |
branch | jv |
changeset 25392 | c52eeea62763 |
parent 23107 | 40173e082cbc |
child 25395 | b5d6963fe4a9 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
23107 | 3 |
COPYRIGHT (c) 2009-2011 Jan Vrany |
4 |
COPYRIGHT (c) 2015-2017 Jan Vrany |
|
25392
c52eeea62763
Fix `Context >> argAndVarNames` in cases when debug info is not available
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
5 |
COPYRIGHT (c) 2020 LabWare |
15933 | 6 |
All Rights Reserved |
1 | 7 |
|
8 |
This software is furnished under a license and may be used |
|
9 |
only in accordance with the terms of that license and with the |
|
10 |
inclusion of the above copyright notice. This software may not |
|
11 |
be provided or otherwise made available to, or used by, any |
|
12853
3d15dcbe0057
added method-in-context slot.
Claus Gittinger <cg@exept.de>
parents:
12841
diff
changeset
|
12 |
other person. No t itle to or ownership of the software is |
1 | 13 |
hereby transferred. |
14 |
" |
|
5422 | 15 |
"{ Package: 'stx:libbasic' }" |
16 |
||
17304 | 17 |
"{ NameSpace: Smalltalk }" |
18 |
||
1 | 19 |
Object variableSubclass:#Context |
13020 | 20 |
instanceVariableNames:'flags sender* home receiver selector searchClass method lineNr |
21 |
retvalTemp handle*' |
|
15659 | 22 |
classVariableNames:'SingleStepInterruptRequest' |
13020 | 23 |
poolDictionaries:'' |
24 |
category:'Kernel-Methods' |
|
1 | 25 |
! |
26 |
||
1810 | 27 |
!Context class methodsFor:'documentation'! |
54 | 28 |
|
88 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
23107 | 32 |
COPYRIGHT (c) 2009-2011 Jan Vrany |
33 |
COPYRIGHT (c) 2015-2017 Jan Vrany |
|
25392
c52eeea62763
Fix `Context >> argAndVarNames` in cases when debug info is not available
Jan Vrany <jan.vrany@labware.com>
parents:
23107
diff
changeset
|
34 |
COPYRIGHT (c) 2020 LabWare |
15933 | 35 |
All Rights Reserved |
88 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
12841 | 41 |
other person. No t itle to or ownership of the software is |
88 | 42 |
hereby transferred. |
43 |
" |
|
44 |
! |
|
45 |
||
54 | 46 |
documentation |
47 |
" |
|
402 | 48 |
Contexts represent the stack frame objects, which keep the processing |
49 |
state of a method or block (i.e. its local variables, temporaries etc.) |
|
12841 | 50 |
Every message send adds a context to a chain, which can be traced back via |
402 | 51 |
the sender field. The context of the currently active method is always |
19110 | 52 |
accessible via the pseuodoVariable called 'thisContext'. |
15688 | 53 |
The actual implementation uses the machines stack for this, building real |
54 |
contexts on demand only, whenever a contexts is needed. Also, initially these are |
|
55 |
allocated on the stack and only moved to the heap, when a context outlives its |
|
56 |
activation. |
|
54 | 57 |
|
12841 | 58 |
For both method- and block-contexts, the layout is the same. |
402 | 59 |
For method contexts, the home-field is nil, while for block contexts the home- |
141 | 60 |
field is either the context of its surrounding block (i.e. the context of the |
61 |
block, in which the receiving block was created, if its a nested block) or of |
|
12841 | 62 |
its home method. |
63 |
||
15688 | 64 |
Cheap blocks are blocks which do not refer to any locals or the receiver (currently), |
65 |
but only access globals, class vars or arguments (for example: [:a :b | a < b] is a cheap block). |
|
66 |
Cheap blocks do not need a home and therefore never require that their home context be moved |
|
67 |
to the heap. Contexts of cheap blocks do not have a home context - their home field is also nil. |
|
141 | 68 |
|
402 | 69 |
LineNumbers vs. program counter: |
70 |
||
71 |
Due to the compilation to machine code, methods and/or block do not |
|
216 | 72 |
always (actually: do seldom) contain bytecodes. Thus, there is no such concept |
73 |
as a bytecode p-counter. To support debugging, the linenumber within the |
|
74 |
original source is instead remembered when a send or loop entry is performed. |
|
75 |
Since linenumbers are not always sufficient for debugging (multiple sends in one |
|
402 | 76 |
line), this may be changed in future versions to a character offset, giving |
216 | 77 |
the position of the selector in the source. |
1 | 78 |
|
402 | 79 |
Restartable / Returnable contexts: |
80 |
||
81 |
In previous versions (up to ST/X 2.10.5), every method stored enough |
|
82 |
information in the context for that one to be restartable later (for example, |
|
15688 | 83 |
via the debugger's restart button). As stc is supposed to generate portable C-code, |
84 |
this means that technically, a setjmp needs to be done at the beginning of the method |
|
85 |
in order to have a resumable (and portable) state (however, inline asm code does this setjmp, |
|
86 |
so it is much faster than the libc-setjmo, which stores a lot of additional state, not needed here). |
|
15933 | 87 |
With 2.10.6, this is now an stc-compiler option, and the system as delivered is compiled |
15688 | 88 |
to only create restartable contexts for those which contain blocks or are marked as special |
15933 | 89 |
via a directive. |
90 |
This resulted in an overall speedup of roughly 10-20% percent, depending on the type of CPU. |
|
91 |
However, it makes most methods non-restartable (however, abort, signal handling and unwind blocks |
|
15688 | 92 |
work as usual). |
402 | 93 |
In practice, this was reported to be not a severe limitation and all users were happy |
94 |
to trade the increased performance for that slight inconvenience. |
|
95 |
(during development, this is seldom a problem, since interpreted methods are always |
|
96 |
returnable and restartable) |
|
15688 | 97 |
If you do not like this, you should recompile all classes with stc's '-optContext' flag. |
402 | 98 |
|
99 |
Resuming contexts: |
|
100 |
||
15688 | 101 |
Strictly speaking, ST/X does not support a context to be resumed (because the setjmp is |
15933 | 102 |
not done on the caller side, but in the callee). |
15688 | 103 |
However, it does support a forced return (i.e. non-local-return) from a context. |
402 | 104 |
Thus, resume of a context is implemented by forcing a return from the context |
105 |
which was created by the method called from the first one. The effect is the same. |
|
106 |
||
107 |
Returning from a dead method: |
|
108 |
||
15688 | 109 |
Block-return from an outlived context (i.e. its home method has already returned) |
402 | 110 |
is now rewarded by an invalidReturn exception - it used to be a noop in previous |
15688 | 111 |
releases. The blue book described this to be a noop, but other Smalltalk implementations |
112 |
changed this to be an invalid operation - a good decision, as it makes debugging much easier. |
|
402 | 113 |
|
114 |
||
1282 | 115 |
[instance variables:] |
19110 | 116 |
flags <SmallInteger> used by the VM; never touch. |
117 |
contains info about number of args, |
|
118 |
locals and temporaries. |
|
119 |
||
120 |
sender <Context> the 'calling / sending' context |
|
121 |
This is not directly accessible, since it may |
|
122 |
be a lazy context (i.e. an empty frame). |
|
123 |
The #sender method cares for this. |
|
124 |
||
125 |
home <Context> the context, where this block was |
|
126 |
created, or nil if its a method context |
|
127 |
There are also cheap blocks, which do |
|
128 |
not need a reference to the home context, |
|
129 |
for those, its nil too. |
|
130 |
||
131 |
receiver <Object> the receiver of this message |
|
132 |
||
133 |
selector <Symbol> the selector of this message |
|
134 |
||
135 |
searchClass <Class> the class, where the message lookup started |
|
136 |
(for super sends) or nil, for regular sends. |
|
137 |
||
138 |
lineNr <SmallInteger> the position where the context left off |
|
139 |
(kind of p-counter). Only the low 16bits |
|
140 |
are valid. |
|
141 |
||
142 |
retValTemp nil temporary - always nil, when you see the context |
|
143 |
(used in the VM as temporary) |
|
144 |
||
145 |
handle *noObject* used by the VM; not accessible, not an object |
|
146 |
||
147 |
method the corresponding method |
|
148 |
||
149 |
<indexed> arguments of the send followed by |
|
150 |
locals of the method/block followed by |
|
151 |
temporaries. |
|
1 | 152 |
|
6003 | 153 |
[errors:] |
19110 | 154 |
CannotReturnError raised when a block tries |
155 |
to return ('^') from a method context |
|
156 |
which itself has already returned |
|
157 |
(i.e. there is no place to return to) |
|
12841 | 158 |
|
69 | 159 |
WARNING: layout and size known by the compiler and runtime system - do not change. |
1282 | 160 |
|
1293 | 161 |
|
162 |
[author:] |
|
19110 | 163 |
Claus Gittinger |
1293 | 164 |
|
1282 | 165 |
[see also:] |
19110 | 166 |
Block Process Method |
167 |
( contexts, stacks & unwinding : programming/contexts.html) |
|
54 | 168 |
" |
169 |
! ! |
|
1 | 170 |
|
1810 | 171 |
!Context class methodsFor:'initialization'! |
105 | 172 |
|
173 |
initialize |
|
6000 | 174 |
CannotReturnError notifierString:'invalid return; method cannot return twice'. |
175 |
CannotResumeError notifierString:'invalid resume'. |
|
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
176 |
|
6000 | 177 |
SingleStepInterruptRequest isNil ifTrue:[ |
15933 | 178 |
SingleStepInterruptRequest := QuerySignal new. |
179 |
SingleStepInterruptRequest nameClass:self message:#singleStepInterruptRequest. |
|
180 |
SingleStepInterruptRequest notifierString:'single step'. |
|
105 | 181 |
] |
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
182 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
183 |
"Modified: 6.5.1996 / 16:46:03 / cg" |
105 | 184 |
! ! |
185 |
||
1810 | 186 |
!Context class methodsFor:'Signal constants'! |
105 | 187 |
|
6000 | 188 |
cannotResumeSignal |
189 |
"return the signal used when a method is tried to be resumed, which cannot" |
|
190 |
||
191 |
^ CannotResumeError |
|
192 |
! |
|
193 |
||
194 |
cannotReturnSignal |
|
195 |
"return the signal used when a method is tried to be returned twice |
|
196 |
or, when some dead context is unwound or restarted." |
|
197 |
||
198 |
^ CannotReturnError |
|
199 |
! |
|
200 |
||
105 | 201 |
invalidReturnSignal |
141 | 202 |
"return the signal used when a method is tried to be returned twice |
203 |
or, when some dead context is unwound or restarted." |
|
204 |
||
8357 | 205 |
<resource: #obsolete> |
6000 | 206 |
self obsoleteMethodWarning:'use #cannotReturnSignal'. |
207 |
^ self cannotReturnSignal. |
|
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
208 |
! |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
209 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
210 |
singleStepInterruptRequest |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
211 |
"return the dummy query signal to ask for single stepping" |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
212 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
213 |
^ SingleStepInterruptRequest |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
214 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
215 |
"Created: 6.5.1996 / 16:46:32 / cg" |
105 | 216 |
! ! |
217 |
||
11473 | 218 |
!Context class methodsFor:'error handling'! |
219 |
||
220 |
showWhereWeCameFrom |
|
12841 | 221 |
"show the stack backtrace: at least 4 levels, or until the first |
11473 | 222 |
send to a non-collection object (because we want to know, |
223 |
which non-collection send invoked a bad collection-method)." |
|
224 |
||
225 |
|con count| |
|
226 |
||
227 |
con := thisContext sender sender. |
|
228 |
count := 0. |
|
229 |
[ |
|
15933 | 230 |
(' from ' , con printString) errorPrintCR. |
231 |
con := con sender. |
|
232 |
count := count + 1. |
|
11631 | 233 |
] doWhile:[con notNil and:[count < 5 or:[con receiver isCollection]]]. |
234 |
"/ one more |
|
235 |
con notNil ifTrue:[ |
|
15933 | 236 |
(' from ' , con printString) errorPrintCR. |
11631 | 237 |
]. |
11473 | 238 |
|
239 |
" |
|
240 |
#() asSet add:nil |
|
241 |
" |
|
242 |
! ! |
|
243 |
||
1810 | 244 |
!Context class methodsFor:'queries'! |
3 | 245 |
|
246 |
isBuiltInClass |
|
1264 | 247 |
"return true if this class is known by the run-time-system. |
248 |
Here, true is returned." |
|
3 | 249 |
|
250 |
^ true |
|
1264 | 251 |
|
252 |
"Modified: 23.4.1996 / 15:58:00 / cg" |
|
3 | 253 |
! ! |
254 |
||
4485 | 255 |
!Context class methodsFor:'special searching'! |
256 |
||
257 |
findFirstSpecialHandle:searchForHandle raise:searchForRaise |
|
258 |
|c| |
|
259 |
||
260 |
%{ |
|
18406 | 261 |
#ifdef __SCHTEAM__ |
262 |
c = __c__.currentContinuation.sender(); |
|
263 |
if (c == null) c = STObject.Nil; |
|
264 |
#else |
|
4485 | 265 |
OBJ __c__; |
266 |
||
267 |
__c__ = __ContextInstPtr(__thisContext)->c_sender; |
|
10537
9ebc87dd0738
Better check for nil sender...
Stefan Vogel <sv@exept.de>
parents:
10136
diff
changeset
|
268 |
if (!__isNonNilObject(__c__)) { |
15933 | 269 |
RETURN(nil) |
10537
9ebc87dd0738
Better check for nil sender...
Stefan Vogel <sv@exept.de>
parents:
10136
diff
changeset
|
270 |
} |
4485 | 271 |
if (__isLazy(__c__)) { |
15933 | 272 |
__PATCHUPCONTEXT(__c__); |
4485 | 273 |
} |
274 |
c = __c__; |
|
18190 | 275 |
#endif |
4485 | 276 |
%}. |
277 |
^ c findSpecialHandle:searchForHandle raise:searchForRaise |
|
278 |
! ! |
|
279 |
||
12573 | 280 |
!Context methodsFor:'Compatibility-Squeak'! |
281 |
||
282 |
longStack |
|
15644 | 283 |
^ self fullPrintAllString |
12573 | 284 |
! ! |
285 |
||
7261 | 286 |
!Context methodsFor:'Compatibility-VW'! |
5983 | 287 |
|
288 |
resumeWith:value |
|
289 |
"same as #resume: - visualWorks compatibility" |
|
290 |
||
291 |
self resume:value |
|
292 |
! ! |
|
293 |
||
623 | 294 |
!Context methodsFor:'accessing'! |
295 |
||
16489 | 296 |
arg1Index |
16544 | 297 |
"return the index of the 1st arg (redefined in JavaContext)" |
298 |
||
299 |
^ 1 |
|
16489 | 300 |
! |
301 |
||
623 | 302 |
argAt:n |
303 |
"return the n'th argument" |
|
304 |
||
18437 | 305 |
n > self argumentCount ifTrue:[ |
306 |
^ self subscriptBoundsError:n. |
|
1726 | 307 |
]. |
623 | 308 |
^ self at:n |
1726 | 309 |
|
310 |
"Modified: 12.10.1996 / 21:44:28 / cg" |
|
623 | 311 |
! |
312 |
||
313 |
argAt:n put:value |
|
314 |
"set the n'th argument - useful when the receiver should be restarted" |
|
154 | 315 |
|
18437 | 316 |
n > self argumentCount ifTrue:[ |
317 |
^ self subscriptBoundsError:n. |
|
1726 | 318 |
]. |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
319 |
self at:n put:value. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
320 |
^ value |
1726 | 321 |
|
322 |
"Modified: 12.10.1996 / 21:44:32 / cg" |
|
623 | 323 |
! |
324 |
||
325 |
args |
|
326 |
"return an array filled with the arguments of this context" |
|
327 |
||
328 |
|n| |
|
329 |
||
18437 | 330 |
n := self argumentCount. |
3130 | 331 |
n == 0 ifTrue:[ |
18437 | 332 |
"/ little optimization here - avaoid creating empty containers |
333 |
^ #() |
|
3130 | 334 |
]. |
623 | 335 |
^ (Array new:n) replaceFrom:1 to:n with:self. |
336 |
! |
|
154 | 337 |
|
623 | 338 |
argsAndVars |
339 |
"return an array filled with the arguments and variables of this context" |
|
340 |
||
341 |
|n| |
|
342 |
||
18437 | 343 |
n := self argumentCount + self numVars. |
3130 | 344 |
n == 0 ifTrue:[ |
18437 | 345 |
"/ little optimization here - avoid creating empty containers |
346 |
^ #() |
|
3130 | 347 |
]. |
623 | 348 |
^ (Array new:n) replaceFrom:1 to:n with:self. |
1810 | 349 |
|
350 |
"Modified: 23.10.1996 / 16:19:41 / cg" |
|
623 | 351 |
! |
154 | 352 |
|
8687
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
353 |
argumentCount |
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
354 |
"ANSI alias for numArgs: return the number of arguments to the Block/Method" |
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
355 |
|
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
356 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
357 |
#ifdef __SCHTEAM__ |
18289 | 358 |
return context._RETURN( STInteger._new( self.asSTContinuation().numStArgs() ) ); |
18190 | 359 |
#else |
8913 | 360 |
RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) ); |
18190 | 361 |
#endif |
8687
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
362 |
%} |
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
363 |
! |
d6e6e2c0c27c
Define #argumentCount as ANSI alias for #numArgs
Stefan Vogel <sv@exept.de>
parents:
8578
diff
changeset
|
364 |
|
7324
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
365 |
at:n put:value |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
366 |
super at:n put:value. |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
367 |
|
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
368 |
"/ need some aid for optimized code - |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
369 |
"/ some machines have the arguments/receiver etc. kept in register vars ... |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
370 |
"/ the unfix updates the machine-stack version of the receiver. |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
371 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
372 |
#ifndef __SCHTEAM__ |
7324
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
373 |
__UNFIXCONTEXT(self, 0); |
18190 | 374 |
#endif |
7324
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
375 |
%}. |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
376 |
^ value |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
377 |
! |
9e145a7ae670
need unfix, when changed via at:put:
Claus Gittinger <cg@exept.de>
parents:
7261
diff
changeset
|
378 |
|
623 | 379 |
home |
380 |
"return the immediate home of the receiver. |
|
381 |
for block contexts, this is the methodcontext, where the block was created, |
|
15688 | 382 |
for nested block contexts, it's the surrounding block's context. |
623 | 383 |
for method-contexts this is nil." |
25 | 384 |
|
623 | 385 |
^ nil "home" |
386 |
! |
|
1 | 387 |
|
3324
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
388 |
homeReceiver |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
389 |
"return the receiver from the context, where the receiver was defined" |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
390 |
|
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
391 |
^ receiver |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
392 |
|
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
393 |
"Created: / 5.3.1998 / 16:18:26 / stefan" |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
394 |
! |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
395 |
|
1 | 396 |
instVarAt:index |
69 | 397 |
"have to catch instVar access to retVal and handle - they are invalid. |
12841 | 398 |
Notice, that one of the next ST/X versions might get some syntactic |
69 | 399 |
extension to get this automatically)." |
1 | 400 |
|
18190 | 401 |
|what| |
402 |
||
403 |
%{ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
404 |
#ifdef __SCHTEAM__ |
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
405 |
{ |
18406 | 406 |
int idx = index.intValue("[instVarAt:]"); |
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
407 |
|
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
408 |
if (idx == I_sender) { |
18406 | 409 |
STContinuation c = self.sender(); |
410 |
if (c == null) { |
|
411 |
return __c__._RETURN_nil(); |
|
412 |
} |
|
413 |
return __c__._RETURN( c ); |
|
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
414 |
} |
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
415 |
if (idx == I_retvalTemp) { |
18406 | 416 |
return __c__._RETURN( Nil ); |
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
417 |
} |
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
418 |
if (idx == I_handle) { |
18406 | 419 |
return __c__._RETURN( Nil ); |
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
420 |
} |
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
421 |
} |
18190 | 422 |
#else |
423 |
if (index == __MKSMALLINT(__SLOT_CONTEXT_SENDER)) { // sender - must be accessed specially |
|
424 |
what = @symbol(sender); |
|
425 |
} else if (index == __MKSMALLINT(__SLOT_CONTEXT_RETVAL)) { // retvalTemp - invisible |
|
426 |
RETURN (nil); |
|
427 |
} else if (index == __MKSMALLINT(__SLOT_CONTEXT_HANDLE)) { // handle to machine stack - invisible |
|
20204
9a24c81d04ff
Context: return value of context's pSelf slot as large integer rather then nil.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19478
diff
changeset
|
428 |
RETURN ( __MKUINT ( (unsigned INT)(__ContextInstPtr(self)->c_pSelf) ) ); |
18190 | 429 |
} |
430 |
#endif |
|
431 |
%}. |
|
18214
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
432 |
what == #sender ifTrue:[ |
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
433 |
^ self sender |
60e1764add21
oops - some bugs introduced by java support code
Claus Gittinger <cg@exept.de>
parents:
18190
diff
changeset
|
434 |
]. |
1 | 435 |
^ super instVarAt:index |
436 |
! |
|
437 |
||
438 |
instVarAt:index put:value |
|
69 | 439 |
"have to catch instVar access to retVal and handle - they are invalid. |
12841 | 440 |
Notice, that one of the next ST/X versions might get some syntactic |
69 | 441 |
extension to get this automatically)." |
1 | 442 |
|
18190 | 443 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
444 |
#ifdef __SCHTEAM__ |
18190 | 445 |
ERROR("unimplemented"); |
446 |
#else |
|
447 |
if (index == __MKSMALLINT(__SLOT_CONTEXT_SENDER)) { // sender - not allowed to change |
|
448 |
RETURN (nil); |
|
449 |
} else if (index == __MKSMALLINT(__SLOT_CONTEXT_RETVAL)) { // retvalTemp - not allowed to change |
|
450 |
RETURN (nil); |
|
451 |
} else if (index == __MKSMALLINT(__SLOT_CONTEXT_HANDLE)) { // handle to machine stack - not allowed to change |
|
452 |
RETURN (nil); |
|
453 |
} |
|
454 |
#endif |
|
455 |
%}. |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
456 |
super instVarAt:index put:value. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
457 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
458 |
"/ need some aid for optimized code - |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
459 |
"/ some machines have the arguments kept in register vars ... |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
460 |
"/ the unfix updates the machine-stack version of the receiver. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
461 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
462 |
#ifndef __SCHTEAM__ |
4570 | 463 |
__UNFIXCONTEXT(self, 0); |
18190 | 464 |
#endif |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
465 |
%}. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
466 |
^ value |
1 | 467 |
! |
468 |
||
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
469 |
javaLineNumber |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
470 |
|nr pc| |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
471 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
472 |
lineNr notNil ifTrue:[ |
15933 | 473 |
pc := lineNr bitAnd:16rFFFF. |
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
474 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
475 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
476 |
"/ 'ask line for pc:' print. pc printCR. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
477 |
pc isNil ifTrue:[ |
15933 | 478 |
nr := self lineNumberFromMethod. |
479 |
nr notNil ifTrue:[ |
|
480 |
^ nr |
|
481 |
]. |
|
482 |
" '-> 0 [a]' printCR. " |
|
483 |
^0 |
|
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
484 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
485 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
486 |
nr := self method lineNumberForPC:pc. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
487 |
nr isNil ifTrue:[ |
15933 | 488 |
nr := self lineNumberFromMethod. |
489 |
nr notNil ifTrue:[ |
|
490 |
^ nr |
|
491 |
]. |
|
492 |
" '-> 0 [b]' printCR. " |
|
493 |
^ 0 |
|
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
494 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
495 |
"/ '-> ' print. nr printCR. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
496 |
^ nr. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
497 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
498 |
! |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
499 |
|
623 | 500 |
lineNumber |
501 |
"this returns the lineNumber within the methods source, where the context was |
|
502 |
interrupted or called another method. (currently, sometimes this information |
|
503 |
is not available - in this case 0 is returned)" |
|
1 | 504 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
505 |
|l| |
3923 | 506 |
|
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
507 |
receiver isJavaObject ifTrue:[ |
19001
b798921e18e4
Improved Contextr>argAndVarNames to better deal with inlined blocks
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18978
diff
changeset
|
508 |
"/ chances are good that I am a javContext ... |
b798921e18e4
Improved Contextr>argAndVarNames to better deal with inlined blocks
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18978
diff
changeset
|
509 |
self method isJavaMethod ifTrue:[ |
b798921e18e4
Improved Contextr>argAndVarNames to better deal with inlined blocks
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18978
diff
changeset
|
510 |
^ self javaLineNumber |
b798921e18e4
Improved Contextr>argAndVarNames to better deal with inlined blocks
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18978
diff
changeset
|
511 |
] |
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
512 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
513 |
|
3923 | 514 |
lineNr notNil ifTrue:[ |
19001
b798921e18e4
Improved Contextr>argAndVarNames to better deal with inlined blocks
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18978
diff
changeset
|
515 |
l := lineNr bitAnd:16rFFFF. |
3923 | 516 |
]. |
517 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
518 |
"/ self isJavaContext ifTrue:[ |nr m| |
3923 | 519 |
"/ m := self method. |
520 |
"/ l isNil ifTrue:[ |
|
521 |
"/ m notNil ifTrue:[ |
|
522 |
"/ nr := m lineNumber |
|
523 |
"/ ]. |
|
524 |
"/ nr notNil ifTrue:[ |
|
525 |
"/ ^ nr |
|
526 |
"/ ]. |
|
527 |
"/ ^0 |
|
528 |
"/ ]. |
|
529 |
"/ nr := self method lineNumberForPC:l. |
|
530 |
"/ nr isNil ifTrue:[ |
|
531 |
"/ m notNil ifTrue:[ |
|
532 |
"/ nr := m lineNumber |
|
533 |
"/ ]. |
|
534 |
"/ nr notNil ifTrue:[ |
|
535 |
"/ ^ nr |
|
536 |
"/ ]. |
|
537 |
"/ ^ 0 |
|
538 |
"/ ]. |
|
539 |
"/ ^ nr. |
|
540 |
"/ ]. |
|
541 |
||
542 |
^ l |
|
543 |
||
544 |
"Modified: / 10.11.1998 / 13:19:48 / cg" |
|
1 | 545 |
! |
546 |
||
4450 | 547 |
lineNumberFromMethod |
548 |
^ 1 |
|
549 |
! |
|
550 |
||
8488 | 551 |
message |
552 |
^ Message selector:selector arguments:self args |
|
553 |
||
554 |
" |
|
9355 | 555 |
thisContext methodHome message |
556 |
thisContext message |
|
8488 | 557 |
" |
558 |
! |
|
559 |
||
15851 | 560 |
messageSend |
561 |
^ MessageSend receiver:receiver selector:selector arguments:self args |
|
562 |
||
563 |
" |
|
564 |
thisContext methodHome messageSend |
|
565 |
thisContext messageSend |
|
566 |
" |
|
567 |
! |
|
568 |
||
1 | 569 |
method |
54 | 570 |
"return the method for which the receiver was created. |
13020 | 571 |
Change with ST/X vsn 6: |
15933 | 572 |
In older versions, the method was not stored in the context, but a lookup |
573 |
was simulated using selector and class. |
|
574 |
(which occasionally returned the wrong method - especially in the debugger, |
|
575 |
when the debugged method was changed). |
|
576 |
This has been changed - especially to support Jan's meta-object protocol. |
|
577 |
It is now stored in the context" |
|
1 | 578 |
|
3508 | 579 |
|c sender sendersSelector m| |
14225 | 580 |
|
581 |
(method notNil and:[method isMethod]) ifTrue:[ |
|
15933 | 582 |
^ method |
14225 | 583 |
]. |
584 |
||
585 |
"mhmh - maybe I am a context for an unbound method (as generated by doIt); |
|
586 |
look in the sender's context. Consider this a kludge. |
|
587 |
Future versions of ST/X's message lookup may store the method in |
|
588 |
the context. |
|
589 |
" |
|
590 |
sender := self sender. |
|
591 |
sender notNil ifTrue:[ |
|
15933 | 592 |
sendersSelector := sender selector. |
593 |
sendersSelector notNil ifTrue:[ |
|
594 |
(sendersSelector startsWith:'valueWithReceiver:') ifTrue:[ |
|
595 |
m := sender receiver. |
|
596 |
m isMethod ifTrue:[ |
|
597 |
method := m. |
|
598 |
^ m |
|
599 |
] |
|
600 |
] |
|
601 |
] |
|
12853
3d15dcbe0057
added method-in-context slot.
Claus Gittinger <cg@exept.de>
parents:
12841
diff
changeset
|
602 |
]. |
12841 | 603 |
|
325 | 604 |
c := self searchClass. |
605 |
" |
|
606 |
the below cannot happen in normal circumstances |
|
607 |
(added to avoid recursive errors in case of a broken sender chain) |
|
608 |
" |
|
609 |
c isBehavior ifFalse:[ |
|
15933 | 610 |
'Context [error]: non class in searchClass' errorPrintCR. |
611 |
' selector: ' errorPrint. selector errorPrint. |
|
612 |
' receiver: ' errorPrint. receiver errorPrintCR. |
|
613 |
^ nil |
|
325 | 614 |
]. |
615 |
||
328 | 616 |
c := c whichClassIncludesSelector:selector. |
1 | 617 |
c notNil ifTrue:[ |
15933 | 618 |
method := c compiledMethodAt:selector. |
619 |
^ method |
|
1 | 620 |
]. |
216 | 621 |
|
1 | 622 |
^ nil |
2135
6bd144c1c358
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1853
diff
changeset
|
623 |
|
13426 | 624 |
"Modified: / 28-06-2011 / 20:23:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
14225 | 625 |
"Modified: / 20-07-2012 / 14:46:37 / cg" |
1 | 626 |
! |
627 |
||
212 | 628 |
methodClass |
629 |
"return the class in which the method for which the receiver was created is." |
|
630 |
||
1456 | 631 |
|cls m| |
632 |
||
12853
3d15dcbe0057
added method-in-context slot.
Claus Gittinger <cg@exept.de>
parents:
12841
diff
changeset
|
633 |
method notNil ifTrue:[ |
15933 | 634 |
method isMethod ifTrue:[ |
635 |
^ method mclass |
|
636 |
] |
|
12853
3d15dcbe0057
added method-in-context slot.
Claus Gittinger <cg@exept.de>
parents:
12841
diff
changeset
|
637 |
]. |
12841 | 638 |
|
1456 | 639 |
cls := self searchClass. |
3923 | 640 |
(cls isMeta |
641 |
and:[cls soleInstance isJavaClass]) ifTrue:[ |
|
15933 | 642 |
cls := cls soleInstance |
3923 | 643 |
]. |
1456 | 644 |
|
3923 | 645 |
[cls notNil] whileTrue:[ |
15933 | 646 |
cls := cls whichClassIncludesSelector:selector. |
647 |
cls isNil ifTrue:[^ nil]. |
|
648 |
||
649 |
m := cls compiledMethodAt:selector. |
|
650 |
m notNil ifTrue:[ |
|
651 |
m isIgnored ifFalse:[^ cls]. |
|
652 |
]. |
|
653 |
cls := cls superclass |
|
1456 | 654 |
]. |
655 |
^ cls |
|
656 |
||
3923 | 657 |
"Modified: / 5.11.1998 / 19:07:43 / cg" |
212 | 658 |
! |
659 |
||
623 | 660 |
methodHome |
661 |
"return the method-home - for method contexts this is the receiver" |
|
662 |
||
663 |
^ self |
|
664 |
! |
|
665 |
||
15091 | 666 |
methodSelector |
667 |
"return the method's (or home method's) selector" |
|
668 |
||
669 |
^ self methodHome selector |
|
670 |
! |
|
671 |
||
623 | 672 |
ntemp |
673 |
"return the number of temporary variables of the Block/Method. |
|
1810 | 674 |
(for debugging only). |
20792 | 675 |
I don't like the name of this method; its here for compatibility." |
623 | 676 |
|
1810 | 677 |
^ self numTemps |
678 |
||
679 |
"Modified: 23.10.1996 / 16:19:06 / cg" |
|
623 | 680 |
! |
681 |
||
682 |
numArgs |
|
683 |
"return the number of arguments to the Block/Method" |
|
684 |
||
685 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
686 |
#ifdef __SCHTEAM__ |
18289 | 687 |
return context._RETURN(STInteger._new(self.asSTContinuation().numStArgs())); |
18190 | 688 |
#else |
8913 | 689 |
RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) ); |
18190 | 690 |
#endif |
623 | 691 |
%} |
692 |
! |
|
693 |
||
1810 | 694 |
numTemps |
695 |
"return the number of temporary variables of the Block/Method. |
|
696 |
(for debugging only)" |
|
697 |
||
18437 | 698 |
^ self size - self argumentCount - self numVars |
1810 | 699 |
|
700 |
"Created: 23.10.1996 / 16:19:10 / cg" |
|
701 |
"Modified: 23.10.1996 / 16:19:48 / cg" |
|
702 |
! |
|
703 |
||
704 |
numVars |
|
623 | 705 |
"return the number of local variables of the Block/Method" |
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
706 |
|
623 | 707 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
708 |
#ifdef __SCHTEAM__ |
18289 | 709 |
return context._RETURN(STInteger._new(self.asSTContinuation().numLocals(context))); |
18190 | 710 |
#else |
8913 | 711 |
RETURN ( __mkSmallInteger( (__intVal(__INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) ); |
18190 | 712 |
#endif |
623 | 713 |
%} |
714 |
! |
|
715 |
||
1810 | 716 |
nvars |
717 |
"return the number of local variables of the Block/Method. |
|
20792 | 718 |
I don't like the name of this method; its here for compatibility." |
1810 | 719 |
|
720 |
^ self numVars |
|
721 |
||
722 |
"Modified: 23.10.1996 / 16:18:44 / cg" |
|
723 |
! |
|
724 |
||
13426 | 725 |
programmingLanguage |
726 |
||
15933 | 727 |
^method notNil |
728 |
ifTrue:[method programmingLanguage] |
|
729 |
ifFalse:[SmalltalkLanguage instance] |
|
13426 | 730 |
|
731 |
"Created: / 17-03-2011 / 10:17:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13543
63c783128bae
changed: #programmingLanguage
Claus Gittinger <cg@exept.de>
parents:
13519
diff
changeset
|
732 |
"Modified (format): / 02-08-2011 / 09:23:39 / cg" |
13426 | 733 |
! |
734 |
||
623 | 735 |
receiver |
736 |
"return the receiver of the context" |
|
18253 | 737 |
%{ /* NOCONTEXT */ |
738 |
#ifdef __SCHTEAM__ |
|
18289 | 739 |
return context._RETURN( self.asSTContinuation().stSelf(context) ); |
18253 | 740 |
#endif |
741 |
%}. |
|
623 | 742 |
^ receiver |
743 |
! |
|
744 |
||
4543 | 745 |
receiver:aCompiledCode |
746 |
"set the receiver of the message" |
|
747 |
||
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
748 |
receiver := aCompiledCode. |
4543 | 749 |
|
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
750 |
"/ need some aid for optimized code - |
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
751 |
"/ some machines have the arguments kept in register vars ... |
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
752 |
"/ the unfix updates the machine-stack version of the receiver. |
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
753 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
754 |
#ifdef __SCHTEAM__ |
18190 | 755 |
ERROR("unimplemented"); |
756 |
#else |
|
4570 | 757 |
__UNFIXCONTEXT(self, 0); |
18190 | 758 |
#endif |
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
759 |
%}. |
4543 | 760 |
|
761 |
! |
|
762 |
||
623 | 763 |
searchClass |
764 |
"this is the class where the method-lookup started; |
|
19448 | 765 |
for normal sends, it is nil (or sometimes the receiver's class). |
623 | 766 |
For supersends, its the superclass of the one, in which the |
767 |
caller was defined." |
|
768 |
||
769 |
searchClass notNil ifTrue:[^ searchClass]. |
|
770 |
^ receiver class |
|
771 |
! |
|
772 |
||
773 |
selector |
|
774 |
"return the selector of the method for which the context was created" |
|
775 |
||
776 |
^ selector |
|
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
777 |
! |
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
778 |
|
1 | 779 |
sender |
780 |
"return the sender of the context" |
|
781 |
||
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
782 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
783 |
#ifdef __SCHTEAM__ |
18406 | 784 |
STContinuation sender = self.sender(); |
785 |
if (sender == null) { |
|
786 |
return __c__._RETURN_nil(); |
|
787 |
} |
|
788 |
return __c__._RETURN(sender); |
|
18253 | 789 |
/* NOTREACHED */ |
18190 | 790 |
#else |
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
791 |
OBJ theContext; |
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
792 |
|
3508 | 793 |
theContext = __INST(sender_); |
949 | 794 |
/* |
795 |
* this special nil test is for the very first context (startup-context); |
|
796 |
* actually, its cosmetics, to avoid a visible nil>>nil context in the debugger. |
|
797 |
*/ |
|
2205 | 798 |
if (__isNonNilObject(theContext)) { |
949 | 799 |
|
15933 | 800 |
if (__isLazy(theContext)) { |
801 |
/* |
|
802 |
* this cannot happen |
|
803 |
*/ |
|
804 |
__PATCHUPCONTEXT(theContext); |
|
805 |
} |
|
806 |
if (! __isNonLIFO(theContext)) { |
|
807 |
__markNonLIFO(theContext); |
|
808 |
} |
|
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
809 |
} |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
810 |
RETURN (theContext); |
18190 | 811 |
#endif |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
812 |
%} |
1 | 813 |
! |
814 |
||
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
815 |
senderIsNil |
15319 | 816 |
"return true, if I have no sender. |
817 |
This little ugly piece of code is needed (instead of the obvious |
|
818 |
'sender isNil') because sender is a protected field, which cannot be |
|
819 |
directly accessed by smalltalk code. The reason is that the sender field |
|
820 |
is lazily filled in by the VM, in the sender-accessor, and is usually |
|
821 |
invalid until needed." |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
822 |
|
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
823 |
%{ /* NOCONTEXT */ |
18412 | 824 |
#ifdef __SCHTEAM__ |
825 |
if (((STContinuation)self).caller == null) { |
|
826 |
return __c__._RETURN_true(); |
|
827 |
} |
|
828 |
return __c__._RETURN_false(); |
|
829 |
/* NOTREACHED */ |
|
830 |
#else |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
831 |
if ( __INST(sender_) == nil ) { |
15933 | 832 |
RETURN (true); |
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
833 |
} |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
834 |
RETURN (false); |
18412 | 835 |
#endif |
5422 | 836 |
%}. |
18289 | 837 |
^ self sender isNil |
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
838 |
! |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
839 |
|
623 | 840 |
setLineNumber:aNumber |
841 |
"private entry for uncompiledCodeObject ..." |
|
1 | 842 |
|
623 | 843 |
lineNr := aNumber |
340 | 844 |
! |
845 |
||
5749 | 846 |
setNumArgs:nA numVars:nV |
847 |
"set the number of arguments and variables" |
|
848 |
||
849 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
850 |
#ifdef __SCHTEAM__ |
18190 | 851 |
ERROR("unimplemented"); |
852 |
#else |
|
8910 | 853 |
INT flg; |
5749 | 854 |
|
855 |
flg = __intVal(__INST(flags)); |
|
856 |
flg = flg & ~(__NARG_MASK << __NARG_SHIFT); |
|
857 |
flg = flg & ~(__NVAR_MASK << __NVAR_SHIFT); |
|
858 |
flg = flg | __intVal(nA) << __NARG_SHIFT; |
|
859 |
flg = flg | __intVal(nV) << __NVAR_SHIFT; |
|
8913 | 860 |
__INST(flags) = __mkSmallInteger(flg); |
18190 | 861 |
#endif |
5749 | 862 |
%} |
863 |
! |
|
864 |
||
12841 | 865 |
tempAt:index |
8578 | 866 |
"return the n'th stack-temporary variable" |
867 |
||
868 |
^ self at:index |
|
869 |
! |
|
870 |
||
12841 | 871 |
temporaries |
202 | 872 |
"return an array filled with the temporaries of this context" |
873 |
||
308 | 874 |
|nonTemps mySize| |
202 | 875 |
|
18437 | 876 |
nonTemps := self argumentCount + self numVars. |
1810 | 877 |
mySize := self numTemps. |
3130 | 878 |
mySize == 0 ifTrue:[ |
18437 | 879 |
"/ little optimization here - avaoid creating empty containers |
880 |
^ #() |
|
3130 | 881 |
]. |
308 | 882 |
^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonTemps+1 |
1810 | 883 |
|
884 |
"Modified: 23.10.1996 / 16:20:00 / cg" |
|
202 | 885 |
! |
886 |
||
10 | 887 |
varAt:n |
888 |
"return the n'th local variable" |
|
889 |
||
18437 | 890 |
^ self at:(n + self argumentCount) |
10 | 891 |
! |
892 |
||
893 |
varAt:n put:value |
|
894 |
"set the n'th local variable - useful when the receiver should be restarted |
|
54 | 895 |
or continued" |
10 | 896 |
|
18437 | 897 |
self at:(n + self argumentCount) put:value |
10 | 898 |
! |
899 |
||
12841 | 900 |
vars |
623 | 901 |
"return an array filled with the local variables of this context" |
375 | 902 |
|
623 | 903 |
|nonVars mySize| |
360 | 904 |
|
18437 | 905 |
nonVars := self argumentCount. |
1810 | 906 |
mySize := self numVars. |
3130 | 907 |
mySize == 0 ifTrue:[ |
18437 | 908 |
"/ little optimization here - avaoid creating empty containers |
909 |
^ #() |
|
3130 | 910 |
]. |
623 | 911 |
^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1 |
1810 | 912 |
|
913 |
"Modified: 23.10.1996 / 16:20:06 / cg" |
|
1 | 914 |
! ! |
915 |
||
623 | 916 |
!Context methodsFor:'copying'! |
415 | 917 |
|
10943 | 918 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
10136 | 919 |
|copyOfMe| |
3350
40dc4807a6d4
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3324
diff
changeset
|
920 |
|
10136 | 921 |
copyOfMe := self shallowCopy. |
922 |
copyOfMe setSender:nil. |
|
13516
9bbdb9d05a51
changed: #deepCopyUsing:postCopySelector:
Claus Gittinger <cg@exept.de>
parents:
13473
diff
changeset
|
923 |
copyOfMe perform:postCopySelector withOptionalArgument:self and:aDictionary. |
10136 | 924 |
^ copyOfMe |
925 |
||
926 |
"Created: / 31-03-1998 / 15:51:14 / cg" |
|
13516
9bbdb9d05a51
changed: #deepCopyUsing:postCopySelector:
Claus Gittinger <cg@exept.de>
parents:
13473
diff
changeset
|
927 |
"Modified: / 21-07-2011 / 13:30:21 / cg" |
1 | 928 |
! ! |
929 |
||
15010 | 930 |
!Context methodsFor:'enumerating'! |
931 |
||
932 |
withAllSendersDo:aBlock |
|
933 |
"evaluate aBlock for me and all contexts of my sender chain" |
|
934 |
||
21146 | 935 |
self withSendersUpToContextForWhich:[:con | false] do:aBlock |
936 |
! |
|
937 |
||
938 |
withSendersThroughContextForWhich:checkBlock do:aBlock |
|
939 |
"evaluate aBlock for me and all contexts of my sender chain, |
|
940 |
until checkBlock returns true (incl. that last one)" |
|
941 |
||
15010 | 942 |
|con| |
943 |
||
944 |
con := self. |
|
945 |
[ con notNil ] whileTrue:[ |
|
21146 | 946 |
aBlock value:con. |
947 |
(checkBlock value:con) ifTrue:[^ self]. |
|
948 |
con := con sender. |
|
949 |
] |
|
950 |
! |
|
951 |
||
952 |
withSendersUpToContextForWhich:checkBlock do:aBlock |
|
953 |
"evaluate aBlock for me and all contexts of my sender chain, |
|
954 |
until checkBlock returns true, excl. that context." |
|
955 |
||
956 |
|con| |
|
957 |
||
958 |
con := self. |
|
959 |
[ con notNil ] whileTrue:[ |
|
960 |
(checkBlock value:con) ifTrue:[^ self]. |
|
961 |
aBlock value:con. |
|
962 |
con := con sender. |
|
15010 | 963 |
] |
964 |
! ! |
|
965 |
||
77 | 966 |
!Context methodsFor:'error handling'! |
967 |
||
968 |
invalidReturn:returnValue |
|
969 |
"this message is sent by the VM, when a methods context |
|
970 |
which has already returned is about to return again. |
|
971 |
(i.e. about to execute a return from an already returned |
|
105 | 972 |
method in a block). |
141 | 973 |
We raise a signal here, to allow catching of that situation." |
77 | 974 |
|
406 | 975 |
" |
976 |
in previous versions of ST/X and ST-80, this was no error; |
|
977 |
(instead, a normal blockreturn was performed to the value-sender). |
|
978 |
From a note in comp.lang.smalltalk, I conclude that new ST-80 versions |
|
979 |
now raise an error if this happens. |
|
980 |
Comment out the raise below to get that (old) behavior |
|
981 |
BETTER REWRITE YOUR APPLICATION |
|
12841 | 982 |
" |
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
983 |
"/ old behavior: |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
984 |
"/ ^ returnValue |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
985 |
|
282 | 986 |
"/ new behavior: |
987 |
||
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
988 |
"/ if this context is one of another process, |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
989 |
"/ use another error message. |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
990 |
|
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
991 |
(home notNil and:[home sender notNil]) ifTrue:[ |
15933 | 992 |
^ CannotReturnError |
993 |
raiseRequestWith:returnValue |
|
994 |
errorString:'cannot return from another process''s context'. |
|
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
995 |
]. |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
996 |
|
12841 | 997 |
^ CannotReturnError |
15933 | 998 |
raiseRequestWith:returnValue. |
282 | 999 |
|
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
1000 |
"Modified: / 2.2.1998 / 15:19:52 / cg" |
406 | 1001 |
! |
1002 |
||
1003 |
invalidReturnOrRestart:returnValue |
|
15268 | 1004 |
"this message is sent by the VM, when a method's or block's context |
1005 |
which was compiled non-returnable is about to return again, |
|
1006 |
or a non-restartable context is tried to be restarted. |
|
1007 |
In ST/X, not all contexts are restartable/returnable. |
|
406 | 1008 |
We raise a signal here, to allow catching of that situation." |
1009 |
||
6002 | 1010 |
^ CannotReturnError |
15933 | 1011 |
raiseRequestWith:returnValue |
1012 |
errorString:'method was compiled non-resumable' |
|
360 | 1013 |
! |
1014 |
||
1015 |
invalidReturnOrRestartError:how with:value |
|
1016 |
"common error reporter for restart/return errors" |
|
12841 | 1017 |
|
360 | 1018 |
self canReturn ifTrue:[ |
15933 | 1019 |
" |
1020 |
tried to return from/restart a context which is already dead |
|
1021 |
(i.e. the method/block has already executed a return) |
|
1022 |
" |
|
1023 |
^ CannotReturnError |
|
1024 |
raiseRequestWith:value |
|
1025 |
errorString:(how , ' context not on calling chain') |
|
360 | 1026 |
]. |
1027 |
" |
|
1028 |
tried to return from/restart a context of a method which was compiled |
|
1029 |
unrestartable or of a block (which is never restartable) |
|
1030 |
" |
|
12841 | 1031 |
^ CannotReturnError |
15933 | 1032 |
raiseRequestWith:value |
1033 |
errorString:(how , ' context cannot be restarted/returned from') |
|
77 | 1034 |
! ! |
1035 |
||
6404 | 1036 |
!Context methodsFor:'fixups'! |
1037 |
||
1038 |
fixAllLineNumbers |
|
1039 |
%{ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1040 |
#ifdef __SCHTEAM__ |
18190 | 1041 |
ERROR("unimplemented"); |
1042 |
#else |
|
6404 | 1043 |
__PATCHUPCONTEXTS(__thisContext); |
6424 | 1044 |
__CONTEXTLINENOS(self); |
18190 | 1045 |
#endif |
6404 | 1046 |
%} |
1047 |
! ! |
|
1048 |
||
623 | 1049 |
!Context methodsFor:'minidebugger printing'! |
1050 |
||
1051 |
fullPrint |
|
12841 | 1052 |
"print the receiver, selector and args of the context |
20840 | 1053 |
- used only for MiniDebugger's walkback print" |
1054 |
||
1055 |
self receiverPrintString _errorPrint. ' ' _errorPrint. selector _errorPrint. |
|
18437 | 1056 |
self argumentCount ~~ 0 ifTrue: [ |
20840 | 1057 |
' ' _errorPrint. self argsDisplayString _errorPrint |
623 | 1058 |
]. |
20840 | 1059 |
' [' _errorPrint. self lineNumber _errorPrint. ']' _errorPrintCR |
623 | 1060 |
|
1061 |
" |
|
1062 |
thisContext fullPrint |
|
1063 |
" |
|
1426 | 1064 |
|
1065 |
"Modified: 20.5.1996 / 10:27:14 / cg" |
|
623 | 1066 |
! |
1067 |
||
1068 |
fullPrintAll |
|
1069 |
"print a full walkback starting at the receiver |
|
20840 | 1070 |
- used only for MiniDebugger's walkback print" |
623 | 1071 |
|
15010 | 1072 |
self withAllSendersDo:[:con | con fullPrint]. |
623 | 1073 |
|
1074 |
" |
|
1075 |
thisContext fullPrintAll |
|
1076 |
" |
|
2173 | 1077 |
! |
1078 |
||
4674 | 1079 |
fullPrintAllLevels:nOrNil |
1080 |
"print a full walkback starting at the receiver, only print n levels |
|
20840 | 1081 |
- used only for MiniDebugger's walkback print" |
4674 | 1082 |
|
1083 |
|context count| |
|
1084 |
||
1085 |
count := 0. |
|
1086 |
context := self. |
|
1087 |
[context notNil] whileTrue: [ |
|
20840 | 1088 |
context fullPrint. |
1089 |
context := context sender. |
|
1090 |
nOrNil notNil ifTrue:[ |
|
1091 |
(count := count+1) > nOrNil ifTrue:[^self]. |
|
1092 |
] |
|
4674 | 1093 |
] |
1094 |
||
1095 |
" |
|
6648 | 1096 |
thisContext fullPrintAllLevels:5 |
4674 | 1097 |
" |
1098 |
||
1099 |
"Created: / 3.9.1999 / 14:02:38 / ps" |
|
11540 | 1100 |
! |
1101 |
||
11542 | 1102 |
printAll |
1103 |
"print a full walkback starting at the receiver, only print n levels |
|
20840 | 1104 |
- used only for MiniDebugger's walkback print" |
11542 | 1105 |
|
1106 |
self printAllLevels:nil |
|
1107 |
||
1108 |
" |
|
1109 |
thisContext printAll |
|
1110 |
" |
|
1111 |
! |
|
1112 |
||
11540 | 1113 |
printAllLevels:nOrNil |
1114 |
"print a full walkback starting at the receiver, only print n levels |
|
20840 | 1115 |
- used only for MiniDebugger's walkback print" |
11540 | 1116 |
|
1117 |
|context count| |
|
1118 |
||
1119 |
count := 0. |
|
1120 |
context := self. |
|
16247 | 1121 |
'--------------------------' errorPrintCR. |
11540 | 1122 |
[context notNil] whileTrue: [ |
20840 | 1123 |
context errorPrintCR. |
1124 |
context := context sender. |
|
1125 |
nOrNil notNil ifTrue:[ |
|
1126 |
(count := count+1) > nOrNil ifTrue:[ |
|
1127 |
'--------------------------' errorPrintCR. |
|
1128 |
^ self |
|
1129 |
]. |
|
1130 |
] |
|
11545 | 1131 |
]. |
16247 | 1132 |
'--------------------------' errorPrintCR. |
11540 | 1133 |
|
1134 |
" |
|
1135 |
thisContext printAllLevels:5 |
|
1136 |
" |
|
623 | 1137 |
! ! |
1138 |
||
1 | 1139 |
!Context methodsFor:'non local control flow'! |
1140 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1141 |
evaluateUnwindActionsUpTo:aContext |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1142 |
"walk up the calling chain, looking for unwind-cleanup actions to |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1143 |
be performed. This depends upon those contexts being specially |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1144 |
marked using #markForUnwind. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1145 |
Returns the argument (i.e. non-nil), if all went well, |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1146 |
nil if aContext is not on the caller chain (definitely an error)" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1147 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1148 |
|con unwindBlock| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1149 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1150 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1151 |
start with this context, moving up, looking for unwind actions |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1152 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1153 |
con := self findNextUnwindContextOr:aContext. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1154 |
[con notNil and:[con ~~ aContext]] whileTrue:[ |
15933 | 1155 |
unwindBlock := con receiver unwindHandlerInContext:con. |
1156 |
con unmarkForUnwind. |
|
1157 |
unwindBlock value. |
|
1158 |
||
1159 |
con := con findNextUnwindContextOr:aContext. |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1160 |
]. |
11340
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
1161 |
"/ mhmh - the just unwound context could itself be markedForUnwind |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
1162 |
(con notNil and:[con isMarkedForUnwind]) ifTrue:[ |
15933 | 1163 |
unwindBlock := con receiver unwindHandlerInContext:con. |
1164 |
con unmarkForUnwind. |
|
1165 |
unwindBlock value. |
|
11340
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
1166 |
]. |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1167 |
^ con |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1168 |
! |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1169 |
|
15688 | 1170 |
resend |
1171 |
"EXPERIMENTAL: resend the context's message (to the same receiver). |
|
1172 |
if the method's implementation has been changed in the meanwhile (for example, in the debugger), |
|
1173 |
the new code is executed. Otherwise the same code is reexecuted from the start." |
|
1174 |
||
1175 |
self returnDoing:[ receiver perform:selector withArguments:(self args) ]. |
|
1176 |
||
1177 |
" |
|
1178 |
when we arrive here, something went wrong. |
|
1179 |
debugging ... |
|
1180 |
" |
|
1181 |
^ self invalidReturnOrRestartError:#'resend' with:nil |
|
1182 |
! |
|
1183 |
||
1 | 1184 |
restart |
1185 |
"restart the receiver - i.e. the method is evaluated again. |
|
402 | 1186 |
if the context to restart already died, trigger an error. |
141 | 1187 |
This is a low level helper for unwindAndRestart. |
1188 |
||
12841 | 1189 |
NOTICE: |
15933 | 1190 |
NO unwind actions are performed - this is usually not |
1191 |
what you want (see Context>>unwindAndRestart). |
|
12841 | 1192 |
|
1193 |
LIMITATION: |
|
15933 | 1194 |
currently a context can only be restarted by |
1195 |
the owning process - not from outside. |
|
1196 |
Also, the compiler has an option (+optcontext) to create |
|
1197 |
non-restartable contexts (which are faster). |
|
1198 |
If such a context is restarted, a runtime error is raised." |
|
1 | 1199 |
|
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1200 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1201 |
#ifdef __SCHTEAM__ |
18364 | 1202 |
return __c__.RESTART(self); |
1203 |
/* NOTREACHED */ |
|
18190 | 1204 |
#else |
15650 | 1205 |
if (__INST(sender_) == nil) { |
15933 | 1206 |
RETURN(nil); |
15650 | 1207 |
} else { |
15933 | 1208 |
__RESUMECONTEXT__(self, RESTART_VALUE, 0); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1209 |
} |
18190 | 1210 |
#endif |
360 | 1211 |
%}. |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1212 |
|
69 | 1213 |
" |
360 | 1214 |
when we arrive here, something went wrong. |
69 | 1215 |
debugging ... |
1216 |
" |
|
360 | 1217 |
^ self invalidReturnOrRestartError:#restart with:nil |
1 | 1218 |
! |
1219 |
||
623 | 1220 |
resume |
1221 |
"resume execution in this context. I.e. as if the method called |
|
1222 |
last by the receiver did a ^ nil. |
|
1223 |
If the context has already returned, report an error. |
|
1224 |
||
1225 |
NOTICE: |
|
15933 | 1226 |
NO unwind actions are performed (see Context>>unwind). |
12841 | 1227 |
|
1228 |
LIMITATION: |
|
15933 | 1229 |
currently a context can only be resumed by |
1230 |
the owning process - not from outside. |
|
1231 |
Also, the compiler has an option (+optcontext) to create |
|
1232 |
non-resumable contexts (which are faster). |
|
1233 |
If such a context is restarted, a runtime error is raised." |
|
623 | 1234 |
|
1235 |
^ self resume:nil |
|
1236 |
! |
|
1237 |
||
1238 |
resume:value |
|
1239 |
"resume the receiver - as if it got 'value' from whatever |
|
19448 | 1240 |
it called. This continues execution in the receiver's method |
623 | 1241 |
after the point where it did its last send. |
12841 | 1242 |
If the context has already returned - report an error. |
623 | 1243 |
|
1244 |
NOTICE: |
|
19448 | 1245 |
NO unwind actions are performed (see Context>>unwind:). |
623 | 1246 |
|
12841 | 1247 |
LIMITATION: |
19448 | 1248 |
currently a context can only be resumed by |
1249 |
the owning process - not from outside. |
|
1250 |
Also, the compiler has an option (+optcontext) to create |
|
1251 |
non-resumable contexts (which are faster). |
|
1252 |
If such a context is restarted, a runtime error is raised." |
|
623 | 1253 |
|
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1254 |
|theContext| |
623 | 1255 |
|
1256 |
" |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
1257 |
starting with this context, find the one below |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
1258 |
(i.e. the one that I have called) and return from it. |
623 | 1259 |
" |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1260 |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
1261 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1262 |
#ifdef __SCHTEAM__ |
18408 | 1263 |
return __c__._RETURN_TO(value, self.asSTContinuation()); |
1264 |
/* NOTREACHED */ |
|
18190 | 1265 |
#else |
4557 | 1266 |
OBJ sndr; |
1267 |
||
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
1268 |
theContext = __thisContext; |
4557 | 1269 |
while (theContext != nil) { |
19448 | 1270 |
sndr = __ContextInstPtr(theContext)->c_sender; |
1271 |
if (sndr == self) break; |
|
1272 |
theContext = sndr; |
|
623 | 1273 |
} |
3508 | 1274 |
if (theContext != nil) { |
19448 | 1275 |
if (__isLazy(theContext)) { |
1276 |
__PATCHUPCONTEXT(theContext); |
|
1277 |
} |
|
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1278 |
} |
18190 | 1279 |
#endif |
623 | 1280 |
%}. |
1281 |
||
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1282 |
theContext isNil ifTrue:[ |
19448 | 1283 |
" |
1284 |
tried to resume in context which is already dead |
|
1285 |
(i.e. the method/block has already executed a return) |
|
1286 |
" |
|
1287 |
^ thisContext invalidReturnOrRestartError:#'resume:' with:value |
|
623 | 1288 |
]. |
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
1289 |
^ theContext return:value |
623 | 1290 |
! |
1291 |
||
4557 | 1292 |
resumeIgnoringErrors:value |
1293 |
"resume the receiver - as if it got 'value' from whatever |
|
19448 | 1294 |
it called. This continues execution in the receiver's method |
4557 | 1295 |
after the point where it did its last send. |
12841 | 1296 |
If the context has already returned - simply return. |
4557 | 1297 |
|
1298 |
NOTICE: |
|
19448 | 1299 |
NO unwind actions are performed (see Context>>unwind:). |
4557 | 1300 |
|
12841 | 1301 |
LIMITATION: |
19448 | 1302 |
currently a context can only be resumed by |
1303 |
the owning process - not from outside. |
|
1304 |
Also, the compiler has an option (+optcontext) to create |
|
1305 |
non-resumable contexts (which are faster). |
|
1306 |
If such a context is restarted, a runtime error is raised." |
|
4557 | 1307 |
|
1308 |
" |
|
1309 |
starting with this context, find the one below |
|
1310 |
(i.e. the one that I have called) and return from it. |
|
1311 |
" |
|
1312 |
||
1313 |
%{ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1314 |
#ifdef __SCHTEAM__ |
18408 | 1315 |
return __c__._RETURN_TO(value, self.asSTContinuation()); |
1316 |
/* NOTREACHED */ |
|
18190 | 1317 |
#else |
4557 | 1318 |
OBJ theContext, sndr; |
1319 |
||
1320 |
theContext = __thisContext; |
|
1321 |
while (theContext != nil) { |
|
19448 | 1322 |
sndr = __ContextInstPtr(theContext)->c_sender; |
1323 |
if (sndr == self) break; |
|
1324 |
theContext = sndr; |
|
4557 | 1325 |
} |
1326 |
if (theContext != nil) { |
|
19448 | 1327 |
if (__ContextInstPtr(theContext)->c_sender) { |
1328 |
if (!((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__CANNOT_RETURN))) { |
|
1329 |
__RESUMECONTEXT__(theContext, value, 0); |
|
1330 |
} |
|
1331 |
} |
|
4557 | 1332 |
} |
18190 | 1333 |
#endif |
4557 | 1334 |
%}. |
1335 |
||
1336 |
"/ no error reporting |
|
1337 |
! |
|
1338 |
||
1339 |
resumeOnErrorProceed:value |
|
1340 |
"resume the receiver - as if it got 'value' from whatever |
|
19448 | 1341 |
it called. This continues execution in the receiver's method |
4557 | 1342 |
after the point where it did its last send. |
12841 | 1343 |
If the context has already returned - simply return. |
4557 | 1344 |
|
1345 |
NOTICE: |
|
19448 | 1346 |
NO unwind actions are performed (see Context>>unwind:). |
4557 | 1347 |
|
12841 | 1348 |
LIMITATION: |
19448 | 1349 |
currently a context can only be resumed by |
1350 |
the owning process - not from outside. |
|
1351 |
Also, the compiler has an option (+optcontext) to create |
|
1352 |
non-resumable contexts (which are faster). |
|
1353 |
If such a context is restarted, a runtime error is raised." |
|
4557 | 1354 |
|
1355 |
" |
|
1356 |
starting with this context, find the one below |
|
1357 |
(i.e. the one that I have called) and return from it. |
|
1358 |
" |
|
1359 |
||
1360 |
%{ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1361 |
#ifdef __SCHTEAM__ |
18408 | 1362 |
return __c__._RETURN_TO(value, self.asSTContinuation()); |
1363 |
/* NOTREACHED */ |
|
18190 | 1364 |
#else |
4557 | 1365 |
OBJ theContext, sndr; |
1366 |
||
1367 |
theContext = __thisContext; |
|
1368 |
while (theContext != nil) { |
|
19448 | 1369 |
sndr = __ContextInstPtr(theContext)->c_sender; |
1370 |
if (sndr == self) break; |
|
1371 |
theContext = sndr; |
|
4557 | 1372 |
} |
1373 |
if (theContext != nil) { |
|
19448 | 1374 |
if (__ContextInstPtr(theContext)->c_sender) { |
1375 |
__RESUMECONTEXT__(theContext, value, 0); |
|
1376 |
} |
|
4557 | 1377 |
} |
18190 | 1378 |
#endif |
4557 | 1379 |
%}. |
1380 |
||
1381 |
"/ no error reporting |
|
1382 |
! |
|
1383 |
||
69 | 1384 |
return |
141 | 1385 |
"return from this context with nil. I.e. as if it did a ^ nil. |
1386 |
NOTICE: |
|
15933 | 1387 |
NO unwind actions are performed - this is usually not |
1388 |
what you want (See Context>>unwind). |
|
1389 |
This is a low level method - a helper for unwind. |
|
12841 | 1390 |
|
1391 |
LIMITATION: |
|
15933 | 1392 |
currently a context can only be returned by |
1393 |
the owning process - not from outside. |
|
1394 |
Also, the compiler has an option (+optcontext) to create |
|
1395 |
non-returnable contexts (which are faster). |
|
1396 |
If such a context is restarted, a runtime error is raised." |
|
141 | 1397 |
|
1398 |
^ self return:nil |
|
1 | 1399 |
! |
1400 |
||
69 | 1401 |
return:value |
1402 |
"return from this context as if it did a '^ value'. |
|
141 | 1403 |
NOTICE: |
15933 | 1404 |
NO unwind actions are performed - this is usually not |
1405 |
what you want (See Context>>unwind:). |
|
1406 |
This is a low level method - a helper for unwind. |
|
141 | 1407 |
|
12841 | 1408 |
LIMITATION: |
15933 | 1409 |
currently a context can only be returned by |
1410 |
the owning process - not from outside. |
|
1411 |
Also, the compiler has an option (+optcontext) to create |
|
1412 |
non-returnable contexts (which are faster). |
|
1413 |
If such a context is restarted, a runtime error is raised." |
|
1 | 1414 |
|
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1415 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1416 |
#ifdef __SCHTEAM__ |
18408 | 1417 |
return __c__._RETURN_FROM(value, self.asSTContinuation()); |
1418 |
/* NOTREACHED */ |
|
18190 | 1419 |
#else |
15651 | 1420 |
if (__INST(sender_) == nil) { |
15933 | 1421 |
RETURN(nil); |
15651 | 1422 |
} else { |
15933 | 1423 |
__RESUMECONTEXT__(self, value, 0); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1424 |
} |
18190 | 1425 |
#endif |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1426 |
%}. |
1 | 1427 |
|
69 | 1428 |
" |
360 | 1429 |
when we arrive here, something went wrong. |
69 | 1430 |
debugging ... |
1431 |
" |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1432 |
^ self invalidReturnOrRestartError:#'return' with:value |
1 | 1433 |
! |
1434 |
||
328 | 1435 |
returnDoing:aBlock |
1436 |
"return from this context as if it did a '^ aBlock value'. |
|
1437 |
The block is evaluated as if called by the receiver context; |
|
1438 |
NOT the true executing context. |
|
1439 |
NOTICE: |
|
15933 | 1440 |
NO unwind actions are performed - this is usually not |
1441 |
what you want (See Context>>unwindThenDo:). |
|
1442 |
This is a low level method - a helper for unwind. |
|
328 | 1443 |
|
1444 |
LIMITATION: |
|
15933 | 1445 |
currently a context can only be returned by |
1446 |
the owning process - not from outside. |
|
1447 |
Also, the compiler has an option (+optcontext) to create |
|
1448 |
non-returnable contexts (which are faster). |
|
1449 |
If such a context is restarted, a runtime error is raised." |
|
328 | 1450 |
|
12841 | 1451 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
1452 |
#ifdef __SCHTEAM__ |
18190 | 1453 |
ERROR("unimplemented"); |
1454 |
#else |
|
15651 | 1455 |
if (__INST(sender_) == nil) { |
15933 | 1456 |
RETURN(nil); |
15651 | 1457 |
} else { |
15933 | 1458 |
__RESUMECONTEXT__(self, aBlock, 2); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1459 |
} |
18190 | 1460 |
#endif |
360 | 1461 |
%}. |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1462 |
|
328 | 1463 |
" |
360 | 1464 |
when we arrive here, something went wrong. |
328 | 1465 |
debugging ... |
1466 |
" |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1467 |
^ self invalidReturnOrRestartError:#'returnDoing' with:aBlock |
328 | 1468 |
! |
1469 |
||
1 | 1470 |
unwind |
69 | 1471 |
"return nil from the receiver - i.e. simulate a '^ nil'. |
11337 | 1472 |
If the context has already returned, report an error. |
1 | 1473 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
69 | 1474 |
and Block>>valueOnUnwindDo: on the way. |
1 | 1475 |
|
12841 | 1476 |
LIMITATION: |
15933 | 1477 |
currently a context can only be unwound by |
1478 |
the owning process - not from outside. |
|
1479 |
i.e. it is not possible for one thread to unwind |
|
1480 |
another threads context - which does not make sense anyway. |
|
1481 |
However, you can force another thread to do this in its own process |
|
1482 |
context, by giving it an interrupt action - this does make sense. |
|
1483 |
||
1484 |
Also, the compiler has an option (+optcontext) to create |
|
1485 |
non-returnable contexts (which are faster). |
|
1486 |
If such a context is restarted, a runtime error is raised." |
|
141 | 1487 |
|
1488 |
^ self unwind:nil |
|
1 | 1489 |
! |
1490 |
||
1491 |
unwind:value |
|
69 | 1492 |
"return value from the receiver - i.e. simulate a '^ value'. |
360 | 1493 |
If the context has already returned , report an error. |
1 | 1494 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
69 | 1495 |
and Block>>valueOnUnwindDo: on the way. |
141 | 1496 |
|
12841 | 1497 |
LIMITATION: |
15933 | 1498 |
currently a context can only be unwound by |
1499 |
the owning process - not from outside. |
|
1500 |
i.e. it is not possible for one thread to unwind |
|
1501 |
another threads context - which does not make sense anyway. |
|
1502 |
However, you can force another thread to do this in its own process |
|
1503 |
context, by giving it an interrupt action - this does make sense. |
|
1504 |
||
1505 |
Also, the compiler has an option (+optcontext) to create |
|
1506 |
non-returnable contexts (which are faster). |
|
1507 |
If such a context is restarted, a runtime error is raised." |
|
1 | 1508 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1509 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1510 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1511 |
self senderIsNil ifFalse:[ |
15933 | 1512 |
con := thisContext evaluateUnwindActionsUpTo:self. |
141 | 1513 |
]. |
1 | 1514 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1515 |
"oops, if nil, I am not on the calling chain; |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1516 |
(bad bad, unwind action have already been performed. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1517 |
should we check for this situation first and NOT evaluate |
141 | 1518 |
the unwind actions in this case ?) |
1519 |
" |
|
69 | 1520 |
con isNil ifTrue:[ |
15933 | 1521 |
" |
1522 |
tried to return to a context which is already dead |
|
1523 |
(i.e. the method/block has already executed a return) |
|
1524 |
" |
|
1525 |
^ self invalidReturnOrRestartError:#'unwind:' with:value |
|
69 | 1526 |
]. |
141 | 1527 |
" |
1528 |
now, that all unwind-actions are done, I can use the |
|
1529 |
low-level return ... |
|
1530 |
" |
|
1531 |
^ self return:value |
|
1532 |
! |
|
1533 |
||
1534 |
unwindAndRestart |
|
1535 |
"restart the receiver - i.e. the method is evaluated again. |
|
13804 | 1536 |
if the context to restart already did report an error. |
141 | 1537 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
1538 |
and Block>>valueOnUnwindDo: before restarting. |
|
1539 |
||
12841 | 1540 |
LIMITATION: |
15933 | 1541 |
a context can only be restarted by |
1542 |
the owning process - not from outside. |
|
1543 |
i.e. it is not possible for one thread to unwindAndRestart |
|
1544 |
another threads context - which does not make sense anyway. |
|
1545 |
However, you can force another thread to do this in its own process |
|
1546 |
context, by giving it an interrupt action - this does make sense. |
|
1547 |
||
1548 |
Also, the compiler has an option (+optcontext) to create |
|
1549 |
non-restartable contexts (which are faster). |
|
1550 |
If such a context is restarted, a runtime error is raised." |
|
552
694ecccaa1a0
only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents:
536
diff
changeset
|
1551 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1552 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1553 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1554 |
self senderIsNil ifFalse:[ |
15933 | 1555 |
con := thisContext evaluateUnwindActionsUpTo:self. |
141 | 1556 |
]. |
1557 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1558 |
"oops, if nil, I am not on the calling chain; |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1559 |
(bad bad, unwind action have already been performed. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1560 |
should we check for this situation first and NOT evaluate |
141 | 1561 |
the unwind actions in this case ?) |
1562 |
" |
|
1563 |
con isNil ifTrue:[ |
|
15933 | 1564 |
" |
1565 |
tried to return to a context which is already dead |
|
1566 |
(i.e. the method/block has already executed a return) |
|
1567 |
" |
|
1568 |
^ self invalidReturnOrRestartError:#'unwindAndRestart:' with:nil |
|
141 | 1569 |
]. |
1570 |
" |
|
1571 |
now, that all unwind-actions are done, I can use the |
|
1572 |
low-level restart ... |
|
1573 |
" |
|
1574 |
^ self restart |
|
328 | 1575 |
! |
1576 |
||
4485 | 1577 |
unwindAndResume:value |
1578 |
"resume execution in the the receiver - i.e. simulate a '^ value' |
|
1579 |
from whatever it called last. |
|
1580 |
If the context has already returned , report an error. |
|
1581 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
|
1582 |
and Block>>valueOnUnwindDo: on the way. |
|
1583 |
||
12841 | 1584 |
LIMITATION: |
15933 | 1585 |
currently a context can only be unwound by |
1586 |
the owning process - not from outside. |
|
1587 |
i.e. it is not possible for one thread to unwind |
|
1588 |
another threads context - which does not make sense anyway. |
|
1589 |
However, you can force another thread to do this in its own process |
|
1590 |
context, by giving it an interrupt action - this does make sense. |
|
1591 |
||
1592 |
Also, the compiler has an option (+optcontext) to create |
|
1593 |
non-returnable contexts (which are faster). |
|
1594 |
If such a context is restarted, a runtime error is raised." |
|
4485 | 1595 |
|
1596 |
|con| |
|
1597 |
||
1598 |
self senderIsNil ifFalse:[ |
|
15933 | 1599 |
con := thisContext evaluateUnwindActionsUpTo:self. |
4485 | 1600 |
]. |
1601 |
||
1602 |
"oops, if nil, I am not on the calling chain; |
|
1603 |
(bad bad, unwind action have already been performed. |
|
1604 |
should we check for this situation first and NOT evaluate |
|
1605 |
the unwind actions in this case ?) |
|
1606 |
" |
|
1607 |
con isNil ifTrue:[ |
|
15933 | 1608 |
" |
1609 |
tried to return to a context which is already dead |
|
1610 |
(i.e. the method/block has already executed a return) |
|
1611 |
" |
|
1612 |
^ self invalidReturnOrRestartError:#'unwindAndResume:' with:value |
|
4485 | 1613 |
]. |
1614 |
" |
|
1615 |
now, that all unwind-actions are done, I can use the |
|
1616 |
low-level resume ... |
|
1617 |
" |
|
1618 |
^ self resume:value |
|
1619 |
! |
|
1620 |
||
12841 | 1621 |
unwindThenDo:aBlock |
328 | 1622 |
"return the value of aBlock from the receiver - i.e. simulate a '^ aBlock value'. |
13804 | 1623 |
If the context has already returned, report an error. |
328 | 1624 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
1625 |
and Block>>valueOnUnwindDo: on the way. |
|
1626 |
The block is evaluated AFTER all unwind actions are performed |
|
15688 | 1627 |
(i.e. the block's sender will be the receiving context, not the |
402 | 1628 |
currently executing context) |
328 | 1629 |
|
12841 | 1630 |
LIMITATION: |
15933 | 1631 |
currently a context can only be unwound by |
1632 |
the owning process - not from outside |
|
1633 |
i.e. it is not possible for one thread to unwindThenDo |
|
1634 |
another threads context - which does not make sense anyway. |
|
1635 |
However, you can force another thread to do this in its own process |
|
1636 |
context, by giving it an interrupt action - this does make sense. |
|
1637 |
||
1638 |
Also, the compiler has an option (+optcontext) to create |
|
1639 |
non-returnable contexts (which are faster). |
|
1640 |
If such a context is restarted, a runtime error is raised." |
|
328 | 1641 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1642 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1643 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1644 |
self senderIsNil ifFalse:[ |
15933 | 1645 |
con := thisContext evaluateUnwindActionsUpTo:self. |
328 | 1646 |
]. |
1647 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1648 |
"oops, if nil, I am not on the calling chain; |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1649 |
(bad bad, unwind action have already been performed. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1650 |
should we check for this situation first and NOT evaluate |
328 | 1651 |
the unwind actions in this case ?) |
1652 |
" |
|
1653 |
con isNil ifTrue:[ |
|
15933 | 1654 |
" |
1655 |
tried to return to a context which is already dead |
|
1656 |
(i.e. the method/block has already executed a return) |
|
1657 |
" |
|
1658 |
^ self invalidReturnOrRestartError:#'unwindThenDo:' with:aBlock |
|
328 | 1659 |
]. |
1660 |
" |
|
1661 |
now, that all unwind-actions are done, I can use the |
|
1662 |
low-level return ... |
|
1663 |
" |
|
12841 | 1664 |
^ self returnDoing:aBlock |
15688 | 1665 |
! |
1666 |
||
1667 |
unwindThenResend |
|
1668 |
"EXPERIMENTAL: resend the context's message (to the same receiver). |
|
1669 |
if the method's implementation has been changed in the meanwhile (for example, in the debugger), |
|
1670 |
the new code is executed. Otherwise the same code is reexecuted from the start. |
|
1671 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
|
1672 |
and Block>>valueOnUnwindDo: on the way. |
|
1673 |
The resend happens AFTER all unwind actions are performed |
|
1674 |
||
1675 |
LIMITATION: |
|
15933 | 1676 |
currently a context can only be unwound by |
1677 |
the owning process - not from outside |
|
1678 |
i.e. it is not possible for one thread to unwindThenDo |
|
1679 |
another threads context - which does not make sense anyway. |
|
1680 |
However, you can force another thread to do this in its own process |
|
1681 |
context, by giving it an interrupt action - this does make sense. |
|
1682 |
||
1683 |
Also, the compiler has an option (+optcontext) to create |
|
1684 |
non-returnable contexts (which are faster). |
|
1685 |
If such a context is restarted, a runtime error is raised." |
|
15688 | 1686 |
|
1687 |
|con| |
|
1688 |
||
1689 |
self senderIsNil ifFalse:[ |
|
15933 | 1690 |
con := thisContext evaluateUnwindActionsUpTo:self. |
15688 | 1691 |
]. |
1692 |
||
1693 |
"oops, if nil, I am not on the calling chain; |
|
1694 |
(bad bad, unwind action have already been performed. |
|
1695 |
should we check for this situation first and NOT evaluate |
|
1696 |
the unwind actions in this case ?) |
|
1697 |
" |
|
1698 |
con isNil ifTrue:[ |
|
15933 | 1699 |
" |
1700 |
tried to return to a context which is already dead |
|
1701 |
(i.e. the method/block has already executed a return) |
|
1702 |
" |
|
1703 |
^ self invalidReturnOrRestartError:#'unwindThenResend' with:nil |
|
15688 | 1704 |
]. |
1705 |
||
1706 |
"/ now, that all unwind-actions are done, I can use the low-level resend... |
|
1707 |
^ self resend |
|
1 | 1708 |
! ! |
623 | 1709 |
|
1710 |
!Context methodsFor:'printing & storing'! |
|
1711 |
||
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1712 |
argStringFor:someObject |
15644 | 1713 |
|s| |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1714 |
%{ |
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
1715 |
#ifndef __SCHTEAM__ |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1716 |
/* |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1717 |
* special handling for (invalid) free objects. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1718 |
* these only appear if some primitiveCode does not correctly use SEND macros, |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1719 |
* which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
14051 | 1720 |
* However, these print methods are also invoked for low-level pointer errors, so better be prepared... |
12841 | 1721 |
*/ |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1722 |
if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) { |
15933 | 1723 |
s = __MKSTRING("FreeObject"); |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1724 |
} |
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
1725 |
#endif /* not SCHTEAM */ |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1726 |
%}. |
11539 | 1727 |
s isNil ifTrue:[ |
15933 | 1728 |
s := someObject displayString. |
1729 |
s isNil ifTrue:[ |
|
1730 |
^ '**************** nil displayString of ',(someObject class name ? '??') |
|
1731 |
]. |
|
11539 | 1732 |
]. |
15933 | 1733 |
"/ JV@2013-04-26: Following is rubbish, the callers must handle string output correctly. |
15644 | 1734 |
"/ moreover storeString does not work on self-referencing structures, but that doesn't matter |
1735 |
"/ for wide strings. |
|
1736 |
"/ SV@2013-08-19: I checked/fixed the callers to use CharacterWriteStreams. |
|
1737 |
"/ s isWideString ifTrue:[ |
|
1738 |
"/ "make sure that the object really returns something we can stream into a string" |
|
1739 |
"/ s := someObject storeString. |
|
1740 |
"/ ]. |
|
11539 | 1741 |
^ s |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1742 |
! |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1743 |
|
623 | 1744 |
argsDisplayString |
14051 | 1745 |
^ String streamContents:[:s | self displayArgsOn:s ]. |
1746 |
||
1747 |
"Modified (format): / 07-03-2012 / 13:11:17 / cg" |
|
623 | 1748 |
! |
1749 |
||
6648 | 1750 |
displayArgsOn:aStream |
15933 | 1751 |
| n "{ Class: SmallInteger }" |
15388 | 1752 |
s | |
6648 | 1753 |
|
18437 | 1754 |
n := self argumentCount. |
6648 | 1755 |
1 to:n do:[:index | |
18437 | 1756 |
Error handle:[:ex | |
1757 |
s := '*Error in argString*'. |
|
1758 |
] do:[ |
|
1759 |
s := self argStringFor:(self at:index). |
|
1760 |
s := s contractTo:100. |
|
1761 |
]. |
|
1762 |
||
1763 |
aStream nextPutAll:s asString string. |
|
1764 |
index ~~ n ifTrue:[ aStream space ]. |
|
6648 | 1765 |
]. |
14051 | 1766 |
|
1767 |
"Modified: / 07-03-2012 / 13:09:17 / cg" |
|
6648 | 1768 |
! |
1769 |
||
14293
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1770 |
displayOn:aGCOrStream |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1771 |
"return a string to display the receiver - for display in Inspector" |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1772 |
|
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1773 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1774 |
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1775 |
(aGCOrStream isStream) ifFalse:[ |
15933 | 1776 |
^ super displayOn:aGCOrStream |
14293
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1777 |
]. |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1778 |
|
15933 | 1779 |
aGCOrStream |
1780 |
nextPutAll:self class name; |
|
1781 |
nextPut:$(. |
|
14293
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1782 |
self printOn:aGCOrStream. |
f1bc5da76f93
Implement #displayOn: instead of #displayString
Stefan Vogel <sv@exept.de>
parents:
14225
diff
changeset
|
1783 |
aGCOrStream nextPut:$). |
623 | 1784 |
! |
1785 |
||
6648 | 1786 |
fullPrintAllOn:aStream |
12789 | 1787 |
"print a full walkback (incl arguments) starting at the receiver" |
6648 | 1788 |
|
15010 | 1789 |
self withAllSendersDo:[:con | con fullPrintOn:aStream. aStream cr]. |
6648 | 1790 |
|
1791 |
" |
|
1792 |
thisContext fullPrintAllOn:Transcript |
|
1793 |
" |
|
1794 |
||
1795 |
"Created: 15.1.1997 / 18:09:05 / cg" |
|
1796 |
! |
|
1797 |
||
18977 | 1798 |
fullPrintAllOn:aStream throughContextForWhich:aBlock |
1799 |
"print a full walkback (incl arguments) starting at the receiver" |
|
1800 |
||
21146 | 1801 |
self withSendersThroughContextForWhich:aBlock do:[:con | |
18977 | 1802 |
con fullPrintOn:aStream. aStream cr. |
1803 |
]. |
|
1804 |
||
1805 |
" |
|
1806 |
thisContext fullPrintAllOn:Transcript throughContextForWhich:[:con | con selector == #doIt]. |
|
1807 |
" |
|
1808 |
! |
|
1809 |
||
1810 |
fullPrintAllOn:aStream upToContextForWhich:aBlock |
|
1811 |
"print a full walkback (incl arguments) starting at the receiver" |
|
1812 |
||
21146 | 1813 |
self withSendersUpToContextForWhich:aBlock do:[:con | |
18977 | 1814 |
con fullPrintOn:aStream. aStream cr. |
1815 |
]. |
|
1816 |
||
1817 |
" |
|
1818 |
thisContext fullPrintAllOn:Transcript upToContextForWhich:[:con | con selector == #doIt]. |
|
1819 |
" |
|
1820 |
! |
|
1821 |
||
13612 | 1822 |
fullPrintAllString |
1823 |
"return a string containing the full walkback (incl. arguments)" |
|
1824 |
||
21146 | 1825 |
|s| |
1826 |
||
1827 |
s := WriteStream on:''. |
|
1828 |
self fullPrintAllOn:s. |
|
1829 |
^ s contents |
|
13612 | 1830 |
|
1831 |
" |
|
1832 |
thisContext fullPrintAllString |
|
1833 |
" |
|
1834 |
||
1835 |
"Created: / 21-08-2011 / 07:37:36 / cg" |
|
1836 |
! |
|
1837 |
||
6648 | 1838 |
fullPrintOn:aStream |
12789 | 1839 |
"append a verbose description (incl. arguments) of the receiver onto aStream" |
6648 | 1840 |
|
15383 | 1841 |
self printReceiverOn:aStream. |
12841 | 1842 |
aStream nextPutAll:' >> '. |
11311 | 1843 |
self selector printOn:aStream. "show as string (as symbol looks too ugly in browser ...)" |
1844 |
"/ self selector storeOn:aStream. "show as symbol" |
|
8578 | 1845 |
|
6648 | 1846 |
self size ~~ 0 ifTrue: [ |
15933 | 1847 |
aStream space. |
1848 |
self displayArgsOn:aStream |
|
6648 | 1849 |
]. |
12841 | 1850 |
aStream nextPutAll:' {'. |
1851 |
self identityHash printOn:aStream. |
|
15383 | 1852 |
aStream nextPut:$}. |
12841 | 1853 |
|
1854 |
aStream nextPutAll:' ['. |
|
6648 | 1855 |
self lineNumber printOn:aStream. |
15383 | 1856 |
aStream nextPut:$]. |
6648 | 1857 |
|
1858 |
" |
|
1859 |
thisContext fullPrintOn:Transcript |
|
1860 |
" |
|
1861 |
||
1862 |
"Modified: 20.5.1996 / 10:27:14 / cg" |
|
1863 |
"Created: 15.1.1997 / 18:09:06 / cg" |
|
1864 |
! |
|
1865 |
||
623 | 1866 |
fullPrintString |
1867 |
"return a string describing the context - this includes the linenumber, |
|
1868 |
receiver printString and argument printString" |
|
1869 |
||
15644 | 1870 |
^ String streamContents:[:s | self fullPrintOn:s] |
623 | 1871 |
|
1872 |
" |
|
1873 |
thisContext fullPrintString |
|
1874 |
" |
|
1875 |
! |
|
1876 |
||
1877 |
methodPrintString |
|
12841 | 1878 |
"return a string describing the contexts method as 'implementorClass>>selector'" |
623 | 1879 |
|
1853
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1880 |
|mthd who| |
623 | 1881 |
|
1882 |
mthd := self method. |
|
1883 |
mthd notNil ifTrue:[ |
|
15933 | 1884 |
who := mthd who. |
1885 |
who notNil ifTrue:[ |
|
1886 |
^ who methodClass name , ' >> #' , who methodSelector |
|
1887 |
] |
|
623 | 1888 |
]. |
1889 |
^ mthd displayString. |
|
1890 |
||
1891 |
" |
|
12841 | 1892 |
thisContext methodPrintString |
1893 |
thisContext sender methodPrintString |
|
623 | 1894 |
" |
1853
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1895 |
|
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1896 |
"Modified: 1.11.1996 / 16:21:49 / cg" |
623 | 1897 |
! |
1898 |
||
12789 | 1899 |
printAllOn:aStream |
1900 |
"print a brief walkback (excl. arguments) starting at the receiver" |
|
1901 |
||
15010 | 1902 |
self withAllSendersDo:[:con | con printOn:aStream. aStream cr]. |
12789 | 1903 |
|
1904 |
" |
|
1905 |
thisContext printAllOn:Transcript |
|
1906 |
" |
|
1907 |
||
1908 |
"Created: 15.1.1997 / 18:09:05 / cg" |
|
1909 |
! |
|
1910 |
||
21146 | 1911 |
printAllOn:aStream throughContextForWhich:aBlock |
1912 |
"print a short walkback (excl. arguments) starting at the receiver" |
|
1913 |
||
1914 |
self withSendersThroughContextForWhich:aBlock do:[:con | |
|
1915 |
con printOn:aStream. aStream cr. |
|
1916 |
]. |
|
1917 |
||
1918 |
" |
|
1919 |
thisContext printAllOn:Transcript throughContextForWhich:[:con | con selector == #doIt]. |
|
1920 |
" |
|
1921 |
! |
|
1922 |
||
1923 |
printAllOn:aStream upToContextForWhich:aBlock |
|
1924 |
"print a short walkback (excl. arguments) starting at the receiver" |
|
1925 |
||
1926 |
self withSendersUpToContextForWhich:aBlock do:[:con | |
|
1927 |
con printOn:aStream. aStream cr. |
|
1928 |
]. |
|
1929 |
||
1930 |
" |
|
1931 |
thisContext printAllOn:Transcript upToContextForWhich:[:con | con selector == #withCursor:do:]. |
|
1932 |
" |
|
1933 |
! |
|
1934 |
||
13612 | 1935 |
printAllString |
1936 |
"return a string containing the walkback (excl. arguments)" |
|
1937 |
||
1938 |
|s| |
|
1939 |
||
15383 | 1940 |
s := WriteStream on:''. |
13612 | 1941 |
self printAllOn:s. |
1942 |
^ s contents |
|
1943 |
||
1944 |
" |
|
1945 |
thisContext printAllString |
|
1946 |
" |
|
1947 |
||
1948 |
"Created: / 21-08-2011 / 07:38:05 / cg" |
|
1949 |
! |
|
1950 |
||
16223 | 1951 |
printClassNameOf:aClass on:aStream |
1952 |
"helper for printing" |
|
1953 |
||
16819
c96b396b7307
Oops, fix in Context >> printClassNameOf:on: for Java static methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16818
diff
changeset
|
1954 |
| nonMeta | |
c96b396b7307
Oops, fix in Context >> printClassNameOf:on: for Java static methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16818
diff
changeset
|
1955 |
|
c96b396b7307
Oops, fix in Context >> printClassNameOf:on: for Java static methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16818
diff
changeset
|
1956 |
(nonMeta := aClass theNonMetaclass) isJavaClass ifTrue:[ |
c96b396b7307
Oops, fix in Context >> printClassNameOf:on: for Java static methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16818
diff
changeset
|
1957 |
nonMeta javaName printOn: aStream |
16223 | 1958 |
] ifFalse:[ |
18190 | 1959 |
(aClass name ? '????') printOn:aStream. |
16223 | 1960 |
]. |
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1961 |
|
16819
c96b396b7307
Oops, fix in Context >> printClassNameOf:on: for Java static methods
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16818
diff
changeset
|
1962 |
"Modified: / 08-08-2014 / 09:39:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
16223 | 1963 |
! |
1964 |
||
623 | 1965 |
printOn:aStream |
12789 | 1966 |
"append a brief description (excl. arguments) of the receiver onto aStream" |
623 | 1967 |
|
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1968 |
| m | |
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1969 |
|
15383 | 1970 |
self printReceiverOn:aStream. |
10549 | 1971 |
"/ aStream nextPutAll:' '. |
1972 |
aStream nextPutAll:' >> '. |
|
1973 |
||
1974 |
aStream bold. |
|
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1975 |
m := self method. |
18190 | 1976 |
m isJavaMethod ifTrue:[ |
1977 |
aStream nextPutAll: (m printStringForBrowserWithSelector: self selector). |
|
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1978 |
] ifFalse:[ |
18190 | 1979 |
self selector printOn:aStream. "show as string (as symbol looks too ugly in browser ...)" |
1980 |
"/ self selector storeOn:aStream. "show as symbol" |
|
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1981 |
]. |
10549 | 1982 |
aStream normal. |
16569 | 1983 |
|
14225 | 1984 |
(method notNil and:[method isWrapped]) ifTrue:[ |
18190 | 1985 |
aStream nextPutAll:' (wrapped) ' |
14225 | 1986 |
]. |
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1987 |
aStream nextPutAll:' ['. |
18190 | 1988 |
m isJavaMethod ifTrue:[ |
1989 |
aStream nextPutAll: self method mclass sourceFile ? '???' . |
|
1990 |
m isNative ifTrue:[ |
|
1991 |
aStream nextPutAll: ':in native code' |
|
1992 |
] ifFalse:[ |
|
1993 |
aStream nextPut: $:. |
|
1994 |
(m lineNumberForPC0: lineNr) ? '???' printOn: aStream. |
|
1995 |
]. |
|
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1996 |
] ifFalse:[ |
18190 | 1997 |
self lineNumber printOn: aStream |
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1998 |
]. |
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
1999 |
aStream nextPut:$]. |
4393 | 2000 |
|
14302 | 2001 |
"Modified: / 05-08-2012 / 12:00:00 / cg" |
16818
2f2ff0820cef
Fixes in Context>>#printClassNameOf:on: / #printOn: for Java classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16797
diff
changeset
|
2002 |
"Modified: / 08-08-2014 / 07:37:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
623 | 2003 |
! |
2004 |
||
15383 | 2005 |
printReceiverOn:aStream |
2006 |
"print description of the receiver of the context to aStream" |
|
2007 |
||
2008 |
|receiverClass receiverClassName implementorClass| |
|
2009 |
||
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2010 |
receiverClassName := self safeReceiverClassNameIfInvalid. |
15383 | 2011 |
receiverClassName notNil ifTrue:[ |
18190 | 2012 |
"if we come here, this is a context with an illegal class" |
2013 |
receiverClassName printOn:aStream. |
|
2014 |
^ self. |
|
15383 | 2015 |
]. |
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
2016 |
|
623 | 2017 |
receiverClass := receiver class. |
15383 | 2018 |
|
2019 |
(receiverClass == SmallInteger or:[receiverClass == Float]) ifTrue:[ |
|
18190 | 2020 |
aStream nextPut:$(. receiver printOn:aStream. aStream nextPutAll:') '. |
15383 | 2021 |
]. |
16223 | 2022 |
self printClassNameOf:receiverClass on:aStream. |
15383 | 2023 |
|
2024 |
(selector notNil or:[method notNil]) ifTrue:[ |
|
18190 | 2025 |
"/ implementorClass := self searchClass whichClassIncludesSelector:selector. |
2026 |
||
2027 |
" |
|
2028 |
kludge to avoid slow search for containing class |
|
2029 |
" |
|
2030 |
(method notNil |
|
2031 |
or:[selector ~~ #doIt and:[selector ~~ #doIt:]]) ifTrue:[ |
|
2032 |
implementorClass := self methodClass. |
|
2033 |
implementorClass isNil ifTrue:[ |
|
2034 |
" |
|
2035 |
kludge for the frame called by a wrappedmethod; |
|
2036 |
the wrappedmethod is in the class, so its mclass is correct. |
|
2037 |
however, the originalmethod is invoked via performMethod, and its mclass |
|
2038 |
is nil. Care for this here. Think about keeping the mclass in the original method. |
|
2039 |
" |
|
2040 |
(method notNil and:[method isWrapped not]) ifTrue:[ |
|
2041 |
WrappedMethod notNil ifTrue:[ |
|
2042 |
WrappedMethod allWrappedMethodsDo:[:wrapped | |
|
2043 |
wrapped originalMethodIfWrapped == method ifTrue:[ |
|
2044 |
implementorClass := wrapped mclass. |
|
2045 |
]. |
|
2046 |
]. |
|
2047 |
]. |
|
2048 |
] |
|
2049 |
]. |
|
2050 |
]. |
|
2051 |
||
2052 |
implementorClass notNil ifTrue: [ |
|
2053 |
(implementorClass ~~ receiverClass) ifTrue: [ |
|
2054 |
aStream nextPut:$(. |
|
2055 |
self printClassNameOf:implementorClass on:aStream. |
|
2056 |
aStream nextPut:$). |
|
2057 |
] |
|
2058 |
] ifFalse:[ |
|
2059 |
| srchClass where | |
|
2060 |
||
2061 |
srchClass := self searchClass. |
|
2062 |
srchClass ~~ receiverClass ifTrue:[ |
|
2063 |
aStream nextPut:$(. |
|
2064 |
self printClassNameOf:srchClass on:aStream. |
|
2065 |
aStream nextPut:$). |
|
2066 |
]. |
|
2067 |
" |
|
2068 |
kludge for doIt - these unbound methods are not |
|
2069 |
found in the classes methodDictionary |
|
2070 |
" |
|
2071 |
true "(selector ~~ #doIt and:[selector ~~ #doIt:])" ifTrue:[ |
|
2072 |
" |
|
2073 |
kludge for methods invoked explicitly via valueWithReceiver... |
|
2074 |
" |
|
2075 |
(self sender notNil |
|
2076 |
and:[ self sender receiver isMethod |
|
2077 |
and:[ self sender selector startsWith:'valueWithReceiver:' ]]) ifTrue:[ |
|
2078 |
where := '(**DIRECTED**)'. |
|
2079 |
] ifFalse:[ |
|
2080 |
where := '(**NONE**)'. |
|
2081 |
]. |
|
2082 |
aStream nextPutAll:where |
|
2083 |
] |
|
2084 |
] |
|
623 | 2085 |
]. |
2086 |
||
15961 | 2087 |
"Created: / 23-10-2013 / 11:13:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2088 |
"Modified: / 05-02-2014 / 17:50:33 / cg" |
|
10549 | 2089 |
! |
2090 |
||
15383 | 2091 |
receiverPrintString |
2092 |
"return a string describing the receiver of the context" |
|
2093 |
||
2094 |
|s| |
|
2095 |
||
2096 |
s := WriteStream on:''. |
|
2097 |
self printReceiverOn:s. |
|
2098 |
^ s contents |
|
2099 |
||
2100 |
" |
|
15933 | 2101 |
thisContext receiverPrintString |
15383 | 2102 |
" |
2103 |
! |
|
2104 |
||
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2105 |
safeReceiverClassNameIfInvalid |
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2106 |
"if the receiver refers to an invalid object, |
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2107 |
return a replacement string. otherwise nil. |
10549 | 2108 |
This cares for invalid (free) objects which may appear with bad primitive code, |
2109 |
and prevents a crash in such a case." |
|
2110 |
||
2111 |
%{ |
|
18412 | 2112 |
#ifdef __SCHTEAM__ |
2113 |
return __c__._RETURN( ((STContinuation)self).stSelf(__c__) ); |
|
2114 |
#else |
|
10549 | 2115 |
/* |
2116 |
* special handling for (invalid) free objects. |
|
2117 |
* these only appear if some primitiveCode does not correctly use SEND macros, |
|
2118 |
* which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
|
12841 | 2119 |
*/ |
10549 | 2120 |
if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) { |
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2121 |
RETURN( __MKSTRING("FreeObject") ); |
10549 | 2122 |
} |
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2123 |
#endif /* not SCHTEAM */ |
10549 | 2124 |
%}. |
18297
e0881b40ff42
safeReceiverName fix (was confusing and had wrong name)
Claus Gittinger <cg@exept.de>
parents:
18291
diff
changeset
|
2125 |
^ nil |
10549 | 2126 |
|
2127 |
"Created: / 21-05-2007 / 13:19:37 / cg" |
|
623 | 2128 |
! ! |
2129 |
||
7257 | 2130 |
!Context methodsFor:'private-accessing'! |
623 | 2131 |
|
11340
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2132 |
isMarkedForUnwind |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2133 |
"true if the mark for unwind flag is set in the receiver. |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2134 |
The VM needs this to know that some special action is to be performed with |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2135 |
this context - a highly internal mechanism and not for public use." |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2136 |
|
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2137 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2138 |
#ifdef __SCHTEAM__ |
18412 | 2139 |
return context._RETURN ( ((STContinuation)self).isMarkedForUnwind() ); |
18190 | 2140 |
#else |
18253 | 2141 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false ); |
18190 | 2142 |
#endif |
11340
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2143 |
%} |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2144 |
" |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2145 |
thisContext isMarkedForUnwind |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2146 |
" |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2147 |
! |
ceae06796c52
unwinding fixed for on:do:ensure:
Claus Gittinger <cg@exept.de>
parents:
11337
diff
changeset
|
2148 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2149 |
markForHandle |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2150 |
"set the mark for exception handle flag in the receiver. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2151 |
The VM needs this to know that some special action is to be performed with |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2152 |
this context - a highly internal mechanism and not for public use." |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2153 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2154 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2155 |
#ifdef __SCHTEAM__ |
18412 | 2156 |
((STContinuation)self).markForHandle(); |
18190 | 2157 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2158 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__HANDLE_MARK)); |
18190 | 2159 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2160 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2161 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2162 |
"Modified: 13.12.1995 / 19:05:22 / cg" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2163 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2164 |
|
753
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2165 |
markForInterrupt |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2166 |
"set the interrupt flag. |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2167 |
The VM needs this to know that some special action is to be performed with |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2168 |
this context upon return - a highly internal mechanism and not for public use." |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2169 |
|
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2170 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2171 |
#ifdef __SCHTEAM__ |
18412 | 2172 |
((STContinuation)self).markForInterrupt(); |
18190 | 2173 |
#else |
753
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2174 |
__markInterrupted(__ContextInstPtr(self)); |
18190 | 2175 |
#endif |
753
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2176 |
%} |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2177 |
! |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
2178 |
|
1727 | 2179 |
markForInterruptOnUnwind |
2180 |
"set the interrupt-on-unwind flag in the receiver. |
|
2181 |
The VM will generate a stepInterrupt, when this context returns or |
|
2182 |
is unwound. This is used by the debugger for faster single-stepping; |
|
2183 |
- a highly internal mechanism and not for public use." |
|
2184 |
||
2185 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2186 |
#ifdef __SCHTEAM__ |
18412 | 2187 |
((STContinuation)self).markForInterruptOnUnwind(); |
18190 | 2188 |
#else |
3508 | 2189 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__IRQ_ON_UNWIND)); |
18190 | 2190 |
#endif |
1727 | 2191 |
%} |
2192 |
! |
|
2193 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2194 |
markForRaise |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2195 |
"set the mark for exception raise flag in the receiver. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2196 |
The VM needs this to know that some special action is to be performed with |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2197 |
this context - a highly internal mechanism and not for public use." |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2198 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2199 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2200 |
#ifdef __SCHTEAM__ |
18412 | 2201 |
((STContinuation)self).markForRaise(); |
18190 | 2202 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2203 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__RAISE_MARK)); |
18190 | 2204 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2205 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2206 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2207 |
"Modified: 13.12.1995 / 19:05:22 / cg" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2208 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2209 |
|
623 | 2210 |
markForUnwind |
749 | 2211 |
"set the mark for unwind flag in the receiver. |
2212 |
The VM needs this to know that some special action is to be performed with |
|
2213 |
this context - a highly internal mechanism and not for public use." |
|
2214 |
||
623 | 2215 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2216 |
#ifdef __SCHTEAM__ |
18412 | 2217 |
((STContinuation)self).markForUnwind(); |
18190 | 2218 |
#else |
1133 | 2219 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__UNWIND_MARK)); |
18190 | 2220 |
#endif |
623 | 2221 |
%} |
749 | 2222 |
|
2223 |
"Modified: 13.12.1995 / 19:05:22 / cg" |
|
623 | 2224 |
! |
2225 |
||
5780 | 2226 |
setHome:aContext |
2227 |
"set the homeContext. |
|
2228 |
DANGER: this is for experimental, internal use only (byteCode interpreters)" |
|
2229 |
||
2230 |
home := aContext. |
|
2231 |
! |
|
2232 |
||
2233 |
setSender:aContext |
|
2234 |
"set the sender of the context. |
|
2235 |
DANGER: this is for experimental, internal use only (byteCode interpreters)" |
|
2236 |
||
2237 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2238 |
#ifdef __SCHTEAM__ |
18412 | 2239 |
((STContinuation)self).caller = aContext.asSTContinuation(); |
18190 | 2240 |
#else |
5780 | 2241 |
__INST(sender_) = aContext; |
18190 | 2242 |
#endif |
5780 | 2243 |
%} |
2244 |
! |
|
2245 |
||
623 | 2246 |
unmarkForUnwind |
749 | 2247 |
"clear the mark for unwind flag in the receiver. |
2248 |
The VM needs this to know that some special action is to be performed with |
|
2249 |
this context - a highly internal mechanism and not for public use." |
|
2250 |
||
623 | 2251 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2252 |
#ifdef __SCHTEAM__ |
18412 | 2253 |
((STContinuation)self).unmarkForUnwind(); |
18190 | 2254 |
#else |
1133 | 2255 |
__INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK)); |
18190 | 2256 |
#endif |
623 | 2257 |
%} |
2258 |
! ! |
|
2259 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2260 |
!Context methodsFor:'searching'! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2261 |
|
8284 | 2262 |
findExceptional |
12841 | 2263 |
"walk along the sender chain (starting with the sender), |
8284 | 2264 |
for a context which is marked as handle or raise context. |
2265 |
This non-standard interface is only to be used by exception" |
|
2266 |
||
2267 |
"/ this could have been (actually: was) implemented as: |
|
2268 |
"/ |
|
2269 |
"/ |con| |
|
2270 |
"/ |
|
2271 |
"/ con := self. |
|
2272 |
"/ [con notNil] whileTrue:[ |
|
2273 |
"/ [con isHandleContext] ifTrue:[^con]. |
|
2274 |
"/ [con isRaiseContext] ifTrue:[^con]. |
|
2275 |
"/ con := con sender. |
|
2276 |
"/ ]. |
|
2277 |
"/ ^ nil |
|
2278 |
"/ |
|
2279 |
"/ and the code below does exactly this (somewhat faster, though). |
|
2280 |
"/ |
|
2281 |
"/ (it avoids referencing all intermediate contexts, which would mark them special, |
|
2282 |
"/ although they aren't really - this is expert knowledge, no need to understand that ...) |
|
2283 |
||
2284 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2285 |
#ifdef __SCHTEAM__ |
18253 | 2286 |
{ |
18412 | 2287 |
STContinuation lastCallee = (STContinuation)self; |
2288 |
STContinuation caller = lastCallee.caller; |
|
18406 | 2289 |
|
2290 |
while (caller != null) { |
|
18253 | 2291 |
if (caller.isExceptionalSmalltalkContext()) { |
18412 | 2292 |
caller = lastCallee.sender(); // exposed |
18253 | 2293 |
return context._RETURN(caller); |
2294 |
} |
|
18412 | 2295 |
lastCallee = caller; |
2296 |
caller = lastCallee.caller; |
|
18253 | 2297 |
} |
2298 |
return context._RETURN( STObject.Nil ); |
|
2299 |
} |
|
2300 |
/* NOTREACHED */ |
|
18190 | 2301 |
#else |
8284 | 2302 |
OBJ theContext; |
2303 |
||
2304 |
theContext = self; |
|
2305 |
while (__isNonNilObject(theContext)) { |
|
15933 | 2306 |
if ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__HANDLE_MARK|__RAISE_MARK)) { |
2307 |
if (__isLazy(theContext)) { |
|
2308 |
__PATCHUPCONTEXT(theContext); |
|
2309 |
} |
|
2310 |
RETURN (theContext); |
|
2311 |
} |
|
2312 |
theContext = __ContextInstPtr(theContext)->c_sender; |
|
8284 | 2313 |
} |
18253 | 2314 |
#endif /* not SCHTEAM */ |
8284 | 2315 |
%}. |
2316 |
^ nil |
|
2317 |
! |
|
2318 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2319 |
findNextContextWithSelector:selector1 or:selector2 or:selector3 |
12841 | 2320 |
"walk along the sender chain (starting with the sender), |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2321 |
for a context with either one of the given selectors. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2322 |
This non-standard interface is only to be used by exception" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2323 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2324 |
"/ this could have been (actually: was) implemented as: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2325 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2326 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2327 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2328 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2329 |
"/ [con notNil] whileTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2330 |
"/ con selector == aSelector ifTrue:[^ con]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2331 |
"/ con := con sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2332 |
"/ ]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2333 |
"/ ^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2334 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2335 |
"/ and the code below does exactly this (somewhat faster, though). |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2336 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2337 |
"/ (it avoids referencing all intermediate contexts, which would mark them special, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2338 |
"/ although they aren't really - this is expert knowledge, no need to understand that ...) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2339 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2340 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2341 |
#ifdef __SCHTEAM__ |
18216 | 2342 |
{ |
18412 | 2343 |
STContinuation lastCallee = (STContinuation)self; |
2344 |
STContinuation cont = lastCallee.caller; |
|
2345 |
||
18216 | 2346 |
STObject sel1 = context.stArg(0); |
2347 |
STObject sel2 = context.stArg(1); |
|
2348 |
STObject sel3 = context.stArg(2); |
|
2349 |
||
18406 | 2350 |
while (cont != null) { |
2351 |
if (cont.isSmalltalkContext()) { |
|
2352 |
STObject thisSelector = cont.contextSelector(); |
|
18216 | 2353 |
|
2354 |
if ((thisSelector == sel1) |
|
2355 |
|| (thisSelector == sel2) |
|
2356 |
|| (thisSelector == sel3)) { |
|
2357 |
break; |
|
2358 |
} |
|
2359 |
} |
|
18412 | 2360 |
lastCallee = cont; |
2361 |
cont = lastCallee.caller; |
|
18216 | 2362 |
} |
18406 | 2363 |
if (cont == null) { |
2364 |
return __c__._RETURN_nil(); |
|
2365 |
} |
|
18412 | 2366 |
cont = lastCallee.sender(); // exposed |
18406 | 2367 |
return __c__._RETURN(cont); |
18216 | 2368 |
} |
2369 |
/* NOTREACHED */ |
|
18190 | 2370 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2371 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2372 |
OBJ sel; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2373 |
OBJ __FETCHSELECTOR(); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2374 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2375 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2376 |
while (__isNonNilObject(theContext)) { |
15933 | 2377 |
if (__isLazy(theContext)) { |
18190 | 2378 |
# ifdef TRADITIONAL_STACK_FRAME |
15933 | 2379 |
sel = __FETCHSELECTOR(theContext); |
18190 | 2380 |
# else |
15933 | 2381 |
/* mhmh - not really needed */ |
2382 |
__PATCHUPCONTEXT(theContext); |
|
2383 |
sel = __ContextInstPtr(theContext)->c_selector; |
|
18190 | 2384 |
# endif |
15933 | 2385 |
} else { |
2386 |
sel = __ContextInstPtr(theContext)->c_selector; |
|
2387 |
} |
|
2388 |
||
2389 |
if ((sel == selector1) |
|
2390 |
|| ((selector2 != nil) && (sel == selector2)) |
|
2391 |
|| ((selector3 != nil) && (sel == selector3))) { |
|
2392 |
if (__isLazy(theContext)) { |
|
2393 |
__PATCHUPCONTEXT(theContext); |
|
2394 |
} |
|
2395 |
RETURN (theContext); |
|
2396 |
} |
|
2397 |
theContext = __ContextInstPtr(theContext)->c_sender; |
|
5422 | 2398 |
} |
2399 |
RETURN (nil); |
|
18190 | 2400 |
#endif |
5422 | 2401 |
%}. |
2402 |
" |
|
2403 |
|con sel| |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2404 |
|
5422 | 2405 |
con := self sender. |
2406 |
[con notNil] whileTrue:[ |
|
15933 | 2407 |
sel := con selector. |
2408 |
sel == selector1 ifTrue:[^ con]. |
|
2409 |
(selector2 notNil and:[sel == selector2]) ifTrue:[^ con]. |
|
2410 |
(selector3 notNil and:[sel == selector3]) ifTrue:[^ con]. |
|
2411 |
con := con sender. |
|
5422 | 2412 |
]. |
2413 |
^ nil |
|
2414 |
" |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2415 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2416 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2417 |
findNextUnwindContextOr:aContext |
12841 | 2418 |
"walk along the sender chain (starting at the sender), |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2419 |
for a context marked for unwindAction or aContext. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2420 |
This non-standard interface is only to be used by mySelf" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2421 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2422 |
"/ this could have been (actually: was) implemented as: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2423 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2424 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2425 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2426 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2427 |
"/ [con notNil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2428 |
"/ and:[con ~~ aContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2429 |
"/ and:[con isUnwindContext not]]] whileTrue:[con := con sender]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2430 |
"/ ^ con |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2431 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2432 |
"/ and the code below does exactly this (somewhat faster, though). |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2433 |
"/ (it avoids referencing all intermediate contexts, which would mark them special, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2434 |
"/ although they aren't really - this is expert knowledge, no need to understand that ...) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2435 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2436 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2437 |
#ifdef __SCHTEAM__ |
18408 | 2438 |
{ |
2439 |
if (self == aContext) { |
|
2440 |
return __c__._RETURN(self); |
|
2441 |
} |
|
2442 |
||
18412 | 2443 |
STContinuation lastCallee = (STContinuation)self; |
2444 |
STContinuation theContext = lastCallee.caller; |
|
18408 | 2445 |
|
2446 |
while (theContext != null) { |
|
2447 |
if ((theContext == aContext) |
|
2448 |
|| theContext.isMarkedForUnwind()) { |
|
18412 | 2449 |
theContext = lastCallee.sender(); // exposed |
18408 | 2450 |
return __c__._RETURN(theContext); |
2451 |
} |
|
18412 | 2452 |
lastCallee = theContext; |
2453 |
theContext = lastCallee.caller; |
|
18408 | 2454 |
} |
2455 |
} |
|
18190 | 2456 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2457 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2458 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2459 |
if (self == aContext) { |
15933 | 2460 |
RETURN (self); |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2461 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2462 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2463 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2464 |
while (__isNonNilObject(theContext)) { |
15933 | 2465 |
if ((theContext == aContext) |
2466 |
|| ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__UNWIND_MARK))) { |
|
2467 |
if (__isLazy(theContext)) { |
|
2468 |
__PATCHUPCONTEXT(theContext); |
|
2469 |
} |
|
2470 |
RETURN (theContext); |
|
2471 |
} |
|
2472 |
theContext = __ContextInstPtr(theContext)->c_sender; |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2473 |
} |
18190 | 2474 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2475 |
%}. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2476 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2477 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2478 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2479 |
findSpecialHandle:findHandleContext raise:findRaiseContext |
12841 | 2480 |
"walk along the sender chain (starting with the sender), |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2481 |
for a context which is marked as handle or raise context. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2482 |
This non-standard interface is only to be used by exception" |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2483 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2484 |
"/ this could have been (actually: was) implemented as: |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2485 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2486 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2487 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2488 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2489 |
"/ [con notNil] whileTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2490 |
"/ (findHandleContext and:[con isHandleContext]) ifTrue:[^con]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2491 |
"/ (findRaiseContext and:[con isRaiseContext]) ifTrue:[^con]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2492 |
"/ con := con sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2493 |
"/ ]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2494 |
"/ ^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2495 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2496 |
"/ and the code below does exactly this (somewhat faster, though). |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2497 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2498 |
"/ (it avoids referencing all intermediate contexts, which would mark them special, |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2499 |
"/ although they aren't really - this is expert knowledge, no need to understand that ...) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2500 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2501 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2502 |
#ifdef __SCHTEAM__ |
18406 | 2503 |
{ |
18412 | 2504 |
STContinuation lastCallee = (STContinuation)self; |
2505 |
STContinuation theContext = lastCallee.caller; |
|
2506 |
||
18406 | 2507 |
while (theContext != null) { |
2508 |
if (theContext.isMarkedSpecial()) { |
|
2509 |
if ((findHandleContext == STObject.True) |
|
2510 |
&& theContext.isMarkedForHandle()) { |
|
18412 | 2511 |
theContext = lastCallee.sender(); // exposed |
18406 | 2512 |
return __c__._RETURN(theContext); |
2513 |
} |
|
2514 |
if ((findRaiseContext == STObject.True) |
|
2515 |
&& theContext.isMarkedForRaise()) { |
|
18412 | 2516 |
theContext = lastCallee.sender(); // exposed |
18406 | 2517 |
return __c__._RETURN(theContext); |
2518 |
} |
|
2519 |
} |
|
18412 | 2520 |
lastCallee = theContext; |
2521 |
theContext = lastCallee.caller; |
|
18406 | 2522 |
} |
2523 |
} |
|
18190 | 2524 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2525 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2526 |
int flagMask = 0; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2527 |
INT mask; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2528 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2529 |
if (findHandleContext == true) |
15933 | 2530 |
flagMask = __HANDLE_MARK; |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2531 |
if (findRaiseContext == true) |
15933 | 2532 |
flagMask |= __RAISE_MARK; |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2533 |
|
12841 | 2534 |
mask = __MASKSMALLINT(flagMask); |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2535 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2536 |
while (__isNonNilObject(theContext)) { |
15933 | 2537 |
if ((INT)(__ContextInstPtr(theContext)->c_flags) & mask) { |
2538 |
if (__isLazy(theContext)) { |
|
2539 |
__PATCHUPCONTEXT(theContext); |
|
2540 |
} |
|
2541 |
RETURN (theContext); |
|
2542 |
} |
|
2543 |
theContext = __ContextInstPtr(theContext)->c_sender; |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2544 |
} |
18190 | 2545 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2546 |
%}. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2547 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2548 |
! ! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2549 |
|
1051 | 2550 |
!Context methodsFor:'special accessing'! |
2551 |
||
4557 | 2552 |
canResume |
2553 |
"return true, if the receiver allows to be resumed. |
|
18412 | 2554 |
In ST/X, due to the implementation, this requires that the context which |
2555 |
is right below the receiver is returnable and still active." |
|
4557 | 2556 |
|
2557 |
|theContext| |
|
2558 |
||
2559 |
" |
|
2560 |
starting with this context, find the one below |
|
2561 |
(i.e. the one that I have called) and return from it. |
|
2562 |
" |
|
2563 |
%{ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2564 |
#ifdef __SCHTEAM__ |
18412 | 2565 |
// in the SCHTEAM-engine, all contexts are resumable |
18289 | 2566 |
return context._RETURN_true(); |
18190 | 2567 |
#else |
4557 | 2568 |
OBJ sndr; |
2569 |
||
2570 |
theContext = __thisContext; |
|
2571 |
while (theContext != nil) { |
|
15933 | 2572 |
sndr = __ContextInstPtr(theContext)->c_sender; |
2573 |
if (sndr == self) break; |
|
2574 |
theContext = sndr; |
|
4557 | 2575 |
} |
2576 |
if (theContext != nil) { |
|
15933 | 2577 |
if (__isLazy(theContext)) { |
2578 |
__PATCHUPCONTEXT(theContext); |
|
2579 |
} |
|
4557 | 2580 |
} |
18190 | 2581 |
#endif |
4557 | 2582 |
%}. |
2583 |
theContext isNil ifTrue:[ |
|
15933 | 2584 |
^ false |
4557 | 2585 |
]. |
2586 |
^ theContext canReturn |
|
2587 |
! |
|
2588 |
||
1051 | 2589 |
canReturn |
2590 |
"return true, if the receiver allows returning through it. |
|
4557 | 2591 |
Blocks, (currently) always return false. |
2646 | 2592 |
Methods which contain a (non-inlined) block are always |
2593 |
returnable - for other methods, it depends on how the system |
|
2594 |
was compiled (stc flag +/-optContext). |
|
2595 |
If it was compiled with +optContext, methods are compiled |
|
4557 | 2596 |
non returnable, unless a return-pragma was present in the method. |
2646 | 2597 |
Since this saves some administrative work in every method |
2598 |
invocation and makes overall execution faster, the system classes |
|
18412 | 2599 |
are all compiled with this flag turned on. |
2600 |
This means, that by default, it is not possible to walk up the |
|
2601 |
calling chain and return to an arbitrary context. |
|
2602 |
For contexts which are known to require this (i.e. handlers as found |
|
2603 |
by the exception walkers, these are marked specially (markForReturn), |
|
2604 |
so compilers know that they should create full featured contexts." |
|
1051 | 2605 |
|
2606 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2607 |
#ifdef __SCHTEAM__ |
18412 | 2608 |
// in the SCHTEAM-engine, all contexts can be returned from |
18289 | 2609 |
return context._RETURN_true(); |
18190 | 2610 |
#else |
3508 | 2611 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true ); |
18190 | 2612 |
#endif |
5441 | 2613 |
%}. |
2614 |
^ true |
|
1051 | 2615 |
! |
2616 |
||
1492 | 2617 |
hasStackToShow |
2646 | 2618 |
"private interface to the debugger. |
2619 |
Smalltalk contexts return false here - other language frames |
|
2620 |
(i.e. Java frames) may want to show the evaluation stack" |
|
2621 |
||
1492 | 2622 |
^ false |
2623 |
||
2624 |
"Created: 28.6.1996 / 14:48:39 / cg" |
|
2646 | 2625 |
"Modified: 13.5.1997 / 16:31:12 / cg" |
1492 | 2626 |
! |
2627 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2628 |
isHandleContext |
4505 | 2629 |
"return true, if this is a context with exception-handle flag set" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2630 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2631 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2632 |
#ifdef __SCHTEAM__ |
18412 | 2633 |
return __c__._RETURN ( ((STContinuation)self).isMarkedForHandle() ); |
18190 | 2634 |
#else |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2635 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__HANDLE_MARK)) ? true : false ); |
18190 | 2636 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2637 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2638 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2639 |
|
1051 | 2640 |
isNonLifo |
2646 | 2641 |
"return true, if this is a nonLifo context. |
2642 |
A nonLifo context is one that is still on the machine stack, |
|
2643 |
but has a reference taken and needs to be converted to a real |
|
2644 |
object (in objectMemory) when the method/block returns. |
|
18412 | 2645 |
You don't have to understand this - this is a special ST/X |
2646 | 2646 |
debug query, which may be removed without notice." |
1051 | 2647 |
|
2648 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2649 |
#ifdef __SCHTEAM__ |
18412 | 2650 |
return __c__._RETURN ( ((STContinuation)self).isNonLifo() ); |
18190 | 2651 |
#else |
1133 | 2652 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__NONLIFO)) ? true : false ); |
18190 | 2653 |
#endif |
1051 | 2654 |
%} |
2655 |
! |
|
2656 |
||
2657 |
isOnMachineStack |
|
12841 | 2658 |
"return true, if this is a machine stack context as opposed to a |
18412 | 2659 |
real heap context (i.e. if it has not been captured and returned from). |
2660 |
You don't have to understand this - this is a special ST/X |
|
2646 | 2661 |
debug query, which may be removed without notice." |
1051 | 2662 |
|
2663 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2664 |
#ifdef __SCHTEAM__ |
18412 | 2665 |
return __c__._RETURN ( ! ((STContinuation)self).isCopiedToHeap() ); |
18190 | 2666 |
#else |
18412 | 2667 |
RETURN ( (__qSpace(self) >= STACKSPACE) ? true : false ); |
18190 | 2668 |
#endif |
1051 | 2669 |
%} |
2670 |
! |
|
2671 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2672 |
isRaiseContext |
4505 | 2673 |
"return true, if this is a context with exception-raise flag set" |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2674 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2675 |
%{ /* NOCONTEXT */ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2676 |
#ifdef __SCHTEAM__ |
18412 | 2677 |
return __c__._RETURN ( ((STContinuation)self).isMarkedForRaise() ); |
18190 | 2678 |
#else |
18412 | 2679 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__RAISE_MARK)) ? true : false ); |
18190 | 2680 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2681 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2682 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
2683 |
|
1051 | 2684 |
isSpecial |
2685 |
"return true, if this is either a nonLifo or interrupted context" |
|
2686 |
||
2687 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2688 |
#ifdef __SCHTEAM__ |
18412 | 2689 |
return __c__._RETURN ( ((STContinuation)self).isMarkedSpecial() ); |
18190 | 2690 |
#else |
18412 | 2691 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__SPECIAL)) ? true : false ); |
18190 | 2692 |
#endif |
1051 | 2693 |
%} |
2694 |
! |
|
2695 |
||
2696 |
isUnwindContext |
|
2697 |
"return true, if this is an unwindContext" |
|
2698 |
||
2699 |
%{ /* NOCONTEXT */ |
|
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18216
diff
changeset
|
2700 |
#ifdef __SCHTEAM__ |
18412 | 2701 |
return __c__._RETURN ( ((STContinuation)self).isMarkedForUnwind() ); |
18190 | 2702 |
#else |
18412 | 2703 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false ); |
18190 | 2704 |
#endif |
1051 | 2705 |
%} |
8578 | 2706 |
! |
2707 |
||
2708 |
tempNames |
|
2709 |
"helper: given a context, return a collection of arg, var and temporary names" |
|
2710 |
||
2711 |
|names nTemps| |
|
2712 |
||
2713 |
names := self argAndVarNames. |
|
2714 |
(nTemps := self numTemps) > 0 ifTrue:[ |
|
15933 | 2715 |
^ names , ((1 to:nTemps) collect:[:idx | '_tmp' , idx printString]). |
8578 | 2716 |
]. |
2717 |
^ names. |
|
1051 | 2718 |
! ! |
2719 |
||
623 | 2720 |
!Context methodsFor:'testing'! |
2721 |
||
2722 |
isBlockContext |
|
2723 |
"return true, iff the receiver is a BlockContext, false otherwise" |
|
2724 |
||
2725 |
^ false |
|
2726 |
! |
|
2727 |
||
14214 | 2728 |
isCheapBlockContext |
2729 |
"return true, iff the receiver is a BlockContext, for a cheap block, false otherwise. |
|
2730 |
Cheap blocks do not refer to their home" |
|
2731 |
||
2732 |
^ false |
|
2733 |
||
2734 |
"Created: / 19-07-2012 / 11:22:38 / cg" |
|
2735 |
! |
|
2736 |
||
623 | 2737 |
isContext |
2738 |
"return true, iff the receiver is a Context, false otherwise" |
|
2739 |
||
2740 |
^ true |
|
2741 |
! |
|
2742 |
||
16078 | 2743 |
isReallyRecursive |
2744 |
"return true, if this context is one of a recursive send of the same |
|
2745 |
selector AND same argument(s) to the same receiver before. |
|
2746 |
Here, different arguments are NOT ignored" |
|
2747 |
||
2748 |
|c count "{Class: SmallInteger }" sameArgs| |
|
2749 |
||
2750 |
count := 0. |
|
2751 |
||
2752 |
c := self findNextContextWithSelector:selector or:nil or:nil. |
|
2753 |
[c notNil] whileTrue:[ |
|
18437 | 2754 |
(c receiver == receiver) ifTrue:[ |
2755 |
c method == self method ifTrue:[ |
|
2756 |
sameArgs := true. |
|
2757 |
1 to:self argumentCount do:[:i | |
|
2758 |
(c argAt:1) ~~ (self argAt:i)ifTrue:[ |
|
2759 |
sameArgs := false |
|
2760 |
] |
|
2761 |
]. |
|
2762 |
sameArgs ifTrue:[^ true]. |
|
2763 |
] |
|
2764 |
]. |
|
2765 |
c := c findNextContextWithSelector:selector or:nil or:nil. |
|
2766 |
||
2767 |
" |
|
2768 |
this special test was added to get out after a while |
|
2769 |
if the sender chain is corrupt - this gives us at least |
|
2770 |
a chance to find those errors. |
|
2771 |
" |
|
2772 |
count := count + 1. |
|
2773 |
count >= 100000 ifTrue:[ |
|
2774 |
'Context [warning]: bad context chain' errorPrintCR. |
|
2775 |
^ true |
|
2776 |
] |
|
16078 | 2777 |
]. |
2778 |
^ false |
|
2779 |
! |
|
2780 |
||
623 | 2781 |
isRecursive |
2782 |
"return true, if this context is one of a recursive send of the same |
|
1483 | 2783 |
selector to the same receiver before. |
2784 |
Here, different arguments are ignored - i.e. only the same method |
|
2785 |
counts for recursiveness. |
|
623 | 2786 |
Used to detect recursive errors or recursive printing - for example." |
2787 |
||
16078 | 2788 |
|c count "{Class: SmallInteger }"| |
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
2789 |
|
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
2790 |
count := 0. |
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
2791 |
|
2893 | 2792 |
c := self findNextContextWithSelector:selector or:nil or:nil. |
623 | 2793 |
[c notNil] whileTrue:[ |
18190 | 2794 |
(c receiver == receiver) ifTrue:[ |
16077 | 2795 |
"/ " |
2796 |
"/ stupid: the current ST/X context does not include |
|
2797 |
"/ the method, but the class, in which the search started ... |
|
2798 |
"/ " |
|
2799 |
"/ myMethodsClass isNil ifTrue:[ |
|
2800 |
"/ myMethodsClass := self methodClass. |
|
2801 |
"/ ]. |
|
2802 |
"/ c methodClass == myMethodsClass ifTrue:[ |
|
2803 |
"/ ^ true |
|
2804 |
"/ ]. |
|
18190 | 2805 |
"/ now it does!! |
2806 |
c method == self method ifTrue:[^ true]. |
|
2807 |
]. |
|
2808 |
c := c findNextContextWithSelector:selector or:nil or:nil. |
|
2809 |
||
2810 |
" |
|
2811 |
this special test was added to get out after a while |
|
2812 |
if the sender chain is corrupt - this gives us at least |
|
2813 |
a chance to find those errors. |
|
2814 |
" |
|
2815 |
count := count + 1. |
|
2816 |
count >= 100000 ifTrue:[ |
|
2817 |
'Context [warning]: bad context chain' errorPrintCR. |
|
2818 |
^ true |
|
2819 |
] |
|
623 | 2820 |
]. |
2821 |
^ false |
|
1483 | 2822 |
|
2135
6bd144c1c358
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1853
diff
changeset
|
2823 |
"Modified: 10.1.1997 / 17:34:26 / cg" |
623 | 2824 |
! ! |
2825 |
||
1810 | 2826 |
!Context class methodsFor:'documentation'! |
749 | 2827 |
|
14418
6558e5c3b32e
changed: #receiverPrintString
Claus Gittinger <cg@exept.de>
parents:
14413
diff
changeset
|
2828 |
version |
18977 | 2829 |
^ '$Header$' |
14418
6558e5c3b32e
changed: #receiverPrintString
Claus Gittinger <cg@exept.de>
parents:
14413
diff
changeset
|
2830 |
! |
6558e5c3b32e
changed: #receiverPrintString
Claus Gittinger <cg@exept.de>
parents:
14413
diff
changeset
|
2831 |
|
13426 | 2832 |
version_CVS |
18977 | 2833 |
^ '$Header$' |
15644 | 2834 |
! |
2835 |
||
2836 |
version_HG |
|
2837 |
||
2838 |
^ '$Changeset: <not expanded> $' |
|
12573 | 2839 |
! |
2840 |
||
13426 | 2841 |
version_SVN |
15232 | 2842 |
^ '$ Id: Context.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
749 | 2843 |
! ! |
7257 | 2844 |
|
14700 | 2845 |
|
623 | 2846 |
Context initialize! |