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