Category: Language-Implementation
Superclass: Object
I am a factotum class. My instances represent Smalltalk blocks, portions of executeable code that have access to the environment that they were declared in, take parameters, and can be passed around as objects to be executed by methods outside the current class. Block closures are sent a message to compute their value and create a new execution context; this property can be used in the construction of control flow methods. They also provide some methods that are used in the creation of Processes from blocks.

Method category index

instance creation (class)
testing (class)
accessing (instance)
built ins (instance)
control structures (instance)
exception handling (instance)
multiple process (instance)
overriding (instance)
testing (instance)
unwind protection (instance)

instance creation (class)

block: aCompiledBlock
Answer a BlockClosure that activates the passed CompiledBlock.

block: aCompiledBlock receiver: anObject

Answer a BlockClosure that activates the passed CompiledBlock with the given receiver.

block: aCompiledBlock receiver: anObject outerContext: aContext

Answer a BlockClosure that activates the passed CompiledBlock with the given receiver.

numArgs: args numTemps: temps bytecodes: bytecodes depth: depth literals: literalArray

Answer a BlockClosure for a new CompiledBlock that is created using the passed parameters. To make it work, you must put the BlockClosure into a CompiledMethod's literals.

top


testing (class)

isImmediate
Answer whether, if x is an instance of the receiver, x copy == x

top


accessing (instance)

argumentCount
Answer the number of arguments passed to the receiver

block

Answer the CompiledBlock which contains the receiver's bytecodes

block: aCompiledBlock

Set the CompiledBlock which contains the receiver's bytecodes

finalIP

Answer the last instruction that can be executed by the receiver

fixTemps

This should fix the values of the temporary variables used in the block that are ordinarily shared with the method in which the block is defined. Not defined yet, but it is not harmful that it isn't. Answer the receiver.

initialIP

Answer the initial instruction pointer into the receiver.

method

Answer the CompiledMethod in which the receiver lies

numArgs

Answer the number of arguments passed to the receiver

numTemps

Answer the number of temporary variables used by the receiver

outerContext

Answer the method/block context which is the immediate outer of the receiver

outerContext: containingContext

Set the method/block context which is the immediate outer of the receiver

receiver

Answer the object that is used as `self' when executing the receiver (if nil, it might mean that the receiver is not valid though...)

receiver: anObject

Set the object that is used as `self' when executing the receiver

stackDepth

Answer the number of stack slots needed for the receiver

top


built ins (instance)

cull: arg1
Evaluate the receiver, passing arg1 as the only parameter if the receiver has parameters.

cull: arg1 cull: arg2

Evaluate the receiver, passing arg1 and arg2 as parameters if the receiver accepts them.

cull: arg1 cull: arg2 cull: arg3

Evaluate the receiver, passing arg1, arg2 and arg3 as parameters if the receiver accepts them.

value

Evaluate the receiver passing no parameters

value: arg1

Evaluate the receiver passing arg1 as the only parameter

value: arg1 value: arg2

Evaluate the receiver passing arg1 and arg2 as the parameters

value: arg1 value: arg2 value: arg3

Evaluate the receiver passing arg1, arg2 and arg3 as the parameters

valueWithArguments: argumentsArray

Evaluate the receiver passing argArray's elements as the parameters

top


control structures (instance)

repeat
Evaluate the receiver 'forever' (actually until a return is executed or the process is terminated).

whileFalse

Evaluate the receiver until it returns true

whileFalse: aBlock

Evaluate the receiver. If it returns false, evaluate aBlock and restart

whileTrue

Evaluate the receiver until it returns false

whileTrue: aBlock

Evaluate the receiver. If it returns true, evaluate aBlock and restart

top


exception handling (instance)

ifError: aBlock
Evaluate the receiver; when #error: is called, pass to aBlock the receiver and the parameter, and answer the result of evaluating aBlock. If another exception is raised, it is passed to an outer handler; if no exception is raised, the result of evaluating the receiver is returned.

on: anException do: aBlock

Evaluate the receiver; when anException is signaled, evaluate aBlock passing a Signal describing the exception. Answer either the result of evaluating the receiver or the parameter of a Signal>>#return:

on: e1 do: b1 on: e2 do: b2

Evaluate the receiver; when e1 or e2 are signaled, evaluate respectively b1 or b2, passing a Signal describing the exception. Answer either the result of evaluating the receiver or the argument of a Signal>>#return:

on: e1 do: b1 on: e2 do: b2 on: e3 do: b3

Evaluate the receiver; when e1, e2 or e3 are signaled, evaluate respectively b1, b2 or b3, passing a Signal describing the exception. Answer either the result of evaluating the receiver or the parameter of a Signal>>#return:

on: e1 do: b1 on: e2 do: b2 on: e3 do: b3 on: e4 do: b4

Evaluate the receiver; when e1, e2, e3 or e4 are signaled, evaluate respectively b1, b2, b3 or b4, passing a Signal describing the exception. Answer either the result of evaluating the receiver or the parameter of a Signal>>#return:

on: e1 do: b1 on: e2 do: b2 on: e3 do: b3 on: e4 do: b4 on: e5 do: b5

Evaluate the receiver; when e1, e2, e3, e4 or e5 are signaled, evaluate respectively b1, b2, b3, b4 or b5, passing a Signal describing the exception. Answer either the result of evaluating the receiver or the parameter of a Signal>>#return:

top


multiple process (instance)

fork
Create a new process executing the receiver and start it

forkAt: priority

Create a new process executing the receiver with given priority and start it

forkWithoutPreemption

Evaluate the receiver in a process that cannot be preempted. If the receiver expect a parameter, pass the current process.

newProcess

Create a new process executing the receiver in suspended state. The priority is the same as for the calling process. The receiver must not contain returns

newProcessWith: anArray

Create a new process executing the receiver with the passed arguments, and leave it in suspended state. The priority is the same as for the calling process. The receiver must not contain returns

valueWithoutInterrupts

Evaluate aBlock and delay all interrupts that are requested to the active process during its execution to after aBlock returns.

valueWithoutPreemption

Evaluate the receiver with external interrupts disabled. This effectively disables preemption as long as the block does not explicitly yield control, wait on semaphores, and the like.

top


overriding (instance)

copy
Answer the receiver.

deepCopy

Answer a shallow copy.

top


testing (instance)

hasMethodReturn
Answer whether the block contains a method return

top


unwind protection (instance)

ensure: aBlock
Evaluate the receiver; when any exception is signaled exit returning the result of evaluating aBlock; if no exception is raised, return the result of evaluating aBlock when the receiver has ended

ifCurtailed: aBlock

Evaluate the receiver; if its execution triggers an unwind which truncates the execution of the block (`curtails' the block), evaluate aBlock. The three cases which can curtail the execution of the receiver are: a non-local return in the receiver, a non-local return in a block evaluated by the receiver which returns past the receiver itself, and an exception raised and not resumed during the execution of the receiver.

valueWithUnwind

Evaluate the receiver. Any errors caused by the block will cause a backtrace, but execution will continue in the method that sent #valueWithUnwind, after that call. Example: [ 1 / 0 ] valueWithUnwind. 'unwind works!' printNl. Important: this method is public, but it is intended to be used in very special cases (as a rule of thumb, use it only when the corresponding C code uses the _gst_prepare_execution_environment and _gst_finish_execution_environment functions). You should usually rely on #ensure: and #on:do:.

top