5.4.2.7 Exit Do Statement
Note
This section describes the implementation of MS-VBAL §5.4.2.7 Exit Do Statement.
Syntax
| AST node | Instruction kind(s) | Notes |
|---|---|---|
KeywordStatementNode (Token: "Exit Do") |
ExitLoop |
Target: the offset right past the closer of the innermost enclosing Do loop. |
See RD-VBAL §3.4.2 Simple Statements and RD-VBAL §3.5.2 Instruction.
Static Semantics
Exit Do needs an enclosing loop of one of the five Do…Loop forms
(RD-VBAL §5.4.2.6 Do Statement). It resolves against the innermost enclosing
loop of that kind.
A While…Wend loop does not satisfy Exit Do: MS-VBAL gives While…Wend no exit statement of its own
(RD-VBAL §5.4.2.2 While Statement). An Exit Do written inside a
While…Wend is not consumed by it; it resolves against the Do loop that encloses the While…Wend.
An Exit Do that has no enclosing Do loop, including one inside a While…Wend that no Do loop encloses, is
VBC09312 (ExitDoNotWithinDoLoop). The rule is
ExitStatementStaticSemantics's, which
StatementStaticSemanticsEvaluator and instruction-list
lowering both ask. Lowering emits no instruction for the statement that is an error.
Runtime Semantics
ExitLoopbranches to Instruction.Target, in the same way asJump(RD-VBAL §5.4.2.12 GoTo Statement).- No runtime search is needed: lowering has already resolved
Targetto the offset right past the innermost enclosing loop of the matching kind.
Implementation
- InstructionListLowering resolves the
ExitLooptarget (RD-VBAL §3.5.3 Lowering Block Statements). ProcedureExecutoruses the samecasearm forExitLoopandJump(RD-VBAL §5.4.2.5 Exit For Statement).
⏮️ RD-VBAL §5.4.2.6 Do Statement | ⏭️ RD-VBAL §5.4.2.8 If Statement