Squeak Class Documentation category index | class index  
 
BlockContext
  category: Kernel-Methods
  superclass: ContextPart
  subclasses:

My instances function similarly to instances of MethodContext, but they hold the dynamic state for execution of a block in Smalltalk. They access all temporary variables and the method sender via their home pointer, so that those values are effectively shared. Their indexable part is used to store their independent value stack during execution.

My instance must hold onto its home in order to work. This can cause circularities if the home is also pointing (via a temp, perhaps) to the instance. In the rare event that this happens (as in SortedCollection sortBlock:) the message fixTemps will replace home with a copy of home, thus defeating the sharing of temps but, nonetheless, eliminating the circularity.

BlockContexts must only be created using the method newForMethod:. Note that it is impossible to determine the real object size of a BlockContext except by asking for the frameSize of its method. Any fields above the stack pointer (stackp) are truly invisible -- even (and especially!) to the garbage collector. Any store into stackp other than by the primitive method stackp: is potentially fatal.

instance methods
  Camp Smalltalk
  sunitEnsure:
sunitOn:do:

  Worlds
 

  accessing
  copyForSaving
fixTemps
hasInstVarRef
hasMethodReturn
home
method
numArgs
receiver
tempAt:
tempAt:put:

  controlling
  repeat
repeatWithGCIf:
whileFalse
whileFalse:
whileTrue
whileTrue:

  evaluating
  ifError:
timeToRun
value
value:
value:ifError:
value:value:
value:value:value:
value:value:value:value:
valueWithArguments:

  exceptions
  assert
ensure:
ifCurtailed:
on:do:

  initialize-release
  home:startpc:nargs:

  instruction decoding
  blockReturnTop

  printing
  printOn:
printOnStream:

  private
  aboutToReturn:through:
cannotReturn:
instVarAt:put:
startpc
valueError
valueUnpreemptively

  private-debugger
  hideFromDebugger

  private-exceptions
  ifProperUnwindSupportedElseSignalAboutToReturn
valueUninterruptably

  scheduling
  fork
forkAt:
newProcess
newProcessWith:

  system simulation
  pushArgs:from:
stepToSendOrReturn

  tiles
  valueWithPossibleArgs:

class methods
  no messages
 

instance methods
  Camp Smalltalk top  
 

sunitEnsure:


 

sunitOn:do:


  Worlds top  

  accessing top  
 

copyForSaving

Fix the values of the temporary variables used in the block that are
ordinarily shared with the method in which the block is defined.


 

fixTemps

Fix the values of the temporary variables used in the block that are
ordinarily shared with the method in which the block is defined.


 

hasInstVarRef

Answer whether the receiver references an instance variable.


 

hasMethodReturn

Answer whether the receiver has a return ('^') in its code.


 

home

Answer the context in which the receiver was defined.


 

method

Answer the compiled method in which the receiver was defined.


 

numArgs

Answer the number of arguments that must be used to evaluate this block


 

receiver

Refer to the comment in ContextPart|receiver.


 

tempAt:

Refer to the comment in ContextPart|tempAt:.


 

tempAt:put:

Refer to the comment in ContextPart|tempAt:put:.


  controlling top  
 

repeat

Evaluate the receiver repeatedly, ending only if the block explicitly returns.


 

repeatWithGCIf:

run the receiver, and if testBlock returns true, garbage collect and run the receiver again


 

whileFalse

Ordinarily compiled in-line, and therefore not overridable.
This is in case the message is sent to other than a literal block.
Evaluate the receiver, as long as its value is false.


 

whileFalse:

Ordinarily compiled in-line, and therefore not overridable.
This is in case the message is sent to other than a literal block.
Evaluate the argument, aBlock, as long as the value of the receiver is false.


 

whileTrue

Ordinarily compiled in-line, and therefore not overridable.
This is in case the message is sent to other than a literal block.
Evaluate the receiver, as long as its value is true.


 

whileTrue:

Ordinarily compiled in-line, and therefore not overridable.
This is in case the message is sent to other than a literal block.
Evaluate the argument, aBlock, as long as the value of the receiver is true.


  evaluating top  
 

ifError:

Evaluate the block represented by the receiver, and normally return it's value. If an error occurs, the errorHandlerBlock is evaluated, and it's value is instead returned. The errorHandlerBlock must accept either no parameters, or two (the error message and the receiver). The receiver should not contain an explicit return statement as this would leave an obsolete error handler hanging around.


 

timeToRun

Answer the number of milliseconds taken to execute this block.


 

value

Primitive. Evaluate the block represented by the receiver. Fail if the
block expects any arguments or if the block is already being executed.
Optional. No Lookup. See Object documentation whatIsAPrimitive.


 

value:

Primitive. Evaluate the block represented by the receiver. Fail if the
block expects other than one argument or if the block is already being
executed. Optional. No Lookup. See Object documentation
whatIsAPrimitive.


 

value:ifError:

Evaluate the block represented by the receiver. If an error occurs aBlock is evaluated
with the error message and the receiver as parameters. The receiver should not contain
an explicit return statement as this would leave an obsolete error handler hanging around.


 

value:value:

Primitive. Evaluate the block represented by the receiver. Fail if the
block expects other than two arguments or if the block is already being
executed. Optional. See Object documentation whatIsAPrimitive.


 

value:value:value:

Primitive. Evaluate the block represented by the receiver. Fail if the
block expects other than three arguments or if the block is already being
executed. Optional. See Object documentation whatIsAPrimitive.


 

value:value:value:value:

Primitive. Evaluate the block represented by the receiver. Fail if the
block expects other than three arguments or if the block is already being
executed. Optional. See Object documentation whatIsAPrimitive.


 

valueWithArguments:

Primitive. Evaluate the block represented by the receiver. The argument
is an Array whose elements are the arguments for the block. Fail if the
length of the Array is not the same as the the number of arguments that
the block was expecting. Fail if the block is already being executed.
Essential. See Object documentation whatIsAPrimitive.


  exceptions top  
 

assert


 

ensure:

Evaluate a termination block after evaluating the receiver, regardless of whether the receiver's evaluation completes.


 

ifCurtailed:

Evaluate the receiver with an abnormal termination action.


 

on:do:

Evaluate the receiver in the scope of an exception handler.


  initialize-release top  
 

home:startpc:nargs:

This is the initialization message. The receiver has been initialized with
the correct size only.


  instruction decoding top  
 

blockReturnTop

Simulate the interpreter's action when a ReturnTopOfStack bytecode is
encountered in the receiver.


  printing top  
 

printOn:

Append to the argument, aStream, a sequence of characters that
identifies the receiver.


 

printOnStream:


  private top  
 

aboutToReturn:through:

Use the passed in context as the first marked context; evaluate the
unwind block and then scan upwards for the next unwind marked
method context


 

cannotReturn:

The receiver tried to return result to a method context that no longer exists.


 

instVarAt:put:

Primitive. Store a value into a fixed variable in the receiver. The
numbering of the variables corresponds to the named instance variables.
Fail if the index is not an Integer or is not the index of a fixed variable.
Answer the value stored as the result. Using this message violates the
principle that each object has sovereign control over the storing of
values into its instance variables. Essential. See Object documentation
whatIsAPrimitive.


 

startpc

for use by the System Tracer only


 

valueError


 

valueUnpreemptively

Evaluate the receiver (block), without the possibility of preemption by higher priority processes. Use this facility VERY sparingly!


  private-debugger top  
 

hideFromDebugger


  private-exceptions top  
 

ifProperUnwindSupportedElseSignalAboutToReturn

A really ugly hack to simulate the necessary unwind behavior for VMs not having proper unwind support


 

valueUninterruptably

Temporarily make my home Context unable to return control to its sender, to guard against circumlocution of the ensured behavior.


  scheduling top  
 

fork

Create and schedule a Process running the code in the receiver.


 

forkAt:

Create and schedule a Process running the code in the receiver at the given priority. Answer the newly created process.


 

newProcess

Answer a Process running the code in the receiver. The process is not
scheduled.


 

newProcessWith:

Answer a Process running the code in the receiver. The receiver's block
arguments are bound to the contents of the argument, anArray. The
process is not scheduled.


  system simulation top  
 

pushArgs:from:

Simulates action of the value primitive.


 

stepToSendOrReturn

Simulate the execution of bytecodes until either sending a message or
returning a value to the receiver (that is, until switching contexts).


  tiles top  
 

valueWithPossibleArgs:


class methods
  no messages top