author | Stefan Vogel <sv@exept.de> |
Fri, 18 May 2001 00:28:30 +0200 | |
changeset 5871 | cf03b06e442e |
parent 5780 | 6851b6dcbefa |
child 5911 | b9b601514f13 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
154 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
5422 | 13 |
"{ Package: 'stx:libbasic' }" |
14 |
||
1 | 15 |
Object variableSubclass:#Context |
2646 | 16 |
instanceVariableNames:'flags sender* home receiver selector searchClass lineNr |
17 |
retvalTemp handle*' |
|
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
18 |
classVariableNames:'InvalidReturnSignal SingleStepInterruptRequest' |
749 | 19 |
poolDictionaries:'' |
20 |
category:'Kernel-Methods' |
|
1 | 21 |
! |
22 |
||
1810 | 23 |
!Context class methodsFor:'documentation'! |
54 | 24 |
|
88 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
154 | 28 |
All Rights Reserved |
88 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
54 | 39 |
documentation |
40 |
" |
|
402 | 41 |
Contexts represent the stack frame objects, which keep the processing |
42 |
state of a method or block (i.e. its local variables, temporaries etc.) |
|
43 |
Every message send adds a context to a chain, which can be traced back via |
|
44 |
the sender field. The context of the currently active method is always |
|
45 |
accessable via the pseuodoVariable called 'thisContext'. |
|
141 | 46 |
(The actual implementation uses the machines stack for this, building real |
402 | 47 |
contexts on demand only). |
54 | 48 |
|
69 | 49 |
For both method- and block-contexts, the layout is the same. |
402 | 50 |
For method contexts, the home-field is nil, while for block contexts the home- |
141 | 51 |
field is either the context of its surrounding block (i.e. the context of the |
52 |
block, in which the receiving block was created, if its a nested block) or of |
|
53 |
its home method. |
|
54 |
||
55 |
Contexts of cheap blocks do not have a home context - their home field is |
|
56 |
also nil. |
|
54 | 57 |
|
141 | 58 |
Currently, contexts do not contain a reference to the method or block which |
59 |
created it - this is not needed for program execution, but could get the debugger |
|
60 |
somewhat into trouble: it has to search the class hierarchy for receiver/selector |
|
61 |
combinations to find the method. This usually works, but fails in case of methods |
|
62 |
which are not anchored in any class - especially leading to problems with wrapper- |
|
63 |
and lazy methods. Also, Method>>valueWithReceiver - type of invocations cannot |
|
64 |
be easily debugged. |
|
402 | 65 |
Therefore, the implementation may be changed in the near future, to include a |
141 | 66 |
field for the method/block, and set it in the VM during program execution. |
67 |
(there may be some small performance penalty for this, though). |
|
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, |
|
83 |
via the debuggers restart button). With 2.10.6, this is now an stc-compiler |
|
84 |
option, and the system as delivered is compiled to only create restartable |
|
85 |
contexts for those which contain blocks. This resulted in an overall speedup of |
|
86 |
roughly 10-20% percent, depending on the type of CPU. However, it makes most |
|
87 |
methods non-restartable (however, abort, signal handling and unwind blocks work |
|
88 |
as usual). |
|
89 |
In practice, this was reported to be not a severe limitation and all users were happy |
|
90 |
to trade the increased performance for that slight inconvenience. |
|
91 |
(during development, this is seldom a problem, since interpreted methods are always |
|
92 |
returnable and restartable) |
|
93 |
If you do not like this (and you are a happy owner of the full distribution), you |
|
94 |
should recompile all classes with stc's '-optContext' flag. |
|
95 |
||
96 |
Resuming contexts: |
|
97 |
||
98 |
Strictly speaking, ST/X does not support a context to be resumed. However, |
|
99 |
it does support a forced return (i.e. non-local-return) from a context. |
|
100 |
Thus, resume of a context is implemented by forcing a return from the context |
|
101 |
which was created by the method called from the first one. The effect is the same. |
|
102 |
||
103 |
Returning from a dead method: |
|
104 |
||
105 |
Blocksreturn from an outlived context (i.e. its home method has already returned) |
|
106 |
is now rewarded by an invalidReturn exception - it used to be a noop in previous |
|
107 |
releases (The blue book described this to be a noop, but other smalltalk implementations |
|
108 |
changed this to be an invalid operation - good decision) |
|
109 |
||
110 |
||
1282 | 111 |
[instance variables:] |
3143 | 112 |
flags <SmallInteger> used by the VM; never touch. |
113 |
contains info about number of args, |
|
114 |
locals and temporaries. |
|
216 | 115 |
|
3143 | 116 |
sender <Context> the 'calling / sending' context |
3508 | 117 |
This is not directly accessable, since it may |
118 |
be a lazy context (i.e. an empty frame). |
|
119 |
The #sender method cares for this. |
|
216 | 120 |
|
3143 | 121 |
home <Context> the context, where this block was |
122 |
created, or nil if its a method context |
|
123 |
There are also cheap blocks, which do |
|
124 |
not need a reference to the home context, |
|
125 |
for those, its nil too. |
|
216 | 126 |
|
3143 | 127 |
receiver <Object> the receiver of this message |
216 | 128 |
|
3143 | 129 |
selector <Symbol> the selector of this message |
216 | 130 |
|
3143 | 131 |
searchClass <Class> the class, where the message lookup started |
132 |
(for super sends) or nil, for regular sends. |
|
141 | 133 |
|
3143 | 134 |
lineNr <SmallInteger> the position where the context left off |
135 |
(kind of p-counter). Only the low 16bits |
|
136 |
are valid. |
|
141 | 137 |
|
3143 | 138 |
retValTemp nil temporary - always nil, when you see the context |
139 |
(used in the VM as temporary) |
|
216 | 140 |
|
3143 | 141 |
handle *noObject* used by the VM; not accessable, not an object |
141 | 142 |
|
3143 | 143 |
<indexed> arguments of the send followed by |
144 |
locals of the method/block followed by |
|
145 |
temporaries. |
|
1 | 146 |
|
1282 | 147 |
[class variables:] |
3143 | 148 |
InvalidReturnSignal signal raised when a block tries |
149 |
to return ('^') from a method context |
|
150 |
which itself has already returned |
|
151 |
(i.e. there is no place to return to) |
|
216 | 152 |
|
69 | 153 |
WARNING: layout and size known by the compiler and runtime system - do not change. |
1282 | 154 |
|
1293 | 155 |
|
156 |
[author:] |
|
3143 | 157 |
Claus Gittinger |
1293 | 158 |
|
1282 | 159 |
[see also:] |
3143 | 160 |
Block Process Method |
161 |
( contexts, stacks & unwinding : programming/contexts.html) |
|
54 | 162 |
" |
163 |
! ! |
|
1 | 164 |
|
1810 | 165 |
!Context class methodsFor:'initialization'! |
105 | 166 |
|
167 |
initialize |
|
168 |
InvalidReturnSignal isNil ifTrue:[ |
|
3143 | 169 |
InvalidReturnSignal := ErrorSignal newSignalMayProceed:true. |
170 |
InvalidReturnSignal nameClass:self message:#invalidReturnSignal. |
|
171 |
InvalidReturnSignal notifierString:'invalid return; method cannot return twice'. |
|
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
172 |
|
3143 | 173 |
SingleStepInterruptRequest := QuerySignal new. |
174 |
SingleStepInterruptRequest nameClass:self message:#singleStepInterruptRequest. |
|
175 |
SingleStepInterruptRequest notifierString:'single step'. |
|
105 | 176 |
] |
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
177 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
178 |
"Modified: 6.5.1996 / 16:46:03 / cg" |
105 | 179 |
! ! |
180 |
||
1810 | 181 |
!Context class methodsFor:'Signal constants'! |
105 | 182 |
|
183 |
invalidReturnSignal |
|
141 | 184 |
"return the signal used when a method is tried to be returned twice |
185 |
or, when some dead context is unwound or restarted." |
|
186 |
||
105 | 187 |
^ InvalidReturnSignal |
1334
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
188 |
! |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
189 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
190 |
singleStepInterruptRequest |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
191 |
"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
|
192 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
193 |
^ SingleStepInterruptRequest |
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
194 |
|
8b21c5f67b15
allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents:
1293
diff
changeset
|
195 |
"Created: 6.5.1996 / 16:46:32 / cg" |
105 | 196 |
! ! |
197 |
||
1810 | 198 |
!Context class methodsFor:'queries'! |
3 | 199 |
|
200 |
isBuiltInClass |
|
1264 | 201 |
"return true if this class is known by the run-time-system. |
202 |
Here, true is returned." |
|
3 | 203 |
|
204 |
^ true |
|
1264 | 205 |
|
206 |
"Modified: 23.4.1996 / 15:58:00 / cg" |
|
3 | 207 |
! ! |
208 |
||
4485 | 209 |
!Context class methodsFor:'special searching'! |
210 |
||
211 |
findFirstSpecialHandle:searchForHandle raise:searchForRaise |
|
212 |
|c| |
|
213 |
||
214 |
%{ |
|
215 |
OBJ __c__; |
|
216 |
||
217 |
__c__ = __ContextInstPtr(__thisContext)->c_sender; |
|
218 |
if (__isLazy(__c__)) { |
|
219 |
__PATCHUPCONTEXT(__c__); |
|
220 |
} |
|
221 |
c = __c__; |
|
222 |
%}. |
|
223 |
^ c findSpecialHandle:searchForHandle raise:searchForRaise |
|
224 |
||
225 |
||
226 |
! ! |
|
227 |
||
623 | 228 |
!Context methodsFor:'accessing'! |
229 |
||
230 |
argAt:n |
|
231 |
"return the n'th argument" |
|
232 |
||
1726 | 233 |
n > self numArgs ifTrue:[ |
3143 | 234 |
^ self error:'invalid arg access' |
1726 | 235 |
]. |
623 | 236 |
^ self at:n |
1726 | 237 |
|
238 |
"Modified: 12.10.1996 / 21:44:28 / cg" |
|
623 | 239 |
! |
240 |
||
241 |
argAt:n put:value |
|
242 |
"set the n'th argument - useful when the receiver should be restarted" |
|
154 | 243 |
|
1726 | 244 |
n > self numArgs ifTrue:[ |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
245 |
^ self error:'invalid arg access' |
1726 | 246 |
]. |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
247 |
self at:n put:value. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
248 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
249 |
"/ need some aid for optimized code - |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
250 |
"/ 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
|
251 |
"/ 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
|
252 |
%{ |
4570 | 253 |
__UNFIXCONTEXT(self, 0); |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
254 |
%}. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
255 |
^ value |
1726 | 256 |
|
257 |
"Modified: 12.10.1996 / 21:44:32 / cg" |
|
623 | 258 |
! |
259 |
||
260 |
args |
|
261 |
"return an array filled with the arguments of this context" |
|
262 |
||
263 |
|n| |
|
264 |
||
265 |
n := self numArgs. |
|
3130 | 266 |
n == 0 ifTrue:[ |
267 |
"/ little optimization here - avaoid creating empty containers |
|
268 |
^ #() |
|
269 |
]. |
|
623 | 270 |
^ (Array new:n) replaceFrom:1 to:n with:self. |
271 |
! |
|
154 | 272 |
|
623 | 273 |
argsAndVars |
274 |
"return an array filled with the arguments and variables of this context" |
|
275 |
||
276 |
|n| |
|
277 |
||
1810 | 278 |
n := self numArgs + self numVars. |
3130 | 279 |
n == 0 ifTrue:[ |
3143 | 280 |
"/ little optimization here - avoid creating empty containers |
3130 | 281 |
^ #() |
282 |
]. |
|
623 | 283 |
^ (Array new:n) replaceFrom:1 to:n with:self. |
1810 | 284 |
|
285 |
"Modified: 23.10.1996 / 16:19:41 / cg" |
|
623 | 286 |
! |
154 | 287 |
|
623 | 288 |
home |
289 |
"return the immediate home of the receiver. |
|
290 |
for block contexts, this is the methodcontext, where the block was created, |
|
291 |
for nested block contexts, its the surrounding blocks context. |
|
292 |
for method-contexts this is nil." |
|
25 | 293 |
|
623 | 294 |
^ nil "home" |
295 |
! |
|
1 | 296 |
|
3324
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
297 |
homeReceiver |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
298 |
"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
|
299 |
|
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
300 |
^ receiver |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
301 |
|
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
302 |
"Created: / 5.3.1998 / 16:18:26 / stefan" |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
303 |
! |
0295f7b3b208
Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents:
3258
diff
changeset
|
304 |
|
1 | 305 |
instVarAt:index |
69 | 306 |
"have to catch instVar access to retVal and handle - they are invalid. |
307 |
Notice, that one of the next ST/X versions will get some syntactic |
|
308 |
extension to get this automatically)." |
|
1 | 309 |
|
3508 | 310 |
(index == 2) ifTrue:[^ self sender]."/ sender - must be accessed specially |
3182
2526de1e5030
dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
3143
diff
changeset
|
311 |
(index == 8) ifTrue:[^ nil]. "/ retvalTemp - invisible |
2526de1e5030
dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents:
3143
diff
changeset
|
312 |
(index == 9) ifTrue:[^ nil]. "/ handle to machine stack - invisible |
1 | 313 |
^ super instVarAt:index |
314 |
! |
|
315 |
||
316 |
instVarAt:index put:value |
|
69 | 317 |
"have to catch instVar access to retVal and handle - they are invalid. |
318 |
Notice, that one of the next ST/X versions will get some syntactic |
|
319 |
extension to get this automatically)." |
|
1 | 320 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
321 |
(index == 2) ifTrue:[^ nil]. "/ sender - not allowed to change |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
322 |
(index == 8) ifTrue:[^ nil]. "/ retvalTemp - not allowed to change |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
323 |
(index == 9) ifTrue:[^ nil]. "/ handle to machine stack - not allowed to change |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
324 |
super instVarAt:index put:value. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
325 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
326 |
"/ need some aid for optimized code - |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
327 |
"/ 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
|
328 |
"/ 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
|
329 |
%{ |
4570 | 330 |
__UNFIXCONTEXT(self, 0); |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
331 |
%}. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
332 |
^ value |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
333 |
|
1 | 334 |
! |
335 |
||
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
336 |
javaLineNumber |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
337 |
|nr pc| |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
338 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
339 |
lineNr notNil ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
340 |
pc := lineNr bitAnd:16rFFFF. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
341 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
342 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
343 |
"/ '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
|
344 |
pc isNil ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
345 |
nr := self lineNumberFromMethod. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
346 |
nr notNil ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
347 |
^ nr |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
348 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
349 |
" '-> 0 [a]' printCR. " |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
350 |
^0 |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
351 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
352 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
353 |
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
|
354 |
nr isNil ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
355 |
nr := self lineNumberFromMethod. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
356 |
nr notNil ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
357 |
^ nr |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
358 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
359 |
" '-> 0 [b]' printCR. " |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
360 |
^ 0 |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
361 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
362 |
"/ '-> ' print. nr printCR. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
363 |
^ nr. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
364 |
|
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
365 |
! |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
366 |
|
623 | 367 |
lineNumber |
368 |
"this returns the lineNumber within the methods source, where the context was |
|
369 |
interrupted or called another method. (currently, sometimes this information |
|
370 |
is not available - in this case 0 is returned)" |
|
1 | 371 |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
372 |
|l| |
3923 | 373 |
|
4328
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
374 |
receiver isJavaObject ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
375 |
"/ chances are good that I am a javContext ... |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
376 |
self method isJavaMethod ifTrue:[ |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
377 |
^ self javaLineNumber |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
378 |
] |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
379 |
]. |
9cc10bae2f98
care for contexts which really ought to be java contexts
Claus Gittinger <cg@exept.de>
parents:
3923
diff
changeset
|
380 |
|
3923 | 381 |
lineNr notNil ifTrue:[ |
382 |
l := lineNr bitAnd:16rFFFF. |
|
383 |
]. |
|
384 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
385 |
"/ self isJavaContext ifTrue:[ |nr m| |
3923 | 386 |
"/ m := self method. |
387 |
"/ l isNil ifTrue:[ |
|
388 |
"/ m notNil ifTrue:[ |
|
389 |
"/ nr := m lineNumber |
|
390 |
"/ ]. |
|
391 |
"/ nr notNil ifTrue:[ |
|
392 |
"/ ^ nr |
|
393 |
"/ ]. |
|
394 |
"/ ^0 |
|
395 |
"/ ]. |
|
396 |
"/ nr := self method lineNumberForPC:l. |
|
397 |
"/ nr isNil ifTrue:[ |
|
398 |
"/ m notNil ifTrue:[ |
|
399 |
"/ nr := m lineNumber |
|
400 |
"/ ]. |
|
401 |
"/ nr notNil ifTrue:[ |
|
402 |
"/ ^ nr |
|
403 |
"/ ]. |
|
404 |
"/ ^ 0 |
|
405 |
"/ ]. |
|
406 |
"/ ^ nr. |
|
407 |
"/ ]. |
|
408 |
||
409 |
^ l |
|
410 |
||
411 |
"Modified: / 10.11.1998 / 13:19:48 / cg" |
|
1 | 412 |
! |
413 |
||
4450 | 414 |
lineNumberFromMethod |
415 |
^ 1 |
|
416 |
! |
|
417 |
||
1 | 418 |
method |
54 | 419 |
"return the method for which the receiver was created. |
420 |
To save time during normal execution, this information is not held in the |
|
421 |
context, but computed here on request." |
|
1 | 422 |
|
3508 | 423 |
|c sender sendersSelector m| |
1 | 424 |
|
325 | 425 |
c := self searchClass. |
426 |
" |
|
427 |
the below cannot happen in normal circumstances |
|
428 |
(added to avoid recursive errors in case of a broken sender chain) |
|
429 |
" |
|
430 |
c isBehavior ifFalse:[ |
|
3143 | 431 |
'Context [error]: non class in searchClass' errorPrintCR. |
432 |
' selector: ' errorPrint. selector errorPrint. |
|
433 |
' receiver: ' errorPrint. receiver errorPrintCR. |
|
434 |
^ nil |
|
325 | 435 |
]. |
436 |
||
328 | 437 |
c := c whichClassIncludesSelector:selector. |
1 | 438 |
c notNil ifTrue:[ |
3143 | 439 |
^ c compiledMethodAt:selector |
1 | 440 |
]. |
216 | 441 |
|
3508 | 442 |
"mhmh - seems to be a context for an unbound method (as generated by doIt); |
216 | 443 |
look in the senders context. Consider this a kludge. |
3143 | 444 |
(maybe it was not too good of an idea to NOT keep the current |
445 |
method in the context ...) |
|
446 |
Future versions of ST/X's message lookup may store the method in |
|
447 |
the context. |
|
216 | 448 |
" |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
449 |
sender := self sender. |
3143 | 450 |
sender notNil ifTrue:[ |
451 |
sendersSelector := sender selector. |
|
452 |
sendersSelector notNil ifTrue:[ |
|
453 |
(sendersSelector startsWith:'valueWithReceiver:') ifTrue:[ |
|
3508 | 454 |
m := sender receiver. |
455 |
m isMethod ifTrue:[ |
|
456 |
^ m |
|
457 |
] |
|
3143 | 458 |
] |
459 |
] |
|
216 | 460 |
]. |
461 |
||
1 | 462 |
^ nil |
2135
6bd144c1c358
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1853
diff
changeset
|
463 |
|
3143 | 464 |
"Modified: / 4.1.1998 / 21:15:32 / cg" |
1 | 465 |
! |
466 |
||
212 | 467 |
methodClass |
468 |
"return the class in which the method for which the receiver was created is." |
|
469 |
||
1456 | 470 |
|cls m| |
471 |
||
472 |
cls := self searchClass. |
|
3923 | 473 |
(cls isMeta |
474 |
and:[cls soleInstance isJavaClass]) ifTrue:[ |
|
475 |
cls := cls soleInstance |
|
476 |
]. |
|
1456 | 477 |
|
3923 | 478 |
[cls notNil] whileTrue:[ |
479 |
cls := cls whichClassIncludesSelector:selector. |
|
480 |
cls isNil ifTrue:[^ nil]. |
|
481 |
||
482 |
m := cls compiledMethodAt:selector. |
|
483 |
m notNil ifTrue:[ |
|
484 |
m isIgnored ifFalse:[^ cls]. |
|
485 |
]. |
|
486 |
cls := cls superclass |
|
1456 | 487 |
]. |
488 |
^ cls |
|
489 |
||
3923 | 490 |
"Modified: / 5.11.1998 / 19:07:43 / cg" |
212 | 491 |
! |
492 |
||
623 | 493 |
methodHome |
494 |
"return the method-home - for method contexts this is the receiver" |
|
495 |
||
496 |
^ self |
|
497 |
! |
|
498 |
||
499 |
ntemp |
|
500 |
"return the number of temporary variables of the Block/Method. |
|
1810 | 501 |
(for debugging only). |
502 |
I dont like the name of this method; its here for compatibility." |
|
623 | 503 |
|
1810 | 504 |
^ self numTemps |
505 |
||
506 |
"Modified: 23.10.1996 / 16:19:06 / cg" |
|
623 | 507 |
! |
508 |
||
509 |
numArgs |
|
510 |
"return the number of arguments to the Block/Method" |
|
511 |
||
512 |
%{ /* NOCONTEXT */ |
|
513 |
||
1133 | 514 |
RETURN ( __MKSMALLINT( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) ); |
623 | 515 |
%} |
516 |
! |
|
517 |
||
1810 | 518 |
numTemps |
519 |
"return the number of temporary variables of the Block/Method. |
|
520 |
(for debugging only)" |
|
521 |
||
522 |
^ self size - self numArgs - self numVars |
|
523 |
||
524 |
"Created: 23.10.1996 / 16:19:10 / cg" |
|
525 |
"Modified: 23.10.1996 / 16:19:48 / cg" |
|
526 |
! |
|
527 |
||
528 |
numVars |
|
623 | 529 |
"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
|
530 |
|
623 | 531 |
%{ /* NOCONTEXT */ |
532 |
||
1133 | 533 |
RETURN ( __MKSMALLINT( (__intVal(__INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) ); |
623 | 534 |
%} |
535 |
! |
|
536 |
||
1810 | 537 |
nvars |
538 |
"return the number of local variables of the Block/Method. |
|
539 |
I dont like the name of this method; its here for compatibility." |
|
540 |
||
541 |
^ self numVars |
|
542 |
||
543 |
"Modified: 23.10.1996 / 16:18:44 / cg" |
|
544 |
! |
|
545 |
||
623 | 546 |
receiver |
547 |
"return the receiver of the context" |
|
548 |
||
549 |
^ receiver |
|
550 |
! |
|
551 |
||
4543 | 552 |
receiver:aCompiledCode |
553 |
"set the receiver of the message" |
|
554 |
||
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
555 |
receiver := aCompiledCode. |
4543 | 556 |
|
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
557 |
"/ need some aid for optimized code - |
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
558 |
"/ some machines have the arguments kept in register vars ... |
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
559 |
"/ 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
|
560 |
%{ |
4570 | 561 |
__UNFIXCONTEXT(self, 0); |
4560
618151751813
Need _UNFIXCONTEXT() when changing receiver.
Stefan Vogel <sv@exept.de>
parents:
4557
diff
changeset
|
562 |
%}. |
4543 | 563 |
|
564 |
! |
|
565 |
||
623 | 566 |
searchClass |
567 |
"this is the class where the method-lookup started; |
|
568 |
for normal sends, it is nil (or sometimes the receivers class). |
|
569 |
For supersends, its the superclass of the one, in which the |
|
570 |
caller was defined." |
|
571 |
||
572 |
searchClass notNil ifTrue:[^ searchClass]. |
|
573 |
^ receiver class |
|
574 |
! |
|
575 |
||
576 |
selector |
|
577 |
"return the selector of the method for which the context was created" |
|
578 |
||
579 |
^ selector |
|
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
580 |
! |
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
581 |
|
1 | 582 |
sender |
583 |
"return the sender of the context" |
|
584 |
||
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
585 |
%{ /* NOCONTEXT */ |
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
586 |
OBJ theContext; |
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
587 |
|
3508 | 588 |
theContext = __INST(sender_); |
949 | 589 |
/* |
590 |
* this special nil test is for the very first context (startup-context); |
|
591 |
* actually, its cosmetics, to avoid a visible nil>>nil context in the debugger. |
|
592 |
*/ |
|
2205 | 593 |
if (__isNonNilObject(theContext)) { |
949 | 594 |
|
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
595 |
if (__isLazy(theContext)) { |
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
596 |
/* |
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
597 |
* this cannot happen |
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
598 |
*/ |
2212 | 599 |
__PATCHUPCONTEXT(theContext); |
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
600 |
} |
3508 | 601 |
if (! __isNonLIFO(theContext)) { |
602 |
/* |
|
603 |
* to be prepared for the worst situation |
|
604 |
* (the sender is not stored, so the trap wont catch it) |
|
605 |
* make the writeBarrier trigger manually. |
|
606 |
* We'll see, if this is really required. |
|
607 |
*/ |
|
608 |
theContext->o_space |= CATCHMARK; |
|
609 |
_markNonLIFO(theContext); |
|
610 |
} |
|
536
dcffd1753902
be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents:
528
diff
changeset
|
611 |
} |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
612 |
RETURN (theContext); |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
613 |
%} |
1 | 614 |
! |
615 |
||
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
616 |
senderIsNil |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
617 |
"return true, if I have no sender" |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
618 |
|
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
619 |
%{ /* NOCONTEXT */ |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
620 |
if ( __INST(sender_) == nil ) { |
5422 | 621 |
RETURN (true); |
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
622 |
} |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
623 |
RETURN (false); |
5422 | 624 |
%}. |
625 |
^ self sender isNil |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
626 |
! |
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
627 |
|
623 | 628 |
setLineNumber:aNumber |
629 |
"private entry for uncompiledCodeObject ..." |
|
1 | 630 |
|
623 | 631 |
lineNr := aNumber |
340 | 632 |
! |
633 |
||
5749 | 634 |
setNumArgs:nA numVars:nV |
635 |
"set the number of arguments and variables" |
|
636 |
||
637 |
%{ /* NOCONTEXT */ |
|
638 |
int flg; |
|
639 |
||
640 |
flg = __intVal(__INST(flags)); |
|
641 |
flg = flg & ~(__NARG_MASK << __NARG_SHIFT); |
|
642 |
flg = flg & ~(__NVAR_MASK << __NVAR_SHIFT); |
|
643 |
flg = flg | __intVal(nA) << __NARG_SHIFT; |
|
644 |
flg = flg | __intVal(nV) << __NVAR_SHIFT; |
|
645 |
__INST(flags) = __MKSMALLINT(flg); |
|
646 |
%} |
|
647 |
! |
|
648 |
||
202 | 649 |
temporaries |
650 |
"return an array filled with the temporaries of this context" |
|
651 |
||
308 | 652 |
|nonTemps mySize| |
202 | 653 |
|
1810 | 654 |
nonTemps := self numArgs + self numVars. |
655 |
mySize := self numTemps. |
|
3130 | 656 |
mySize == 0 ifTrue:[ |
657 |
"/ little optimization here - avaoid creating empty containers |
|
658 |
^ #() |
|
659 |
]. |
|
308 | 660 |
^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonTemps+1 |
1810 | 661 |
|
662 |
"Modified: 23.10.1996 / 16:20:00 / cg" |
|
202 | 663 |
! |
664 |
||
10 | 665 |
varAt:n |
666 |
"return the n'th local variable" |
|
667 |
||
154 | 668 |
^ self at:(n + self numArgs) |
10 | 669 |
! |
670 |
||
671 |
varAt:n put:value |
|
672 |
"set the n'th local variable - useful when the receiver should be restarted |
|
54 | 673 |
or continued" |
10 | 674 |
|
154 | 675 |
self at:(n + self numArgs) put:value |
10 | 676 |
! |
677 |
||
623 | 678 |
vars |
679 |
"return an array filled with the local variables of this context" |
|
375 | 680 |
|
623 | 681 |
|nonVars mySize| |
360 | 682 |
|
623 | 683 |
nonVars := self numArgs. |
1810 | 684 |
mySize := self numVars. |
3130 | 685 |
mySize == 0 ifTrue:[ |
686 |
"/ little optimization here - avaoid creating empty containers |
|
687 |
^ #() |
|
688 |
]. |
|
623 | 689 |
^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1 |
1810 | 690 |
|
691 |
"Modified: 23.10.1996 / 16:20:06 / cg" |
|
1 | 692 |
! ! |
693 |
||
623 | 694 |
!Context methodsFor:'copying'! |
415 | 695 |
|
3350
40dc4807a6d4
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3324
diff
changeset
|
696 |
deepCopyUsing:aDictionary |
623 | 697 |
"raise an error - deepCopy is not allowed for contexts" |
37 | 698 |
|
623 | 699 |
^ self deepCopyError |
3350
40dc4807a6d4
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3324
diff
changeset
|
700 |
|
40dc4807a6d4
must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents:
3324
diff
changeset
|
701 |
"Created: / 31.3.1998 / 15:51:14 / cg" |
1 | 702 |
! ! |
703 |
||
77 | 704 |
!Context methodsFor:'error handling'! |
705 |
||
706 |
invalidReturn:returnValue |
|
707 |
"this message is sent by the VM, when a methods context |
|
708 |
which has already returned is about to return again. |
|
709 |
(i.e. about to execute a return from an already returned |
|
105 | 710 |
method in a block). |
141 | 711 |
We raise a signal here, to allow catching of that situation." |
77 | 712 |
|
406 | 713 |
" |
714 |
in previous versions of ST/X and ST-80, this was no error; |
|
715 |
(instead, a normal blockreturn was performed to the value-sender). |
|
716 |
From a note in comp.lang.smalltalk, I conclude that new ST-80 versions |
|
717 |
now raise an error if this happens. |
|
718 |
Comment out the raise below to get that (old) behavior |
|
719 |
BETTER REWRITE YOUR APPLICATION |
|
720 |
" |
|
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
721 |
"/ old behavior: |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
722 |
"/ ^ returnValue |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
723 |
|
282 | 724 |
"/ new behavior: |
725 |
||
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
726 |
"/ 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
|
727 |
"/ use another error message. |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
728 |
|
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
729 |
(home notNil and:[home sender notNil]) ifTrue:[ |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
730 |
^ InvalidReturnSignal |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
731 |
raiseRequestWith:returnValue |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
732 |
errorString:'cannot return from another process''s context'. |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
733 |
]. |
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
734 |
|
406 | 735 |
^ InvalidReturnSignal |
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
736 |
raiseRequestWith:returnValue. |
282 | 737 |
|
3258
2d96bba62ff1
use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents:
3182
diff
changeset
|
738 |
"Modified: / 2.2.1998 / 15:19:52 / cg" |
406 | 739 |
! |
740 |
||
741 |
invalidReturnOrRestart:returnValue |
|
742 |
"this message is sent by the VM, when a methods context |
|
743 |
which was compiled non-returnable is about to return again. |
|
744 |
We raise a signal here, to allow catching of that situation." |
|
745 |
||
360 | 746 |
^ InvalidReturnSignal |
747 |
raiseRequestWith:returnValue |
|
748 |
errorString:'method was compiled non-resumable' |
|
749 |
! |
|
750 |
||
751 |
invalidReturnOrRestartError:how with:value |
|
752 |
"common error reporter for restart/return errors" |
|
753 |
||
754 |
self canReturn ifTrue:[ |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
755 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
756 |
tried to return from/restart a context which is already dead |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
757 |
(i.e. the method/block has already executed a return) |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
758 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
759 |
^ InvalidReturnSignal |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
760 |
raiseRequestWith:value |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
761 |
errorString:(how , ' context not on calling chain') |
360 | 762 |
]. |
763 |
" |
|
764 |
tried to return from/restart a context of a method which was compiled |
|
765 |
unrestartable or of a block (which is never restartable) |
|
766 |
" |
|
767 |
^ InvalidReturnSignal |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
768 |
raiseRequestWith:value |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
769 |
errorString:(how , ' context cannot be restarted/returned from') |
77 | 770 |
! ! |
771 |
||
623 | 772 |
!Context methodsFor:'minidebugger printing'! |
773 |
||
774 |
fullPrint |
|
775 |
"print the receiver, selector and args of the context |
|
776 |
- used only for MiniDebuggers walkback print" |
|
777 |
||
778 |
self receiverPrintString print. ' ' print. selector print. |
|
779 |
self size ~~ 0 ifTrue: [ |
|
3143 | 780 |
' ' print. self argsDisplayString print |
623 | 781 |
]. |
1426 | 782 |
' [' print. self lineNumber print. ']' printCR |
623 | 783 |
|
784 |
" |
|
785 |
thisContext fullPrint |
|
786 |
" |
|
1426 | 787 |
|
788 |
"Modified: 20.5.1996 / 10:27:14 / cg" |
|
623 | 789 |
! |
790 |
||
791 |
fullPrintAll |
|
792 |
"print a full walkback starting at the receiver |
|
793 |
- used only for MiniDebuggers walkback print" |
|
794 |
||
795 |
|context| |
|
796 |
||
797 |
context := self. |
|
798 |
[context notNil] whileTrue: [ |
|
799 |
context fullPrint. |
|
800 |
context := context sender |
|
801 |
] |
|
802 |
||
803 |
" |
|
804 |
thisContext fullPrintAll |
|
805 |
" |
|
2173 | 806 |
! |
807 |
||
4674 | 808 |
fullPrintAllLevels:nOrNil |
809 |
"print a full walkback starting at the receiver, only print n levels |
|
810 |
- used only for MiniDebuggers walkback print" |
|
811 |
||
812 |
|context count| |
|
813 |
||
814 |
count := 0. |
|
815 |
context := self. |
|
816 |
[context notNil] whileTrue: [ |
|
817 |
context fullPrint. |
|
818 |
context := context sender. |
|
819 |
nOrNil ifNotNil:[ |
|
820 |
(count := count+1) > nOrNil ifTrue:[^self]. |
|
821 |
] |
|
822 |
] |
|
823 |
||
824 |
" |
|
825 |
thisContext fullPrintAll |
|
826 |
" |
|
827 |
||
828 |
"Created: / 3.9.1999 / 14:02:38 / ps" |
|
829 |
! |
|
830 |
||
2173 | 831 |
fullPrintAllOn:aStream |
832 |
"print a full walkback starting at the receiver |
|
833 |
- used only for MiniDebuggers walkback print" |
|
834 |
||
835 |
|context| |
|
836 |
||
837 |
context := self. |
|
838 |
[context notNil] whileTrue: [ |
|
3143 | 839 |
context fullPrintOn:aStream. |
840 |
context := context sender |
|
2173 | 841 |
] |
842 |
||
843 |
" |
|
844 |
thisContext fullPrintAllOn:Transcript |
|
845 |
" |
|
846 |
||
847 |
"Created: 15.1.1997 / 18:09:05 / cg" |
|
848 |
! |
|
849 |
||
850 |
fullPrintOn:aStream |
|
851 |
"print the receiver, selector and args of the context |
|
852 |
- used only for MiniDebuggers walkback print" |
|
853 |
||
854 |
self receiverPrintString printOn:aStream. ' ' printOn:aStream. selector printOn:aStream. |
|
855 |
self size ~~ 0 ifTrue: [ |
|
3143 | 856 |
' ' printOn:aStream. self argsDisplayString printOn:aStream |
2173 | 857 |
]. |
858 |
' [' printOn:aStream. self lineNumber printOn:aStream. ']' printOn:aStream. |
|
859 |
aStream cr |
|
860 |
||
861 |
" |
|
862 |
thisContext fullPrintOn:Transcript |
|
863 |
" |
|
864 |
||
865 |
"Modified: 20.5.1996 / 10:27:14 / cg" |
|
866 |
"Created: 15.1.1997 / 18:09:06 / cg" |
|
623 | 867 |
! ! |
868 |
||
1 | 869 |
!Context methodsFor:'non local control flow'! |
870 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
871 |
evaluateUnwindActionsUpTo:aContext |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
872 |
"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
|
873 |
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
|
874 |
marked using #markForUnwind. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
875 |
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
|
876 |
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
|
877 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
878 |
|con unwindBlock| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
879 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
880 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
881 |
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
|
882 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
883 |
con := self findNextUnwindContextOr:aContext. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
884 |
[con notNil and:[con ~~ aContext]] whileTrue:[ |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
885 |
unwindBlock := con receiver unwindHandlerInContext:con. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
886 |
con unmarkForUnwind. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
887 |
unwindBlock value. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
888 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
889 |
con := con findNextUnwindContextOr:aContext. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
890 |
]. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
891 |
^ con |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
892 |
! |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
893 |
|
1 | 894 |
restart |
895 |
"restart the receiver - i.e. the method is evaluated again. |
|
402 | 896 |
if the context to restart already died, trigger an error. |
141 | 897 |
This is a low level helper for unwindAndRestart. |
898 |
||
899 |
NOTICE: |
|
154 | 900 |
NO unwind actions are performed - this is usually not |
901 |
what you want (see Context>>unwindAndRestart). |
|
141 | 902 |
|
903 |
LIMITATION: |
|
154 | 904 |
currently a context can only be restarted by |
928 | 905 |
the owning process - not from outside. |
906 |
Also, the compiler has an option (+optcontext) to create |
|
907 |
non-restartable contexts (which are faster). |
|
908 |
If such a context is restarted, a runtime error is raised." |
|
1 | 909 |
|
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
910 |
%{ /* NOCONTEXT */ |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
911 |
if (__INST(sender_) != nil) { |
3143 | 912 |
__RESUMECONTEXT__(self, RESTART_VALUE, 0); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
913 |
} |
360 | 914 |
%}. |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
915 |
self sender isNil ifTrue:[^ nil]. |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
916 |
|
69 | 917 |
" |
360 | 918 |
when we arrive here, something went wrong. |
69 | 919 |
debugging ... |
920 |
" |
|
360 | 921 |
^ self invalidReturnOrRestartError:#restart with:nil |
1 | 922 |
! |
923 |
||
623 | 924 |
resume |
925 |
"resume execution in this context. I.e. as if the method called |
|
926 |
last by the receiver did a ^ nil. |
|
927 |
If the context has already returned, report an error. |
|
928 |
||
929 |
NOTICE: |
|
930 |
NO unwind actions are performed (see Context>>unwind). |
|
931 |
||
932 |
LIMITATION: |
|
933 |
currently a context can only be resumed by |
|
928 | 934 |
the owning process - not from outside. |
935 |
Also, the compiler has an option (+optcontext) to create |
|
936 |
non-resumable contexts (which are faster). |
|
937 |
If such a context is restarted, a runtime error is raised." |
|
623 | 938 |
|
939 |
^ self resume:nil |
|
940 |
! |
|
941 |
||
942 |
resume:value |
|
943 |
"resume the receiver - as if it got 'value' from whatever |
|
944 |
it called. This continues execution in the receivers method |
|
945 |
after the point where it did its last send. |
|
946 |
If the context has already returned - report an error. |
|
947 |
||
948 |
NOTICE: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
949 |
NO unwind actions are performed (see Context>>unwind:). |
623 | 950 |
|
951 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
952 |
currently a context can only be resumed by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
953 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
954 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
955 |
non-resumable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
956 |
If such a context is restarted, a runtime error is raised." |
623 | 957 |
|
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
958 |
|theContext| |
623 | 959 |
|
960 |
" |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
961 |
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
|
962 |
(i.e. the one that I have called) and return from it. |
623 | 963 |
" |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
964 |
|
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
965 |
%{ |
4557 | 966 |
OBJ sndr; |
967 |
||
2510
393a51424d60
avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents:
2368
diff
changeset
|
968 |
theContext = __thisContext; |
4557 | 969 |
while (theContext != nil) { |
970 |
sndr = __ContextInstPtr(theContext)->c_sender; |
|
971 |
if (sndr == self) break; |
|
972 |
theContext = sndr; |
|
623 | 973 |
} |
3508 | 974 |
if (theContext != nil) { |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
975 |
if (__isLazy(theContext)) { |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
976 |
__PATCHUPCONTEXT(theContext); |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
977 |
} |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
978 |
} |
623 | 979 |
%}. |
980 |
||
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
981 |
theContext isNil ifTrue:[ |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
982 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
983 |
tried to resume in context which is already dead |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
984 |
(i.e. the method/block has already executed a return) |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
985 |
" |
4557 | 986 |
^ thisContext invalidReturnOrRestartError:#'resume:' with:value |
623 | 987 |
]. |
1668
41db5950f9ea
oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents:
1492
diff
changeset
|
988 |
^ theContext return:value |
623 | 989 |
! |
990 |
||
4557 | 991 |
resumeIgnoringErrors:value |
992 |
"resume the receiver - as if it got 'value' from whatever |
|
993 |
it called. This continues execution in the receivers method |
|
994 |
after the point where it did its last send. |
|
995 |
If the context has already returned - simply return. |
|
996 |
||
997 |
NOTICE: |
|
998 |
NO unwind actions are performed (see Context>>unwind:). |
|
999 |
||
1000 |
LIMITATION: |
|
1001 |
currently a context can only be resumed by |
|
1002 |
the owning process - not from outside. |
|
1003 |
Also, the compiler has an option (+optcontext) to create |
|
1004 |
non-resumable contexts (which are faster). |
|
1005 |
If such a context is restarted, a runtime error is raised." |
|
1006 |
||
1007 |
" |
|
1008 |
starting with this context, find the one below |
|
1009 |
(i.e. the one that I have called) and return from it. |
|
1010 |
" |
|
1011 |
||
1012 |
%{ |
|
1013 |
OBJ theContext, sndr; |
|
1014 |
||
1015 |
theContext = __thisContext; |
|
1016 |
while (theContext != nil) { |
|
1017 |
sndr = __ContextInstPtr(theContext)->c_sender; |
|
1018 |
if (sndr == self) break; |
|
1019 |
theContext = sndr; |
|
1020 |
} |
|
1021 |
if (theContext != nil) { |
|
1022 |
if (__ContextInstPtr(theContext)->c_sender) { |
|
4635 | 1023 |
if (!((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__CANNOT_RETURN))) { |
1024 |
__RESUMECONTEXT__(theContext, value, 0); |
|
1025 |
} |
|
4557 | 1026 |
} |
1027 |
} |
|
1028 |
%}. |
|
1029 |
||
1030 |
"/ no error reporting |
|
1031 |
! |
|
1032 |
||
1033 |
resumeOnErrorProceed:value |
|
1034 |
"resume the receiver - as if it got 'value' from whatever |
|
1035 |
it called. This continues execution in the receivers method |
|
1036 |
after the point where it did its last send. |
|
1037 |
If the context has already returned - simply return. |
|
1038 |
||
1039 |
NOTICE: |
|
1040 |
NO unwind actions are performed (see Context>>unwind:). |
|
1041 |
||
1042 |
LIMITATION: |
|
1043 |
currently a context can only be resumed by |
|
1044 |
the owning process - not from outside. |
|
1045 |
Also, the compiler has an option (+optcontext) to create |
|
1046 |
non-resumable contexts (which are faster). |
|
1047 |
If such a context is restarted, a runtime error is raised." |
|
1048 |
||
1049 |
" |
|
1050 |
starting with this context, find the one below |
|
1051 |
(i.e. the one that I have called) and return from it. |
|
1052 |
" |
|
1053 |
||
1054 |
%{ |
|
1055 |
OBJ theContext, sndr; |
|
1056 |
||
1057 |
theContext = __thisContext; |
|
1058 |
while (theContext != nil) { |
|
1059 |
sndr = __ContextInstPtr(theContext)->c_sender; |
|
1060 |
if (sndr == self) break; |
|
1061 |
theContext = sndr; |
|
1062 |
} |
|
1063 |
if (theContext != nil) { |
|
1064 |
if (__ContextInstPtr(theContext)->c_sender) { |
|
1065 |
__RESUMECONTEXT__(theContext, value, 0); |
|
1066 |
} |
|
1067 |
} |
|
1068 |
%}. |
|
1069 |
||
1070 |
"/ no error reporting |
|
1071 |
! |
|
1072 |
||
69 | 1073 |
return |
141 | 1074 |
"return from this context with nil. I.e. as if it did a ^ nil. |
1075 |
NOTICE: |
|
154 | 1076 |
NO unwind actions are performed - this is usually not |
1077 |
what you want (See Context>>unwind). |
|
1078 |
This is a low level method - a helper for unwind. |
|
1 | 1079 |
|
141 | 1080 |
LIMITATION: |
154 | 1081 |
currently a context can only be returned by |
928 | 1082 |
the owning process - not from outside. |
1083 |
Also, the compiler has an option (+optcontext) to create |
|
1084 |
non-returnable contexts (which are faster). |
|
1085 |
If such a context is restarted, a runtime error is raised." |
|
141 | 1086 |
|
1087 |
^ self return:nil |
|
1 | 1088 |
! |
1089 |
||
69 | 1090 |
return:value |
1091 |
"return from this context as if it did a '^ value'. |
|
141 | 1092 |
NOTICE: |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1093 |
NO unwind actions are performed - this is usually not |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1094 |
what you want (See Context>>unwind:). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1095 |
This is a low level method - a helper for unwind. |
141 | 1096 |
|
1097 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1098 |
currently a context can only be returned by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1099 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1100 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1101 |
non-returnable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1102 |
If such a context is restarted, a runtime error is raised." |
1 | 1103 |
|
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1104 |
%{ /* NOCONTEXT */ |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1105 |
if (__INST(sender_) != nil) { |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1106 |
__RESUMECONTEXT__(self, value, 0); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1107 |
} |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1108 |
%}. |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1109 |
self sender isNil ifTrue:[^ nil]. |
1 | 1110 |
|
69 | 1111 |
" |
360 | 1112 |
when we arrive here, something went wrong. |
69 | 1113 |
debugging ... |
1114 |
" |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1115 |
^ self invalidReturnOrRestartError:#'return' with:value |
1 | 1116 |
! |
1117 |
||
328 | 1118 |
returnDoing:aBlock |
1119 |
"return from this context as if it did a '^ aBlock value'. |
|
1120 |
The block is evaluated as if called by the receiver context; |
|
1121 |
NOT the true executing context. |
|
1122 |
NOTICE: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1123 |
NO unwind actions are performed - this is usually not |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1124 |
what you want (See Context>>unwindThenDo:). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1125 |
This is a low level method - a helper for unwind. |
328 | 1126 |
|
1127 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1128 |
currently a context can only be returned by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1129 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1130 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1131 |
non-returnable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1132 |
If such a context is restarted, a runtime error is raised." |
328 | 1133 |
|
4557 | 1134 |
%{ |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1135 |
if (__INST(sender_) != nil) { |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1136 |
__RESUMECONTEXT__(self, aBlock, 2); |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1137 |
} |
360 | 1138 |
%}. |
2368
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1139 |
self sender isNil ifTrue:[^ nil]. |
f13bc879cb45
dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents:
2291
diff
changeset
|
1140 |
|
328 | 1141 |
" |
360 | 1142 |
when we arrive here, something went wrong. |
328 | 1143 |
debugging ... |
1144 |
" |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1145 |
^ self invalidReturnOrRestartError:#'returnDoing' with:aBlock |
328 | 1146 |
! |
1147 |
||
1 | 1148 |
unwind |
69 | 1149 |
"return nil from the receiver - i.e. simulate a '^ nil'. |
360 | 1150 |
If the context has already retruned, report an error. |
1 | 1151 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
69 | 1152 |
and Block>>valueOnUnwindDo: on the way. |
1 | 1153 |
|
141 | 1154 |
LIMITATION: |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1155 |
currently a context can only be unwound by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1156 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1157 |
i.e. it is not possible for one thread to unwind |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1158 |
another threads context - which does not make sense anyway. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1159 |
However, you can force another thread to do this in its own process |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1160 |
context, by giving it an interrupt action - this does make sense. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1161 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1162 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1163 |
non-returnable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1164 |
If such a context is restarted, a runtime error is raised." |
141 | 1165 |
|
1166 |
^ self unwind:nil |
|
1 | 1167 |
! |
1168 |
||
1169 |
unwind:value |
|
69 | 1170 |
"return value from the receiver - i.e. simulate a '^ value'. |
360 | 1171 |
If the context has already returned , report an error. |
1 | 1172 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
69 | 1173 |
and Block>>valueOnUnwindDo: on the way. |
141 | 1174 |
|
1175 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1176 |
currently a context can only be unwound by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1177 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1178 |
i.e. it is not possible for one thread to unwind |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1179 |
another threads context - which does not make sense anyway. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1180 |
However, you can force another thread to do this in its own process |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1181 |
context, by giving it an interrupt action - this does make sense. |
1 | 1182 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1183 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1184 |
non-returnable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1185 |
If such a context is restarted, a runtime error is raised." |
1 | 1186 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1187 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1188 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1189 |
self senderIsNil ifFalse:[ |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1190 |
con := thisContext evaluateUnwindActionsUpTo:self. |
141 | 1191 |
]. |
1 | 1192 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1193 |
"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
|
1194 |
(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
|
1195 |
should we check for this situation first and NOT evaluate |
141 | 1196 |
the unwind actions in this case ?) |
1197 |
" |
|
69 | 1198 |
con isNil ifTrue:[ |
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1199 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1200 |
tried to return to a context which is already dead |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1201 |
(i.e. the method/block has already executed a return) |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1202 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1203 |
^ self invalidReturnOrRestartError:#'unwind:' with:value |
69 | 1204 |
]. |
141 | 1205 |
" |
1206 |
now, that all unwind-actions are done, I can use the |
|
1207 |
low-level return ... |
|
1208 |
" |
|
1209 |
^ self return:value |
|
1210 |
! |
|
1211 |
||
1212 |
unwindAndRestart |
|
1213 |
"restart the receiver - i.e. the method is evaluated again. |
|
402 | 1214 |
if the context to restart already died report an error. |
141 | 1215 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
1216 |
and Block>>valueOnUnwindDo: before restarting. |
|
1217 |
||
1218 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1219 |
a context can only be restarted by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1220 |
the owning process - not from outside. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1221 |
i.e. it is not possible for one thread to unwindAndRestart |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1222 |
another threads context - which does not make sense anyway. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1223 |
However, you can force another thread to do this in its own process |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1224 |
context, by giving it an interrupt action - this does make sense. |
141 | 1225 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1226 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1227 |
non-restartable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1228 |
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
|
1229 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1230 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1231 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1232 |
self senderIsNil ifFalse:[ |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1233 |
con := thisContext evaluateUnwindActionsUpTo:self. |
141 | 1234 |
]. |
1235 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1236 |
"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
|
1237 |
(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
|
1238 |
should we check for this situation first and NOT evaluate |
141 | 1239 |
the unwind actions in this case ?) |
1240 |
" |
|
1241 |
con isNil ifTrue:[ |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1242 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1243 |
tried to return to a context which is already dead |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1244 |
(i.e. the method/block has already executed a return) |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1245 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1246 |
^ self invalidReturnOrRestartError:#'unwindAndRestart:' with:nil |
141 | 1247 |
]. |
1248 |
" |
|
1249 |
now, that all unwind-actions are done, I can use the |
|
1250 |
low-level restart ... |
|
1251 |
" |
|
1252 |
^ self restart |
|
328 | 1253 |
! |
1254 |
||
4485 | 1255 |
unwindAndResume:value |
1256 |
"resume execution in the the receiver - i.e. simulate a '^ value' |
|
1257 |
from whatever it called last. |
|
1258 |
If the context has already returned , report an error. |
|
1259 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
|
1260 |
and Block>>valueOnUnwindDo: on the way. |
|
1261 |
||
1262 |
LIMITATION: |
|
1263 |
currently a context can only be unwound by |
|
1264 |
the owning process - not from outside. |
|
1265 |
i.e. it is not possible for one thread to unwind |
|
1266 |
another threads context - which does not make sense anyway. |
|
1267 |
However, you can force another thread to do this in its own process |
|
1268 |
context, by giving it an interrupt action - this does make sense. |
|
1269 |
||
1270 |
Also, the compiler has an option (+optcontext) to create |
|
1271 |
non-returnable contexts (which are faster). |
|
1272 |
If such a context is restarted, a runtime error is raised." |
|
1273 |
||
1274 |
|con| |
|
1275 |
||
1276 |
self senderIsNil ifFalse:[ |
|
1277 |
con := thisContext evaluateUnwindActionsUpTo:self. |
|
1278 |
]. |
|
1279 |
||
1280 |
"oops, if nil, I am not on the calling chain; |
|
1281 |
(bad bad, unwind action have already been performed. |
|
1282 |
should we check for this situation first and NOT evaluate |
|
1283 |
the unwind actions in this case ?) |
|
1284 |
" |
|
1285 |
con isNil ifTrue:[ |
|
1286 |
" |
|
1287 |
tried to return to a context which is already dead |
|
1288 |
(i.e. the method/block has already executed a return) |
|
1289 |
" |
|
1290 |
^ self invalidReturnOrRestartError:#'unwindAndResume:' with:value |
|
1291 |
]. |
|
1292 |
" |
|
1293 |
now, that all unwind-actions are done, I can use the |
|
1294 |
low-level resume ... |
|
1295 |
" |
|
1296 |
^ self resume:value |
|
1297 |
! |
|
1298 |
||
328 | 1299 |
unwindThenDo:aBlock |
1300 |
"return the value of aBlock from the receiver - i.e. simulate a '^ aBlock value'. |
|
360 | 1301 |
If the context has already returned , report an error. |
328 | 1302 |
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind: |
1303 |
and Block>>valueOnUnwindDo: on the way. |
|
1304 |
The block is evaluated AFTER all unwind actions are performed |
|
1305 |
(i.e. the blocks sender will be the receiving context, not the |
|
402 | 1306 |
currently executing context) |
328 | 1307 |
|
1308 |
LIMITATION: |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1309 |
currently a context can only be unwound by |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1310 |
the owning process - not from outside |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1311 |
i.e. it is not possible for one thread to unwindThenDo |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1312 |
another threads context - which does not make sense anyway. |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1313 |
However, you can force another thread to do this in its own process |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1314 |
context, by giving it an interrupt action - this does make sense. |
328 | 1315 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1316 |
Also, the compiler has an option (+optcontext) to create |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1317 |
non-returnable contexts (which are faster). |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1318 |
If such a context is restarted, a runtime error is raised." |
328 | 1319 |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1320 |
|con| |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1321 |
|
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1322 |
self senderIsNil ifFalse:[ |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1323 |
con := thisContext evaluateUnwindActionsUpTo:self. |
328 | 1324 |
]. |
1325 |
||
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1326 |
"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
|
1327 |
(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
|
1328 |
should we check for this situation first and NOT evaluate |
328 | 1329 |
the unwind actions in this case ?) |
1330 |
" |
|
1331 |
con isNil ifTrue:[ |
|
4477
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1332 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1333 |
tried to return to a context which is already dead |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1334 |
(i.e. the method/block has already executed a return) |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1335 |
" |
ef99343d6756
better #unwind - ask receiver for handler block
Claus Gittinger <cg@exept.de>
parents:
4464
diff
changeset
|
1336 |
^ self invalidReturnOrRestartError:#'unwindThenDo:' with:aBlock |
328 | 1337 |
]. |
1338 |
" |
|
1339 |
now, that all unwind-actions are done, I can use the |
|
1340 |
low-level return ... |
|
1341 |
" |
|
1342 |
^ self returnDoing:aBlock |
|
1 | 1343 |
! ! |
623 | 1344 |
|
1345 |
!Context methodsFor:'printing & storing'! |
|
1346 |
||
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1347 |
argStringFor:someObject |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1348 |
|
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1349 |
|name| |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1350 |
%{ |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1351 |
/* |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1352 |
* 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
|
1353 |
* 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
|
1354 |
* which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1355 |
*/ |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1356 |
if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) { |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1357 |
name = __MKSTRING("FreeObject"); |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1358 |
} |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1359 |
%}. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1360 |
name notNil ifTrue:[^ name]. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1361 |
^ someObject displayString |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1362 |
! |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1363 |
|
623 | 1364 |
argsDisplayString |
1365 |
|fullString n "{ Class: SmallInteger }" | |
|
1366 |
||
1367 |
fullString := ''. |
|
1368 |
n := self numArgs. |
|
1369 |
1 to:n do:[:index | |
|
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1370 |
fullString := fullString , ' ' , (self argStringFor:(self at:index)) |
623 | 1371 |
]. |
1372 |
^ fullString |
|
1373 |
! |
|
1374 |
||
1375 |
displayString |
|
1376 |
"return a string describing the context - for display in Inspector" |
|
1377 |
||
1378 |
^ self class name , '(' , self printString , ')' |
|
1379 |
! |
|
1380 |
||
1381 |
fullPrintString |
|
1382 |
"return a string describing the context - this includes the linenumber, |
|
1383 |
receiver printString and argument printString" |
|
1384 |
||
1385 |
|s| |
|
1386 |
||
1387 |
s := WriteStream on:String new. |
|
1388 |
s nextPutAll:self receiverPrintString; space; nextPutAll:selector. |
|
1389 |
self size ~~ 0 ifTrue: [ |
|
1390 |
s space. |
|
1391 |
s nextPutAll:self argsDisplayString |
|
1392 |
]. |
|
1393 |
s nextPutAll:' ['; nextPutAll:self lineNumber printString; nextPutAll:']' . |
|
1394 |
^ s contents |
|
1395 |
||
1396 |
" |
|
1397 |
thisContext fullPrintString |
|
1398 |
" |
|
1399 |
! |
|
1400 |
||
1401 |
methodPrintString |
|
1402 |
"return a string describing the contexts method as 'implementorClass>>selector'" |
|
1403 |
||
1853
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1404 |
|mthd who| |
623 | 1405 |
|
1406 |
mthd := self method. |
|
1407 |
mthd notNil ifTrue:[ |
|
3143 | 1408 |
who := mthd who. |
1409 |
who notNil ifTrue:[ |
|
1410 |
^ who methodClass name , '>>' , who methodSelector |
|
1411 |
] |
|
623 | 1412 |
]. |
1413 |
^ mthd displayString. |
|
1414 |
||
1415 |
" |
|
1416 |
thisContext methodPrintString |
|
1417 |
thisContext sender methodPrintString |
|
1418 |
" |
|
1853
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1419 |
|
09cd1e8df9a2
use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents:
1810
diff
changeset
|
1420 |
"Modified: 1.11.1996 / 16:21:49 / cg" |
623 | 1421 |
! |
1422 |
||
1423 |
printOn:aStream |
|
1424 |
"append a printed description of the receiver onto aStream" |
|
1425 |
||
1426 |
aStream nextPutAll:(self receiverPrintString). |
|
1427 |
aStream space. |
|
4393 | 1428 |
self selector printOn:aStream. |
1429 |
aStream space. |
|
1430 |
aStream nextPutAll:' ['; nextPutAll:self lineNumber printString; nextPutAll:']' . |
|
1431 |
||
623 | 1432 |
! |
1433 |
||
1434 |
receiverPrintString |
|
1435 |
"return a string describing the receiver of the context" |
|
1436 |
||
1437 |
|receiverClass receiverClassName newString implementorClass| |
|
1438 |
||
1070
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1439 |
%{ |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1440 |
/* |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1441 |
* 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
|
1442 |
* 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
|
1443 |
* which may lead to sends to free objects. In normal operation, this 'cannot' happen. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1444 |
*/ |
1133 | 1445 |
if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) { |
3923 | 1446 |
receiverClassName = __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
|
1447 |
} |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1448 |
%}. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1449 |
receiverClassName notNil ifTrue:[^ receiverClassName]. |
cf35b237612d
in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents:
1051
diff
changeset
|
1450 |
|
623 | 1451 |
receiverClass := receiver class. |
3923 | 1452 |
receiverClass isJavaClass ifTrue:[ |
1453 |
receiverClassName := receiverClass displayString |
|
1454 |
] ifFalse:[ |
|
1455 |
(receiverClass isBehavior |
|
1456 |
and:[receiverClass isMeta |
|
1457 |
and:[receiverClass soleInstance isJavaClass]]) ifTrue:[ |
|
1458 |
"/ receiverClassName := receiverClass soleInstance fullName. |
|
1459 |
receiverClassName := receiverClass name. |
|
1460 |
] ifFalse:[ |
|
1461 |
receiverClassName := receiverClass name. |
|
1462 |
] |
|
1463 |
]. |
|
623 | 1464 |
(receiverClass == SmallInteger) ifTrue:[ |
3923 | 1465 |
newString := '(' , receiver printString , ') ' , receiverClassName |
623 | 1466 |
] ifFalse:[ |
3923 | 1467 |
newString := receiverClassName |
623 | 1468 |
]. |
1469 |
||
1470 |
selector notNil ifTrue:[ |
|
1471 |
"/ implementorClass := self searchClass whichClassIncludesSelector:selector. |
|
1472 |
||
3923 | 1473 |
" |
1474 |
kludge to avoid slow search for containing class |
|
1475 |
" |
|
1476 |
(selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[ |
|
1477 |
implementorClass := self methodClass. |
|
1478 |
]. |
|
1479 |
||
1480 |
implementorClass notNil ifTrue: [ |
|
1481 |
(implementorClass ~~ receiverClass) ifTrue: [ |
|
1482 |
newString := newString , '>>>', |
|
1483 |
implementorClass name printString |
|
1484 |
] |
|
1485 |
] ifFalse:[ |
|
1486 |
self searchClass ~~ receiverClass ifTrue:[ |
|
1487 |
newString := newString , '>>>' , self searchClass name |
|
1488 |
]. |
|
1489 |
" |
|
1490 |
kludge for doIt - these unbound methods are not |
|
1491 |
found in the classes methodDictionary |
|
1492 |
" |
|
1493 |
(selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[ |
|
1494 |
newString := newString , '>>>**NONE**' |
|
1495 |
] |
|
1496 |
] |
|
623 | 1497 |
]. |
1498 |
||
1499 |
^ newString |
|
1500 |
! ! |
|
1501 |
||
1502 |
!Context methodsFor:'private accessing'! |
|
1503 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1504 |
markForHandle |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1505 |
"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
|
1506 |
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
|
1507 |
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
|
1508 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1509 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1510 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__HANDLE_MARK)); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1511 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1512 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1513 |
"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
|
1514 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1515 |
|
753
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1516 |
markForInterrupt |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1517 |
"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
|
1518 |
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
|
1519 |
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
|
1520 |
|
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1521 |
%{ /* NOCONTEXT */ |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1522 |
__markInterrupted(__ContextInstPtr(self)); |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1523 |
%} |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1524 |
! |
81d54fc53a18
added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents:
749
diff
changeset
|
1525 |
|
1727 | 1526 |
markForInterruptOnUnwind |
1527 |
"set the interrupt-on-unwind flag in the receiver. |
|
1528 |
The VM will generate a stepInterrupt, when this context returns or |
|
1529 |
is unwound. This is used by the debugger for faster single-stepping; |
|
1530 |
- a highly internal mechanism and not for public use." |
|
1531 |
||
1532 |
%{ /* NOCONTEXT */ |
|
3508 | 1533 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__IRQ_ON_UNWIND)); |
1727 | 1534 |
%} |
1535 |
! |
|
1536 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1537 |
markForRaise |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1538 |
"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
|
1539 |
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
|
1540 |
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
|
1541 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1542 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1543 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__RAISE_MARK)); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1544 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1545 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1546 |
"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
|
1547 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1548 |
|
623 | 1549 |
markForUnwind |
749 | 1550 |
"set the mark for unwind flag in the receiver. |
1551 |
The VM needs this to know that some special action is to be performed with |
|
1552 |
this context - a highly internal mechanism and not for public use." |
|
1553 |
||
623 | 1554 |
%{ /* NOCONTEXT */ |
1133 | 1555 |
__INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__UNWIND_MARK)); |
623 | 1556 |
%} |
749 | 1557 |
|
1558 |
"Modified: 13.12.1995 / 19:05:22 / cg" |
|
623 | 1559 |
! |
1560 |
||
5780 | 1561 |
setHome:aContext |
1562 |
"set the homeContext. |
|
1563 |
DANGER: this is for experimental, internal use only (byteCode interpreters)" |
|
1564 |
||
1565 |
home := aContext. |
|
1566 |
! |
|
1567 |
||
1568 |
setSender:aContext |
|
1569 |
"set the sender of the context. |
|
1570 |
DANGER: this is for experimental, internal use only (byteCode interpreters)" |
|
1571 |
||
1572 |
%{ /* NOCONTEXT */ |
|
1573 |
__INST(sender_) = aContext; |
|
1574 |
%} |
|
1575 |
! |
|
1576 |
||
623 | 1577 |
unmarkForUnwind |
749 | 1578 |
"clear the mark for unwind flag in the receiver. |
1579 |
The VM needs this to know that some special action is to be performed with |
|
1580 |
this context - a highly internal mechanism and not for public use." |
|
1581 |
||
623 | 1582 |
%{ /* NOCONTEXT */ |
1133 | 1583 |
__INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK)); |
623 | 1584 |
%} |
1585 |
! ! |
|
1586 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1587 |
!Context methodsFor:'searching'! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1588 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1589 |
findNextContextWithSelector:selector1 or:selector2 or:selector3 |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1590 |
"walk along the sender chain (starting with the sender), |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1591 |
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
|
1592 |
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
|
1593 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1594 |
"/ 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
|
1595 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1596 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1597 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1598 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1599 |
"/ [con notNil] whileTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1600 |
"/ 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
|
1601 |
"/ con := con sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1602 |
"/ ]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1603 |
"/ ^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1604 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1605 |
"/ 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
|
1606 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1607 |
"/ (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
|
1608 |
"/ 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
|
1609 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1610 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1611 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1612 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1613 |
OBJ sel; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1614 |
OBJ __FETCHSELECTOR(); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1615 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1616 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1617 |
while (__isNonNilObject(theContext)) { |
5422 | 1618 |
if (__isLazy(theContext)) { |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1619 |
#ifdef TRADITIONAL_STACK_FRAME |
5422 | 1620 |
sel = __FETCHSELECTOR(theContext); |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1621 |
#else |
5422 | 1622 |
/* mhmh - not really needed */ |
1623 |
__PATCHUPCONTEXT(theContext); |
|
1624 |
sel = __ContextInstPtr(theContext)->c_selector; |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1625 |
#endif |
5422 | 1626 |
} else { |
1627 |
sel = __ContextInstPtr(theContext)->c_selector; |
|
1628 |
} |
|
1629 |
||
1630 |
if ((sel == selector1) |
|
1631 |
|| ((selector2 != nil) && (sel == selector2)) |
|
1632 |
|| ((selector3 != nil) && (sel == selector3))) { |
|
1633 |
if (__isLazy(theContext)) { |
|
1634 |
__PATCHUPCONTEXT(theContext); |
|
1635 |
} |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1636 |
|
5422 | 1637 |
if (! __isNonLIFO(theContext)) { |
1638 |
/* |
|
1639 |
* to be prepared for the worst situation |
|
1640 |
* (the sender is not stored, so the trap wont catch it) |
|
1641 |
* make the writeBarrier trigger manually. |
|
1642 |
* We'll see, if this is really required. |
|
1643 |
*/ |
|
1644 |
theContext->o_space |= CATCHMARK; |
|
1645 |
_markNonLIFO(theContext); |
|
1646 |
} |
|
1647 |
RETURN (theContext); |
|
1648 |
} |
|
1649 |
theContext = __ContextInstPtr(theContext)->c_sender; |
|
1650 |
} |
|
1651 |
RETURN (nil); |
|
1652 |
%}. |
|
1653 |
" |
|
1654 |
|con sel| |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1655 |
|
5422 | 1656 |
con := self sender. |
1657 |
[con notNil] whileTrue:[ |
|
1658 |
sel := con selector. |
|
1659 |
sel == selector1 ifTrue:[^ con]. |
|
1660 |
(selector2 notNil and:[sel == selector2]) ifTrue:[^ con]. |
|
1661 |
(selector3 notNil and:[sel == selector3]) ifTrue:[^ con]. |
|
1662 |
con := con sender. |
|
1663 |
]. |
|
1664 |
^ nil |
|
1665 |
" |
|
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1666 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1667 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1668 |
findNextUnwindContextOr:aContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1669 |
"walk along the sender chain (starting at the sender), |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1670 |
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
|
1671 |
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
|
1672 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1673 |
"/ 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
|
1674 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1675 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1676 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1677 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1678 |
"/ [con notNil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1679 |
"/ and:[con ~~ aContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1680 |
"/ 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
|
1681 |
"/ ^ con |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1682 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1683 |
"/ 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
|
1684 |
"/ (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
|
1685 |
"/ 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
|
1686 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1687 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1688 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1689 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1690 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1691 |
if (self == aContext) { |
4485 | 1692 |
RETURN (self); |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1693 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1694 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1695 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1696 |
while (__isNonNilObject(theContext)) { |
4485 | 1697 |
if ((theContext == aContext) |
1698 |
|| ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__UNWIND_MARK))) { |
|
1699 |
if (__isLazy(theContext)) { |
|
1700 |
__PATCHUPCONTEXT(theContext); |
|
1701 |
} |
|
1702 |
if (! __isNonLIFO(theContext)) { |
|
1703 |
/* |
|
1704 |
* to be prepared for the worst situation |
|
1705 |
* (the sender is not stored, so the trap wont catch it) |
|
1706 |
* make the writeBarrier trigger manually. |
|
1707 |
* We'll see, if this is really required. |
|
1708 |
*/ |
|
1709 |
theContext->o_space |= CATCHMARK; |
|
1710 |
#if 0 |
|
1711 |
_markNonLIFO(theContext); |
|
1712 |
#endif |
|
1713 |
} |
|
1714 |
RETURN (theContext); |
|
1715 |
} |
|
1716 |
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
|
1717 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1718 |
%}. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1719 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1720 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1721 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1722 |
findSpecialHandle:findHandleContext raise:findRaiseContext |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1723 |
"walk along the sender chain (starting with the sender), |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1724 |
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
|
1725 |
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
|
1726 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1727 |
"/ 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
|
1728 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1729 |
"/ |con| |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1730 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1731 |
"/ con := self sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1732 |
"/ [con notNil] whileTrue:[ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1733 |
"/ (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
|
1734 |
"/ (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
|
1735 |
"/ con := con sender. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1736 |
"/ ]. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1737 |
"/ ^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1738 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1739 |
"/ 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
|
1740 |
"/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1741 |
"/ (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
|
1742 |
"/ 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
|
1743 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1744 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1745 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1746 |
OBJ theContext; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1747 |
OBJ sel; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1748 |
OBJ __FETCHSELECTOR(); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1749 |
int flagMask = 0; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1750 |
INT mask; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1751 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1752 |
if (findHandleContext == true) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1753 |
flagMask = __HANDLE_MARK; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1754 |
if (findRaiseContext == true) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1755 |
flagMask |= __RAISE_MARK; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1756 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1757 |
mask = __MASKSMALLINT(flagMask); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1758 |
theContext = __INST(sender_); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1759 |
while (__isNonNilObject(theContext)) { |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1760 |
if ((INT)(__ContextInstPtr(theContext)->c_flags) & mask) { |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1761 |
if (__isLazy(theContext)) { |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1762 |
__PATCHUPCONTEXT(theContext); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1763 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1764 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1765 |
if (! __isNonLIFO(theContext)) { |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1766 |
/* |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1767 |
* to be prepared for the worst situation |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1768 |
* (the sender is not stored, so the trap won't catch it) |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1769 |
* make the writeBarrier trigger manually. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1770 |
* We'll see, if this is really required. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1771 |
*/ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1772 |
theContext->o_space |= CATCHMARK; |
4485 | 1773 |
#if 0 |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1774 |
_markNonLIFO(theContext); |
4485 | 1775 |
#endif |
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1776 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1777 |
RETURN (theContext); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1778 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1779 |
theContext = __ContextInstPtr(theContext)->c_sender; |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1780 |
} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1781 |
%}. |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1782 |
^ nil |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1783 |
! ! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1784 |
|
1051 | 1785 |
!Context methodsFor:'special accessing'! |
1786 |
||
4557 | 1787 |
canResume |
1788 |
"return true, if the receiver allows to be resumed. |
|
1789 |
Due to the implementation, this requires that the context which |
|
1790 |
is right below the receiver is returnable." |
|
1791 |
||
1792 |
|theContext| |
|
1793 |
||
1794 |
" |
|
1795 |
starting with this context, find the one below |
|
1796 |
(i.e. the one that I have called) and return from it. |
|
1797 |
" |
|
1798 |
%{ |
|
1799 |
OBJ sndr; |
|
1800 |
||
1801 |
theContext = __thisContext; |
|
1802 |
while (theContext != nil) { |
|
1803 |
sndr = __ContextInstPtr(theContext)->c_sender; |
|
1804 |
if (sndr == self) break; |
|
1805 |
theContext = sndr; |
|
1806 |
} |
|
1807 |
if (theContext != nil) { |
|
1808 |
if (__isLazy(theContext)) { |
|
1809 |
__PATCHUPCONTEXT(theContext); |
|
1810 |
} |
|
1811 |
} |
|
1812 |
%}. |
|
1813 |
theContext isNil ifTrue:[ |
|
1814 |
^ false |
|
1815 |
]. |
|
1816 |
^ theContext canReturn |
|
1817 |
! |
|
1818 |
||
1051 | 1819 |
canReturn |
1820 |
"return true, if the receiver allows returning through it. |
|
4557 | 1821 |
Blocks, (currently) always return false. |
2646 | 1822 |
Methods which contain a (non-inlined) block are always |
1823 |
returnable - for other methods, it depends on how the system |
|
1824 |
was compiled (stc flag +/-optContext). |
|
1825 |
If it was compiled with +optContext, methods are compiled |
|
4557 | 1826 |
non returnable, unless a return-pragma was present in the method. |
2646 | 1827 |
Since this saves some administrative work in every method |
1828 |
invocation and makes overall execution faster, the system classes |
|
1829 |
are all compiled with this flag turned on." |
|
1051 | 1830 |
|
1831 |
%{ /* NOCONTEXT */ |
|
1832 |
||
3508 | 1833 |
RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true ); |
5441 | 1834 |
%}. |
1835 |
^ true |
|
1051 | 1836 |
! |
1837 |
||
1492 | 1838 |
hasStackToShow |
2646 | 1839 |
"private interface to the debugger. |
1840 |
Smalltalk contexts return false here - other language frames |
|
1841 |
(i.e. Java frames) may want to show the evaluation stack" |
|
1842 |
||
1492 | 1843 |
^ false |
1844 |
||
1845 |
"Created: 28.6.1996 / 14:48:39 / cg" |
|
2646 | 1846 |
"Modified: 13.5.1997 / 16:31:12 / cg" |
1492 | 1847 |
! |
1848 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1849 |
isHandleContext |
4505 | 1850 |
"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
|
1851 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1852 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1853 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__HANDLE_MARK)) ? true : false ); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1854 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1855 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1856 |
|
1051 | 1857 |
isNonLifo |
2646 | 1858 |
"return true, if this is a nonLifo context. |
1859 |
A nonLifo context is one that is still on the machine stack, |
|
1860 |
but has a reference taken and needs to be converted to a real |
|
1861 |
object (in objectMemory) when the method/block returns. |
|
1862 |
You dont have to understand this - this is a special ST/X |
|
1863 |
debug query, which may be removed without notice." |
|
1051 | 1864 |
|
1865 |
%{ /* NOCONTEXT */ |
|
1133 | 1866 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__NONLIFO)) ? true : false ); |
1051 | 1867 |
%} |
1868 |
! |
|
1869 |
||
1870 |
isOnMachineStack |
|
1871 |
"return true, if this is a machine stack context as opposed to a |
|
2646 | 1872 |
real heap context. |
1873 |
You dont have to understand this - this is a special ST/X |
|
1874 |
debug query, which may be removed without notice." |
|
1051 | 1875 |
|
1876 |
%{ /* NOCONTEXT */ |
|
1877 |
RETURN ( (__qSpace(self) >= STACKSPACE) ? true : false ); |
|
1878 |
%} |
|
1879 |
! |
|
1880 |
||
4464
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1881 |
isRaiseContext |
4505 | 1882 |
"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
|
1883 |
|
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1884 |
%{ /* NOCONTEXT */ |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1885 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__RAISE_MARK)) ? true : false ); |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1886 |
%} |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1887 |
! |
cec93c942c14
Use context flag for exception handling instead of searching for
Stefan Vogel <sv@exept.de>
parents:
4450
diff
changeset
|
1888 |
|
1051 | 1889 |
isSpecial |
1890 |
"return true, if this is either a nonLifo or interrupted context" |
|
1891 |
||
1892 |
%{ /* NOCONTEXT */ |
|
1133 | 1893 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__SPECIAL)) ? true : false ); |
1051 | 1894 |
%} |
1895 |
! |
|
1896 |
||
1897 |
isUnwindContext |
|
1898 |
"return true, if this is an unwindContext" |
|
1899 |
||
1900 |
%{ /* NOCONTEXT */ |
|
1133 | 1901 |
RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false ); |
1051 | 1902 |
%} |
1903 |
! ! |
|
1904 |
||
623 | 1905 |
!Context methodsFor:'testing'! |
1906 |
||
1907 |
isBlockContext |
|
1908 |
"return true, iff the receiver is a BlockContext, false otherwise" |
|
1909 |
||
1910 |
^ false |
|
1911 |
! |
|
1912 |
||
1913 |
isContext |
|
1914 |
"return true, iff the receiver is a Context, false otherwise" |
|
1915 |
||
1916 |
^ true |
|
1917 |
! |
|
1918 |
||
1919 |
isRecursive |
|
1920 |
"return true, if this context is one of a recursive send of the same |
|
1483 | 1921 |
selector to the same receiver before. |
1922 |
Here, different arguments are ignored - i.e. only the same method |
|
1923 |
counts for recursiveness. |
|
623 | 1924 |
Used to detect recursive errors or recursive printing - for example." |
1925 |
||
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1926 |
|c count "{Class: SmallInteger }" myMethodsClass| |
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1927 |
|
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1928 |
count := 0. |
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1929 |
|
2893 | 1930 |
c := self findNextContextWithSelector:selector or:nil or:nil. |
623 | 1931 |
[c notNil] whileTrue:[ |
3143 | 1932 |
(c receiver == receiver) ifTrue:[ |
1933 |
" |
|
1934 |
stupid: the current ST/X context does not include |
|
1935 |
the method, but the class, in which the search started ... |
|
1936 |
" |
|
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1937 |
myMethodsClass isNil ifTrue:[ |
3143 | 1938 |
myMethodsClass := self methodClass. |
2291
af7652b82404
avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents:
2285
diff
changeset
|
1939 |
]. |
3143 | 1940 |
c methodClass == myMethodsClass ifTrue:[ |
1941 |
^ true |
|
1942 |
] |
|
1943 |
]. |
|
1944 |
c := c findNextContextWithSelector:selector or:nil or:nil. |
|
2135
6bd144c1c358
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1853
diff
changeset
|
1945 |
|
3143 | 1946 |
" |
1947 |
this special test was added to get out after a while |
|
1948 |
if the sender chain is corrupt - this gives us at least |
|
1949 |
a chance to find those errors. |
|
1950 |
" |
|
1951 |
count := count + 1. |
|
1952 |
count >= 100000 ifTrue:[ |
|
1953 |
'Context [warning]: bad context chain' errorPrintCR. |
|
1954 |
^ true |
|
1955 |
] |
|
623 | 1956 |
]. |
1957 |
^ false |
|
1483 | 1958 |
|
2135
6bd144c1c358
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1853
diff
changeset
|
1959 |
"Modified: 10.1.1997 / 17:34:26 / cg" |
623 | 1960 |
! ! |
1961 |
||
1810 | 1962 |
!Context class methodsFor:'documentation'! |
749 | 1963 |
|
1964 |
version |
|
5780 | 1965 |
^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.106 2001-01-10 17:11:07 cg Exp $' |
749 | 1966 |
! ! |
623 | 1967 |
Context initialize! |