Table of Contents

Class Instruction

Namespace
RDCore.SDK.Semantics.Instructions
Assembly
RDCore.SDK.dll

One entry of an InstructionList — RD-VBAL §3.5. Offset is both the entry's index into Items and the program-counter value that fetches it.

public sealed record Instruction : IEquatable<Instruction>
Inheritance
Instruction
Implements
Inherited Members

Constructors

Instruction(int, StatementNode?, InstructionKind, int?, ImmutableArray<int?>, int?, int?, int?, int?)

One entry of an InstructionList — RD-VBAL §3.5. Offset is both the entry's index into Items and the program-counter value that fetches it.

public Instruction(int Offset, StatementNode? Node, InstructionKind Kind, int? Target, ImmutableArray<int?> Targets, int? Else, int? End, int? Matching, int? EnclosingWith)

Parameters

Offset int

The entry's index into the owning Items.

Node StatementNode

The StatementNode this instruction was lowered from, or null for an instruction lowering synthesized — a block statement's closer, or the unconditional jump a branch's body ends with — which no source statement corresponds to.

Kind InstructionKind

The control-flow shape of this instruction.

Target int?

For Jump, GoSub, LoopBack, ForNext, ForEachNext, ExitLoop, OnErrorGoTo, and ResumeLabel: the resolved offset to branch to. null for a Jump lowered from GoTo/On…GoTo, a GoSub lowered from GoSub, or an OnErrorGoTo/ResumeLabel, whose operand did not resolve to a label the procedure defines (lowering already reported the LabelNotDefined diagnostic for it), or for an ExitLoop lowering found no matching enclosing loop for. Unused otherwise.

Targets ImmutableArray<int?>

For JumpTable and GoSubTable: the resolved offset for each label in source order, with a null entry wherever the corresponding label did not resolve. Empty otherwise.

Else int?

For ConditionalBranch: the offset to branch to when the condition is false, or the case does not match — the next header in the same If/ElseIf/Case chain, or the offset right past the whole construct when there is no next branch to try. Unused otherwise.

End int?

On a block's own opening instruction (an If's first header, a pre-test loop's header, a ForOpener/ForEachOpener/ With/Select): the offset right past the whole construct. null on every other instruction, including a construct's own inner headers (an ElseIf or a Case) and constructs with no single opening instruction (a bare Do…Loop, a post-test loop, an inline If).

Matching int?

The offset of the enclosing block-opening instruction whose own per-activation hidden state this instruction reads back. For a Select Case Case header (ConditionalBranch lowered from a CaseExpressionStatementNode): the enclosing Select instruction whose hidden selector value this header's range clauses are matched against (null on a Case Else, which never reads it). For a ForNext/ForEachNext closer: its own ForOpener/ForEachOpener, whose stashed counter/end/step (or enumerator) this closer advances and tests — a GoTo landing directly on the closer without that opener having run this activation is MS-VBAL §5.4.2.3 error 92, "For loop not initialized", detected the same way an unresolved with-target would be: no state stashed for the offset this instruction names. null on every other instruction kind.

EnclosingWith int?

The offset of the innermost With instruction lexically enclosing this one, so a .Member/!member with-expression reads the right hidden target however control arrived here — a GoTo into or out of a With block leaves no stale stack to unwind. null when this instruction is not inside any With block.

Properties

Else

For ConditionalBranch: the offset to branch to when the condition is false, or the case does not match — the next header in the same If/ElseIf/Case chain, or the offset right past the whole construct when there is no next branch to try. Unused otherwise.

public int? Else { get; init; }

Property Value

int?

EnclosingWith

The offset of the innermost With instruction lexically enclosing this one, so a .Member/!member with-expression reads the right hidden target however control arrived here — a GoTo into or out of a With block leaves no stale stack to unwind. null when this instruction is not inside any With block.

public int? EnclosingWith { get; init; }

Property Value

int?

End

On a block's own opening instruction (an If's first header, a pre-test loop's header, a ForOpener/ForEachOpener/ With/Select): the offset right past the whole construct. null on every other instruction, including a construct's own inner headers (an ElseIf or a Case) and constructs with no single opening instruction (a bare Do…Loop, a post-test loop, an inline If).

public int? End { get; init; }

Property Value

int?

Kind

The control-flow shape of this instruction.

public InstructionKind Kind { get; init; }

Property Value

InstructionKind

Matching

The offset of the enclosing block-opening instruction whose own per-activation hidden state this instruction reads back. For a Select Case Case header (ConditionalBranch lowered from a CaseExpressionStatementNode): the enclosing Select instruction whose hidden selector value this header's range clauses are matched against (null on a Case Else, which never reads it). For a ForNext/ForEachNext closer: its own ForOpener/ForEachOpener, whose stashed counter/end/step (or enumerator) this closer advances and tests — a GoTo landing directly on the closer without that opener having run this activation is MS-VBAL §5.4.2.3 error 92, "For loop not initialized", detected the same way an unresolved with-target would be: no state stashed for the offset this instruction names. null on every other instruction kind.

public int? Matching { get; init; }

Property Value

int?

Node

The StatementNode this instruction was lowered from, or null for an instruction lowering synthesized — a block statement's closer, or the unconditional jump a branch's body ends with — which no source statement corresponds to.

public StatementNode? Node { get; init; }

Property Value

StatementNode

Offset

The entry's index into the owning Items.

public int Offset { get; init; }

Property Value

int

Target

For Jump, GoSub, LoopBack, ForNext, ForEachNext, ExitLoop, OnErrorGoTo, and ResumeLabel: the resolved offset to branch to. null for a Jump lowered from GoTo/On…GoTo, a GoSub lowered from GoSub, or an OnErrorGoTo/ResumeLabel, whose operand did not resolve to a label the procedure defines (lowering already reported the LabelNotDefined diagnostic for it), or for an ExitLoop lowering found no matching enclosing loop for. Unused otherwise.

public int? Target { get; init; }

Property Value

int?

Targets

For JumpTable and GoSubTable: the resolved offset for each label in source order, with a null entry wherever the corresponding label did not resolve. Empty otherwise.

public ImmutableArray<int?> Targets { get; init; }

Property Value

ImmutableArray<int?>