Class ObjectValueStaticSemantics
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
Nothingliteral: InvalidUseOfObject. An object variable that holdsNothingcompiles, and raises error 91 when it runs. - An object of a class whose default member takes an argument, as a
Collection'sItemdoes: ArgumentNotOptional. - An object of a class whose default member returns an object, where a value of a declared type is expected:
TypeMismatch (TypedValue).
Abs,IntandFixtake one, and read it when they run (AnyValue);LenandLenBtake aStringor 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
contextStaticEvaluationContextThe compile-time context the arguments are evaluated against.
parametersImmutableArray<VBParameterSymbol>The parameters of the procedure called; an implicit
Meis not one a call gives an argument to.argumentsIEnumerable<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
contextStaticEvaluationContextThe compile-time context the target is evaluated against.
targetExpressionNodeThe expression an assignment is written on.
Returns
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
parameterVBParameterSymbolA parameter of a procedure.
Returns
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
typeVBTypeA declared type.
Returns
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
factsIExpressionFactSinkWhere the fact of
expressionis; nothing is told without one.expressionExpressionNodeThe 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
contextStaticEvaluationContextThe compile-time context the callee is evaluated against.
calleeExpressionNodeThe expression the call is written on.
Returns
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
contextStaticEvaluationContextThe compile-time context the call is evaluated against.
calleeExpressionNodeWhat is called.
argumentsImmutableArray<ExpressionNode>The arguments of the call.
argumentExpressionNodeThe argument whose evaluation is
error.errorVBCompileErrorInfoThe argument's error.
Returns
- VBCompileErrorInfo
The error to report instead, or null when
erroris 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
contextStaticEvaluationContextThe compile-time context the callee is evaluated against.
calleeExpressionNodeThe expression the call is written on.
Returns
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
contextStaticEvaluationContextThe compile-time context: the class of an object is read from it as the composition has it now (see CurrentTypes).
expressionExpressionNodeThe expression whose value is expected.
declaredTypeVBTypeThe declared type of
expression.destinationValueDestinationWhat the place that expects a value expects of an object.
Returns
- StaticSemanticsEvaluationResult
declaredTypefor 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.