eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Context':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Context


Inheritance:

   Object
   |
   +--Context
      |
      +--BlockContext

Package:
stx:libbasic
Category:
Kernel-Methods
Version:
rev: 1.286 date: 2024/03/10 21:01:01
user: cg
file: Context.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


Contexts represent the stack frame objects, which keep the processing
state of a method or block (i.e. its local variables, temporaries etc.)
Every message send adds a context to a chain, which can be traced back via
the sender field. The context of the currently active method is always
accessible via the pseuodoVariable called 'thisContext'.
The actual implementation uses the machine's stack for this, building real
contexts on demand only, whenever a context is needed. Also, initially these are
allocated on the stack and only moved to the heap, when a context outlives its
activation.

For both method- and block-contexts, the layout is the same.
For method contexts, the home-field is nil, while for block contexts the home-
field is either the context of its surrounding block (i.e. the context of the
block, in which the receiving block was created, if it's a nested block) or of
its home method.

Cheap blocks are blocks which do not refer to any locals or the receiver (currently),
but only access globals, class vars or arguments (for example: [:a :b | a < b] is a cheap block).
Cheap blocks do not need a home and therefore never require that their home context be moved
to the heap. Contexts of cheap blocks do not have a home context - their home field is also nil.

LineNumbers vs. program counter:

Due to the compilation to machine code, methods and/or block do not
always (actually: do seldom) contain bytecodes. Thus, there is no such concept
as a bytecode p-counter. To support debugging, the linenumber within the
original source is instead remembered when a send or loop entry is performed.
Since linenumbers are not always sufficient for debugging (multiple sends in one
line), this may be changed in future versions to a character offset, giving
the position of the selector in the source.

Restartable / Returnable contexts:

In previous versions (up to ST/X 2.10.5), every method stored enough
information in the context for that one to be restartable later (for example,
via the debugger's restart button). As stc is supposed to generate portable C-code,
this means that technically, a setjmp needs to be done at the beginning of the method
in order to have a resumable (and portable) state (however, inline asm code does this setjmp,
so it is much faster than the libc-setjmo, which stores a lot of additional state, not needed here).
With 2.10.6, this is now an stc-compiler option, and the system as delivered is compiled
to only create restartable contexts for those which contain blocks or are marked as special
via a directive.
This resulted in an overall speedup of roughly 10-20% percent, depending on the type of CPU.
However, it makes most methods non-restartable (however, abort, signal handling and unwind blocks
work as usual).
In practice, this was reported to be not a severe limitation and all users were happy
to trade the increased performance for that slight inconvenience.
(during development, this is seldom a problem, since interpreted methods are always
 returnable and restartable)
If you do not like this, you should recompile all classes with stc's '-optContext' flag.

Resuming contexts:

Strictly speaking, ST/X does not support a context to be resumed (because the setjmp is
not done on the caller side, but in the callee).
However, it does support a forced return (i.e. non-local-return) from a context.
Thus, resume of a context is implemented by forcing a return from the context
which was created by the method called from the first one. The effect is the same.

Returning from a dead method:

Block-return from an outlived context (i.e. its home method has already returned)
is now rewarded by an invalidReturn exception - it used to be a noop in previous
releases. The blue book described this to be a noop, but other Smalltalk implementations
changed this to be an invalid operation - a good decision, as it makes debugging much easier.


[instance variables:]
    flags       <SmallInteger>          used by the VM; never touch.
                                        contains info about number of args,
                                        locals and temporaries.

    sender      <Context>               the 'calling / sending' context
                                        This is not directly accessible, since it may
                                        be a lazy context (i.e. an empty frame).
                                        The #sender method cares for this.

    home        <Context>               the context, where this block was
                                        created, or nil if its a method context
                                        There are also cheap blocks, which do
                                        not need a reference to the home context,
                                        for those, its nil too.

    receiver    <Object>                the receiver of this message

    selector    <Symbol>                the selector of this message

    searchClass <Class>                 the class, where the message lookup started
                                        (for super sends) or nil, for regular sends.

    lineNr      <SmallInteger>          the position where the context left off
                                        (kind of p-counter). Only the low 16bits
                                         are valid.

    retValTemp  nil                     temporary - always nil, when you see the context
                                        (used in the VM as temporary)

    handle      *noObject*              used by the VM; not accessible, not an object

    method                              the corresponding method

    <indexed>                           arguments of the send followed by
                                        locals of the method/block followed by
                                        temporaries.

[errors:]
    CannotReturnError                   raised when a block tries
                                        to return ('^') from a method context
                                        which itself has already returned
                                        (i.e. there is no place to return to)

WARNING: layout and size known by the compiler and runtime system - do not change.

copyright

COPYRIGHT (c) 1988 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No t itle to or ownership of the software is hereby transferred.

Class protocol:

Signal constants
o  cannotResumeSignal
return the signal used when a method is tried to be resumed, which cannot

o  cannotReturnSignal
return the signal used when a method is tried to be returned twice
or, when some dead context is unwound or restarted.

o  invalidReturnSignal
return the signal used when a method is tried to be returned twice
or, when some dead context is unwound or restarted.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  singleStepInterruptRequest
return the dummy query signal to ask for single stepping

accessing
o  printWithReceiverHashes

o  printWithReceiverHashes: aBoolean
if aBoolean is true, add the identityHash of the receiver to the printString.
Answer the previous setting.

error handling
o  showWhereWeCameFrom
show the stack backtrace: at least 4 levels, or until the first
send to a non-collection object (because we want to know,
which non-collection send invoked a bad collection-method).

Usage example(s):

      Context showWhereWeCameFrom

initialization
o  initialize
if true, print the identityHash of the Receiver in walkbacks

queries
o  isBuiltInClass
return true if this class is known by the run-time-system.
Here, true is returned.

special searching
o  findFirstSpecialHandle: searchForHandle raise: searchForRaise
find the first handle context (if searchForHandle is true)
or raise context (if serachForRaise is true)
below thisContext


Instance protocol:

Compatibility-Squeak
o  longStack

Compatibility-VW
o  resumeWith: value
same as #resume: - visualWorks compatibility

accessing
o  arg1Index
return the index of the 1st arg (redefined in JavaContext)

o  argAt: n
return the n'th argument

o  argAt: n put: value
set the n'th argument - useful when the receiver should be restarted

o  args
return an array filled with the arguments of this context

o  argsAndVars
return an array filled with the arguments and variables of this context

o  argumentCount
ANSI alias for numArgs: return the number of arguments to the Block/Method

o  at: n put: value
need some aid for optimized code -

o  home
return the immediate home of the receiver.
for block contexts, this is the methodcontext, where the block was created,
for nested block contexts, it's the surrounding block's context.
for method-contexts this is nil.

Usage example(s):

home

o  homeReceiver
return the receiver from the context, where the receiver was defined

o  instVarAt: index
have to catch instVar access to retVal and handle - they are invalid.
Notice, that one of the next ST/X versions might get some syntactic
extension to get this automatically).

o  instVarAt: index put: value
have to catch instVar access to retVal and handle - they are invalid.
Notice, that one of the next ST/X versions might get some syntactic
extension to get this automatically).

o  lineNumber
this returns the lineNumber within the method's source, where the context was
interrupted or called another method. (currently, sometimes this information
is not available - in this case 0 is returned)

Usage example(s):

nr := m lineNumber

Usage example(s):

nr := self method lineNumberForPC:l.

Usage example(s):

nr := m lineNumber

o  lineNumberFromMethod

o  logFacility
the 'log facility';
this is used by the Logger both as a prefix to the log message,
and maybe (later) used to filter and/or control per-facility log thresholds.
The default here is to base the facility on the package:
if the class is anywhere in the base ST/X system, 'STX' is returned as facility.
Otherwise, the last component of the package name is returned.

Usage example(s):

     thisContext logFacility
     thisContext sender logFacility

o  message
thisContext methodHome message
thisContext message

o  messageSend
thisContext methodHome messageSend
thisContext messageSend

o  method
return the method for which the receiver was created.
Change with ST/X vsn 6:
In older versions, the method was not stored in the context, but a lookup
was simulated using selector and class.
(which occasionally returned the wrong method - especially in the debugger,
when the debugged method was changed).
This has been changed - especially to support Jan's meta-object protocol.
It is now stored in the context

Usage example(s):

VM should have placed the method into the context

o  methodClass
return the class in which the method for which the receiver was created is.

o  methodHome
return the method-home - for method contexts this is the receiver;
For block contexts, this is the context of the containing method
(which could be a context which is no longer alive)

o  methodSelector
return the method's (or home method's) selector

o  ntemp
return the number of temporary variables of the Block/Method.
(for debugging only).
I don't like the name of this method; its here for compatibility.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  numArgs
marked as obsolete by Stefan Vogel at 9-Feb-2024

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  numTemps
return the number of temporary variables of the Block/Method.
(for debugging only)

o  numVars
return the number of local variables of the Block/Method

o  nvars
return the number of local variables of the Block/Method.
I don't like the name of this method; its here for compatibility.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  programmingLanguage

o  receiver
return the receiver of the context

o  receiver: aCompiledCode
set the receiver of the message

o  searchClass
this is the class where the method-lookup started;
for normal sends, it is nil (or sometimes the receiver's class).
For supersends, its the superclass of the one, in which the
caller was defined.

o  selector
return the selector of the method for which the context was created

o  sender
return the sender of the context

o  senderIsNil
return true, if I have no sender.
This little ugly piece of code is needed (instead of the obvious
'sender isNil') because sender is a protected field, which cannot be
directly accessed by smalltalk code. The reason is that the sender field
is lazily filled in by the VM, in the sender-accessor, and is usually
invalid until needed.

o  setLineNumber: aNumber
private entry for uncompiledCodeObject ...

o  setNumArgs: nA numVars: nV
set the number of arguments and variables

o  tempAt: index
return the n'th stack-temporary variable

o  temporaries
return an array filled with the temporaries of this context

o  varAt: n
return the n'th local variable

o  varAt: n put: value
set the n'th local variable - useful when the receiver should be restarted
or continued

o  vars
return an array filled with the local variables of this context

copying
o  deepCopyUsing: aDictionary postCopySelector: postCopySelector
(comment from inherited method)
a helper for deepCopy; return a copy of the object with
all subobjects also copied. If the to-be-copied object is in the dictionary,
use the value found there. The class of the receiver is not copied.
This method DOES handle cycles/self references.

enumerating
o  withAllSendersDo: aBlock
evaluate aBlock for me and all contexts of my sender chain

o  withSendersThroughContextForWhich: checkBlock do: aBlock
evaluate aBlock for me and all contexts of my sender chain,
until checkBlock returns true (incl. that last one)

o  withSendersUpToContextForWhich: checkBlock do: aBlock
evaluate aBlock for me and all contexts of my sender chain,
until checkBlock returns true, excl. that context.

error handling
o  invalidReturn: returnValue
this message is sent by the VM, when a methods context
which has already returned is about to return again.
(i.e. about to execute a return from an already returned
method in a block).
We raise a signal here, to allow catching of that situation.

o  invalidReturnOrRestart: returnValue
this message is sent by the VM, when a method's or block's context
which was compiled non-returnable is about to return again,
or a non-restartable context is tried to be restarted.
In ST/X, not all contexts are restartable/returnable.
We raise a signal here, to allow catching of that situation.

o  invalidReturnOrRestartError: how with: value
common error reporter for restart/return errors

fixups
o  fixAllLineNumbers

internationalization support
o  resources
try to provide the resourcePack for internationalization
from:
the receiver
the class of the receiver.
(Parser >> #stringWithEmbeddedExpressions and stc generate code
to call this method for i'internationalized text' strings).

Usage example(s):

     thisContext resources
     AAA new test value.

minidebugger printing
o  fullPrint
print the receiver, selector and args of the context
- used only for MiniDebugger's walkback print

Usage example(s):

     thisContext fullPrint

o  fullPrintAll
print a full walkback starting at the receiver
- used only for MiniDebugger's walkback print

Usage example(s):

     thisContext fullPrintAll

o  fullPrintAllLevels: nOrNil
print a full walkback starting at the receiver, only print n levels
- used only for MiniDebugger's walkback print

Usage example(s):

     thisContext fullPrintAllLevels:5

o  printAll
print a full walkback starting at the receiver, only print n levels
- used only for MiniDebugger's walkback print

Usage example(s):

     thisContext printAll

o  printAllLevels: nOrNil
print a full walkback starting at the receiver, only print n levels
- used only for MiniDebugger's walkback print

Usage example(s):

     thisContext printAllLevels:5

o  savePrint
print the receiver-class and selector only
- used when there is a danger that printing results in errors

Usage example(s):

     thisContext fullPrint
     thisContext savePrint

non local control flow
o  evaluateUnwindActionsUpTo: aContext
walk up the calling chain, looking for unwind-cleanup actions to
be performed. This depends upon those contexts being specially
marked using #markForUnwind.
Returns the argument (i.e. non-nil), if all went well,
nil if aContext is not on the caller chain (definitely an error)

o  resend
EXPERIMENTAL: resend the context's message (to the same receiver).
if the method's implementation has been changed in the meanwhile (for example, in the debugger),
the new code is executed. Otherwise the same code is reexecuted from the start.

o  restart
restart the receiver - i.e. the method is evaluated again.
if the context to restart already died, trigger an error.
This is a low level helper for unwindAndRestart.

NOTICE:
NO unwind actions are performed - this is usually not
what you want (see Context>>unwindAndRestart).

LIMITATION:
currently a context can only be restarted by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-restartable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  resume
resume execution in this context. I.e. as if the method called
last by the receiver did a ^ nil.
If the context has already returned, report an error.

NOTICE:
NO unwind actions are performed (see Context>>unwind).

LIMITATION:
currently a context can only be resumed by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-resumable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  resume: value
resume the receiver - as if it got 'value' from whatever
it called. This continues execution in the receiver's method
after the point where it did its last send.
If the context has already returned - report an error.

NOTICE:
NO unwind actions are performed (see Context>>unwind:).

LIMITATION:
currently a context can only be resumed by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-resumable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  resumeIgnoringErrors: value
resume the receiver - as if it got 'value' from whatever
it called. This continues execution in the receiver's method
after the point where it did its last send.
If the context has already returned - simply return.

NOTICE:
NO unwind actions are performed (see Context>>unwind:).

LIMITATION:
currently a context can only be resumed by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-resumable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  resumeOnErrorProceed: value
resume the receiver - as if it got 'value' from whatever
it called. This continues execution in the receiver's method
after the point where it did its last send.
If the context has already returned - simply return.

NOTICE:
NO unwind actions are performed (see Context>>unwind:).

LIMITATION:
currently a context can only be resumed by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-resumable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  return
return from this context with nil. I.e. as if it did a ^ nil.
NOTICE:
NO unwind actions are performed - this is usually not
what you want (See Context>>unwind).
This is a low level method - a helper for unwind.

LIMITATION:
currently a context can only be returned by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  return: value
return from this context as if it did a '^ value'.
NOTICE:
NO unwind actions are performed - this is usually not
what you want (See Context>>unwind:).
This is a low level method - a helper for unwind.

LIMITATION:
currently a context can only be returned by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  returnDoing: aBlock
return from this context as if it did a '^ aBlock value'.
The block is evaluated as if called by the receiver context;
NOT the true executing context.
NOTICE:
NO unwind actions are performed - this is usually not
what you want (See Context>>unwindThenDo:).
This is a low level method - a helper for unwind.

LIMITATION:
currently a context can only be returned by
the owning process - not from outside.
Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwind
return nil from the receiver - i.e. simulate a '^ nil'.
If the context has already returned, report an error.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: on the way.

LIMITATION:
currently a context can only be unwound by
the owning process - not from outside.
i.e. it is not possible for one thread to unwind
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwind: value
return value from the receiver - i.e. simulate a '^ value'.
If the context has already returned , report an error.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: on the way.

LIMITATION:
currently a context can only be unwound by
the owning process - not from outside.
i.e. it is not possible for one thread to unwind
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwindAndRestart
restart the receiver - i.e. the method is evaluated again.
if the context to restart already did report an error.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: before restarting.

LIMITATION:
a context can only be restarted by
the owning process - not from outside.
i.e. it is not possible for one thread to unwindAndRestart
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-restartable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwindAndResume: value
resume execution in the the receiver - i.e. simulate a '^ value'
from whatever it called last.
If the context has already returned , report an error.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: on the way.

LIMITATION:
currently a context can only be unwound by
the owning process - not from outside.
i.e. it is not possible for one thread to unwind
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwindThenDo: aBlock
return the value of aBlock from the receiver - i.e. simulate a '^ aBlock value'.
If the context has already returned, report an error.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: on the way.
The block is evaluated AFTER all unwind actions are performed
(i.e. the block's sender will be the receiving context, not the
currently executing context)

LIMITATION:
currently a context can only be unwound by
the owning process - not from outside
i.e. it is not possible for one thread to unwindThenDo
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

o  unwindThenResend
EXPERIMENTAL: resend the context's message (to the same receiver).
if the method's implementation has been changed in the meanwhile (for example, in the debugger),
the new code is executed. Otherwise the same code is reexecuted from the start.
Evaluate all unwind-blocks as specified in Block>>valueNowOrOnUnwind:
and Block>>valueOnUnwindDo: on the way.
The resend happens AFTER all unwind actions are performed

LIMITATION:
currently a context can only be unwound by
the owning process - not from outside
i.e. it is not possible for one thread to unwindThenDo
another threads context - which does not make sense anyway.
However, you can force another thread to do this in its own process
context, by giving it an interrupt action - this does make sense.

Also, the compiler has an option (+optcontext) to create
non-returnable contexts (which are faster).
If such a context is restarted, a runtime error is raised.

printing & storing
o  argStringFor: someObject
take care, do not evaluate lazy or do sends to
a bridge when showing backtrace. Especially not after
timeout of a bridge call!

o  argsDisplayString
Modified (format): / 07-03-2012 / 13:11:17 / cg

o  argsDisplayStringShort

o  displayArgsOn: aStream withCRs: withCRs indent: i

o  displayArgsOn: aStream withCRs: withCRs indent: i contractEachTo: limitOrNil

o  displayLocalsOn: aStream withCRs: withCRs indent: i

o  displayOn: aGCOrStream
return a string to display the receiver - for display in Inspector

o  fullPrintAllOn: aStream
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript

o  fullPrintAllOn: aStream levels: numLevels
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript levels:10

o  fullPrintAllOn: aStream levels: numLevels indent: indent
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript levels:10 indent:4

o  fullPrintAllOn: aStream throughContext: topContextToPrint
print a full walkback (incl. arguments) starting at the receiver,
and ending at topContextToPrint

o  fullPrintAllOn: aStream throughContextForWhich: aBlock
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript throughContextForWhich:[:con | con selector == #doIt].

o  fullPrintAllOn: aStream upToContext: firstContextToStopPrint indent: indent
print a full walkback (incl. arguments) starting at the receiver,
and ending at (but excluding) firstContextToStopPrint

o  fullPrintAllOn: aStream upToContextForWhich: aBlock
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript upToContextForWhich:[:con | con selector == #doIt].

o  fullPrintAllOn: aStream upToContextForWhich: aBlock indent: indent
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript upToContextForWhich:[:con | con selector == #doIt].

o  fullPrintAllOn: aStream withVariables: withVariablesBool
print a full walkback (incl. arguments) starting at the receiver

Usage example(s):

     thisContext fullPrintAllOn:Transcript withVariables:true

o  fullPrintAllString
return a string containing the full walkback (incl. arguments)

Usage example(s):

     thisContext fullPrintAllString
     Logger info:'Backtrace: %1' with:thisContext fullPrintAllString

o  fullPrintAllStringWithVariables
return a string containing the full walkback (incl. arguments)

o  fullPrintOn: aStream
append a verbose description (incl. arguments) of the receiver onto aStream

Usage example(s):

     thisContext fullPrintOn:Transcript
     thisContext sender fullPrintOn:Transcript

o  fullPrintOn: aStream withVariables: withVariablesBool
append a verbose description (incl. arguments) of the receiver onto aStream

Usage example(s):

     thisContext fullPrintOn:Transcript withVariables:true

o  fullPrintString
return a string describing the context - this includes the linenumber,
receiver printString and argument printString

Usage example(s):

     thisContext fullPrintString => 'Context class(**DIRECTED**) >> doIt  [1]'

o  methodPrintString
return a string describing the context's method as 'implementorClass>>selector'

Usage example(s):

     thisContext methodPrintString           => 'a Method(unbound)'
     thisContext sender methodPrintString    => 'CompiledCode >> valueWithReceiver:arguments:selector:search:sender:'

o  printAllOn: aStream
print a brief walkback (excl. arguments) starting at the receiver

Usage example(s):

     thisContext printAllOn:Transcript

o  printAllOn: aStream throughContext: topContextToPrint
print a brief walkback (excl. arguments) starting at the receiver,
and ending at topContextToPrint

o  printAllOn: aStream throughContextForWhich: aBlock
print a brief walkback (excl. arguments) starting at the receiver

Usage example(s):

     thisContext printAllOn:Transcript throughContextForWhich:[:con | con selector == #doIt].

o  printAllOn: aStream upToContextForWhich: aBlock
print a brief walkback (excl. arguments) starting at the receiver

Usage example(s):

     thisContext printAllOn:Transcript upToContextForWhich:[:con | con selector == #withCursor:do:].

o  printAllString
return a string containing the brief walkback (excl. arguments)

Usage example(s):

     thisContext printAllString

o  printClassNameOf: aClass on: aStream
helper for printing

o  printOn: aStream
append a brief description (excl. arguments) of the receiver onto aStream

o  printReceiverOn: aStream
print description of the receiver of the context to aStream

o  printReceiverWithSeparator: sep on: aStream
print description of the receiver of the context to aStream

o  printWithSeparator: sep on: aStream
append a brief description (excl. arguments) of the receiver onto aStream.
Used eg. by the debugger to get a representation in the top walkback list

o  receiverPrintString
return a string describing the receiver of the context

Usage example(s):

	thisContext receiverPrintString

o  safeReceiverClassNameIfInvalid
if the receiver refers to an invalid object,
return a replacement string. otherwise nil.
This cares for invalid (free) objects which may appear with bad primitive code,
and prevents a crash in such a case.

private-accessing
o  isMarkedForUnwind
true if the mark for unwind flag is set in the receiver.
The VM needs this to know that some special action is to be performed with
this context - a highly internal mechanism and not for public use.

Usage example(s):

     thisContext isMarkedForUnwind

o  markForHandle
set the mark for exception handle flag in the receiver.
The VM needs this to know that some special action is to be performed with
this context - a highly internal mechanism and not for public use.

o  markForInterrupt
set the interrupt flag.
The VM needs this to know that some special action is to be performed with
this context upon return - a highly internal mechanism and not for public use.

o  markForInterruptOnUnwind
set the interrupt-on-unwind flag in the receiver.
The VM will generate a stepInterrupt, when this context returns or
is unwound. This is used by the debugger for faster single-stepping;
- a highly internal mechanism and not for public use.

o  markForRaise
set the mark for exception raise flag in the receiver.
The VM needs this to know that some special action is to be performed with
this context - a highly internal mechanism and not for public use.

o  markForUnwind
set the mark for unwind flag in the receiver.
The VM needs this to know that some special action is to be performed with
this context - a highly internal mechanism and not for public use.

o  setHome: aContext
set the homeContext.
DANGER: this is for experimental, internal use only (byteCode interpreters)

o  setSender: aContext
set the sender of the context.
DANGER: this is for experimental, internal use only (byteCode interpreters)

o  unmarkForUnwind
clear the mark for unwind flag in the receiver.
The VM needs this to know that some special action is to be performed with
this context - a highly internal mechanism and not for public use.

searching
o  findExceptional
walk along the sender chain (starting with the sender),
for a context which is marked as handle or raise context.
This non-standard interface is only to be used by exception

o  findNextContextWithSelector: selector1 or: selector2 or: selector3
walk along the sender chain (starting with the sender),
for a context with either one of the given selectors.
This non-standard interface is only to be used by exception

o  findNextUnwindContextOr: aContext
walk along the sender chain (starting at the sender),
for a context marked for unwindAction or aContext.
This non-standard interface is only to be used by mySelf

o  findSpecialHandle: findHandleContext raise: findRaiseContext
walk along the sender chain (starting with the sender),
for a context which is marked as handle or raise context.
This non-standard interface is only to be used by exception

special accessing
o  argAndVarNames
helper: given a context, return a collection of arg&var names

o  canResume
return true, if the receiver allows to be resumed.
In ST/X, due to the implementation, this requires that the context which
is right below the receiver is returnable and still active.

o  canReturn
return true, if the receiver allows returning through it.
Blocks, (currently) always return false.
Methods which contain a (non-inlined) block are always
returnable - for other methods, it depends on how the system
was compiled (stc flag +/-optContext).
If it was compiled with +optContext, methods are compiled
non returnable, unless a return-pragma was present in the method.
Since this saves some administrative work in every method
invocation and makes overall execution faster, the system classes
are all compiled with this flag turned on.
This means, that by default, it is not possible to walk up the
calling chain and return to an arbitrary context.
For contexts which are known to require this (i.e. handlers as found
by the exception walkers, these are marked specially (markForReturn),
so compilers know that they should create full featured contexts.

o  hasStackToShow
private interface to the debugger.
Smalltalk contexts return false here - other language frames
(i.e. Java frames) may want to show the evaluation stack

o  isHandleContext
return true, if this is a context with exception-handle flag set

o  isNonLifo
return true, if this is a nonLifo context.
A nonLifo context is one that is still on the machine stack,
but has a reference taken and needs to be converted to a real
object (in objectMemory) when the method/block returns.
You don't have to understand this - this is a special ST/X
debug query, which may be removed without notice.

o  isOnMachineStack
return true, if this is a machine stack context as opposed to a
real heap context (i.e. if it has not been captured and returned from).
You don't have to understand this - this is a special ST/X
debug query, which may be removed without notice.

o  isRaiseContext
return true, if this is a context with exception-raise flag set

o  isSpecial
return true, if this is either a nonLifo or interrupted context

o  isUnwindContext
return true, if this is an unwindContext

o  tempNames
helper: given a context, return a collection of arg, var and temporary names

testing
o  isBlockContext
return true, iff the receiver is a BlockContext, false otherwise

o  isCheapBlockContext
return true, iff the receiver is a BlockContext, for a cheap block, false otherwise.
Cheap blocks do not refer to their home

o  isContext
return true, iff the receiver is a Context, false otherwise

o  isReallyRecursive
return true, if this context is one of a recursive send of the same
selector AND same argument(s) to the same receiver before.
Here, different arguments are NOT ignored.

o  isRecursive
return true, if this context is one of a recursive send of the same
selector to the same receiver before.
Here, different arguments are ignored - i.e. only the same method
counts for recursiveness.
Used to detect recursive errors or recursive printing - for example.

o  isWeakRecursive: maxNestCount
return true, if this context is one of a recursive send of the same
method.
Here, different receivers and different arguments are ignored -
i.e. only the same method counts for recursiveness.

Use this to limit nesting of calls to the same method.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:19:44 GMT