Table of Contents

Class ObjectValueStaticSemantics

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

What an object is where a value is expected, at compile time: the static half of MS-VBAL §5.5.1.2.13's simple data value (MS-VBAL §5.5.1.1).

public static class ObjectValueStaticSemantics
Inheritance
ObjectValueStaticSemantics
Inherited Members

Remarks

A value is expected of the value of a Let assignment to a variable of a value type, of an operand of any operator but Is, of an argument of a parameter declared with a value type - ByVal, or ByRef and given an expression - and of an argument of the standard library's parameters that read a value (ValueDestination). There, an object stands for what its default member returns, and what cannot have a value is a compile error, as MS-VBA has it (recorded in Excel):

  • The Nothing literal: InvalidUseOfObject. An object variable that holds Nothing compiles, and raises error 91 when it runs.
  • An object of a class whose default member takes an argument, as a Collection's Item does: ArgumentNotOptional.
  • An object of a class whose default member returns an object, where a value of a declared type is expected: TypeMismatch (TypedValue). Abs, Int and Fix take one, and read it when they run (AnyValue); Len and LenB take a String or a variable, which it is not (StringOrVariable).

👉 An object of a class that has no default member, where a value of a declared type is expected, is statically invalid by MS-VBAL §5.5.1.1. MS-VBA compiles it, and raises error 438 when it runs (91 when the object is Nothing): RD-VBA does the same (RD-VBAL §5.5.1.1), and states it (MarkNoDefaultMember(IExpressionFactSink?, ExpressionNode)).

Methods

ArgumentsError(StaticEvaluationContext, ImmutableArray<VBParameterSymbol>, IEnumerable<ExpressionNode>)

The first compile error of the arguments of a call, each given to the parameter it is the argument of (MS-VBAL §5.3.1.11): an object given to a parameter that expects a value of it must have one.

public static VBCompileErrorInfo? ArgumentsError(StaticEvaluationContext context, ImmutableArray<VBParameterSymbol> parameters, IEnumerable<ExpressionNode> arguments)

Parameters

context StaticEvaluationContext

The compile-time context the arguments are evaluated against.

parameters ImmutableArray<VBParameterSymbol>

The parameters of the procedure called; an implicit Me is not one a call gives an argument to.

arguments IEnumerable<ExpressionNode>

The arguments of the call, positional and named, as they are written.

Returns

VBCompileErrorInfo

The first error, or null when there is none.

Remarks

An argument that matches no parameter is not this check's to report: the call's argument list is checked when it runs. A ParamArray takes what it collects as it is.

DesignerControlOf(StaticEvaluationContext, ExpressionNode)

The control of a form that target names - by its bare name in the form's code, or as a member of the form (Me.TextBox1, UserForm1.TextBox1); null when it names something else (DesignerControl).

public static VBTypeMemberSymbol? DesignerControlOf(StaticEvaluationContext context, ExpressionNode target)

Parameters

context StaticEvaluationContext

The compile-time context the target is evaluated against.

target ExpressionNode

The expression an assignment is written on.

Returns

VBTypeMemberSymbol

DestinationOf(VBParameterSymbol)

What parameter expects of an object given to it; null when it takes an object as it is.

public static ValueDestination? DestinationOf(VBParameterSymbol parameter)

Parameters

parameter VBParameterSymbol

A parameter of a procedure.

Returns

ValueDestination?

Remarks

A parameter declared with a value type expects a value of that type; a standard-library parameter declared Variant says what it expects, if it reads a value at all (ValueDestination); any other parameter - Variant, an object, an array, a user-defined type, a ParamArray - takes what it is given.

IsValueType(VBType)

Whether type is the declared type of a value - a number, a string, a Boolean, a Date, an enumeration - which a variable or a parameter declared with it expects of what it is given.

public static bool IsValueType(VBType type)

Parameters

type VBType

A declared type.

Returns

bool

MarkNoDefaultMember(IExpressionFactSink?, ExpressionNode)

Tells the fact of expression that it is an object of a class that has no default member, Let-coerced to a value (ValueOfObjectWithNoDefaultMember).

public static void MarkNoDefaultMember(IExpressionFactSink? facts, ExpressionNode expression)

Parameters

facts IExpressionFactSink

Where the fact of expression is; nothing is told without one.

expression ExpressionNode

The expression that is the object.

Remarks

👉 MS-VBAL §5.5.1.1 makes it statically invalid. MS-VBA compiles it, and raises error 438 (Object doesn't support this property or method) when it runs, or 91 when the object is Nothing; RD-VBA does as MS-VBA does, and the fact is for an analyzer to report.

MemberOfCallee(StaticEvaluationContext, ExpressionNode)

The procedure a call written on callee calls - by its bare name, qualified by the project or module that declares it, or as a member of an object of a class; null when it calls no procedure that is known (an array, a late-bound member).

public static VBTypeMemberSymbol? MemberOfCallee(StaticEvaluationContext context, ExpressionNode callee)

Parameters

context StaticEvaluationContext

The compile-time context the callee is evaluated against.

callee ExpressionNode

The expression the call is written on.

Returns

VBTypeMemberSymbol

NotAValueArgumentError(StaticEvaluationContext, ExpressionNode, ImmutableArray<ExpressionNode>, ExpressionNode, VBCompileErrorInfo?)

The error of an argument that is a project, a module or an enumeration (error, the argument's own), given to a parameter that takes a String or a variable - what Len and LenB measure: MS-VBA requires a variable there (Excel-verified, oracle\s29 C05, C06, C35, O19).

public static VBCompileErrorInfo? NotAValueArgumentError(StaticEvaluationContext context, ExpressionNode callee, ImmutableArray<ExpressionNode> arguments, ExpressionNode argument, VBCompileErrorInfo? error)

Parameters

context StaticEvaluationContext

The compile-time context the call is evaluated against.

callee ExpressionNode

What is called.

arguments ImmutableArray<ExpressionNode>

The arguments of the call.

argument ExpressionNode

The argument whose evaluation is error.

error VBCompileErrorInfo

The argument's error.

Returns

VBCompileErrorInfo

The error to report instead, or null when error is the one.

ParametersOfCallee(StaticEvaluationContext, ExpressionNode)

The parameters of the procedure a call written on callee calls - by its bare name, qualified by the project or module that declares it, or as a member of an object of a class; null when it calls no procedure that is known (an array, a late-bound member).

public static ImmutableArray<VBParameterSymbol>? ParametersOfCallee(StaticEvaluationContext context, ExpressionNode callee)

Parameters

context StaticEvaluationContext

The compile-time context the callee is evaluated against.

callee ExpressionNode

The expression the call is written on.

Returns

ImmutableArray<VBParameterSymbol>?

ValueOf(StaticEvaluationContext, ExpressionNode, VBType, ValueDestination)

The declared type of the value expression stands for where a value is expected, or the compile error that it has none.

public static StaticSemanticsEvaluationResult ValueOf(StaticEvaluationContext context, ExpressionNode expression, VBType declaredType, ValueDestination destination)

Parameters

context StaticEvaluationContext

The compile-time context: the class of an object is read from it as the composition has it now (see CurrentTypes).

expression ExpressionNode

The expression whose value is expected.

declaredType VBType

The declared type of expression.

destination ValueDestination

What the place that expects a value expects of an object.

Returns

StaticSemanticsEvaluationResult

declaredType for anything that is not an object of a class; the declared type of the class's default member for one that has a default member; VBObjectType - late-bound - for one that has none, and where a value of any type is expected, for one whose default member returns an object; or the error.