Context.st
author Claus Gittinger <cg@exept.de>
Thu, 30 Jul 1998 18:06:34 +0200
changeset 3695 9ebf6de8a764
parent 3508 4b45b39011c9
child 3923 c66385c00a0f
permissions -rw-r--r--
added #removeAllIfAbsent:
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
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
    14
	instanceVariableNames:'flags sender* home receiver selector searchClass lineNr
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
    15
		retvalTemp handle*'
1334
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
    16
	classVariableNames:'InvalidReturnSignal SingleStepInterruptRequest'
749
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
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
    21
!Context class methodsFor:'documentation'!
54
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
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   109
    [instance variables:]
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   110
	flags       <SmallInteger>          used by the VM; never touch.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   111
					    contains info about number of args, 
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   112
					    locals and temporaries.
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   113
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   114
	sender      <Context>               the 'calling / sending' context
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   115
					    This is not directly accessable, since it may
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   116
					    be a lazy context (i.e. an empty frame).
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   117
					    The #sender method cares for this.
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   118
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   119
	home        <Context>               the context, where this block was 
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   120
					    created, or nil if its a method context
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   121
					    There are also cheap blocks, which do
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   122
					    not need a reference to the home context,
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   123
					    for those, its nil too.
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   124
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   125
	receiver    <Object>                the receiver of this message
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   126
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   127
	selector    <Symbol>                the selector of this message
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   128
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   129
	searchClass <Class>                 the class, where the message lookup started
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   130
					    (for super sends) or nil, for regular sends.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   131
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   132
	lineNr      <SmallInteger>          the position where the context left off
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   133
					    (kind of p-counter). Only the low 16bits
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   134
					     are valid.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   135
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   136
	retValTemp  nil                     temporary - always nil, when you see the context
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   137
					    (used in the VM as temporary)
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   138
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   139
	handle      *noObject*              used by the VM; not accessable, not an object
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   140
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   141
	<indexed>                           arguments of the send followed by
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   142
					    locals of the method/block followed by
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   143
					    temporaries.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   144
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   145
    [class variables:]
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   146
	InvalidReturnSignal                 signal raised when a block tries
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   147
					    to return ('^') from a method context
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   148
					    which itself has already returned
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   149
					    (i.e. there is no place to return to)
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   150
        
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   151
    WARNING: layout and size known by the compiler and runtime system - do not change.
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   152
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   153
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   154
    [author:]
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   155
	Claus Gittinger
1293
02fb05148c98 documentation
Claus Gittinger <cg@exept.de>
parents: 1282
diff changeset
   156
1282
3f5eda57c516 commentary
Claus Gittinger <cg@exept.de>
parents: 1264
diff changeset
   157
    [see also:]
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   158
	Block Process Method
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   159
	( contexts, stacks & unwinding : programming/contexts.html)
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   160
"
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   161
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   162
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   163
!Context class methodsFor:'initialization'!
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   164
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   165
initialize
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   166
    InvalidReturnSignal isNil ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   167
	InvalidReturnSignal := ErrorSignal newSignalMayProceed:true.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   168
	InvalidReturnSignal nameClass:self message:#invalidReturnSignal.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   169
	InvalidReturnSignal notifierString:'invalid return; method cannot return twice'.
1334
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   170
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   171
	SingleStepInterruptRequest := QuerySignal new.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   172
	SingleStepInterruptRequest nameClass:self message:#singleStepInterruptRequest.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   173
	SingleStepInterruptRequest notifierString:'single step'.
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   174
    ]
1334
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   175
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   176
    "Modified: 6.5.1996 / 16:46:03 / cg"
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   177
! !
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   178
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   179
!Context class methodsFor:'Signal constants'!
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   180
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   181
invalidReturnSignal
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   182
    "return the signal used when a method is tried to be returned twice
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   183
     or, when some dead context is unwound or restarted."
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   184
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   185
    ^ InvalidReturnSignal
1334
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   186
!
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   187
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   188
singleStepInterruptRequest
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   189
    "return the dummy query signal to ask for single stepping"
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   190
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   191
    ^ SingleStepInterruptRequest
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   192
8b21c5f67b15 allow different implementations of singleStep (JAVA support)
Claus Gittinger <cg@exept.de>
parents: 1293
diff changeset
   193
    "Created: 6.5.1996 / 16:46:32 / cg"
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   194
! !
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   195
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   196
!Context class methodsFor:'queries'!
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   197
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   198
isBuiltInClass
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   199
    "return true if this class is known by the run-time-system.
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   200
     Here, true is returned."
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   201
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   202
    ^ true
1264
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   203
8d916aa63bce commentary
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
   204
    "Modified: 23.4.1996 / 15:58:00 / cg"
3
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   205
! !
24d81bf47225 *** empty log message ***
claus
parents: 1
diff changeset
   206
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   207
!Context methodsFor:'accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   208
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   209
argAt:n
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   210
    "return the n'th argument"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   211
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   212
    n > self numArgs ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   213
	^ self error:'invalid arg access'
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   214
    ].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   215
    ^ self at:n
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   216
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   217
    "Modified: 12.10.1996 / 21:44:28 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   218
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   219
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   220
argAt:n put:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   221
    "set the n'th argument - useful when the receiver should be restarted"
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   222
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   223
    n > self numArgs ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   224
	^ self error:'invalid arg access'
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   225
    ].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   226
    ^ self at:n put:value
1726
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   227
de533c7f3172 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1668
diff changeset
   228
    "Modified: 12.10.1996 / 21:44:32 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   229
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   230
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   231
args
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   232
    "return an array filled with the arguments of this context"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   233
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   234
    |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   235
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   236
    n := self numArgs.
3130
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   237
    n == 0 ifTrue:[
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   238
	"/ little optimization here - avaoid creating empty containers
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   239
	^ #()
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   240
    ].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   241
    ^ (Array new:n) replaceFrom:1 to:n with:self.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   242
!
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   243
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   244
argsAndVars
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   245
    "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
   246
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   247
    |n|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   248
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   249
    n := self numArgs + self numVars.
3130
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   250
    n == 0 ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   251
	"/ little optimization here - avoid creating empty containers
3130
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   252
	^ #()
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   253
    ].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   254
    ^ (Array new:n) replaceFrom:1 to:n with:self.
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   255
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   256
    "Modified: 23.10.1996 / 16:19:41 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   257
!
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   258
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   259
home
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   260
    "return the immediate home of the receiver.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   261
     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
   262
     for nested block contexts, its the surrounding blocks context.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   263
     for method-contexts this is nil."
25
e34a6267c79b *** empty log message ***
claus
parents: 12
diff changeset
   264
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   265
    ^ nil "home"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   266
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
3324
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   268
homeReceiver
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   269
    "return the receiver from the context, where the receiver was defined"
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   270
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   271
    ^ receiver
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   272
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   273
    "Created: / 5.3.1998 / 16:18:26 / stefan"
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   274
!
0295f7b3b208 Add #homeReceiver (as in ST80).
Stefan Vogel <sv@exept.de>
parents: 3258
diff changeset
   275
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   276
instVarAt:index
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   277
    "have to catch instVar access to retVal and handle - they are invalid.
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   278
     Notice, that one of the next ST/X versions will get some syntactic
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   279
     extension to get this automatically)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   280
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   281
    (index == 2) ifTrue:[^ self sender]."/ sender - must be accessed specially
3182
2526de1e5030 dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   282
    (index == 8) ifTrue:[^ nil].	"/ retvalTemp - invisible
2526de1e5030 dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   283
    (index == 9) ifTrue:[^ nil].	"/ handle to machine stack - invisible
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   284
    ^ super instVarAt:index
a27a279701f8 Initial revision
claus
parents:
diff changeset
   285
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   286
a27a279701f8 Initial revision
claus
parents:
diff changeset
   287
instVarAt:index put:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   288
    "have to catch instVar access to retVal and handle - they are invalid.
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   289
     Notice, that one of the next ST/X versions will get some syntactic
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   290
     extension to get this automatically)."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   291
3182
2526de1e5030 dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   292
    (index == 2) ifTrue:[^ nil].	"/ sender - not allowed to change
2526de1e5030 dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   293
    (index == 8) ifTrue:[^ nil].	"/ retvalTemp - not allowed to change
2526de1e5030 dont allow setting of the sender via instVarAt:put:
Claus Gittinger <cg@exept.de>
parents: 3143
diff changeset
   294
    (index == 9) ifTrue:[^ nil].	"/ handle to machine stack - not allowed to change
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   295
    ^ super instVarAt:index put:value
a27a279701f8 Initial revision
claus
parents:
diff changeset
   296
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   297
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   298
lineNumber
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   299
    "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
   300
     interrupted or called another method. (currently, sometimes this information
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   301
     is not available - in this case 0 is returned)"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   302
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   303
    lineNr isNil ifTrue:[^ nil].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   304
    ^ lineNr bitAnd:16rFFFF
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   305
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   306
a27a279701f8 Initial revision
claus
parents:
diff changeset
   307
method
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   308
    "return the method for which the receiver was created.
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   309
     To save time during normal execution, this information is not held in the
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   310
     context, but computed here on request."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   311
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   312
    |c sender sendersSelector m|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   313
325
claus
parents: 308
diff changeset
   314
    c := self searchClass.
claus
parents: 308
diff changeset
   315
    "
claus
parents: 308
diff changeset
   316
     the below cannot happen in normal circumstances
claus
parents: 308
diff changeset
   317
     (added to avoid recursive errors in case of a broken sender chain)
claus
parents: 308
diff changeset
   318
    "
claus
parents: 308
diff changeset
   319
    c isBehavior ifFalse:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   320
	'Context [error]: non class in searchClass' errorPrintCR.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   321
	'      selector: ' errorPrint. selector errorPrint.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   322
	' receiver: ' errorPrint. receiver errorPrintCR.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   323
	^ nil
325
claus
parents: 308
diff changeset
   324
    ].
claus
parents: 308
diff changeset
   325
328
claus
parents: 326
diff changeset
   326
    c := c whichClassIncludesSelector:selector.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   327
    c notNil ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   328
	^ c compiledMethodAt:selector
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   329
    ].
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   330
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   331
    "mhmh - seems to be a context for an unbound method (as generated by doIt);
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   332
     look in the senders context. Consider this a kludge.
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   333
     (maybe it was not too good of an idea to NOT keep the current
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   334
      method in the context ...)
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   335
     Future versions of ST/X's message lookup may store the method in
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   336
     the context.
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   337
    "
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   338
    sender := self sender.
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   339
    sender notNil ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   340
	sendersSelector := sender selector.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   341
	sendersSelector notNil ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   342
	    (sendersSelector startsWith:'valueWithReceiver:') ifTrue:[
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   343
		m := sender receiver.
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   344
		m isMethod ifTrue:[
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   345
		    ^ m
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   346
		]
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   347
	    ]
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   348
	]
216
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   349
    ].
a8abff749575 *** empty log message ***
claus
parents: 212
diff changeset
   350
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   351
    ^ nil
2135
6bd144c1c358 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
   352
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   353
    "Modified: / 4.1.1998 / 21:15:32 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   354
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   355
212
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   356
methodClass
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   357
    "return the class in which the method for which the receiver was created is."
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   358
1456
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   359
    |cls m|
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   360
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   361
    cls := self searchClass.
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   362
    [cls notNil] whileTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   363
	cls := cls whichClassIncludesSelector:selector.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   364
	cls isNil ifTrue:[^ nil].
1456
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   365
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   366
	m := cls compiledMethodAt:selector.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   367
	m notNil ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   368
	    m isIgnored ifFalse:[^ cls].
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   369
	].
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   370
	cls := cls superclass
1456
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   371
    ].
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   372
    ^ cls
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   373
a544a722ec32 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   374
    "Modified: 10.6.1996 / 14:34:59 / cg"
212
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   375
!
3edd10edefaf *** empty log message ***
claus
parents: 202
diff changeset
   376
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   377
methodHome
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   378
    "return the method-home - for method contexts this is the receiver"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   379
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   380
    ^ self
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   381
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   382
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   383
ntemp
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   384
    "return the number of temporary variables of the Block/Method.
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   385
     (for debugging only).
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   386
     I dont like the name of this method; its here for compatibility."
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   387
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   388
    ^ self numTemps
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   389
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   390
    "Modified: 23.10.1996 / 16:19:06 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   391
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   392
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   393
numArgs
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   394
    "return the number of arguments to the Block/Method"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   395
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   396
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   397
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
   398
    RETURN ( __MKSMALLINT( (__intVal(__INST(flags)) >> __NARG_SHIFT) & __NARG_MASK) );
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   399
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   400
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   401
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   402
numTemps
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   403
    "return the number of temporary variables of the Block/Method.
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   404
     (for debugging only)"
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   405
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   406
    ^ self size - self numArgs - self numVars
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   407
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   408
    "Created: 23.10.1996 / 16:19:10 / cg"
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   409
    "Modified: 23.10.1996 / 16:19:48 / cg"
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   410
!
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   411
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   412
numVars
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   413
    "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
   414
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   415
%{  /* NOCONTEXT */
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   416
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
   417
    RETURN ( __MKSMALLINT( (__intVal(__INST(flags)) >> __NVAR_SHIFT) & __NVAR_MASK) );
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   418
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   419
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   420
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   421
nvars
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   422
    "return the number of local variables of the Block/Method.
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   423
     I dont like the name of this method; its here for compatibility."
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   424
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   425
    ^ self numVars
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   426
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   427
    "Modified: 23.10.1996 / 16:18:44 / cg"
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   428
!
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   429
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   430
receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   431
    "return the receiver of the context"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   432
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   433
    ^ receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   434
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   435
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   436
searchClass
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   437
    "this is the class where the method-lookup started;
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   438
     for normal sends, it is nil (or sometimes the receivers class).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   439
     For supersends, its the superclass of the one, in which the
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   440
     caller was defined."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   441
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   442
    searchClass notNil ifTrue:[^ searchClass].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   443
    ^ receiver class
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   444
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   445
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   446
selector
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   447
    "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
   448
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   449
    ^ selector
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   450
!
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   451
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   452
sender
a27a279701f8 Initial revision
claus
parents:
diff changeset
   453
    "return the sender of the context"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   454
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   455
%{  /* NOCONTEXT */
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   456
    OBJ theContext;
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   457
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   458
    theContext = __INST(sender_);
949
3816e831f5f3 commentary
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   459
    /*
3816e831f5f3 commentary
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   460
     * this special nil test is for the very first context (startup-context);
3816e831f5f3 commentary
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   461
     * actually, its cosmetics, to avoid a visible nil>>nil context in the debugger.
3816e831f5f3 commentary
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   462
     */
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   463
    if (__isNonNilObject(theContext)) {
949
3816e831f5f3 commentary
Claus Gittinger <cg@exept.de>
parents: 928
diff changeset
   464
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   465
	if (__isLazy(theContext)) {
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   466
	    /*
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   467
	     * this cannot happen
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   468
	     */
2212
be31fd0cea4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2205
diff changeset
   469
	    __PATCHUPCONTEXT(theContext);
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   470
	}
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   471
	if (! __isNonLIFO(theContext)) {
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   472
	    /* 
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   473
	     * to be prepared for the worst situation 
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   474
	     * (the sender is not stored, so the trap wont catch it)
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   475
	     * make the writeBarrier trigger manually.
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   476
	     * We'll see, if this is really required.
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   477
	     */
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   478
	    theContext->o_space |= CATCHMARK;
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   479
	    _markNonLIFO(theContext);
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   480
	}
536
dcffd1753902 be safe, when accessing a contexts sender.
Claus Gittinger <cg@exept.de>
parents: 528
diff changeset
   481
    }
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   482
    RETURN (theContext);
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   483
%}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   484
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   485
2510
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   486
senderIsNil
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   487
    "return true, if I have no sender"
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   488
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   489
%{  /* NOCONTEXT */
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   490
    if ( __INST(sender_) == nil ) {
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   491
	RETURN (true);
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   492
    }
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   493
    RETURN (false);
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   494
%}
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   495
!
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   496
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   497
setLineNumber:aNumber
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   498
    "private entry for uncompiledCodeObject ..."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   499
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   500
    lineNr := aNumber
340
claus
parents: 339
diff changeset
   501
!
claus
parents: 339
diff changeset
   502
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   503
temporaries 
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   504
    "return an array filled with the temporaries of this context"
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   505
308
f04744ef7b5d *** empty log message ***
claus
parents: 302
diff changeset
   506
    |nonTemps mySize|
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   507
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   508
    nonTemps := self numArgs + self numVars.
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   509
    mySize := self numTemps.
3130
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   510
    mySize == 0 ifTrue:[
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   511
	"/ little optimization here - avaoid creating empty containers
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   512
	^ #()
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   513
    ].
308
f04744ef7b5d *** empty log message ***
claus
parents: 302
diff changeset
   514
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonTemps+1
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   515
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   516
    "Modified: 23.10.1996 / 16:20:00 / cg"
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   517
!
40ca7cc6fb9c *** empty log message ***
claus
parents: 170
diff changeset
   518
10
claus
parents: 5
diff changeset
   519
varAt:n
claus
parents: 5
diff changeset
   520
    "return the n'th local variable"
claus
parents: 5
diff changeset
   521
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   522
    ^ self at:(n + self numArgs)
10
claus
parents: 5
diff changeset
   523
!
claus
parents: 5
diff changeset
   524
claus
parents: 5
diff changeset
   525
varAt:n put:value
claus
parents: 5
diff changeset
   526
    "set the n'th local variable - useful when the receiver should be restarted
54
06dbdeeed4f9 *** empty log message ***
claus
parents: 48
diff changeset
   527
     or continued"
10
claus
parents: 5
diff changeset
   528
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   529
    self at:(n + self numArgs) put:value
10
claus
parents: 5
diff changeset
   530
!
claus
parents: 5
diff changeset
   531
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   532
vars 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   533
    "return an array filled with the local variables of this context"
375
claus
parents: 360
diff changeset
   534
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   535
    |nonVars mySize|
360
claus
parents: 345
diff changeset
   536
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   537
    nonVars := self numArgs.
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   538
    mySize := self numVars.
3130
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   539
    mySize == 0 ifTrue:[
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   540
	"/ little optimization here - avaoid creating empty containers
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   541
	^ #()
6cef19640207 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2893
diff changeset
   542
    ].
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   543
    ^ (Array new:mySize) replaceFrom:1 to:mySize with:self startingAt:nonVars+1
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   544
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
   545
    "Modified: 23.10.1996 / 16:20:06 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   546
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   547
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   548
!Context methodsFor:'copying'!
415
claus
parents: 406
diff changeset
   549
3350
40dc4807a6d4 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
   550
deepCopyUsing:aDictionary
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   551
    "raise an error - deepCopy is not allowed for contexts"
37
d9a302eaa3ef *** empty log message ***
claus
parents: 25
diff changeset
   552
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   553
    ^ self deepCopyError
3350
40dc4807a6d4 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
   554
40dc4807a6d4 must catch #deppCopyUsing: instead of #deepCopy.
Claus Gittinger <cg@exept.de>
parents: 3324
diff changeset
   555
    "Created: / 31.3.1998 / 15:51:14 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   556
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   557
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   558
!Context methodsFor:'error handling'!
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   559
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   560
invalidReturn:returnValue
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   561
    "this message is sent by the VM, when a methods context
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   562
     which has already returned is about to return again.
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   563
     (i.e. about to execute a return from an already returned
105
7fe3d60db5e1 invalid return now raises a signal
claus
parents: 92
diff changeset
   564
      method in a block).
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   565
    We raise a signal here, to allow catching of that situation."
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   566
406
claus
parents: 402
diff changeset
   567
    "
claus
parents: 402
diff changeset
   568
     in previous versions of ST/X and ST-80, this was no error;
claus
parents: 402
diff changeset
   569
     (instead, a normal blockreturn was performed to the value-sender).
claus
parents: 402
diff changeset
   570
     From a note in comp.lang.smalltalk, I conclude that new ST-80 versions
claus
parents: 402
diff changeset
   571
     now raise an error if this happens.
claus
parents: 402
diff changeset
   572
     Comment out the raise below to get that (old) behavior
claus
parents: 402
diff changeset
   573
     BETTER REWRITE YOUR APPLICATION
claus
parents: 402
diff changeset
   574
    " 
3258
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   575
"/ old behavior:
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   576
"/  ^ returnValue
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   577
282
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   578
"/ new behavior:
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   579
3258
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   580
    "/ if this context is one of another process,
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   581
    "/ use another error message.
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   582
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   583
    (home notNil and:[home sender notNil]) ifTrue:[
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   584
        ^ InvalidReturnSignal 
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   585
            raiseRequestWith:returnValue
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   586
            errorString:'cannot return from another process''s context'.
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   587
    ].
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   588
406
claus
parents: 402
diff changeset
   589
    ^ InvalidReturnSignal 
3258
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   590
        raiseRequestWith:returnValue.
282
94f5c3a6230d *** empty log message ***
claus
parents: 216
diff changeset
   591
3258
2d96bba62ff1 use another error message if attempting to
Claus Gittinger <cg@exept.de>
parents: 3182
diff changeset
   592
    "Modified: / 2.2.1998 / 15:19:52 / cg"
406
claus
parents: 402
diff changeset
   593
!
claus
parents: 402
diff changeset
   594
claus
parents: 402
diff changeset
   595
invalidReturnOrRestart:returnValue
claus
parents: 402
diff changeset
   596
    "this message is sent by the VM, when a methods context
claus
parents: 402
diff changeset
   597
     which was compiled non-returnable is about to return again.
claus
parents: 402
diff changeset
   598
     We raise a signal here, to allow catching of that situation."
claus
parents: 402
diff changeset
   599
360
claus
parents: 345
diff changeset
   600
    ^ InvalidReturnSignal
claus
parents: 345
diff changeset
   601
	raiseRequestWith:returnValue
claus
parents: 345
diff changeset
   602
	errorString:'method was compiled non-resumable'
claus
parents: 345
diff changeset
   603
!
claus
parents: 345
diff changeset
   604
claus
parents: 345
diff changeset
   605
invalidReturnOrRestartError:how with:value
claus
parents: 345
diff changeset
   606
    "common error reporter for restart/return errors"
claus
parents: 345
diff changeset
   607
    
claus
parents: 345
diff changeset
   608
    self canReturn ifTrue:[
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   609
	"
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   610
	 tried to return from/restart a context which is already dead
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   611
	 (i.e. the method/block has already executed a return)
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   612
	"
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   613
	^ InvalidReturnSignal 
360
claus
parents: 345
diff changeset
   614
	      raiseRequestWith:value
claus
parents: 345
diff changeset
   615
	      errorString:(how , ': context not on calling chain')
claus
parents: 345
diff changeset
   616
    ].
claus
parents: 345
diff changeset
   617
    "
claus
parents: 345
diff changeset
   618
     tried to return from/restart a context of a method which was compiled
claus
parents: 345
diff changeset
   619
     unrestartable or of a block (which is never restartable)
claus
parents: 345
diff changeset
   620
    "
claus
parents: 345
diff changeset
   621
    ^ InvalidReturnSignal 
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
   622
	  raiseRequestWith:value
360
claus
parents: 345
diff changeset
   623
	  errorString:(how , ': context cannot be restarted/returned from')
77
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   624
! !
6c38ca59927f *** empty log message ***
claus
parents: 69
diff changeset
   625
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   626
!Context methodsFor:'exception support'!
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   627
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
   628
findNextContextWithSelector:selector1 or:selector2 or:selector3
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   629
    "walk along the sender chain (starting with the sender), 
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   630
     for a context with either one of the given selectors.
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   631
     This non-standard interface is only to be used by exception"
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   632
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   633
    "/ this could have been (actually: was) implemented as:
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   634
    "/
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   635
    "/  |con|
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   636
    "/
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   637
    "/  con := self sender.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   638
    "/  [con notNil] whileTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   639
    "/      con selector == aSelector ifTrue:[^ con].
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   640
    "/      con := con sender.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   641
    "/  ].
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   642
    "/  ^ nil
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   643
    "/
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   644
    "/ and the code below does exactly this (somewhat faster, though).
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   645
    "/
2285
61195a5be6bb comment
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
   646
    "/ (it avoids referencing all intermediate contexts, which would mark them special,
61195a5be6bb comment
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
   647
    "/  although they aren't really - this is expert knowledge, no need to understand that ...)
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   648
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   649
%{  /* NOCONTEXT */
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   650
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   651
    OBJ theContext;
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   652
    OBJ sel;
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   653
    OBJ __FETCHSELECTOR();
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   654
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   655
    theContext = __INST(sender_);
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   656
    while (__isNonNilObject(theContext)) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   657
	if (__isLazy(theContext)) {
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   658
#ifdef TRADITIONAL_STACK_FRAME
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   659
	    sel = __FETCHSELECTOR(theContext);
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   660
#else
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   661
	    /* mhmh - not really needed */
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   662
	    __PATCHUPCONTEXT(theContext);
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   663
	    sel = __ContextInstPtr(theContext)->c_selector;
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   664
#endif
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   665
	} else {
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   666
	    sel = __ContextInstPtr(theContext)->c_selector;
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   667
	}
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   668
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   669
	if ((sel == selector1)
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
   670
	 || ((selector2 != nil) && (sel == selector2))
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
   671
	 || ((selector3 != nil) && (sel == selector3))) {
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   672
	    if (__isLazy(theContext)) {
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   673
		__PATCHUPCONTEXT(theContext);
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   674
	    }
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   675
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   676
	    if (! __isNonLIFO(theContext)) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   677
		/* 
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   678
		 * to be prepared for the worst situation 
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   679
		 * (the sender is not stored, so the trap wont catch it)
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   680
		 * make the writeBarrier trigger manually.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   681
		 * We'll see, if this is really required.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   682
		 */
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   683
		theContext->o_space |= CATCHMARK;
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   684
		_markNonLIFO(theContext);
2255
0e4c8d88a65d can search for a context, without PATCHING them all
Claus Gittinger <cg@exept.de>
parents: 2212
diff changeset
   685
	    }
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   686
	    RETURN (theContext);
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   687
	}
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   688
	theContext = __ContextInstPtr(theContext)->c_sender;
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   689
    }
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   690
%}.
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   691
    ^ nil
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   692
!
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   693
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   694
findNextUnwindContextOr:aContext
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   695
    "walk along the sender chain (starting at the sender), 
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   696
     for a context marked for unwindAction or aContext.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   697
     This non-standard interface is only to be used by mySelf"
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   698
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   699
    "/ this could have been (actually: was) implemented as:
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   700
    "/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   701
    "/  |con|
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   702
    "/
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   703
    "/  con := self sender.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   704
    "/  [con notNil
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   705
    "/   and:[con ~~ aContext
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   706
    "/   and:[con isUnwindContext not]]] whileTrue:[con := con sender].
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   707
    "/  ^ con
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   708
    "/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   709
    "/ and the code below does exactly this (somewhat faster, though).
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   710
    "/ (it avoids referencing all intermediate contexts, which would mark them special,
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   711
    "/  although they aren't really - this is expert knowledge, no need to understand that ...)
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   712
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   713
%{  /* NOCONTEXT */
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   714
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   715
    OBJ theContext;
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   716
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   717
    if (self == aContext) {
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   718
	RETURN (self);
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   719
    }
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   720
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   721
    theContext = __INST(sender_);
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   722
    while (__isNonNilObject(theContext)) {
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   723
	if ((theContext == aContext)
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   724
	 || ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__UNWIND_MARK))) {
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   725
	    if (__isLazy(theContext)) {
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   726
		__PATCHUPCONTEXT(theContext);
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   727
	    }
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   728
	    if (! __isNonLIFO(theContext)) {
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   729
		/*
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   730
		 * to be prepared for the worst situation
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   731
		 * (the sender is not stored, so the trap wont catch it)
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   732
		 * make the writeBarrier trigger manually.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   733
		 * We'll see, if this is really required.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   734
		 */
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   735
		theContext->o_space |= CATCHMARK;
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   736
		_markNonLIFO(theContext);
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   737
	    }
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   738
	    RETURN (theContext);
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   739
	}
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   740
	theContext = __ContextInstPtr(theContext)->c_sender;
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   741
    }
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   742
%}.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   743
    ^ nil
2205
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   744
! !
ef9bf05e4bc8 faster search support
Claus Gittinger <cg@exept.de>
parents: 2201
diff changeset
   745
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   746
!Context methodsFor:'minidebugger printing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   747
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   748
fullPrint
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   749
    "print the receiver, selector and args of the context 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   750
     - used only for MiniDebuggers walkback print"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   751
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   752
    self receiverPrintString print. ' ' print. selector print.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   753
    self size ~~ 0 ifTrue: [
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   754
	' ' print. self argsDisplayString print
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   755
    ].
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   756
    ' [' print. self lineNumber print. ']' printCR
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   757
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   758
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   759
     thisContext fullPrint
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   760
    "
1426
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   761
3b565d5d0791 printNL -> printCR
Claus Gittinger <cg@exept.de>
parents: 1334
diff changeset
   762
    "Modified: 20.5.1996 / 10:27:14 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   763
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   764
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   765
fullPrintAll
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   766
    "print a full walkback starting at the receiver
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   767
     - used only for MiniDebuggers walkback print"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   768
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   769
    |context|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   770
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   771
    context := self.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   772
    [context notNil] whileTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   773
	context fullPrint.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   774
	context := context sender
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   775
    ]
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   776
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   777
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   778
     thisContext fullPrintAll
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   779
    "
2173
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   780
!
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   781
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   782
fullPrintAllOn:aStream
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   783
    "print a full walkback starting at the receiver
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   784
     - used only for MiniDebuggers walkback print"
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   785
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   786
    |context|
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   787
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   788
    context := self.
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   789
    [context notNil] whileTrue: [
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   790
	context fullPrintOn:aStream.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   791
	context := context sender
2173
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   792
    ]
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   793
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   794
    "
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   795
     thisContext fullPrintAllOn:Transcript
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   796
    "
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   797
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   798
    "Created: 15.1.1997 / 18:09:05 / cg"
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   799
!
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   800
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   801
fullPrintOn:aStream
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   802
    "print the receiver, selector and args of the context 
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   803
     - used only for MiniDebuggers walkback print"
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   804
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   805
    self receiverPrintString printOn:aStream. ' ' printOn:aStream. selector printOn:aStream.
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   806
    self size ~~ 0 ifTrue: [
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   807
	' ' printOn:aStream. self argsDisplayString printOn:aStream
2173
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   808
    ].
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   809
    ' [' printOn:aStream. self lineNumber printOn:aStream. ']' printOn:aStream.
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   810
    aStream cr
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   811
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   812
    "
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   813
     thisContext fullPrintOn:Transcript
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   814
    "
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   815
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   816
    "Modified: 20.5.1996 / 10:27:14 / cg"
01ad5ffe0c9d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 2157
diff changeset
   817
    "Created: 15.1.1997 / 18:09:06 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   818
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   819
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   820
!Context methodsFor:'non local control flow'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   821
a27a279701f8 Initial revision
claus
parents:
diff changeset
   822
restart
a27a279701f8 Initial revision
claus
parents:
diff changeset
   823
    "restart the receiver - i.e. the method is evaluated again.
402
claus
parents: 384
diff changeset
   824
     if the context to restart already died, trigger an error.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   825
     This is a low level helper for unwindAndRestart.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   826
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   827
     NOTICE: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   828
	 NO unwind actions are performed - this is usually not
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   829
	 what you want (see Context>>unwindAndRestart).
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   830
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   831
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   832
	 currently a context can only be restarted by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   833
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   834
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   835
	 non-restartable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   836
	 If such a context is restarted, a runtime error is raised."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   837
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   838
%{  /* NOCONTEXT */
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   839
    if (__INST(sender_) != nil) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   840
	__RESUMECONTEXT__(self, RESTART_VALUE, 0);
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   841
    }
360
claus
parents: 345
diff changeset
   842
%}.
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   843
    self sender isNil ifTrue:[^ nil].
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   844
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   845
    "
360
claus
parents: 345
diff changeset
   846
     when we arrive here, something went wrong.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   847
     debugging ...
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   848
    "
360
claus
parents: 345
diff changeset
   849
    ^ self invalidReturnOrRestartError:#restart with:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   850
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   851
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   852
resume
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   853
    "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
   854
     last by the receiver did a ^ nil.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   855
     If the context has already returned, report an error.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   856
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   857
     NOTICE:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   858
	 NO unwind actions are performed (see Context>>unwind).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   859
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   860
     LIMITATION: 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   861
	 currently a context can only be resumed by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   862
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   863
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   864
	 non-resumable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   865
	 If such a context is restarted, a runtime error is raised."
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   866
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   867
    ^ self resume:nil
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
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   870
resume:value
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   871
    "resume the receiver - as if it got 'value' from whatever
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   872
     it called. This continues execution in the receivers method
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   873
     after the point where it did its last send.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   874
     If the context has already returned - report an error. 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   875
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   876
     NOTICE:
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   877
	 NO unwind actions are performed (see Context>>unwind:).
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
     LIMITATION: 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   880
	 currently a context can only be resumed by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   881
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   882
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   883
	 non-resumable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   884
	 If such a context is restarted, a runtime error is raised."
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   885
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   886
    |theContext|
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   887
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   888
    "
2510
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   889
     starting with this context, find the one below
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   890
     (i.e. the one that I have called) and return from it.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   891
    "
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   892
2510
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   893
%{
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
   894
    theContext = __thisContext;
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   895
    while ((theContext != nil) 
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   896
	   && (__ContextInstPtr(theContext)->c_sender != self)) {
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   897
	theContext = __ContextInstPtr(theContext)->c_sender;
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   898
    }
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
   899
    if (theContext != nil) {
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   900
	if (__isLazy(theContext)) {
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   901
	    __PATCHUPCONTEXT(theContext);
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   902
	}
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   903
    }
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   904
%}.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   905
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   906
    theContext isNil ifTrue:[
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   907
	"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   908
	 tried to resume in context which is already dead
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   909
	 (i.e. the method/block has already executed a return)
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   910
	"
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   911
	^ theContext invalidReturnOrRestartError:#resume with:value
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   912
    ].
1668
41db5950f9ea oops - con local variables are now renamed (last change in stc)
Claus Gittinger <cg@exept.de>
parents: 1492
diff changeset
   913
    ^ theContext return:value
623
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
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   916
return
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   917
    "return from this context with nil. I.e. as if it did a ^ nil.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   918
     NOTICE:
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   919
	 NO unwind actions are performed - this is usually not
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   920
	 what you want (See Context>>unwind).
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   921
	 This is a low level method - a helper for unwind.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   922
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   923
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   924
	 currently a context can only be returned by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   925
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   926
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   927
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   928
	 If such a context is restarted, a runtime error is raised."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   929
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   930
    ^ self return:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   931
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   932
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   933
return:value
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   934
    "return from this context as if it did a '^ value'.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   935
     NOTICE:
402
claus
parents: 384
diff changeset
   936
	 NO unwind actions are performed - this is usually not
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   937
	 what you want (See Context>>unwind:).
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   938
	 This is a low level method - a helper for unwind.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   939
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   940
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   941
	 currently a context can only be returned by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   942
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   943
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   944
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   945
	 If such a context is restarted, a runtime error is raised."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   946
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   947
%{  /* NOCONTEXT */
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   948
    if (__INST(sender_) != nil) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   949
	__RESUMECONTEXT__(self, value, 0);
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   950
    }
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   951
%}.
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   952
    self sender isNil ifTrue:[^ nil].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   953
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   954
    "
360
claus
parents: 345
diff changeset
   955
     when we arrive here, something went wrong.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   956
     debugging ...
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   957
    "
360
claus
parents: 345
diff changeset
   958
    ^ self invalidReturnOrRestartError:#return with:value
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   959
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   960
328
claus
parents: 326
diff changeset
   961
returnDoing:aBlock
claus
parents: 326
diff changeset
   962
    "return from this context as if it did a '^ aBlock value'.
claus
parents: 326
diff changeset
   963
     The block is evaluated as if called by the receiver context;
claus
parents: 326
diff changeset
   964
     NOT the true executing context.
claus
parents: 326
diff changeset
   965
     NOTICE:
402
claus
parents: 384
diff changeset
   966
	 NO unwind actions are performed - this is usually not
claus
parents: 384
diff changeset
   967
	 what you want (See Context>>unwindThenDo:).
328
claus
parents: 326
diff changeset
   968
	 This is a low level method - a helper for unwind.
claus
parents: 326
diff changeset
   969
claus
parents: 326
diff changeset
   970
     LIMITATION:
claus
parents: 326
diff changeset
   971
	 currently a context can only be returned by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   972
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   973
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   974
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   975
	 If such a context is restarted, a runtime error is raised."
328
claus
parents: 326
diff changeset
   976
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   977
%{  /* NOCONTEXT */
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   978
    if (__INST(sender_) != nil) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
   979
	__RESUMECONTEXT__(self, aBlock, 2);
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   980
    }
360
claus
parents: 345
diff changeset
   981
%}.
2368
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   982
    self sender isNil ifTrue:[^ nil].
f13bc879cb45 dont allow direct access to sender
Claus Gittinger <cg@exept.de>
parents: 2291
diff changeset
   983
328
claus
parents: 326
diff changeset
   984
    "
360
claus
parents: 345
diff changeset
   985
     when we arrive here, something went wrong.
328
claus
parents: 326
diff changeset
   986
     debugging ...
claus
parents: 326
diff changeset
   987
    "
360
claus
parents: 345
diff changeset
   988
    ^ self invalidReturnOrRestartError:#return with:aBlock
328
claus
parents: 326
diff changeset
   989
!
claus
parents: 326
diff changeset
   990
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   991
unwind
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   992
    "return nil from the receiver - i.e. simulate a '^ nil'.
360
claus
parents: 345
diff changeset
   993
     If the context has already retruned, report an error.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   994
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
   995
     and Block>>valueOnUnwindDo: on the way.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   996
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
   997
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
   998
	 currently a context can only be unwound by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
   999
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1000
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1001
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1002
	 If such a context is restarted, a runtime error is raised."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1003
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1004
    ^ self unwind:nil
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1005
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1006
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1007
unwind:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1008
    "return value from the receiver - i.e. simulate a '^ value'.
360
claus
parents: 345
diff changeset
  1009
     If the context has already returned , report an error.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1010
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1011
     and Block>>valueOnUnwindDo: on the way.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1012
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1013
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1014
	 currently a context can only be unwound by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1015
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1016
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1017
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1018
	 If such a context is restarted, a runtime error is raised."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1019
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1020
    |con unwindBlock|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1021
2510
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
  1022
    self senderIsNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1023
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1024
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1025
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1026
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1027
	^ self invalidReturnOrRestartError:#unwind with:value
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1028
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1029
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1030
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1031
     start with this context, moving up, looking for unwind actions
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1032
    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1033
    con := thisContext findNextUnwindContextOr:self.
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1034
    [con notNil and:[con ~~ self]] whileTrue:[
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1035
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1036
	"/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1037
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1038
	unwindBlock := con argAt:1.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1039
	con unmarkForUnwind.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1040
	unwindBlock value.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1041
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1042
	con := con findNextUnwindContextOr:self.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1043
    ].
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1044
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1045
    "oops, I am not on the calling chain
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1046
     (should we check for this situation first and NOT evaluate
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1047
      the unwind actions in this case ?)
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1048
    "
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1049
    con isNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1050
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1051
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1052
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1053
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1054
	^ self invalidReturnOrRestartError:#unwind with:value
69
4564b6328136 *** empty log message ***
claus
parents: 54
diff changeset
  1055
    ].
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1056
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1057
     now, that all unwind-actions are done, I can use the
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1058
     low-level return ...
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1059
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1060
    ^ self return:value
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1061
!
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1062
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1063
unwindAndRestart
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1064
    "restart the receiver - i.e. the method is evaluated again.
402
claus
parents: 384
diff changeset
  1065
     if the context to restart already died report an error.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1066
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1067
     and Block>>valueOnUnwindDo: before restarting.
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1068
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1069
     LIMITATION: 
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1070
	 currently a context can only be restarted by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1071
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1072
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1073
	 non-restartable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1074
	 If such a context is restarted, a runtime error is raised."
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1075
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1076
    |con unwindBlock|
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1077
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1078
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1079
     start with this context, moving up, looking for unwind actions
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1080
    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1081
    con := thisContext findNextUnwindContextOr:self.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1082
    [con notNil and:[con ~~ self]] whileTrue:[
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1083
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1084
	"/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1085
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1086
	unwindBlock := con argAt:1.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1087
	con unmarkForUnwind.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1088
	unwindBlock value.
552
694ecccaa1a0 only evaluate unwind blocks once
Claus Gittinger <cg@exept.de>
parents: 536
diff changeset
  1089
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1090
	con := con findNextUnwindContextOr:self.
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1091
    ].
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1092
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1093
    "oops, I am not on the calling chain
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1094
     (should we check for this situation first and NOT evaluate
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1095
      the unwind actions in this case ?)
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1096
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1097
    con isNil ifTrue:[
154
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1098
	"
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1099
	 tried to return to a context which is already dead
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1100
	 (i.e. the method/block has already executed a return)
d4236ec280a6 *** empty log message ***
claus
parents: 141
diff changeset
  1101
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1102
	^ self invalidReturnOrRestartError:#unwindAndRestart with:nil
141
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1103
    ].
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1104
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1105
     now, that all unwind-actions are done, I can use the
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1106
     low-level restart ...
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1107
    "
b530e69052e4 better unwind & new unwindAndRestart
claus
parents: 105
diff changeset
  1108
    ^ self restart
328
claus
parents: 326
diff changeset
  1109
!
claus
parents: 326
diff changeset
  1110
claus
parents: 326
diff changeset
  1111
unwindThenDo:aBlock 
claus
parents: 326
diff changeset
  1112
    "return the value of aBlock from the receiver - i.e. simulate a '^ aBlock value'.
360
claus
parents: 345
diff changeset
  1113
     If the context has already returned , report an error.
328
claus
parents: 326
diff changeset
  1114
     Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
claus
parents: 326
diff changeset
  1115
     and Block>>valueOnUnwindDo: on the way.
claus
parents: 326
diff changeset
  1116
     The block is evaluated AFTER all unwind actions are performed
claus
parents: 326
diff changeset
  1117
     (i.e. the blocks sender will be the receiving context, not the
402
claus
parents: 384
diff changeset
  1118
      currently executing context)
328
claus
parents: 326
diff changeset
  1119
claus
parents: 326
diff changeset
  1120
     LIMITATION: 
claus
parents: 326
diff changeset
  1121
	 currently a context can only be unwound by
928
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1122
	 the owning process - not from outside.
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1123
	 Also, the compiler has an option (+optcontext) to create
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1124
	 non-returnable contexts (which are faster).
1cfc7a947c29 commentary
Claus Gittinger <cg@exept.de>
parents: 753
diff changeset
  1125
	 If such a context is restarted, a runtime error is raised."
328
claus
parents: 326
diff changeset
  1126
559
9a4a728d48d2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 552
diff changeset
  1127
    |con unwindBlock|
328
claus
parents: 326
diff changeset
  1128
2510
393a51424d60 avoid marking context as nonLifo (in unwind:)
Claus Gittinger <cg@exept.de>
parents: 2368
diff changeset
  1129
    self senderIsNil ifTrue:[
328
claus
parents: 326
diff changeset
  1130
	"
claus
parents: 326
diff changeset
  1131
	 tried to return to a context which is already dead
claus
parents: 326
diff changeset
  1132
	 (i.e. the method/block has already executed a return)
claus
parents: 326
diff changeset
  1133
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1134
	^ self invalidReturnOrRestartError:#unwind with:aBlock
328
claus
parents: 326
diff changeset
  1135
    ].
claus
parents: 326
diff changeset
  1136
claus
parents: 326
diff changeset
  1137
    "
claus
parents: 326
diff changeset
  1138
     start with this context, moving up, looking for unwind actions
claus
parents: 326
diff changeset
  1139
    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1140
    con := thisContext findNextUnwindContextOr:self.
328
claus
parents: 326
diff changeset
  1141
    [con notNil and:[con ~~ self]] whileTrue:[
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1142
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1143
	"/ mhmh - hardwired knowledge about those methods (taking the 1st arg) 
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1144
	"/
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1145
	unwindBlock := con argAt:1.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1146
	con unmarkForUnwind.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1147
	unwindBlock value.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1148
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1149
	con := con findNextUnwindContextOr:self.
328
claus
parents: 326
diff changeset
  1150
    ].
claus
parents: 326
diff changeset
  1151
claus
parents: 326
diff changeset
  1152
    "oops, I am not on the calling chain
claus
parents: 326
diff changeset
  1153
     (should we check for this situation first and NOT evaluate
claus
parents: 326
diff changeset
  1154
      the unwind actions in this case ?)
claus
parents: 326
diff changeset
  1155
    "
claus
parents: 326
diff changeset
  1156
    con isNil ifTrue:[
claus
parents: 326
diff changeset
  1157
	"
claus
parents: 326
diff changeset
  1158
	 tried to return to a context which is already dead
claus
parents: 326
diff changeset
  1159
	 (i.e. the method/block has already executed a return)
claus
parents: 326
diff changeset
  1160
	"
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1161
	^ self invalidReturnOrRestartError:#unwind with:aBlock
328
claus
parents: 326
diff changeset
  1162
    ].
claus
parents: 326
diff changeset
  1163
    "
claus
parents: 326
diff changeset
  1164
     now, that all unwind-actions are done, I can use the
claus
parents: 326
diff changeset
  1165
     low-level return ...
claus
parents: 326
diff changeset
  1166
    "
claus
parents: 326
diff changeset
  1167
    ^ self returnDoing:aBlock 
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1168
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1169
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1170
!Context methodsFor:'printing & storing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1171
1070
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1172
argStringFor:someObject
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1173
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1174
    |name|
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1175
%{
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1176
    /*
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1177
     * special handling for (invalid) free objects.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1178
     * these only appear if some primitiveCode does not correctly use SEND macros,
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1179
     * which may lead to sends to free objects. In normal operation, this 'cannot' happen.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1180
     */ 
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1181
    if (__isNonNilObject(someObject) && (__qClass(someObject)==nil)) {
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1182
	name = __MKSTRING("FreeObject");
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1183
    }
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1184
%}.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1185
    name notNil ifTrue:[^ name].
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1186
    ^ someObject displayString
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1187
!
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1188
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1189
argsDisplayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1190
    |fullString n "{ Class: SmallInteger }" |
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1191
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1192
    fullString := ''.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1193
    n := self numArgs.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1194
    1 to:n do:[:index |
1070
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1195
	fullString := fullString , ' ' , (self argStringFor:(self at:index))
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1196
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1197
    ^ fullString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1198
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1199
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1200
displayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1201
    "return a string describing the context - for display in Inspector" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1202
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1203
    ^ self class name , '(' , self printString , ')'
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1204
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1205
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1206
fullPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1207
    "return a string describing the context - this includes the linenumber,
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1208
     receiver printString and argument printString"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1209
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1210
    |s|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1211
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1212
    s := WriteStream on:String new.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1213
    s nextPutAll:self receiverPrintString; space; nextPutAll:selector.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1214
    self size ~~ 0 ifTrue: [
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1215
	s space.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1216
	s nextPutAll:self argsDisplayString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1217
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1218
    s nextPutAll:' ['; nextPutAll:self lineNumber printString; nextPutAll:']' .
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1219
    ^ s contents
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1220
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1221
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1222
     thisContext fullPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1223
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1224
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1225
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1226
methodPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1227
    "return a string describing the contexts method as 'implementorClass>>selector'" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1228
1853
09cd1e8df9a2 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  1229
    |mthd who|
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1230
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1231
    mthd := self method.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1232
    mthd notNil ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1233
	who := mthd who.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1234
	who notNil ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1235
	    ^ who methodClass name , '>>' , who methodSelector
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1236
	]
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1237
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1238
    ^ mthd displayString.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1239
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1240
    "
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1241
     thisContext methodPrintString 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1242
     thisContext sender methodPrintString  
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1243
    "
1853
09cd1e8df9a2 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  1244
09cd1e8df9a2 use new Method>>who interface
Claus Gittinger <cg@exept.de>
parents: 1810
diff changeset
  1245
    "Modified: 1.11.1996 / 16:21:49 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1246
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1247
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1248
printOn:aStream
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1249
    "append a printed description of the receiver onto aStream"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1250
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1251
    aStream nextPutAll:(self receiverPrintString).
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1252
    aStream space.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1253
    self selector printOn:aStream
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1254
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1255
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1256
printString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1257
    "return a string describing the context" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1258
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1259
    ^ self receiverPrintString , ' ' , self selector printString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1260
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1261
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1262
receiverPrintString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1263
    "return a string describing the receiver of the context" 
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1264
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1265
    |receiverClass receiverClassName newString implementorClass|
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1266
1070
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1267
%{
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1268
    /*
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1269
     * special handling for (invalid) free objects.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1270
     * these only appear if some primitiveCode does not correctly use SEND macros,
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1271
     * which may lead to sends to free objects. In normal operation, this 'cannot' happen.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1272
     */ 
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1273
    if (__isNonNilObject(__INST(receiver)) && (__qClass(__INST(receiver))==nil)) {
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1274
	receiverClassName = __MKSTRING("FreeObject");
1070
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1275
    }
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1276
%}.
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1277
    receiverClassName notNil ifTrue:[^ receiverClassName].
cf35b237612d in argPrint: handle invalid objects (avoids crash in MiniDebugger when debugging bad primitives)
Claus Gittinger <cg@exept.de>
parents: 1051
diff changeset
  1278
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1279
    receiverClass := receiver class.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1280
    receiverClassName := receiverClass name.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1281
    (receiverClass == SmallInteger) ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1282
	newString := '(' , receiver printString , ') ' , receiverClassName
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1283
    ] ifFalse:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1284
	newString := receiverClassName
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1285
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1286
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1287
    selector notNil ifTrue:[
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1288
"/        implementorClass := self searchClass whichClassIncludesSelector:selector.
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1289
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1290
	"
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1291
	 kludge to avoid slow search for containing class
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1292
	"
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1293
	(selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1294
	    implementorClass := self methodClass. 
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1295
	].
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1296
	implementorClass notNil ifTrue: [
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1297
	    (implementorClass ~~ receiverClass) ifTrue: [
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1298
		newString := newString , '>>>',
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1299
			     implementorClass name printString
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1300
	    ]
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1301
	] ifFalse:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1302
	    self searchClass ~~ receiverClass ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1303
		newString := newString , '>>>' , self searchClass name
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1304
	    ].
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1305
	    "
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1306
	     kludge for doIt - these unbound methods are not
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1307
	     found in the classes methodDictionary
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1308
	    "
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1309
	    (selector ~~ #doIt and:[selector ~~ #doIt:]) ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1310
		newString := newString , '>>>**NONE**'
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1311
	    ]
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1312
	]
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1313
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1314
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1315
    ^ newString
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1316
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1317
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1318
!Context methodsFor:'private accessing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1319
753
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1320
markForInterrupt
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1321
    "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
  1322
     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
  1323
     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
  1324
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1325
%{  /* NOCONTEXT */
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1326
     __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
  1327
%}
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1328
!
81d54fc53a18 added mechanism to force a stepInterrupt whenever a context returns or unwinds
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
  1329
1727
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1330
markForInterruptOnUnwind
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1331
    "set the interrupt-on-unwind flag in the receiver.
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1332
     The VM will generate a stepInterrupt, when this context returns or
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1333
     is unwound. This is used by the debugger for faster single-stepping;
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1334
     - a highly internal mechanism and not for public use."
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1335
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1336
%{  /* NOCONTEXT */
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
  1337
     __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__IRQ_ON_UNWIND));
1727
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1338
%}
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1339
!
362977e02372 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1726
diff changeset
  1340
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1341
markForUnwind
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1342
    "set the mark for unwind flag in the receiver.
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1343
     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
  1344
     this context - a highly internal mechanism and not for public use."
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1345
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1346
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1347
     __INST(flags) = (OBJ)((INT)__INST(flags) | __MASKSMALLINT(__UNWIND_MARK));
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1348
%}
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1349
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1350
    "Modified: 13.12.1995 / 19:05:22 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1351
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1352
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1353
unmarkForUnwind
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1354
    "clear the mark for unwind flag in the receiver.
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1355
     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
  1356
     this context - a highly internal mechanism and not for public use."
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1357
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1358
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1359
    __INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1360
%}
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1361
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1362
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1363
!Context methodsFor:'special accessing'!
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1364
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1365
canReturn
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1366
    "return true, if the receiver allows returning through it.
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1367
     Blocks, it (currently) always returns false.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1368
     Methods which contain a (non-inlined) block are always
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1369
     returnable - for other methods, it depends on how the system
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1370
     was compiled (stc flag +/-optContext).
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1371
     If it was compiled with +optContext, methods are compiled
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1372
     non returnable.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1373
     Since this saves some administrative work in every method
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1374
     invocation and makes overall execution faster, the system classes
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1375
     are all compiled with this flag turned on."
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1376
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1377
%{  /* NOCONTEXT */
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1378
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
  1379
    RETURN ( ((INT)(__INST(flags)) & __MASKSMALLINT(__CANNOT_RETURN)) ? false : true );
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1380
%}
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1381
!
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1382
1492
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1383
hasStackToShow
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1384
    "private interface to the debugger.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1385
     Smalltalk contexts return false here - other language frames
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1386
     (i.e. Java frames) may want to show the evaluation stack"
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1387
1492
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1388
    ^ false
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1389
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1390
    "Created: 28.6.1996 / 14:48:39 / cg"
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1391
    "Modified: 13.5.1997 / 16:31:12 / cg"
1492
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1392
!
50be184036e3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1483
diff changeset
  1393
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1394
isNonLifo
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1395
    "return true, if this is a nonLifo context.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1396
     A nonLifo context is one that is still on the machine stack,
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1397
     but has a reference taken and needs to be converted to a real
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1398
     object (in objectMemory) when the method/block returns.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1399
     You dont have to understand this - this is a special ST/X
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1400
     debug query, which may be removed without notice."
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1401
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1402
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1403
     RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__NONLIFO)) ? true : false );
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1404
%}
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1405
!
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1406
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1407
isOnMachineStack
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1408
    "return true, if this is a machine stack context as opposed to a 
2646
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1409
     real heap context.
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1410
     You dont have to understand this - this is a special ST/X
90bedd5a9f75 commentary
Claus Gittinger <cg@exept.de>
parents: 2510
diff changeset
  1411
     debug query, which may be removed without notice."
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1412
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1413
%{  /* NOCONTEXT */
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1414
     RETURN ( (__qSpace(self) >= STACKSPACE) ? true : false );
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1415
%}
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1416
!
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1417
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1418
isSpecial
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1419
    "return true, if this is either a nonLifo or interrupted context"
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1420
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1421
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1422
     RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__SPECIAL)) ? true : false );
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1423
%}
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1424
!
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1425
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1426
isUnwindContext
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1427
    "return true, if this is an unwindContext"
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1428
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1429
%{  /* NOCONTEXT */
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1070
diff changeset
  1430
     RETURN ( ((INT)__INST(flags) & __MASKSMALLINT(__UNWIND_MARK)) ? true : false );
1051
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1431
%}
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1432
! !
152139ca5e3e special accessing methods
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
  1433
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1434
!Context methodsFor:'testing'!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1435
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1436
isBlockContext
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1437
    "return true, iff the receiver is a BlockContext, false otherwise"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1438
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1439
    ^ false
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1440
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1441
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1442
isContext
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1443
    "return true, iff the receiver is a Context, false otherwise"
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1444
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1445
    ^ true
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1446
!
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1447
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1448
isRecursive
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1449
    "return true, if this context is one of a recursive send of the same
1483
258d223150ec comment
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1450
     selector to the same receiver before.
258d223150ec comment
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1451
     Here, different arguments are ignored - i.e. only the same method
258d223150ec comment
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1452
     counts for recursiveness.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1453
     Used to detect recursive errors or recursive printing - for example."
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1454
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1455
    |c count "{Class: SmallInteger }" myMethodsClass|
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1456
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1457
    count := 0.
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1458
2893
8ba406da6b22 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2646
diff changeset
  1459
    c := self findNextContextWithSelector:selector or:nil or:nil.
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1460
    [c notNil] whileTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1461
	(c receiver == receiver) ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1462
	    "
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1463
	     stupid: the current ST/X context does not include
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1464
	     the method, but the class, in which the search started ...
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1465
	    "
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1466
	    myMethodsClass isNil ifTrue:[
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1467
		myMethodsClass := self methodClass.
2291
af7652b82404 avoid touching contexts (making them nonLifo) when searching for unwind-contexts,
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
  1468
	    ].
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1469
	    c methodClass == myMethodsClass ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1470
		^ true
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1471
	    ]
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1472
	].
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1473
	c := c findNextContextWithSelector:selector or:nil or:nil.
2135
6bd144c1c358 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1474
3143
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1475
	"
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1476
	 this special test was added to get out after a while
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1477
	 if the sender chain is corrupt - this gives us at least
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1478
	 a chance to find those errors.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1479
	"
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1480
	count := count + 1.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1481
	count >= 100000 ifTrue:[
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1482
	    'Context [warning]: bad context chain' errorPrintCR.
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1483
	    ^ true
9b94535f9026 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3130
diff changeset
  1484
	]
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1485
    ].
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1486
    ^ false
1483
258d223150ec comment
Claus Gittinger <cg@exept.de>
parents: 1456
diff changeset
  1487
2135
6bd144c1c358 newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents: 1853
diff changeset
  1488
    "Modified: 10.1.1997 / 17:34:26 / cg"
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1489
! !
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1490
1810
fc151ad836ef added numVars & numTemps;
Claus Gittinger <cg@exept.de>
parents: 1727
diff changeset
  1491
!Context class methodsFor:'documentation'!
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1492
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1493
version
3508
4b45b39011c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3350
diff changeset
  1494
    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.87 1998-06-04 15:18:52 cg Exp $'
749
be57bbb9ad3d commentary
Claus Gittinger <cg@exept.de>
parents: 623
diff changeset
  1495
! !
623
6795a71e39d1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1496
Context initialize!