ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::expressions::CompilerPlugin::CIAutoCast Struct Reference

Description:

Info struct for compiling automatic type casts. Such automatic cast is tried to be inserted into the expression program by the compiler if:

  • An unary operator for a type cannot be found.
  • A binary operator for a combination of types cannot be found.
  • Two different types for T and F were given with conditional operator Q ? T : F.

For which the scenarios a cast is needed can be determined with field Operator and also by checking the number of given arguments.

Built-in compiler plug-in AutoCast ignores unary operations. For binary operations, it just always tries to match both types to the 'major' one. It does this, as it is more probable, that for two same types an operator is available.

In contrast to this, a custom plug-in may choose to cast both values to a joint one or to any combination of types that it provides an operator for!

Compile-time optimization is supported with auto-casts the same as with other compilation mechanics. Information about whether the arguments are constants is separately given for the first and second argument with fields IsConst and RhsIsConst.

Hence, if a plug-in leaves the parent field Callback and/or field CallbackRhs nulled, but stores a constant cast result value in TypeOrValue and/or TypeOrValueRhs, then this is detected by the compiler and instead of inserting a cast function call, the original constant value is replaced with the returned constant value(s).

If a cast function is compiled (returned with this struct), and the resulting program should be duly "decompilable", then along with the callback information, a compilable expression function name has to be returned in field ReverseCastFunctionName, respectively ReverseCastFunctionNameRhs. For further information on this topic see 11.5.6 Normalized, Optimized Expression Strings

Definition at line 372 of file compilerplugin.inl.

Inheritance diagram for alib::expressions::CompilerPlugin::CIAutoCast:
alib::expressions::CompilerPlugin::CompilationInfo

Public Field Index:

CallbackDecl CallbackRhs
const ncharDbgCallbackNameRhs
bool IsConst
StringOperator
String ReverseCastFunctionName
String ReverseCastFunctionNameRhs
bool RhsIsConst
 Input: denotes if rhs argument is constant value.
Box TypeOrValueRhs
Public Field Index: inherited from alib::expressions::CompilerPlugin::CompilationInfo
ArgIterator ArgsBegin
ArgIterator ArgsEnd
CallbackDecl Callback = nullptr
 Output: The native C++ callback function to be set by one of the plug-ins.
MonoAllocatorCompileTimeAllocator
ScopeCompileTimeScope
const ncharDbgCallbackName =nullptr
Box TypeOrValue = nullptr

Public Method Index:

 CIAutoCast (Scope &scope, MonoAllocator &compileTimeAllocator, String &op, bool isConst, bool rhsIsConst)
Public Method Index: inherited from alib::expressions::CompilerPlugin::CompilationInfo
 CompilationInfo (Scope &scope, MonoAllocator &allocator)

Field Details:

◆ CallbackRhs

CallbackDecl alib::expressions::CompilerPlugin::CIAutoCast::CallbackRhs

Output: Native C++ callback function to cast the first type with.

Note
The optional callback function for casting the left-hand side type is returned with inherited field Callback.

Definition at line 391 of file compilerplugin.inl.

◆ DbgCallbackNameRhs

const nchar* alib::expressions::CompilerPlugin::CIAutoCast::DbgCallbackNameRhs

Output: The C++ name of the callback function. This field is available only in debug compilations of the library. Hence, setting it must be performed with preprocessor conditionals.

Definition at line 416 of file compilerplugin.inl.

◆ IsConst

bool alib::expressions::CompilerPlugin::CIAutoCast::IsConst

Input: denotes if the unary argument, respectively the lhs argument of a binary operator, is a constant value.

Definition at line 382 of file compilerplugin.inl.

◆ Operator

String& alib::expressions::CompilerPlugin::CIAutoCast::Operator

The operator that the cast is required for. If this is '?:' then the request is made for conditional operator Q ? T : F. In this case, the requirement is to cast both given arguments to the same type - otherwise, the conditional operator does not compile!

Definition at line 378 of file compilerplugin.inl.

◆ ReverseCastFunctionName

String alib::expressions::CompilerPlugin::CIAutoCast::ReverseCastFunctionName

This is the name of the left-hand side cast function, respectively that of the unary argument's cast function, that is used when an expression with auto-cast functions is decompiled to generate compilable, optimized expression strings.

Definition at line 405 of file compilerplugin.inl.

◆ ReverseCastFunctionNameRhs

String alib::expressions::CompilerPlugin::CIAutoCast::ReverseCastFunctionNameRhs

This is the name of the right-hand side cast function that is inserted when an expression with an auto-cast functions is decompiled to generate compilable, optimized expression strings.

Definition at line 410 of file compilerplugin.inl.

◆ RhsIsConst

bool alib::expressions::CompilerPlugin::CIAutoCast::RhsIsConst

Input: denotes if rhs argument is constant value.

Definition at line 385 of file compilerplugin.inl.

◆ TypeOrValueRhs

Box alib::expressions::CompilerPlugin::CIAutoCast::TypeOrValueRhs

Output: Specifies the return type of CallbackRhs, respectively, as the name indicates, the result value in case of constant a result.
In case of constant compile-time values, it might be necessary to allocate compile-time memory for the values. For this, field CompileTimeScope is to be used.

Note
The optional return type and value casting the left-hand side argument is returned with inherited field TypeOrValue.

Definition at line 400 of file compilerplugin.inl.

Constructor(s) / Destructor Details:

◆ CIAutoCast()

alib::expressions::CompilerPlugin::CIAutoCast::CIAutoCast ( Scope & scope,
MonoAllocator & compileTimeAllocator,
String & op,
bool isConst,
bool rhsIsConst )
inline

Constructor.

Parameters
scopePassed to parent.
compileTimeAllocatorPassed to parent.
opStored in Operator.
isConstStored in IsConst.
rhsIsConstStored in RhsIsConst.

Definition at line 425 of file compilerplugin.inl.


The documentation for this struct was generated from the following file: