AvailCodeGenerator

An AvailCodeGenerator is used to convert a phrase into the corresponding raw function.

Author

Mark van Gulik

Parameters

module

The module in which the function is defined.

args

The tuple of argument declarations.

primitive

The Primitive or null.

locals

The list of local variable declarations.

constants

The list of local constant declarations.

labels

The list of (zero or one) label declarations.

outers

Any needed outer variable/constant declarations.

resultType

The return type of the function.

resultTypeIfPrimitiveFails

The return type of the function, in the event that the primitive fails, or there is no primitive.

exceptionSet

The declared exception set of the function.

startingLineNumber

The line number of the module at which the function is purported to begin.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The module in which this code occurs.

Link copied to clipboard

The number of arguments that the code under construction accepts.

Functions

Link copied to clipboard
fun emitCall(tokens: A_Tuple, nArgs: Int, bundle: A_Bundle, returnType: A_Type)

Write a regular multimethod call. I expect my arguments to have been pushed already.

Link copied to clipboard
fun emitCloseCode(tokens: A_Tuple, compiledCode: A_RawFunction, neededVariables: A_Tuple)

Create a function from CompiledCodeDescriptor compiled code and the pushed outer (lexically bound) variables.

Link copied to clipboard

Emit code to duplicate the element at the top of the stack.

Link copied to clipboard
fun emitGetLiteral(tokens: A_Tuple, aLiteral: A_BasicObject)

Emit code to get the value of a literal variable.

Link copied to clipboard
fun emitGetLocalOrOuter(tokens: A_Tuple, localOrOuter: A_Phrase)

Emit code to get the value of a local or outer (captured) variable.

Link copied to clipboard

Emit a declaration of a label for the current block.

Link copied to clipboard
fun emitMakeTuple(tokens: A_Tuple, count: Int)

Emit code to create a tuple from the top N items on the stack.

Link copied to clipboard
fun emitPermute(tokens: A_Tuple, permutation: A_Tuple)

Emit code to permute the top N items on the stack with the given N-element permutation.

Link copied to clipboard
fun emitPop()

Emit code to pop the top value from the stack.

Link copied to clipboard
fun emitPushLiteral(tokens: A_Tuple, aLiteral: A_BasicObject)

Emit code to push a literal object onto the stack.

Link copied to clipboard
fun emitPushLocalOrOuter(tokens: A_Tuple, variableDeclaration: A_Phrase)

Push a variable. It can be local to the current block or defined in an outer scope.

Link copied to clipboard
fun emitSetLiteral(tokens: A_Tuple, aLiteral: A_BasicObject)

Emit code to pop the stack and write the popped value into a literal variable.

Link copied to clipboard
fun emitSetLocalFrameSlot(tokens: A_Tuple, localConstant: A_Phrase)

Emit code to pop the stack and write it directly into a local slot of the continuation. This is how local constants become initialized.

Link copied to clipboard
fun emitSetLocalOrOuter(tokens: A_Tuple, localOrOuter: A_Phrase)

Emit code to pop the stack and write into a local or outer variable.

Link copied to clipboard
fun emitSuperCall(tokens: A_Tuple, nArgs: Int, bundle: A_Bundle, returnType: A_Type, superUnionType: A_Type)

Write a super-call. I expect my arguments and their types to have been pushed already (interleaved).

Link copied to clipboard
fun setTokensWhile(tokens: A_Tuple, action: () -> Unit)

Capture an A_Tuple of A_Tokens for the duration of execution of the action]. If the tuple of tokens is empty, just evaluate the action.