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