Table of Contents

Class InstructionList

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

The ordered, keyed instruction list of one procedure body — RD-VBAL §3.5 (MS-VBAL §2.3.1: "sequentially evaluate each instruction in the frame"). Built by InstructionListLowering; immutable.

public sealed class InstructionList
Inheritance
InstructionList
Inherited Members

Remarks

Items is dense: index i is offset i, and every offset a program counter can hold names an entry. A label may resolve to Items.Length itself (a label with nothing after it) — that offset is valid to hold, and a fetch there completes as if execution had reached the end of the body.

Properties

Items

Every instruction, in program-counter order. Items[i].Offset == i for every i.

public ImmutableArray<Instruction> Items { get; }

Property Value

ImmutableArray<Instruction>

Methods

TryGetLabelOffset(string, out int)

Looks up the offset a line label or line number defines, by name (MS-VBAL §5.4.1.1). Case-insensitive, like every VBA identifier.

public bool TryGetLabelOffset(string label, out int offset)

Parameters

label string

The label name, or a line number's decimal string form.

offset int

Returns

bool

false when this procedure defines no such label.

TryGetLineNumber(int, out long)

The line number in effect at offset: the nearest line-number label at or before it. This is what Erl reports for an error raised there.

public bool TryGetLineNumber(int offset, out long lineNumber)

Parameters

offset int

A program-counter offset into Items.

lineNumber long

The line number in effect there, or 0 when no line number precedes it.

Returns

bool

false when no line number is in effect at offset.

Remarks

A line number is sticky - it labels every statement after it until the next one - which is why this searches backwards rather than requiring the faulting statement to carry a label of its own. A named label never sets it; only a label spelled as decimal digits does.

🎯 long, deliberately. MS-VBA reports Erl with ushort resolution and wraps around on anything that does not fit, so a program numbered past 65535 is told it faulted somewhere it did not. RD-VBA widens it instead, so every legal line number label is representable.

TryGetOffset(SyntaxNodeId, out int)

Looks up the offset a source StatementNode lowered to, by its stable SyntaxNodeId — the fault-statement identity a breakpoint or a runtime error anchors to.

public bool TryGetOffset(SyntaxNodeId nodeId, out int offset)

Parameters

nodeId SyntaxNodeId
offset int

Returns

bool

false when nodeId is not a statement of this body.