5.4.2.1 Call Statement
Note
This section describes the implementation of MS-VBAL §5.4.2.1 Call Statement.
Syntax
| AST node | Instruction kind(s) | Notes |
|---|---|---|
| CallStatementNode | Simple |
A Call statement or a bare call. |
See RD-VBAL §3.4.2 Simple Statements and RD-VBAL §3.5.2 Instruction.
Static Semantics
What a call statement calls is a procedure: a Sub, a Function or a Property, of the workspace, of a library or a Declare. A variable or a
constant is none, and a call statement written on one is a compile error, with Call or without, as it is in MS-VBA (recorded in Excel):
| What the statement names | Example | Outcome |
|---|---|---|
| A variable or a constant of the procedure, a parameter included | Dim x As Long … x (1), x, Call x |
VBC09364 Expected Sub, Function, or Property |
| A variable or a constant of a module, bare or qualified | Count (1), Globals.Count (1), Call Count |
VBC09370 Expected procedure, not variable |
A variable of an object, without Call |
Dim c As New Collection … c (1) |
Valid: the statement calls the object's default member. |
A Variant is no object: a call statement on one is the error, whatever it holds. A variable hides a procedure of the same name in the procedure that
declares it, so P (1) in a procedure that declares Dim p As Long is VBC09364, though the module has a Sub P.
Runtime Semantics
A Call statement or a bare-call statement whose callee is a bare name (Foo, Foo(...), Call Foo(...)) invokes
it through a callable binding
(ICallableBindingFactory):
| Callee | Invoked through |
|---|---|
| A procedure of the workspace | IProcedureInvoker |
| A member with an external target (a standard-library member) | IExternalDispatcher (RD-VBAL §6.0 Standard Library) |
The unparenthesized argument form of a bare-call statement (Foo 1, 2, p.Grow 2) and a callee reached through a member access (obj.Foo, Call obj.Foo(1)) are invoked the
same way: a member of an object, of a module (Strings.LenB) or of a project (VBA.LenB) is a callee like any other
(RD-VBAL §5.6.12).
A bare reference to a Sub, Function or Property Get invokes a procedure the same way
(RD-VBAL §5.3.1.11 Procedure Invocation Argument Processing,
RD-VBAL §5.6.10 Simple Name Expressions).
A callee's run-time error propagates like any other run-time error. The callee's error result
(RuntimeSemanticsEvaluationResult) is
converted back into an Error outcome by the caller's ExecuteCall.
Implementation
- A
Simpleinstruction is dispatched by its statement type throughRDCore.Runtime.Semantics.Statements.IStatementRuntimeSemanticsProvider(RD-VBAL §3.5.4 Execution);ExecuteCallhandles aCallStatementNode. RDCore.Runtime.Execution.RuntimeProcedureInvokeris theIProcedureInvokerimplementation.RDCore.Runtime.Execution.RuntimeCallableBindingFactoryis theICallableBindingFactoryimplementation. A member that carries SymbolProperties.ExternalTargetis bound to the external dispatcher; any other member is bound to the procedure invoker.
⏮️ RD-VBAL §5.4.2 Control Statements | ⏭️ RD-VBAL §5.4.2.2 While Statement