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