Struct ForLoopState
The hidden per-activation state a For loop's opener stashes for its own closer to read back
(MS-VBAL §5.4.2.3) — the end/step values are evaluated once, ahead of the loop, and
read again on every Next without re-evaluating their source expressions.
public readonly record struct ForLoopState : IEquatable<ForLoopState>
- Implements
- Inherited Members
Constructors
ForLoopState(Symbol, ExpressionNode, VBTypedValue, VBTypedValue)
The hidden per-activation state a For loop's opener stashes for its own closer to read back
(MS-VBAL §5.4.2.3) — the end/step values are evaluated once, ahead of the loop, and
read again on every Next without re-evaluating their source expressions.
public ForLoopState(Symbol Counter, ExpressionNode ControlExpression, VBTypedValue End, VBTypedValue Step)
Parameters
CounterSymbolThe
bound-variable-expressionsymbol the loop counts through.ControlExpressionExpressionNodeThe counter's own expression node, reused as the location-bearing node for every arithmetic/ let-assignment step a
Nextperforms — never a synthetic stand-in.EndVBTypedValueThe loop's
end-value, evaluated once and never re-evaluated.StepVBTypedValueThe loop's
step-increment, evaluated once and never re-evaluated.
Properties
ControlExpression
The counter's own expression node, reused as the location-bearing node for every arithmetic/
let-assignment step a Next performs — never a synthetic stand-in.
public ExpressionNode ControlExpression { get; init; }
Property Value
Counter
The bound-variable-expression symbol the loop counts through.
public Symbol Counter { get; init; }
Property Value
CounterAssignment
The let-assignment of the counter on every Next, located at ControlExpression: made once for the loop rather than once for
each iteration.
public VBBinaryOperatorExpressionNode CounterAssignment { get; }
Property Value
CounterTarget
The counter, as the target its value is let-assigned to on every Next.
public VBSymbolDescValue CounterTarget { get; }
Property Value
CountsDown
Whether Step is negative: the loop counts down to End, and completes when the counter falls below it, rather than up to it. Known once, as the step is.
public bool CountsDown { get; init; }
Property Value
End
The loop's end-value, evaluated once and never re-evaluated.
public VBTypedValue End { get; init; }
Property Value
RuntimeState
What the runtime that runs the loop keeps of it from one Next to the next - what it would otherwise work out again on every iteration, of
values that do not change while the loop runs (the end, the step, the counter's binding). Opaque here: the runtime that sets it is the one that
reads it, and null means it keeps nothing.
public object? RuntimeState { get; init; }
Property Value
Step
The loop's step-increment, evaluated once and never re-evaluated.
public VBTypedValue Step { get; init; }