AvailPushLabel

class AvailPushLabel(var relevantTokens: A_Tuple) : AvailInstruction

I represent the use of a label. When a label is used, it causes the current continuation to be copied. The copy is then reset to the state that existed when the current function started running, resetting the program counter, stack pointer, and stack slots, and creating new local variables.

The new continuation can subsequently be restart, restarted with new arguments, or exited.

Author

Mark van Gulik

Parameters

relevantTokens

The A_Tuple of A_Tokens that are associated with this instruction.

Constructors

Link copied to clipboard
fun AvailPushLabel(relevantTokens: A_Tuple)

Construct an instruction. Capture the tokens that contributed to it.

Functions

Link copied to clipboard
open override fun fixUsageFlags(    localData: MutableList<AvailVariableAccessNote?>,     outerData: MutableList<AvailVariableAccessNote?>,     codeGenerator: AvailCodeGenerator)

Push a label, which is a continuation. Since the label can be restarted (which constructs new locals while reusing the arguments), or exited (which has no static effect on optimizations), I only have an effect on arguments and outer variables. Scan all arguments and outer variables and ensure the most recent pushes are reset so that isLastAccess is false.

Link copied to clipboard
open fun writeLineNumberDeltasOn(encodedLineNumberDeltas: MutableList<Int>, currentLineNumber: Int): Int

Write an entry to the encoded line number deltas for each L1 instruction generated. Most AvailInstructions write a single L1 instruction, so that implementation is here.

Link copied to clipboard
open override fun writeNybblesOn(aStream: NybbleOutputStream)

Write nybbles representing this instruction to the NybbleOutputStream.

Properties

Link copied to clipboard
open val isOuterUse: Boolean

true iff this instruction is a use of an outer variable.

Link copied to clipboard
val lineNumber: Int

Answer which line number to say that this instruction occurs on. Use the relevantTokens as an approximation, but subclasses might be able to be more precise. Answer -1 if this instruction doesn't seem to have a location in the source associated with it.

Link copied to clipboard
var relevantTokens: A_Tuple

The tuple of tokens that contributed to producing this instruction.