Category: Language-Implementation
Superclass: Object
My instances represent executing Smalltalk code, which represent the local environment of executable code. They contain a stack and also provide some methods that can be used in inspection or debugging.

Method category index

built ins (class)
exception handling (class)
accessing (instance)
built ins (instance)
copying (instance)
debugging (instance)
enumerating (instance)
printing (instance)

built ins (class)

thisContext
Return the value of the thisContext variable. Called internally when the variable is accessed.

top


exception handling (class)

backtrace
Print a backtrace from the caller to the bottom of the stack on the Transcript

backtraceOn: aStream

Print a backtrace from the caller to the bottom of the stack on aStream

top


accessing (instance)

at: index
Answer the index-th slot in the receiver. Any read access from (self size + 1) to (self basicSize) will give nil.

at: index put: anObject

Answer the index-th slot in the receiver. Any write access from (self size + 1) to (self basicSize) will give an error unless nil is being written. This is because doing such an access first, and then updating sp, is racy: the garbage collector may trigger in the middle and move anObject, but the slot in the context won't be adjusted.

client

Answer the client of this context, that is, the object that sent the message that created this context. Fail if the receiver has no parent

currentFileName

Answer the name of the file where the method source code is

environment

To create a valid execution environment for the interpreter even before it starts, GST creates a fake context whose selector is nil and which can be used as a marker for the current execution environment. This method answers that context. For processes, it answers the process block itself

home

Answer the MethodContext to which the receiver refers

initialIP

Answer the value of the instruction pointer when execution starts in the current context

ip

Answer the current instruction pointer into the receiver

ip: newIP

Set the instruction pointer for the receiver

isBlock

Answer whether the receiver is a block context

isDisabled

Answers whether the context is skipped when doing a return. Contexts are marked as disabled whenever a non-local return is done (either by returning from the enclosing method of a block, or with the #continue: method of ContextPart) and there are unwind contexts such as those created by #ensure:. All non-unwind contexts are then marked as disabled.

isEnvironment

To create a valid execution environment for the interpreter even before it starts, GST creates a fake context which invokes a special ``termination'' method. Such a context can be used as a marker for the current execution environment. Answer whether the receiver is that kind of context.

isProcess

Answer whether the receiver represents a process context, i.e. a context created by BlockClosure>>#newProcess. Such a context can be recognized because it has no parent but its flags are different from those of the contexts created by the VM's prepareExecutionEnvironment function.

isUnwind

Answers whether the context must continue execution even after a non-local return (a return from the enclosing method of a block, or a call to the #continue: method of ContextPart). Such contexts are created by #ensure:.

method

Return the CompiledMethod being executed

methodClass

Return the class in which the CompiledMethod being executed is defined

numArgs

Answer the number of arguments passed to the receiver

numTemps

Answer the number of temporaries used by the receiver

parentContext

Answer the context that called the receiver

parentContext: aContext

Set the context to which the receiver will return

push: anObject

Push an object on the receiver's stack.

receiver

Return the receiver (self) for the method being executed

selector

Return the selector for the method being executed

size

Answer the number of valid fields for the receiver. Any read access from (self size + 1) to (self basicSize) will give nil.

sp

Answer the current stack pointer into the receiver. Note that the sp value is zero-based.

sp: newSP

Set the stack pointer for the receiver.

validSize

Answer how many elements in the receiver should be inspected

top


built ins (instance)

continue: anObject
Resume execution from the receiver, faking that the context on top of it in the execution chain has returned anObject. The receiver must belong to the same process as the executing context, otherwise the results are not predictable. All #ensure: (and possibly #ifCurtailed:) blocks between the currently executing context and the receiver are evaluated (which is not what would happen if you directly bashed at the parent context of thisContext).

top


copying (instance)

copyStack
Answer a copy of the entire stack.

deepCopy

Answer a copy of the entire stack, but don't copy any of the other instance variables of the context.

top


debugging (instance)

currentLine
Answer the 1-based number of the line that is pointed to by the receiver's instruction pointer. The DebugTools package caches information, thus making the implementation faster.

currentLineInFile

Answer the 1-based number of the line that is pointed to by the receiver's instruction pointer, relative to the method's file. The implementation is slow unless the DebugTools package is loaded.

debugger

Answer the debugger that is attached to the given context. It is always nil unless the DebugTools package is loaded.

debuggerClass

Answer which debugger should be used to debug the current context chain. The class with the highest debugging priority is picked among those mentioned in the chain.

isInternalExceptionHandlingContext

Answer whether the receiver is a context that should be hidden to the user when presenting a backtrace.

top


enumerating (instance)

scanBacktraceFor: selectors do: aBlock
Scan the backtrace for contexts whose selector is among those listed in selectors; if one is found, invoke aBlock passing the context.

scanBacktraceForAttribute: selector do: aBlock

Scan the backtrace for contexts which have the attribute selector listed in selectors; if one is found, invoke aBlock passing the context and the attribute.

top


printing (instance)

backtrace
Print a backtrace from the receiver to the bottom of the stack on the Transcript.

backtraceOn: aStream

Print a backtrace from the caller to the bottom of the stack on aStream.

examineOn: aStream

Not commented.

printArgumentsOn: aStream spaces: anInteger

Not commented.

printContextState

Not commented.

printContextStateOn: aStream spaces: anInteger

Not commented.

printOptimizedTemporariesOn: aStream spaces: anInteger

Not commented.

printTemporariesOn: aStream spaces: anInteger

Not commented.

printVariable: anArray at: anIndex do: aBlock on: aStream spaces: anInteger

Not commented.

printVariableKind: aString on: aStream spaces: anInteger

Not commented.

top