Table of Contents

5.4 Procedure Bodies and Statements

Note

This section describes the implementation of MS-VBAL §5.4 Procedure Bodies and Statements.

At run time, statements have side effects on program, global, or host environment state (RD-VBAL §5.0 Semantics).

Procedure Bodies

A procedure body executes as an InstructionList: the flat, offset-addressable list of instructions lowered from the body's statement tree.

Stage What happens RD-VBAL
Parsing Each statement of the body is a StatementNode. A block statement's nested statements are held in a StatementBlock. RD-VBAL §3.4 Statements
Lowering InstructionListLowering flattens the statement tree into an InstructionList: one instruction per executable statement, plus the synthesized instructions a block statement needs but has no source node for. RD-VBAL §3.5 Instructions
Execution ProcedureExecutor drives the activation's program counter through the InstructionList: fetch the instruction, decode it by InstructionKind, act on the outcome, repeat. RD-VBAL §3.5.4 Execution
Invocation Invoking a procedure pushes a new activation and runs the callee's lowered body through the same executor. RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing

A statement tree cannot express an arbitrary jump, and GoTo, GoSub, On…GoTo, On…GoSub and Resume can jump to any statement in the procedure. Lowering therefore flattens the statement tree, but never the expression trees each statement holds.

Statement Pages

Each statement page of this section describes one MS-VBAL statement under the headings Syntax (the AST node and the instruction kind it lowers to), Static Semantics, Runtime Semantics and Implementation.


In this section

§ Title MS-VBAL
5.4.1 Statement Blocks — reserved §5.4.1
5.4.2 Control Statements §5.4.2
5.4.3 Data Manipulation Statements §5.4.3
5.4.4 Error Handling Statements §5.4.4
5.4.5 File Statements §5.4.5

⏮️ RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing | ⏭️ RD-VBAL §5.4.1 Statement Blocks