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