Table of Contents

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).

  1. Evaluate the condition. It is a Boolean condition, evaluated by the same ConditionEvaluator an If uses, and forced to Boolean (MS-VBAL §5.5.1.2.2 Let-coercion to and from Boolean).
  2. When the condition is True, fall through into the body. The body's synthesized Jump returns to the header.
  3. When the condition is False, go to the header's Else offset, right past the loop.

The loop needs no per-activation state.

Implementation


⏮️ RD-VBAL §5.4.2.1 Call Statement | ⏭️ RD-VBAL §5.4.2.3 For Statement