Context.st
author Stefan Vogel <sv@exept.de>
Thu, 14 Dec 1995 23:42:02 +0100
changeset 757 93d5f6b86e98
parent 753 81d54fc53a18
child 928 1cfc7a947c29
permissions -rw-r--r--
Add SemaphoreSet.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Object variableSubclass:#Context
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    14
	instanceVariableNames:'flags sender home receiver selector searchClass lineNr retvalTemp
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    15
		handle*'
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    16
	classVariableNames:'InvalidReturnSignal'
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    17
	poolDictionaries:''
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
    18
	category:'Kernel-Methods'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    19
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    20
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    21
!Context class methodsFor:'documentation'!
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    22
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    23
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    24
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
 COPYRIGHT (c) 1988 by Claus Gittinger
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
    26
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    28
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    37
documentation
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    38
"
402
claus
parents: 384
diff changeset
    39
    Contexts represent the stack frame objects, which keep the processing
claus
parents: 384
diff changeset
    40
    state of a method or block (i.e. its local variables, temporaries etc.)
claus
parents: 384
diff changeset
    41
    Every message send adds a context to a chain, which can be traced back via 
claus
parents: 384
diff changeset
    42
    the sender field. The context of the currently active method is always
claus
parents: 384
diff changeset
    43
    accessable via the pseuodoVariable called 'thisContext'.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    44
    (The actual implementation uses the machines stack for this, building real 
402
claus
parents: 384
diff changeset
    45
     contexts on demand only).
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    46
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
    47
    For both method- and block-contexts, the layout is the same. 
402
claus
parents: 384
diff changeset
    48
    For method contexts, the home-field is nil, while for block contexts the home-
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    49
    field is either the context of its surrounding block (i.e. the context of the
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    50
    block, in which the receiving block was created, if its a nested block) or of
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    51
    its home method. 
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    52
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    53
    Contexts of cheap blocks do not have a home context - their home field is 
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    54
    also nil.
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
    55
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    56
    Currently, contexts do not contain a reference to the method or block which
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    57
    created it - this is not needed for program execution, but could get the debugger
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    58
    somewhat into trouble: it has to search the class hierarchy for receiver/selector
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    59
    combinations to find the method. This usually works, but fails in case of methods
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    60
    which are not anchored in any class - especially leading to problems with wrapper-
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    61
    and lazy methods. Also, Method>>valueWithReceiver - type of invocations cannot
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    62
    be easily debugged.
402
claus
parents: 384
diff changeset
    63
    Therefore, the implementation may be changed in the near future, to include a
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    64
    field for the method/block, and set it in the VM during program execution.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    65
    (there may be some small performance penalty for this, though).
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
    66
402
claus
parents: 384
diff changeset
    67
    LineNumbers vs. program counter:
claus
parents: 384
diff changeset
    68
claus
parents: 384
diff changeset
    69
    Due to the compilation to machine code, methods and/or block do not
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
    70
    always (actually: do seldom) contain bytecodes. Thus, there is no such concept
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
    71
    as a bytecode p-counter. To support debugging, the linenumber within the
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
    72
    original source is instead remembered when a send or loop entry is performed.
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
    73
    Since linenumbers are not always sufficient for debugging (multiple sends in one
402
claus
parents: 384
diff changeset
    74
    line), this may be changed in future versions to a character offset, giving
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
    75
    the position of the selector in the source.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    76
402
claus
parents: 384
diff changeset
    77
    Restartable / Returnable contexts:
claus
parents: 384
diff changeset
    78
claus
parents: 384
diff changeset
    79
    In previous versions (up to ST/X 2.10.5), every method stored enough
claus
parents: 384
diff changeset
    80
    information in the context for that one to be restartable later (for example,
claus
parents: 384
diff changeset
    81
    via the debuggers restart button). With 2.10.6, this is now an stc-compiler
claus
parents: 384
diff changeset
    82
    option, and the system as delivered is compiled to only create restartable
claus
parents: 384
diff changeset
    83
    contexts for those which contain blocks. This resulted in an overall speedup of
claus
parents: 384
diff changeset
    84
    roughly 10-20% percent, depending on the type of CPU. However, it makes most
claus
parents: 384
diff changeset
    85
    methods non-restartable (however, abort, signal handling and unwind blocks work
claus
parents: 384
diff changeset
    86
    as usual).
claus
parents: 384
diff changeset
    87
    In practice, this was reported to be not a severe limitation and all users were happy
claus
parents: 384
diff changeset
    88
    to trade the increased performance for that slight inconvenience.
claus
parents: 384
diff changeset
    89
    (during development, this is seldom a problem, since interpreted methods are always
claus
parents: 384
diff changeset
    90
     returnable and restartable)
claus
parents: 384
diff changeset
    91
    If you do not like this (and you are a happy owner of the full distribution), you
claus
parents: 384
diff changeset
    92
    should recompile all classes with stc's '-optContext' flag.
claus
parents: 384
diff changeset
    93
claus
parents: 384
diff changeset
    94
    Resuming contexts:
claus
parents: 384
diff changeset
    95
claus
parents: 384
diff changeset
    96
    Strictly speaking, ST/X does not support a context to be resumed. However,
claus
parents: 384
diff changeset
    97
    it does support a forced return (i.e. non-local-return) from a context.
claus
parents: 384
diff changeset
    98
    Thus, resume of a context is implemented by forcing a return from the context
claus
parents: 384
diff changeset
    99
    which was created by the method called from the first one. The effect is the same.
claus
parents: 384
diff changeset
   100
claus
parents: 384
diff changeset
   101
    Returning from a dead method:
claus
parents: 384
diff changeset
   102
claus
parents: 384
diff changeset
   103
    Blocksreturn from an outlived context (i.e. its home method has already returned)
claus
parents: 384
diff changeset
   104
    is now rewarded by an invalidReturn exception - it used to be a noop in previous
claus
parents: 384
diff changeset
   105
    releases (The blue book described this to be a noop, but other smalltalk implementations
claus
parents: 384
diff changeset
   106
    changed this to be an invalid operation -  good decision)
claus
parents: 384
diff changeset
   107
claus
parents: 384
diff changeset
   108
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   109
    instance variables:
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   110
	flags       <SmallInteger>          used by the VM; never touch.
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   111
					    contains info about number of args, 
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   112
					    locals and temporaries.
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   113
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   114
	sender      <Context>               the 'calling / sending' context
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   115
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   116
	home        <Context>               the context, where this block was 
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   117
					    created, or nil if its a method context
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   118
					    There are also cheap blocks, which do
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   119
					    not need a reference to the home context,
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   120
					    for those, its nil too.
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   121
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   122
	receiver    <Object>                the receiver of this message
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   123
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   124
	selector    <Symbol>                the selector of this message
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   125
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   126
	searchClass <Class>                 the class, where the message lookup started
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   127
					    (for super sends) or nil, for regular sends.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   128
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   129
	lineNr      <SmallInteger>          the position where the context left off
339
claus
parents: 328
diff changeset
   130
					    (kind of p-counter). Only the low 16bits
claus
parents: 328
diff changeset
   131
					     are valid.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   132
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   133
	retValTemp  nil                     temporary - always nil, when you see the context
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   134
					    (used in the VM as temporary)
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   135
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   136
	handle      *noObject*              used by the VM; not accessable, not an object
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   137
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   138
	<indexed>                           arguments of the send followed by
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   139
					    locals of the method/block followed by
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   140
					    temporaries.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   141
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   142
    class variables:
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   143
	InvalidReturnSignal                 signal raised when a block tries
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   144
					    to return ('^') from a method context
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   145
					    which itself has already returned
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   146
					    (i.e. there is no place to return to)
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   147
        
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   148
    WARNING: layout and size known by the compiler and runtime system - do not change.
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   149
"
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   150
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   151
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   152
!Context class methodsFor:'initialization'!
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   153
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   154
initialize
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   155
    InvalidReturnSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 293
diff changeset
   156
	InvalidReturnSignal := ErrorSignal newSignalMayProceed:true.
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   157
	InvalidReturnSignal nameClass:self message:#invalidReturnSignal.
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   158
	InvalidReturnSignal notifierString:'invalid return; method cannot return twice'.
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   159
    ]
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   160
! !
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   161
345
claus
parents: 340
diff changeset
   162
!Context class methodsFor:'Signal constants'!
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   163
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   164
invalidReturnSignal
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   165
    "return the signal used when a method is tried to be returned twice
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   166
     or, when some dead context is unwound or restarted."
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   167
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   168
    ^ InvalidReturnSignal
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   169
! !
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   170
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   171
!Context class methodsFor:'queries'!
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   172
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   173
isBuiltInClass
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   174
    "this class & subclasses are known by the run-time-system"
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   175
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   176
    ^ true
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   177
! !
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   178
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   179
!Context methodsFor:'accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   180
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   181
argAt:n
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   182
    "return the n'th argument"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   183
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   184
    ^ self at:n
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   185
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   186
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   187
argAt:n put:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   188
    "set the n'th argument - useful when the receiver should be restarted"
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   189
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   190
    ^ self at:n put:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   191
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   192
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   193
args
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   194
    "return an array filled with the arguments of this context"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   195
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   196
    |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   197
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   198
    n := self numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   199
    ^ (Array new:n) replaceFrom:1 to:n with:self.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   200
!
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   201
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   202
argsAndVars
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   203
    "return an array filled with the arguments and variables of this context"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   204
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   205
    |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   206
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   207
    n := self numArgs + self nvars.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   208
    ^ (Array new:n) replaceFrom:1 to:n with:self.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   209
!
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   210
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   211
canReturn
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   212
    "return true, if the receiver allows returning through it.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   213
     For normal method contexts, this returns true;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   214
     for blocks, it (currently) always returns false.
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   215
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   216
     However, the system can be compiled (for production code), to create
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   217
     contexts which cannot be returned or restarted
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   218
     (except, if the method contains a returning block). 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   219
     This saves some administrative work in every method
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   220
     invocation and makes overall execution faster. However, it limits
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   221
     the debugger, in that it cannot return from or restart those contexts.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   222
     (unwinding and termination is not affected by this optimization)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   223
     Currently, the system as delivered has this optimization disabled."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   224
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   225
%{  /* NOCONTEXT */
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   226
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   227
    RETURN ( (_intVal(_INST(flags)) & __CANNOT_RETURN) ? false : true );
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   228
%}
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   229
!
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   230
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   231
home
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   232
    "return the immediate home of the receiver.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   233
     for block contexts, this is the methodcontext, where the block was created,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   234
     for nested block contexts, its the surrounding blocks context.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   235
     for method-contexts this is nil."
25
e34a6267c79b *** empty log message ***
claus
parents: 12
diff changeset
   236
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   237
    ^ nil "home"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   238
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   239
a27a279701f8 Initial revision
claus
parents:
diff changeset
   240
instVarAt:index
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   241
    "have to catch instVar access to retVal and handle - they are invalid.
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   242
     Notice, that one of the next ST/X versions will get some syntactic
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   243
     extension to get this automatically)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   244
a27a279701f8 Initial revision
claus
parents:
diff changeset
   245
    (index == 8) ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   246
    (index == 9) ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   247
    ^ super instVarAt:index
a27a279701f8 Initial revision
claus
parents:
diff changeset
   248
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   249
a27a279701f8 Initial revision
claus
parents:
diff changeset
   250
instVarAt:index put:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   251
    "have to catch instVar access to retVal and handle - they are invalid.
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   252
     Notice, that one of the next ST/X versions will get some syntactic
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   253
     extension to get this automatically)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   254
a27a279701f8 Initial revision
claus
parents:
diff changeset
   255
    (index == 8) ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   256
    (index == 9) ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   257
    ^ super instVarAt:index put:value
a27a279701f8 Initial revision
claus
parents:
diff changeset
   258
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   259
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   260
isUnwindContext
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   261
    "return true, if this is an unwindContext"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   262
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   263
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   264
     RETURN ( ((INT)_INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false );
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   265
%}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   268
lineNumber
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   269
    "this returns the lineNumber within the methods source, where the context was
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   270
     interrupted or called another method. (currently, sometimes this information
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   271
     is not available - in this case 0 is returned)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   272
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   273
    lineNr isNil ifTrue:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   274
    ^ lineNr bitAnd:16rFFFF
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   275
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   276
a27a279701f8 Initial revision
claus
parents:
diff changeset
   277
method
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   278
    "return the method for which the receiver was created.
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   279
     To save time during normal execution, this information is not held in the
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   280
     context, but computed here on request."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   281
a27a279701f8 Initial revision
claus
parents:
diff changeset
   282
    |c|
a27a279701f8 Initial revision
claus
parents:
diff changeset
   283
325
claus
parents: 308
diff changeset
   284
    c := self searchClass.
claus
parents: 308
diff changeset
   285
    "
claus
parents: 308
diff changeset
   286
     the below cannot happen in normal circumstances
claus
parents: 308
diff changeset
   287
     (added to avoid recursive errors in case of a broken sender chain)
claus
parents: 308
diff changeset
   288
    "
claus
parents: 308
diff changeset
   289
    c isBehavior ifFalse:[
claus
parents: 308
diff changeset
   290
	'OOPS: non class in searchClass' errorPrintNL.
claus
parents: 308
diff changeset
   291
	'      selector: ' errorPrint. selector errorPrint.
claus
parents: 308
diff changeset
   292
	' receiver: ' errorPrint. receiver errorPrintNL.
claus
parents: 308
diff changeset
   293
	^ nil
claus
parents: 308
diff changeset
   294
    ].
claus
parents: 308
diff changeset
   295
328
claus
parents: 326
diff changeset
   296
    c := c whichClassIncludesSelector:selector.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   297
    c notNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   298
	^ c compiledMethodAt:selector
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   299
    ].
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   300
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   301
    "mhmh - seems to be a context for an unbound method;
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   302
     look in the senders context. Consider this a kludge.
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   303
     (maybe it was not too good of an idea to not keep the current
325
claus
parents: 308
diff changeset
   304
      method in the context ....
claus
parents: 308
diff changeset
   305
      future versions of ST/X's message lookup may store the method in
claus
parents: 308
diff changeset
   306
      the context.)
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   307
    "
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   308
    (sender notNil and:[sender selector startsWith:'valueWithReceiver:']) ifTrue:[
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   309
	^ sender receiver
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   310
    ].
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   311
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   312
    ^ nil
a27a279701f8 Initial revision
claus
parents:
diff changeset
   313
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   314
212
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   315
methodClass
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   316
    "return the class in which the method for which the receiver was created is."
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   317
328
claus
parents: 326
diff changeset
   318
    ^ self searchClass whichClassIncludesSelector:selector.
212
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   319
!
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   320
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   321
methodHome
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   322
    "return the method-home - for method contexts this is the receiver"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   323
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   324
    ^ self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   325
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   326
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   327
ntemp
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   328
    "return the number of temporary variables of the Block/Method.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   329
     (for debugging only)"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   330
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   331
    ^ self size - self numArgs - self nvars
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   332
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   333
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   334
numArgs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   335
    "return the number of arguments to the Block/Method"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   336
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   337
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   338
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   339
    RETURN ( _MKSMALLINT( (_intVal(_INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   340
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   341
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   342
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   343
nvars
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   344
    "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
   345
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   346
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   347
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   348
    RETURN ( _MKSMALLINT( (_intVal(_INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) );
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   349
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   350
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   351
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   352
receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   353
    "return the receiver of the context"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   354
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   355
    ^ receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   356
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   357
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   358
searchClass
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   359
    "this is the class where the method-lookup started;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   360
     for normal sends, it is nil (or sometimes the receivers class).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   361
     For supersends, its the superclass of the one, in which the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   362
     caller was defined."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   363
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   364
    searchClass notNil ifTrue:[^ searchClass].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   365
    ^ receiver class
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   366
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   367
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   368
selector
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   369
    "return the selector of the method for which the context was created"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   370
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   371
    ^ selector
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   372
!
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   373
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   374
sender
a27a279701f8 Initial revision
claus
parents:
diff changeset
   375
    "return the sender of the context"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   376
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   377
    "this special test is for the very first context (startup-context);
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   378
     actually, its cosmetics, to avoid a visible nil>>nil context in the debugger."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   379
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   380
%{  /* NOCONTEXT */
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   381
    OBJ con;
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   382
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   383
    if (__isNonNilObject(con = _INST(sender))) {
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   384
	if (__isLazy(con)) {
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   385
	    /*
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   386
	     * this cannot happen
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   387
	     */
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   388
	    _PATCHUPCONTEXT(con);
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   389
	}
591
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   390
	/* 
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   391
	 * to be prepared for the worst situation 
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   392
	 * (the sender is not stored, so the trap wont catch it)
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   393
	 * make the writeBarrier trigger manually.
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   394
	 * We'll see, if this is really required.
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   395
	 */
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   396
	con->o_space |= CATCHMARK;
11433f47b12b added a method to print a contexts method
Claus Gittinger <cg@exept.de>
parents: 564
diff changeset
   397
	_markNonLIFO(con);
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   398
    }
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   399
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   400
    ^ sender
a27a279701f8 Initial revision
claus
parents:
diff changeset
   401
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   402
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   403
setLineNumber:aNumber
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   404
    "private entry for uncompiledCodeObject ..."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   405
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   406
    lineNr := aNumber
340
claus
parents: 339
diff changeset
   407
!
claus
parents: 339
diff changeset
   408
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   409
temporaries 
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   410
    "return an array filled with the temporaries of this context"
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   411
308
f04744ef7b5d *** empty log message ***
claus
parents: 302
diff changeset
   412
    |nonTemps mySize|
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   413
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   414
    nonTemps := self numArgs + self nvars.
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   415
    mySize := self ntemp.
308
f04744ef7b5d *** empty log message ***
claus
parents: 302
diff changeset
   416
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonTemps+1
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   417
!
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   418
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   419
unsafeSender
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   420
    "temporary: for debugging only"
10
claus
parents: 5
diff changeset
   421
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   422
    ^ sender
10
claus
parents: 5
diff changeset
   423
!
claus
parents: 5
diff changeset
   424
claus
parents: 5
diff changeset
   425
varAt:n
claus
parents: 5
diff changeset
   426
    "return the n'th local variable"
claus
parents: 5
diff changeset
   427
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   428
    ^ self at:(n + self numArgs)
10
claus
parents: 5
diff changeset
   429
!
claus
parents: 5
diff changeset
   430
claus
parents: 5
diff changeset
   431
varAt:n put:value
claus
parents: 5
diff changeset
   432
    "set the n'th local variable - useful when the receiver should be restarted
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   433
     or continued"
10
claus
parents: 5
diff changeset
   434
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   435
    self at:(n + self numArgs) put:value
10
claus
parents: 5
diff changeset
   436
!
claus
parents: 5
diff changeset
   437
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   438
vars 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   439
    "return an array filled with the local variables of this context"
375
claus
parents: 360
diff changeset
   440
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   441
    |nonVars mySize|
360
claus
parents: 345
diff changeset
   442
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   443
    nonVars := self numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   444
    mySize := self nvars.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   445
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   446
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   447
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   448
!Context methodsFor:'copying'!
415
claus
parents: 406
diff changeset
   449
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   450
deepCopy
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   451
    "raise an error - deepCopy is not allowed for contexts"
37
d9a302eaa3ef *** empty log message ***
claus
parents: 25
diff changeset
   452
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   453
    ^ self deepCopyError
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   454
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   455
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   456
!Context methodsFor:'error handling'!
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   457
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   458
invalidReturn:returnValue
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   459
    "this message is sent by the VM, when a methods context
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   460
     which has already returned is about to return again.
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   461
     (i.e. about to execute a return from an already returned
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   462
      method in a block).
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   463
    We raise a signal here, to allow catching of that situation."
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   464
406
claus
parents: 402
diff changeset
   465
    "
claus
parents: 402
diff changeset
   466
     in previous versions of ST/X and ST-80, this was no error;
claus
parents: 402
diff changeset
   467
     (instead, a normal blockreturn was performed to the value-sender).
claus
parents: 402
diff changeset
   468
     From a note in comp.lang.smalltalk, I conclude that new ST-80 versions
claus
parents: 402
diff changeset
   469
     now raise an error if this happens.
claus
parents: 402
diff changeset
   470
     Comment out the raise below to get that (old) behavior
claus
parents: 402
diff changeset
   471
     BETTER REWRITE YOUR APPLICATION
claus
parents: 402
diff changeset
   472
    " 
282
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   473
"/ new behavior:
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   474
406
claus
parents: 402
diff changeset
   475
    ^ InvalidReturnSignal 
claus
parents: 402
diff changeset
   476
	raiseRequestWith:returnValue.
282
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   477
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   478
"/ old behavior:
406
claus
parents: 402
diff changeset
   479
"/  ^ returnValue
claus
parents: 402
diff changeset
   480
!
claus
parents: 402
diff changeset
   481
claus
parents: 402
diff changeset
   482
invalidReturnOrRestart:returnValue
claus
parents: 402
diff changeset
   483
    "this message is sent by the VM, when a methods context
claus
parents: 402
diff changeset
   484
     which was compiled non-returnable is about to return again.
claus
parents: 402
diff changeset
   485
     We raise a signal here, to allow catching of that situation."
claus
parents: 402
diff changeset
   486
360
claus
parents: 345
diff changeset
   487
    ^ InvalidReturnSignal
claus
parents: 345
diff changeset
   488
	raiseRequestWith:returnValue
claus
parents: 345
diff changeset
   489
	errorString:'method was compiled non-resumable'
claus
parents: 345
diff changeset
   490
!
claus
parents: 345
diff changeset
   491
claus
parents: 345
diff changeset
   492
invalidReturnOrRestartError:how with:value
claus
parents: 345
diff changeset
   493
    "common error reporter for restart/return errors"
claus
parents: 345
diff changeset
   494
    
claus
parents: 345
diff changeset
   495
    self canReturn ifTrue:[
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   496
	"
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   497
	 tried to return from/restart a context which is already dead
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   498
	 (i.e. the method/block has already executed a return)
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   499
	"
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   500
	^ InvalidReturnSignal 
360
claus
parents: 345
diff changeset
   501
	      raiseRequestWith:value
claus
parents: 345
diff changeset
   502
	      errorString:(how , ': context not on calling chain')
claus
parents: 345
diff changeset
   503
    ].
claus
parents: 345
diff changeset
   504
    "
claus
parents: 345
diff changeset
   505
     tried to return from/restart a context of a method which was compiled
claus
parents: 345
diff changeset
   506
     unrestartable or of a block (which is never restartable)
claus
parents: 345
diff changeset
   507
    "
claus
parents: 345
diff changeset
   508
    ^ InvalidReturnSignal 
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   509
	  raiseRequestWith:value
360
claus
parents: 345
diff changeset
   510
	  errorString:(how , ': context cannot be restarted/returned from')
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   511
! !
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   512
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   513
!Context methodsFor:'minidebugger printing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   514
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   515
fullPrint
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   516
    "print the receiver, selector and args of the context 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   517
     - used only for MiniDebuggers walkback print"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   518
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   519
    self receiverPrintString print. ' ' print. selector print.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   520
    self size ~~ 0 ifTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   521
	' ' print. self argsDisplayString print
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   522
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   523
    ' [' print. self lineNumber print. ']' printNewline
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   524
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   525
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   526
     thisContext fullPrint
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   527
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   528
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   529
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   530
fullPrintAll
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   531
    "print a full walkback starting at the receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   532
     - used only for MiniDebuggers walkback print"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   533
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   534
    |context|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   535
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   536
    context := self.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   537
    [context notNil] whileTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   538
	context fullPrint.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   539
	context := context sender
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   540
    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   541
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   542
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   543
     thisContext fullPrintAll
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   544
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   545
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   546
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   547
!Context methodsFor:'non local control flow'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   548
a27a279701f8 Initial revision
claus
parents:
diff changeset
   549
restart
a27a279701f8 Initial revision
claus
parents:
diff changeset
   550
    "restart the receiver - i.e. the method is evaluated again.
402
claus
parents: 384
diff changeset
   551
     if the context to restart already died, trigger an error.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   552
     This is a low level helper for unwindAndRestart.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   553
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   554
     NOTICE: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   555
	 NO unwind actions are performed - this is usually not
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   556
	 what you want (see Context>>unwindAndRestart).
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   557
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   558
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   559
	 currently a context can only be restarted by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   560
	 the owning process - not from outside."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   561
a27a279701f8 Initial revision
claus
parents:
diff changeset
   562
    sender isNil ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   563
%{
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   564
    __RESUMECONTEXT__(SND_COMMA self, RESTART_VALUE, 0);
360
claus
parents: 345
diff changeset
   565
%}.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   566
    "
360
claus
parents: 345
diff changeset
   567
     when we arrive here, something went wrong.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   568
     debugging ...
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   569
    "
360
claus
parents: 345
diff changeset
   570
    ^ self invalidReturnOrRestartError:#restart with:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   571
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   572
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   573
resume
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   574
    "resume execution in this context. I.e. as if the method called
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   575
     last by the receiver did a ^ nil.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   576
     If the context has already returned, report an error.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   577
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   578
     NOTICE:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   579
	 NO unwind actions are performed (see Context>>unwind).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   580
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   581
     LIMITATION: 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   582
	 currently a context can only be resumed by
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   583
	 the owning process - not from outside."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   584
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   585
    ^ self resume:nil
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   586
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   587
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   588
resume:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   589
    "resume the receiver - as if it got 'value' from whatever
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   590
     it called. This continues execution in the receivers method
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   591
     after the point where it did its last send.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   592
     If the context has already returned - report an error. 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   593
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   594
     NOTICE:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   595
	 NO unwind actions are performed (see Context>>unwind:).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   596
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   597
     LIMITATION: 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   598
	 currently a context can only be resumed by
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   599
	 the owning process - not from outside."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   600
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   601
    |con|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   602
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   603
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   604
     starting with this context, find the one below (i.e. the one that I
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   605
     have called) and return from it.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   606
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   607
    con := thisContext.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   608
%{
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   609
    while ((con != nil) && (_ContextInstPtr(con)->c_sender != self)) {
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   610
	con = _ContextInstPtr(con)->c_sender;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   611
    }
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   612
%}.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   613
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   614
    con isNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   615
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   616
	 tried to resume in context which is already dead
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   617
	 (i.e. the method/block has already executed a return)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   618
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   619
	^ con invalidReturnOrRestartError:#resume with:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   620
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   621
    ^ con return:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   622
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   623
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   624
return
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   625
    "return from this context with nil. I.e. as if it did a ^ nil.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   626
     NOTICE:
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   627
	 NO unwind actions are performed - this is usually not
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   628
	 what you want (See Context>>unwind).
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   629
	 This is a low level method - a helper for unwind.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   630
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   631
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   632
	 currently a context can only be returned by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   633
	 the owning process - not from outside."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   634
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   635
    ^ self return:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   636
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   637
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   638
return:value
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   639
    "return from this context as if it did a '^ value'.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   640
     NOTICE:
402
claus
parents: 384
diff changeset
   641
	 NO unwind actions are performed - this is usually not
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   642
	 what you want (See Context>>unwind:).
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   643
	 This is a low level method - a helper for unwind.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   644
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   645
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   646
	 currently a context can only be returned by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   647
	 the owning process - not from outside."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   648
a27a279701f8 Initial revision
claus
parents:
diff changeset
   649
    sender isNil ifTrue:[^ nil].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   650
%{
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   651
    __RESUMECONTEXT__(SND_COMMA self, value, 0);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   652
360
claus
parents: 345
diff changeset
   653
%}.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   654
    "
360
claus
parents: 345
diff changeset
   655
     when we arrive here, something went wrong.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   656
     debugging ...
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   657
    "
360
claus
parents: 345
diff changeset
   658
    ^ self invalidReturnOrRestartError:#return with:value
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   659
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   660
328
claus
parents: 326
diff changeset
   661
returnDoing:aBlock
claus
parents: 326
diff changeset
   662
    "return from this context as if it did a '^ aBlock value'.
claus
parents: 326
diff changeset
   663
     The block is evaluated as if called by the receiver context;
claus
parents: 326
diff changeset
   664
     NOT the true executing context.
claus
parents: 326
diff changeset
   665
     NOTICE:
402
claus
parents: 384
diff changeset
   666
	 NO unwind actions are performed - this is usually not
claus
parents: 384
diff changeset
   667
	 what you want (See Context>>unwindThenDo:).
328
claus
parents: 326
diff changeset
   668
	 This is a low level method - a helper for unwind.
claus
parents: 326
diff changeset
   669
claus
parents: 326
diff changeset
   670
     LIMITATION:
claus
parents: 326
diff changeset
   671
	 currently a context can only be returned by
claus
parents: 326
diff changeset
   672
	 the owning process - not from outside."
claus
parents: 326
diff changeset
   673
claus
parents: 326
diff changeset
   674
    sender isNil ifTrue:[^ nil].
claus
parents: 326
diff changeset
   675
%{
claus
parents: 326
diff changeset
   676
    __RESUMECONTEXT__(SND_COMMA self, aBlock, 2);
360
claus
parents: 345
diff changeset
   677
%}.
328
claus
parents: 326
diff changeset
   678
    "
360
claus
parents: 345
diff changeset
   679
     when we arrive here, something went wrong.
328
claus
parents: 326
diff changeset
   680
     debugging ...
claus
parents: 326
diff changeset
   681
    "
360
claus
parents: 345
diff changeset
   682
    ^ self invalidReturnOrRestartError:#return with:aBlock
328
claus
parents: 326
diff changeset
   683
!
claus
parents: 326
diff changeset
   684
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   685
unwind
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   686
    "return nil from the receiver - i.e. simulate a '^ nil'.
360
claus
parents: 345
diff changeset
   687
     If the context has already retruned, report an error.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   688
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   689
     and Block>>valueOnUnwindDo: on the way.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   690
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   691
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   692
	 currently a context can only be unwound by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   693
	 the owning process - not from outside."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   694
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   695
    ^ self unwind:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   696
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   697
a27a279701f8 Initial revision
claus
parents:
diff changeset
   698
unwind:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   699
    "return value from the receiver - i.e. simulate a '^ value'.
360
claus
parents: 345
diff changeset
   700
     If the context has already returned , report an error.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   701
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   702
     and Block>>valueOnUnwindDo: on the way.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   703
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   704
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   705
	 currently a context can only be unwound by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   706
	 the owning process - not from outside."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   707
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   708
    |con unwindBlock|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   709
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   710
    sender isNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   711
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   712
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   713
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   714
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   715
	^ self invalidReturnOrRestartError:#unwind with:value
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   716
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   717
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   718
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   719
     start with this context, moving up, looking for unwind actions
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   720
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   721
    con := thisContext.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   722
    [con notNil and:[con ~~ self]] whileTrue:[
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   723
	con isUnwindContext ifTrue:[
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   724
	    "/
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   725
	    "/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   726
	    "/
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   727
	    unwindBlock := con argAt:1.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   728
	    con unmarkForUnwind.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   729
	    unwindBlock value
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   730
	].
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   731
	con := con sender
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   732
    ].
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   733
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   734
    "oops, I am not on the calling chain
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   735
     (should we check for this situation first and NOT evaluate
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   736
      the unwind actions in this case ?)
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   737
    "
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   738
    con isNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   739
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   740
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   741
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   742
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   743
	^ self invalidReturnOrRestartError:#unwind with:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   744
    ].
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   745
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   746
     now, that all unwind-actions are done, I can use the
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   747
     low-level return ...
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   748
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   749
    ^ self return:value
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   750
!
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   751
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   752
unwindAndRestart
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   753
    "restart the receiver - i.e. the method is evaluated again.
402
claus
parents: 384
diff changeset
   754
     if the context to restart already died report an error.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   755
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   756
     and Block>>valueOnUnwindDo: before restarting.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   757
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   758
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   759
	 currently a context can only be restarted by
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   760
	 the owning process - not from outside."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   761
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   762
    |con unwindBlock|
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   763
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   764
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   765
     start with this context, moving up, looking for unwind actions
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   766
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   767
    con := thisContext.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   768
    [con notNil and:[con ~~ self]] whileTrue:[
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   769
	con isUnwindContext ifTrue:[
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   770
	    "/
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   771
	    "/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   772
	    "/
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   773
	    unwindBlock := con argAt:1.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   774
	    con unmarkForUnwind.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   775
	    unwindBlock value
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   776
	].
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   777
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   778
	con := con sender
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   779
    ].
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   780
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   781
    "oops, I am not on the calling chain
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   782
     (should we check for this situation first and NOT evaluate
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   783
      the unwind actions in this case ?)
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   784
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   785
    con isNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   786
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   787
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   788
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   789
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   790
	^ self invalidReturnOrRestartError:#unwindAndRestart with:nil
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   791
    ].
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   792
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   793
     now, that all unwind-actions are done, I can use the
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   794
     low-level restart ...
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   795
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   796
    ^ self restart
328
claus
parents: 326
diff changeset
   797
!
claus
parents: 326
diff changeset
   798
claus
parents: 326
diff changeset
   799
unwindThenDo:aBlock 
claus
parents: 326
diff changeset
   800
    "return the value of aBlock from the receiver - i.e. simulate a '^ aBlock value'.
360
claus
parents: 345
diff changeset
   801
     If the context has already returned , report an error.
328
claus
parents: 326
diff changeset
   802
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
claus
parents: 326
diff changeset
   803
     and Block>>valueOnUnwindDo: on the way.
claus
parents: 326
diff changeset
   804
     The block is evaluated AFTER all unwind actions are performed
claus
parents: 326
diff changeset
   805
     (i.e. the blocks sender will be the receiving context, not the
402
claus
parents: 384
diff changeset
   806
      currently executing context)
328
claus
parents: 326
diff changeset
   807
claus
parents: 326
diff changeset
   808
     LIMITATION: 
claus
parents: 326
diff changeset
   809
	 currently a context can only be unwound by
claus
parents: 326
diff changeset
   810
	 the owning process - not from outside."
claus
parents: 326
diff changeset
   811
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   812
    |con unwindBlock|
328
claus
parents: 326
diff changeset
   813
claus
parents: 326
diff changeset
   814
    sender isNil ifTrue:[
claus
parents: 326
diff changeset
   815
	"
claus
parents: 326
diff changeset
   816
	 tried to return to a context which is already dead
claus
parents: 326
diff changeset
   817
	 (i.e. the method/block has already executed a return)
claus
parents: 326
diff changeset
   818
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   819
	^ self invalidReturnOrRestartError:#unwind with:aBlock
328
claus
parents: 326
diff changeset
   820
    ].
claus
parents: 326
diff changeset
   821
claus
parents: 326
diff changeset
   822
    "
claus
parents: 326
diff changeset
   823
     start with this context, moving up, looking for unwind actions
claus
parents: 326
diff changeset
   824
    "
claus
parents: 326
diff changeset
   825
    con := thisContext.
claus
parents: 326
diff changeset
   826
    [con notNil and:[con ~~ self]] whileTrue:[
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   827
	con isUnwindContext ifTrue:[
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   828
	    "/
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   829
	    "/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
   830
	    "/
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   831
	    unwindBlock := con argAt:1.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   832
	    con unmarkForUnwind.
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
   833
	    unwindBlock value
328
claus
parents: 326
diff changeset
   834
	].
claus
parents: 326
diff changeset
   835
	con := con sender
claus
parents: 326
diff changeset
   836
    ].
claus
parents: 326
diff changeset
   837
claus
parents: 326
diff changeset
   838
    "oops, I am not on the calling chain
claus
parents: 326
diff changeset
   839
     (should we check for this situation first and NOT evaluate
claus
parents: 326
diff changeset
   840
      the unwind actions in this case ?)
claus
parents: 326
diff changeset
   841
    "
claus
parents: 326
diff changeset
   842
    con isNil ifTrue:[
claus
parents: 326
diff changeset
   843
	"
claus
parents: 326
diff changeset
   844
	 tried to return to a context which is already dead
claus
parents: 326
diff changeset
   845
	 (i.e. the method/block has already executed a return)
claus
parents: 326
diff changeset
   846
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   847
	^ self invalidReturnOrRestartError:#unwind with:aBlock
328
claus
parents: 326
diff changeset
   848
    ].
claus
parents: 326
diff changeset
   849
    "
claus
parents: 326
diff changeset
   850
     now, that all unwind-actions are done, I can use the
claus
parents: 326
diff changeset
   851
     low-level return ...
claus
parents: 326
diff changeset
   852
    "
claus
parents: 326
diff changeset
   853
    ^ self returnDoing:aBlock 
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   854
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   855
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   856
!Context methodsFor:'printing & storing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   857
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   858
argsDisplayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   859
    |fullString n "{ Class: SmallInteger }" |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   860
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   861
    fullString := ''.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   862
    n := self numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   863
    1 to:n do:[:index |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   864
	fullString := fullString , (' ' , (self at:index) displayString)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   865
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   866
    ^ fullString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   867
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   868
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   869
displayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   870
    "return a string describing the context - for display in Inspector" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   871
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   872
    ^ self class name , '(' , self printString , ')'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   873
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   874
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   875
fullPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   876
    "return a string describing the context - this includes the linenumber,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   877
     receiver printString and argument printString"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   878
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   879
    |s|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   880
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   881
    s := WriteStream on:String new.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   882
    s nextPutAll:self receiverPrintString; space; nextPutAll:selector.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   883
    self size ~~ 0 ifTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   884
	s space.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   885
	s nextPutAll:self argsDisplayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   886
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   887
    s nextPutAll:' ['; nextPutAll:self lineNumber printString; nextPutAll:']' .
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   888
    ^ s contents
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   889
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   890
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   891
     thisContext fullPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   892
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   893
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   894
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   895
methodPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   896
    "return a string describing the contexts method as 'implementorClass>>selector'" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   897
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   898
    |mthd w|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   899
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   900
    mthd := self method.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   901
    mthd notNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   902
	w := mthd who.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   903
	w notNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   904
	    ^ (w at:1) name , '>>' , (w at:2)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   905
	]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   906
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   907
    ^ mthd displayString.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   908
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   909
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   910
     thisContext methodPrintString 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   911
     thisContext sender methodPrintString  
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   912
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   913
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   914
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   915
printOn:aStream
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   916
    "append a printed description of the receiver onto aStream"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   917
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   918
    aStream nextPutAll:(self receiverPrintString).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   919
    aStream space.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   920
    self selector printOn:aStream
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   921
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   922
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   923
printString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   924
    "return a string describing the context" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   925
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   926
    ^ self receiverPrintString , ' ' , self selector printString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   927
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   928
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   929
receiverPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   930
    "return a string describing the receiver of the context" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   931
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   932
    |receiverClass receiverClassName newString implementorClass|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   933
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   934
    receiverClass := receiver class.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   935
    receiverClassName := receiverClass name.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   936
    (receiverClass == SmallInteger) ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   937
	newString := '(' , receiver printString , ') ' , receiverClassName
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   938
    ] ifFalse:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   939
	newString := receiverClassName
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   940
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   941
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   942
    selector notNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   943
"/        implementorClass := self searchClass whichClassIncludesSelector:selector.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   944
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   945
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   946
	 kludge to avoid slow search for containing class
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   947
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   948
	selector ~~ #doIt ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   949
	    implementorClass := self methodClass. 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   950
	].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   951
	implementorClass notNil ifTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   952
	    (implementorClass ~~ receiverClass) ifTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   953
		newString := newString , '>>>',
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   954
			     implementorClass name printString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   955
	    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   956
	] ifFalse:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   957
	    self searchClass ~~ receiverClass ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   958
		newString := newString , '>>>' , self searchClass name
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   959
	    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   960
	    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   961
	     kludge for doIt - these unbound methods are not
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   962
	     found in the classes methodDictionary
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   963
	    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   964
	    selector ~~ #doIt ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   965
		newString := newString , '>>>**NONE**'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   966
	    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   967
	]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   968
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   969
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   970
    ^ newString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   971
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   972
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   973
!Context methodsFor:'private accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   974
753
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   975
markForInterrupt
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   976
    "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
   977
     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
   978
     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
   979
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   980
%{  /* NOCONTEXT */
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   981
     __markInterrupted(__ContextInstPtr(self));
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   982
%}
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   983
!
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
   984
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   985
markForUnwind
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   986
    "set the mark for unwind flag in the receiver.
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   987
     The VM needs this to know that some special action is to be performed with
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   988
     this context - a highly internal mechanism and not for public use."
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   989
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   990
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   991
     _INST(flags) = (OBJ)((INT)_INST(flags) | __MASKSMALLINT(__UNWIND_MARK));
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   992
%}
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   993
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   994
    "Modified: 13.12.1995 / 19:05:22 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   995
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   996
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   997
unmarkForUnwind
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   998
    "clear the mark for unwind flag in the receiver.
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
   999
     The VM needs this to know that some special action is to be performed with
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1000
     this context - a highly internal mechanism and not for public use."
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1001
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1002
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1003
    _INST(flags) = (OBJ)((INT)_INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1004
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1005
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1006
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1007
!Context methodsFor:'testing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1008
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1009
isBlockContext
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1010
    "return true, iff the receiver is a BlockContext, false otherwise"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1011
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1012
    ^ false
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1013
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1014
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1015
isContext
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1016
    "return true, iff the receiver is a Context, false otherwise"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1017
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1018
    ^ true
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1019
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1020
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1021
isRecursive
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1022
    "return true, if this context is one of a recursive send of the same
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1023
     selector and same arguments to the same receiver before. 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1024
     Used to detect recursive errors or recursive printing - for example."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1025
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1026
    |c rec "numArgs" "{Class: SmallInteger }"|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1027
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1028
    rec := 0.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1029
    c := self sender.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1030
    [c notNil] whileTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1031
	((c selector == selector) 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1032
	and:[(c receiver == receiver)]) ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1033
	    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1034
	     stupid: the current ST/X context does not include
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1035
	     the method, but the class, in which the search started ...
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1036
	    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1037
"/            (c searchClass whichClassIncludesSelector:selector) == (self searchClass whichClassIncludesSelector:selector) ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1038
	      c methodClass == self methodClass ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1039
"/              "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1040
"/               finally, look for different arguments
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1041
"/              "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1042
"/              numArgs := self numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1043
"/              1 to:numArgs do:[:argIndex |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1044
"/                  (self argAt:argIndex) == (c argAt:argIndex) ifFalse:[^ false]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1045
"/              ]. 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1046
		^ true
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1047
	    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1048
	].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1049
	c := c sender.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1050
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1051
	 this special test was added to get out after a while
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1052
	 if the sender chain is corrupt - this gives us at least
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1053
	 a chance to find those errors.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1054
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1055
	rec := rec + 1.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1056
	rec >= 100000 ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1057
	    'bad context chain' errorPrintNL.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1058
	    ^ true
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1059
	]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1060
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1061
    ^ false
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1062
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1063
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1064
!Context class methodsFor:'documentation'!
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1065
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1066
version
753
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1067
    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.49 1995-12-14 17:49:59 cg Exp $'
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1068
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1069
Context initialize!