Table of Contents

5.4.2.9 Single-line If Statement

Note

This section describes the implementation of MS-VBAL §5.4.2.9 Single-line If Statement.

Syntax

AST node Instruction kind(s) Notes
InlineIfStatementNode ConditionalBranch ThenBody and ElseBody may each hold several colon-separated statements instead of a full block.
GoToStatementNode (synthesized by the parser) Jump A bare line-number target in either branch, e.g. If x Then 100.

A bare line-number target in either branch is not modelled as its own AST shape. MS-VBAL specifies such a target as equivalent to a GoTo statement targeting that line, so the parser synthesizes a GoToStatementNode as that branch's statement, typically its only one (RD-VBAL §5.4.2.12 GoTo Statement).

See RD-VBAL §3.4.1 Block Statements and RD-VBAL §3.5.2 Instruction.

Runtime Semantics

The executor dispatches ConditionalBranch for a single-line If, with a Boolean condition, the same way as for a block If header (RD-VBAL §5.4.2.8 If Statement).

  1. Evaluate the condition, forced to Boolean by ConditionEvaluator (MS-VBAL §5.5.1.2.2 Let-coercion to and from Boolean).
  2. When the condition is True, fall through into ThenBody.
  3. When the condition is False, go to the header's Else offset.

Implementation

  • ProcedureExecutor dispatches ConditionalBranch.
  • RDCore.Runtime.Execution.ConditionEvaluator forces the condition to Boolean (RD-VBAL §3.5.4 Execution).

⏮️ RD-VBAL §5.4.2.8 If Statement | ⏭️ RD-VBAL §5.4.2.10 Select Case Statement