5.4.2.2 While Statement
Note
This section describes the implementation of MS-VBAL §5.4.2.2 While Statement.
Syntax
| AST node | Instruction kind(s) | Notes |
|---|---|---|
| WhileWendStatementNode | ConditionalBranch |
The pre-test loop header. Its Else is right past the whole loop. |
| — (synthesized) | Jump |
The back-edge at the end of the body; Node is null. Its Target is the loop's header. |
Wend has no AST node of its own (RD-VBAL §3.4.1 Block Statements;
RD-VBAL §3.5.2 Instruction).
Static Semantics
MS-VBAL gives While…Wend no exit statement of its own. A While…Wend loop satisfies neither Exit For nor
Exit Do.
An Exit Do written inside a While…Wend is not consumed by it: it resolves against the Do loop that encloses
the While…Wend (RD-VBAL §5.4.2.7 Exit Do Statement).
Runtime Semantics
A While…Wend loop is a pre-test loop, like Do While and Do Until
(RD-VBAL §5.4.2.6 Do Statement). Its header is a ConditionalBranch,
dispatched in the same way as an If header (RD-VBAL §5.4.2.8 If Statement).
- Evaluate the condition. It is a Boolean condition, evaluated by the same
ConditionEvaluatoranIfuses, and forced toBoolean(MS-VBAL §5.5.1.2.2 Let-coercion to and from Boolean). - When the condition is
True, fall through into the body. The body's synthesizedJumpreturns to the header. - When the condition is
False, go to the header'sElseoffset, right past the loop.
The loop needs no per-activation state.
Implementation
ProcedureExecutordispatches the header'sConditionalBranchand the back-edgeJump.RDCore.Runtime.Execution.ConditionEvaluatorforces the condition toBoolean(RD-VBAL §3.5.4 Execution).- Lowering pushes no
Exit Docontext for aWhile…Wendloop (RD-VBAL §3.5.3 Lowering Block Statements).
⏮️ RD-VBAL §5.4.2.1 Call Statement | ⏭️ RD-VBAL §5.4.2.3 For Statement