5.4.2.15 Return Statement
Note
This section describes the implementation of MS-VBAL §5.4.2.15 Return Statement.
Syntax
| AST node | Instruction kind | Notes |
|---|---|---|
| ReturnStatementNode | Return |
No resolved target. |
Return lowers to the InstructionKind
Return (RD-VBAL §3.5.2 Instruction).
Runtime Semantics
Return reads the activation's GoSub Resumption List, the per-activation LIFO stack of return offsets that
GoSub and a successful On…GoSub branch push onto
(RD-VBAL §5.4.2.14 GoSub Statement).
Returnpops the GoSub Resumption List.- Execution branches to the popped offset.
| Condition | Run-time error |
|---|---|
| The GoSub Resumption List is empty. | 3 — Return without GoSub |
Nested GoSubs unwind in LIFO order: the innermost Return is taken first.
Return's runtime semantics resolve no target label at execution time: the offset it branches to is the one
the matching GoSub pushed.
The GoSub Resumption List is a plain stack because Return depends only on the order of its entries, not on which
GoSub pushed each one.
Implementation
RDCore.Runtime.Execution.ProcedureExecutordispatchesReturninstructions.Returnpops the list throughCallStackFrame.TryPopGoSubReturn(RD-VBAL §3.5.4 Execution).
⏮️ RD-VBAL §5.4.2.14 GoSub Statement | ⏭️ RD-VBAL §5.4.2.16 On...GoSub Statement