Table of Contents

Class ConstantExpressionStaticSemantics

Namespace
RDCore.SDK.Semantics.Static
Assembly
RDCore.SDK.dll

Whether the value of a constant is a constant expression (MS-VBAL §5.6.16.1): one that is evaluated once, statically, as MS-VBA evaluates it (recorded in Excel).

public static class ConstantExpressionStaticSemantics
Inheritance
ConstantExpressionStaticSemantics
Inherited Members

Remarks

A constant expression is made of literals, constants - of the module, of the procedure, of a library - members of enumerations, parentheses, and the operators; anything else is ConstantExpressionRequired.

👉 MS-VBAL §5.6.16.1 also admits a call of Int, Fix, Abs, Sgn, Len, LenB and the conversion functions. MS-VBA refuses them in a constant (Const k = Len("abc"), Abs(-1), CLng(1.5); of a module, oracle\s44 C01, C02, and LenB of a procedure, C05), and RD-VBA refuses them as MS-VBA does. A Const of a procedure valued Len of a constant compiles in MS-VBA, and crashes the host when it runs (C03, C04): RD-VBA compiles it, to the length MS-VBAL gives it, and warns (RDC11021, the author's ruling). MS-VBA admits Len and LenB of a constant expression in the bounds of an array, of a procedure and of a module (Dim d(Len(K)), oracle\s46 F02, oracle\s44 C06), and so does RD-VBA.

The Nothing literal is a constant expression, of a type no constant can have: InvalidDataTypeForConstant.

Methods

ValueError(ISymbolResolver, Uri, ExpressionNode)

The compile error of the value of a constant: the first part of it that is not a constant expression, or a value of no type a constant can have.

public static VBCompileErrorInfo? ValueError(ISymbolResolver resolver, Uri scope, ExpressionNode value)

Parameters

resolver ISymbolResolver

Resolves the names the value is written with.

scope Uri

Where the constant is declared: its module, or its procedure.

value ExpressionNode

The value the constant is declared with.

Returns

VBCompileErrorInfo

The error, or null when the value is a constant expression.

Remarks

A value that has one is not evaluated: what it would read - a variable, a function's result - has no value until the code runs.

ValueErrorOf(ISymbolResolver, Symbol, ExpressionNode)

The compile error of the value of constant, as ValueError(ISymbolResolver, Uri, ExpressionNode) - and of a constant of a procedure, a call of the standard library's Len of a constant expression is one, which MS-VBA compiles there and refuses in a module (recorded in Excel: oracle\s44 C01-C04).

public static VBCompileErrorInfo? ValueErrorOf(ISymbolResolver resolver, Symbol constant, ExpressionNode value)

Parameters

resolver ISymbolResolver

Resolves the names the value is written with.

constant Symbol

The constant: of a module, or of a procedure.

value ExpressionNode

The value it is declared with.

Returns

VBCompileErrorInfo

The error, or null when the value is a constant expression.