L1Operation

enum L1Operation : Enum<L1Operation>

An L1Operation is encoded within a nybblecode stream as an opcode followed by operands. Opcodes less than 16 are encoded as a single nybble, and the others are represented as the extension nybble (15), followed by the opcode minus 16. This supports up to 31 distinct nybblecodes, the statically most frequently occurring of which should be assigned to the first 15 values (0-14) for compactness.

The operands are encoded in such a way that very small values occupy a single nybble, but values up to Integer.MAX_VALUE are supported efficiently.

Author

Mark van Gulik

Parameters

ordinalCheck

This operation's ordinal.

operandTypes

This operation's list of operand types.

Entries

Link copied to clipboard

Pop the stack, writing the value directly to the current continuation in the indicated local slot.

Link copied to clipboard
L1Ext_doSuperCall(21, LITERAL, LITERAL, LITERAL)

Invoke a method with a supercall.

Link copied to clipboard
L1Ext_doPermute(20, LITERAL)

Permute the top N stack elements based on the literal which is an N-tuple of distinct integers in 1..N (i.e., a permutation). The mutability of the values is unaffected.

Link copied to clipboard

Duplicate the top stack element (i.e., push another occurrence of the top of stack}. Make the object immutable since it now has an additional reference.

Link copied to clipboard
L1Ext_doSetLiteral(18, LITERAL)

Pop the stack and write the value into a variable literal. This is used to write to module variables.

Link copied to clipboard
L1Ext_doGetLiteral(17, LITERAL)

Get the value of a variable literal. This is used only to read from module variables.

Link copied to clipboard

Push a continuation just like the current one, such that if it is ever resumed it will have the same effect as restarting the current one.

Link copied to clipboard

Process an extension nybblecode, which involves consuming the next nybble and dispatching it as though 16 were added to it.

Link copied to clipboard
L1_doGetOuter(14, OUTER)

Push the current value of the specified outer variable of the function.

Link copied to clipboard
L1_doMakeTuple(13, IMMEDIATE)

Pop the specified number of elements from the stack and assemble them into a tuple. Push the tuple.

Link copied to clipboard
L1_doGetLocal(12, LOCAL)

Push the value of the specified local variable or constant. Make it immutable, since it may still be needed by subsequent instructions.

Link copied to clipboard
L1_doSetOuter(11, OUTER)

Pop the stack and write it to the specified outer variable of the function.

Link copied to clipboard

Push the current value of the specified outer variable. The outer variable is part of the function being executed. Clear this outer variable if it is mutable.

Link copied to clipboard

Discard the top element of the stack.

Link copied to clipboard
L1_doPushOuter(8, OUTER)

Push the specified outer variable of the function.

Link copied to clipboard

Extract the value from the specified local variable or constant. If the variable is mutable, null it out in the continuation. Raise a suitable runtime exception if the variable does not have a value.

Link copied to clipboard
L1_doSetLocal(6, LOCAL)

Pop the stack and write the value into the specified local variable.

Link copied to clipboard
L1_doClose(5, IMMEDIATE, LITERAL)

Create a function from the specified number of pushed outer variables and the specified literal compiled code.

Link copied to clipboard

Push an outer variable, i.e. a variable lexically captured by the current function. This should be the last use of the variable, so clear it from the function if the function is still mutable.

Link copied to clipboard
L1_doPushLocal(3, LOCAL)

Push a local variable -- not its value, but the variable itself. If an argument or constant is specified then push the value, since there is no actual variable to operate on.

Link copied to clipboard

Push a local variable -- not its value, but the variable itself. This should be the last use of the variable, so erase it from the continuation at the same time.

Link copied to clipboard
L1_doPushLiteral(1, LITERAL)

Push the literal whose index is specified by the operand.

Link copied to clipboard
L1_doCall(0, LITERAL, LITERAL)

Invoke a method.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun dispatch(operationDispatcher: L1OperationDispatcher)

Dispatch this operation through an L1OperationDispatcher.

Link copied to clipboard
fun shortName(): String
Link copied to clipboard
fun writeTo(stream: NybbleOutputStream)

Write this operation to a NybbleOutputStream. Do not output operands.

Properties

Link copied to clipboard
val name: String
Link copied to clipboard
val operandTypes: Array<out L1OperandType>

This operation's collection of operand types.

Link copied to clipboard
val ordinal: Int