10.3. Boost package for the AST
The AST_BOOST module provides high-level utilities for working with the AST. It includes helpers for creating expressions, types, and declarations, quote-based AST construction, and common AST query and transformation patterns used by macro authors.
All functions and symbols are in “ast_boost” module, use require to get access to it.
require daslib/ast_boost
10.3.1. Type aliases
- ast_boost::AnnotationDeclarationPtr = smart_ptr<AnnotationDeclaration>
Type alias for smart_ptr<AnnotationDeclaration>, used when constructing or attaching annotation declarations to functions, blocks, or structures.
- ast_boost::bitfield DebugExpressionFlags
- Fields
refCount (0x1) - Bitfield controlling
debug_expressionoutput — currently has a singlerefCountflag that includes smart pointer reference counts in the dump.
10.3.2. Function annotations
- ast_boost::macro
The [macro] function annotation — marks a function to run only during macro module compilation, gating its body behind is_compiling_macros.
- ast_boost::tag_function
The [tag_function] function annotation — attaches named tags to a function so that [tag_function_macro]-based annotations can discover and process it.
10.3.3. Variant macros
- ast_boost::better_rtti_in_expr
Variant macro that enables improved RTTI type matching in is and as expressions. Varian macro better_rtti_in_expr
10.3.4. Structure macros
- ast_boost::function_macro
The [function_macro] structure annotation — registers an AstFunctionAnnotation subclass as a named function annotation available to the compiler.
- ast_boost::block_macro
The [block_macro] structure annotation — registers an AstBlockAnnotation subclass as a named block-level annotation available to the compiler.
- ast_boost::structure_macro
The [structure_macro] structure annotation — registers an AstStructureAnnotation subclass as a named annotation applicable to structures and classes.
- ast_boost::enumeration_macro
The [enumeration_macro] structure annotation — registers an AstEnumerationAnnotation subclass as a named annotation applicable to enumerations.
- ast_boost::contract
The [contract] structure annotation — registers an AstFunctionAnnotation subclass as a named function contract that validates arguments or return values.
- ast_boost::reader_macro
The [reader_macro] structure annotation — registers an AstReaderMacro subclass as a named reader macro invoked by the %name~...~~ syntax during parsing.
- ast_boost::comment_reader
The [comment_reader] structure annotation — registers an AstCommentReader subclass as a named comment reader invoked during parsing.
- ast_boost::call_macro
The [call_macro] structure annotation — registers an AstCallMacro subclass as a named call-expression macro available during compilation.
- ast_boost::typeinfo_macro
The [typeinfo_macro] structure annotation — registers an AstTypeInfoMacro subclass as a named macro that extends the typeinfo(name ...) built-in.
- ast_boost::variant_macro
The [variant_macro] structure annotation — registers an AstVariantMacro subclass as a named macro that can customize is, as, and ?as variant operations.
- ast_boost::for_loop_macro
The [for_loop_macro] structure annotation — registers an AstForLoopMacro subclass as a named macro that can transform for loop expressions.
- ast_boost::capture_macro
The [capture_macro] structure annotation — registers an AstCaptureMacro subclass as a named capture macro that can customize lambda capture behavior.
- ast_boost::type_macro
The [type_macro] structure annotation — registers an AstTypeMacro subclass as a named macro that can intercept and transform type expressions.
- ast_boost::simulate_macro
The [simulate_macro] structure annotation — registers an AstSimulateMacro subclass as a named macro invoked during the simulation (code generation) phase.
- ast_boost::tag_structure
The [tag_structure] structure annotation — attaches named boolean tags to a structure, allowing macro code to discover and process tagged structures.
- ast_boost::tag_function_macro
The [tag_function_macro] structure annotation — registers an AstFunctionAnnotation that is automatically applied to every function carrying a matching [tag_function(tag)] tag.
- ast_boost::infer_macro
The [infer_macro] structure annotation — registers an AstPassMacro subclass that is invoked during the type inference compilation pass.
- ast_boost::dirty_infer_macro
The [dirty_infer_macro] structure annotation — registers an AstPassMacro subclass that is invoked during the dirty infer compilation pass.
- ast_boost::optimization_macro
The [optimization_macro] structure annotation — registers an AstPassMacro subclass that is invoked during the optimization compilation pass.
- ast_boost::lint_macro
The [lint_macro] structure annotation — registers an AstPassMacro subclass that is invoked during the lint compilation pass.
- ast_boost::global_lint_macro
The [global_lint_macro] structure annotation — registers an AstPassMacro subclass that is invoked during the global lint compilation pass.
10.3.5. Classes
- ast_boost::MacroMacro : AstFunctionAnnotation
Implements the [macro] function annotation, which wraps the function body so it only executes during macro module compilation.
- MacroMacro.apply(func: FunctionPtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool()
Wraps the annotated function body in an is_compiling_macros guard and sets macroInit flag so it only runs during macro module compilation.
- Arguments
func : FunctionPtr
group : ModuleGroup
args : AnnotationArgumentList
errors : das_string
- ast_boost::TagFunctionAnnotation : AstFunctionAnnotation
Implements the [tag_function] function annotation, which attaches named boolean tags to functions so they can be discovered and processed by [tag_function_macro].
- TagFunctionAnnotation.apply(func: FunctionPtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool()
Validates that all [tag_function(...)] annotation arguments are tag names (boolean flags) and rejects any non-boolean arguments with an error.
- Arguments
func : FunctionPtr
group : ModuleGroup
args : AnnotationArgumentList
errors : das_string
- ast_boost::TagStructureAnnotation : AstStructureAnnotation
Implements the [tag_structure] structure annotation, which attaches named boolean tags to structures for later discovery by macro code.
- TagStructureAnnotation.apply(str: StructurePtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool()
Validates that all [tag_structure(...)] annotation arguments are tag names (boolean flags) and rejects any non-boolean arguments with an error.
- Arguments
str : StructurePtr
group : ModuleGroup
args : AnnotationArgumentList
errors : das_string
- ast_boost::SetupAnyAnnotation : AstStructureAnnotation
This is base class for any annotation or macro setup.
- Fields
annotation_function_call : string = “” - Function call name, which is used to setup any annotation.
name : string - Name of the annotation to setup.
- SetupAnyAnnotation.apply(st: StructurePtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool()
Generates a macro-init function that constructs an instance of the annotated class and registers it with the compiler under the specified name.
- Arguments
st : StructurePtr
group : ModuleGroup
args : AnnotationArgumentList
errors : das_string
- SetupAnyAnnotation.setup_call(st: StructurePtr; cll: smart_ptr<ExprCall>)
Populates the registration call arguments — by default adds the annotation name as a string constant; overridden in subclasses to add extra parameters.
- Arguments
st : StructurePtr
cll : smart_ptr< ExprCall>
- ast_boost::SetupFunctionAnnotation : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_function_annotation” - Base class for creating function annotations via the
[function_macro]structure annotation; registers anAstFunctionAnnotationwith the compiler.
- ast_boost::SetupBlockAnnotation : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_block_annotation” - Base class for creating block annotations via the
[block_macro]structure annotation; registers anAstBlockAnnotationwith the compiler.
- ast_boost::SetupStructureAnnotation : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_structure_annotation” - Base class for creating structure annotations via the
[structure_macro]structure annotation; registers anAstStructureAnnotationwith the compiler.
- ast_boost::SetupEnumerationAnnotation : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_enumeration_annotation” - Base class for creating enumeration annotations via the
[enumeration_macro]structure annotation; registers anAstEnumerationAnnotationwith the compiler.
- ast_boost::SetupContractAnnotation : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_contract_annotation” - Base class for creating function contract annotations via the
[contract]structure annotation; registers anAstFunctionAnnotationas a contract.
- ast_boost::SetupReaderMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_reader_macro” - Base class for creating reader macros via the
[reader_macro]structure annotation; registers anAstReaderMacrowith the compiler.
- ast_boost::SetupCommentReader : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_comment_reader” - Base class for creating comment readers via the
[comment_reader]structure annotation; registers anAstCommentReaderwith the compiler.
- ast_boost::SetupVariantMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_variant_macro” - Base class for creating variant macros via the
[variant_macro]structure annotation; registers anAstVariantMacrowith the compiler.
- ast_boost::SetupForLoopMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_for_loop_macro” - Base class for creating for-loop macros via the
[for_loop_macro]structure annotation; registers anAstForLoopMacrowith the compiler.
- ast_boost::SetupCaptureMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_capture_macro” - Base class for creating capture macros via the
[capture_macro]structure annotation; registers anAstCaptureMacrowith the compiler.
- ast_boost::SetupTypeMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_type_macro” - Base class for creating type macros via the
[type_macro]structure annotation; registers anAstTypeMacrowith the compiler.
- ast_boost::SetupSimulateMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_simulate_macro” - Base class for creating simulate macros via the
[simulate_macro]structure annotation; registers anAstSimulateMacrowith the compiler.
- ast_boost::SetupCallMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_call_macro” - Base class for creating call macros via the
[call_macro]structure annotation; registers anAstCallMacrowith the compiler.
- ast_boost::SetupTypeInfoMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_typeinfo_macro” - Base class for creating typeinfo macros via the
[typeinfo_macro]structure annotation; registers anAstTypeInfoMacrowith the compiler.
- ast_boost::SetupInferMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_infer_macro” - Base class for creating infer pass macros via the
[infer_macro]structure annotation; registers anAstPassMacrothat runs during the type inference pass.
- ast_boost::SetupDirtyInferMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_dirty_infer_macro” - Base class for creating dirty-infer pass macros via the
[dirty_infer_macro]structure annotation; registers anAstPassMacrothat runs during the dirty infer pass.
- ast_boost::SetupLintMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_lint_macro” - Base class for creating lint pass macros via the
[lint_macro]structure annotation; registers anAstPassMacrothat runs during the lint pass.
- ast_boost::SetupGlobalLintMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_global_lint_macro” - Base class for creating global lint pass macros via the
[global_lint_macro]structure annotation; registers anAstPassMacrothat runs during the global lint pass.
- ast_boost::SetupOptimizationMacro : SetupAnyAnnotation
- Fields
annotation_function_call : string = “add_new_optimization_macro” - Base class for creating optimization pass macros via the
[optimization_macro]structure annotation; registers anAstPassMacrothat runs during the optimization pass.
- ast_boost::TagFunctionMacro : SetupAnyAnnotation
[tag_function_macro] implementation.
- Fields
annotation_function_call : string = “setup_tag_annotation” - Name of the function call, which setups up the annotation.
tag : string - Name of the tag.
- TagFunctionMacro.apply(st: StructurePtr; group: ModuleGroup; args: AnnotationArgumentList; errors: das_string) : bool()
Extends SetupAnyAnnotation apply to extract the required tag argument and register a setup_tag_annotation call that links the annotation to tagged functions.
- Arguments
st : StructurePtr
group : ModuleGroup
args : AnnotationArgumentList
errors : das_string
- TagFunctionMacro.setup_call(st: StructurePtr; cll: smart_ptr<ExprCall>)
Overrides the default setup_call to pass both the annotation name and the tag string as arguments to setup_tag_annotation.
- Arguments
st : StructurePtr
cll : smart_ptr< ExprCall>
- ast_boost::BetterRttiVisitor : AstVariantMacro
An AstVariantMacro that replaces is, as, and ?as variant operations on Expression subclasses with runtime __rtti string checks and casts.
- BetterRttiVisitor.visitExprIsVariant(prog: ProgramPtr; mod: Module?; expr: smart_ptr<ExprIsVariant>) : ExpressionPtr()
Visitor override that replaces expr is Type on Expression subclasses with an __rtti string comparison, returning true if the runtime type matches.
- Arguments
prog : ProgramPtr
mod : Module?
expr : smart_ptr< ExprIsVariant>
- BetterRttiVisitor.visitExprAsVariant(prog: ProgramPtr; mod: Module?; expr: smart_ptr<ExprAsVariant>) : ExpressionPtr()
Visitor override that replaces expr as Type on Expression subclasses with an RTTI-checked cast via __rtti, panicking on mismatch.
- Arguments
prog : ProgramPtr
mod : Module?
expr : smart_ptr< ExprAsVariant>
- BetterRttiVisitor.visitExprSafeAsVariant(prog: ProgramPtr; mod: Module?; expr: smart_ptr<ExprSafeAsVariant>) : ExpressionPtr()
Visitor override that replaces expr ?as Type on Expression subclasses with an RTTI-checked cast via __rtti, returning null on mismatch instead of panicking.
- Arguments
prog : ProgramPtr
mod : Module?
expr : smart_ptr< ExprSafeAsVariant>
10.3.6. Containers
emplace_new (var vec: dasvector`smart_ptr`TypeDecl; var ptr: smart_ptr<TypeDecl>)
emplace_new (var vec: dasvector`smart_ptr`Expression; var ptr: smart_ptr<Expression>)
emplace_new (var vec: MakeStruct; var ptr: smart_ptr<MakeFieldDecl>)
emplace_new (var vec: dasvector`smart_ptr`Variable; var ptr: smart_ptr<Variable>)
10.3.6.1. emplace_new
- ast_boost::emplace_new(vec: dasvector`smart_ptr`TypeDecl; ptr: smart_ptr<TypeDecl>)
Moves a newly created smart_ptr (Expression, TypeDecl, Variable, or MakeFieldDecl) into a vector container with correct reference counting.
- Arguments
vec : vector<smart_ptr<TypeDecl>>
ptr : smart_ptr< TypeDecl>
- ast_boost::emplace_new(vec: dasvector`smart_ptr`Expression; ptr: smart_ptr<Expression>)
- ast_boost::emplace_new(vec: MakeStruct; ptr: smart_ptr<MakeFieldDecl>)
- ast_boost::emplace_new(vec: dasvector`smart_ptr`Variable; ptr: smart_ptr<Variable>)
10.3.7. Textual descriptions of the objects
10.3.7.1. debug_expression
- ast_boost::debug_expression(expr: Expression?) : string()
Returns a hierarchical, Lisp-like textual dump of an ExpressionPtr tree showing RTTI types, field values, and nested sub-expressions for debugging.
- Arguments
expr : Expression?
- ast_boost::debug_expression(expr: ExpressionPtr; deFlags: DebugExpressionFlags = bitfield(0x0)) : string()
10.3.7.2. describe
- ast_boost::describe(vvar: VariablePtr) : string()
Returns a human-readable textual representation of an AST object (AnnotationArgumentList, AnnotationDeclaration, AnnotationList, Variable, or Expression).
- Arguments
vvar : VariablePtr
- ast_boost::describe(ann: AnnotationDeclaration) : string()
- ast_boost::describe(expr: Expression?) : string()
- ast_boost::describe(list: AnnotationArgumentList) : string()
- ast_boost::describe(list: AnnotationList) : string()
- ast_boost::describe_bitfield(bf: auto; merger: string = "") : auto()
Returns a textual representation of the set bits in a bitfield value, listing the names of all active flags joined by the specified merger string.
- Arguments
bf : auto
merger : string
- ast_boost::describe_function_short(func: smart_ptr<Function>|Function?) : auto()
Returns a compact signature string for a function in the form name (arg:Type; ...) : ReturnType.
- Arguments
func : option< FunctionPtr| Function?>
10.3.8. Queries
find_annotation (mod_name: string; ann_name: string) : Annotation const?
find_arg (args: AnnotationArgumentList; argn: string) : RttiValue
find_arg (argn: string; args: AnnotationArgumentList) : RttiValue
find_unique_function (mod: Module?; name: string; canfail: bool = false) : smart_ptr<Function>
find_unique_generic (mod: Module?; name: string; canfail: bool = false) : smart_ptr<Function>
get_for_source_index (expr: smart_ptr<ExprFor>; svar: VariablePtr) : int
get_for_source_index (expr: smart_ptr<ExprFor>; source: ExpressionPtr) : int
is_class_method (cinfo: StructurePtr; finfo: TypeDeclPtr) : bool
is_same_or_inherited (parent: Structure const?; child: Structure const?) : bool
- ast_boost::find_annotation(mod_name: string; ann_name: string) : Annotation const?()
Looks up an Annotation by name within the specified module during compilation and returns a pointer to it, or null if not found.
- Arguments
mod_name : string
ann_name : string
10.3.8.1. find_arg
- ast_boost::find_arg(args: AnnotationArgumentList; argn: string) : RttiValue()
Searches an AnnotationArgumentList for an argument by name and returns its RttiValue; returns nothing if the argument is not present.
- Arguments
args : AnnotationArgumentList
argn : string
- ast_boost::find_arg(argn: string; args: AnnotationArgumentList) : RttiValue()
- ast_boost::find_argument_index(typ: TypeDeclPtr; name: string) : int()
Searches the argNames of a TypeDeclPtr (tuple or variant) for the given name and returns its zero-based index, or -1 if not found.
- Arguments
typ : TypeDeclPtr
name : string
- ast_boost::find_unique_function(mod: Module?; name: string; canfail: bool = false) : smart_ptr<Function>()
Searches the compiling program for exactly one non-generic function with the given name; returns it or null if zero or multiple matches exist.
- Arguments
mod : Module?
name : string
canfail : bool
- ast_boost::find_unique_generic(mod: Module?; name: string; canfail: bool = false) : smart_ptr<Function>()
Searches the compiling program for exactly one generic function with the given name; returns it or null if zero or multiple matches exist.
- Arguments
mod : Module?
name : string
canfail : bool
- ast_boost::getVectorElementCount(bt: Type) : int()
Returns the number of scalar elements in a vector Type (e.g., 2 for float2/range, 3 for float3, 4 for float4), or 0 for non-vector types.
- Arguments
bt : Type
- ast_boost::getVectorElementSize(bt: Type) : int()
Returns the byte size of a single scalar element in a vector Type — 8 for range64/urange64, 4 for all other vector types.
- Arguments
bt : Type
- ast_boost::getVectorElementType(bt: Type) : Type()
Returns the scalar Type of each element in a vector type (e.g., tFloat for float2, tInt for int3 and range, tInt64 for range64).
- Arguments
bt : Type
- ast_boost::getVectorOffset(bt: Type; ident: string) : int()
Returns the zero-based element index for a named swizzle component (x/y/z/w or r/g/b/a) within a vector Type, or -1 if out of bounds.
- Arguments
bt : Type
ident : string
10.3.8.2. get_for_source_index
- ast_boost::get_for_source_index(expr: smart_ptr<ExprFor>; svar: VariablePtr) : int()
Returns the zero-based index of a given iterator variable or source expression within a for loop’s source list, or -1 if not found.
- Arguments
expr : smart_ptr< ExprFor>
svar : VariablePtr
- ast_boost::get_for_source_index(expr: smart_ptr<ExprFor>; source: ExpressionPtr) : int()
- ast_boost::get_workhorse_types() : Type[34]()
Returns a fixed array of all commonly used Type values — booleans, strings, pointers, numeric scalars, enumerations, bitfields, vectors, and ranges.
10.3.8.3. isCMRES
- ast_boost::isCMRES(fun: Function?) : bool()
Returns true if a Function returns its result via copy-or-move-result-on-stack (CMRES) semantics rather than through a register.
- Arguments
fun : Function?
- ast_boost::isCMRES(fun: FunctionPtr) : bool()
- ast_boost::isCMRESType(blockT: TypeDeclPtr) : bool()
Returns true if a TypeDeclPtr represents a reference type without an explicit ref flag, meaning it will use copy-or-move-on-stack semantics.
- Arguments
blockT : TypeDeclPtr
- ast_boost::isExprCallFunc(expr: ExpressionPtr) : bool()
Returns true if the expression’s RTTI tag is ExprCallFunc, ExprOp, ExprNew, or ExprCall — i.e., any function-call-like expression.
- Arguments
expr : ExpressionPtr
- ast_boost::isExpression(t: TypeDeclPtr; top: bool = true) : bool()
Returns true if the given TypeDeclPtr refers to an ast module handled type whose name starts with Expr, including pointer-to-expression types.
- Arguments
t : TypeDeclPtr
top : bool
- ast_boost::isMakeLocal(expr: ExpressionPtr) : bool()
Returns true if the expression is any ExprMakeLocal subclass: ExprMakeStruct, ExprMakeArray, ExprMakeTuple, or ExprMakeVariant.
- Arguments
expr : ExpressionPtr
- ast_boost::isVectorType(typ: Type) : bool()
Returns true if the given Type is a vector, range, or urange type (int2..``int4``, uint2..``uint4``, float2..``float4``, range, urange, range64, urange64).
- Arguments
typ : Type
- ast_boost::is_class_method(cinfo: StructurePtr; finfo: TypeDeclPtr) : bool()
Returns true if a TypeDeclPtr field represents a class method — a non-dim tFunction whose first argument is the class structure (or a parent of it).
- Arguments
cinfo : StructurePtr
finfo : TypeDeclPtr
- ast_boost::is_same_or_inherited(parent: Structure const?; child: Structure const?) : bool()
Returns true if child is the same Structure as parent or is transitively inherited from parent by walking the parent chain.
10.3.9. Annotations
add_annotation_argument (var arguments: AnnotationArgumentList; argName: string; val: string) : int
add_annotation_argument (var arguments: AnnotationArgumentList; argName: string; val: bool) : int
add_annotation_argument (var arguments: AnnotationArgumentList; argName: string; val: int) : int
add_annotation_argument (var arguments: AnnotationArgumentList; ann: AnnotationArgument) : int
add_annotation_argument (var arguments: AnnotationArgumentList; argName: string; val: float) : int
append_annotation (var blk: smart_ptr<ExprBlock>; mod_name: string; ann_name: string)
append_annotation (mod_name: string; ann_name: string) : smart_ptr<AnnotationDeclaration>
append_annotation (var func: FunctionPtr; mod_name: string; ann_name: string)
append_annotation (var st: smart_ptr<Structure>; mod_name: string; ann_name: string)
10.3.9.1. add_annotation_argument
- ast_boost::add_annotation_argument(arguments: AnnotationArgumentList; argName: string; val: string) : int()
Adds a typed annotation argument (bool, int, float, string, or AnnotationArgument) to an AnnotationArgumentList and returns the new argument index.
- Arguments
arguments : AnnotationArgumentList
argName : string
val : string
- ast_boost::add_annotation_argument(arguments: AnnotationArgumentList; argName: string; val: bool) : int()
- ast_boost::add_annotation_argument(arguments: AnnotationArgumentList; argName: string; val: int) : int()
- ast_boost::add_annotation_argument(arguments: AnnotationArgumentList; ann: AnnotationArgument) : int()
- ast_boost::add_annotation_argument(arguments: AnnotationArgumentList; argName: string; val: float) : int()
10.3.9.2. append_annotation
- ast_boost::append_annotation(blk: smart_ptr<ExprBlock>; mod_name: string; ann_name: string; args: array<tuple<argname:string;argvalue:variant<tBool:bool;tInt:int;tUInt:uint;tInt64:int64;tUInt64:uint64;tFloat:float;tDouble:double;tString:string;nothing:any>>>)
Creates an AnnotationDeclaration for the named annotation (with optional typed arguments) and attaches it to a Function, ExprBlock, or Structure.
- Arguments
- ast_boost::append_annotation(func: FunctionPtr; mod_name: string; ann_name: string; args: array<tuple<argname:string;argvalue:variant<tBool:bool;tInt:int;tUInt:uint;tInt64:int64;tUInt64:uint64;tFloat:float;tDouble:double;tString:string;nothing:any>>>)
- ast_boost::append_annotation(st: smart_ptr<Structure>; mod_name: string; ann_name: string; args: array<tuple<argname:string;argvalue:variant<tBool:bool;tInt:int;tUInt:uint;tInt64:int64;tUInt64:uint64;tFloat:float;tDouble:double;tString:string;nothing:any>>>)
- ast_boost::append_annotation(blk: smart_ptr<ExprBlock>; mod_name: string; ann_name: string)
- ast_boost::append_annotation(mod_name: string; ann_name: string) : smart_ptr<AnnotationDeclaration>()
- ast_boost::append_annotation(mod_name: string; ann_name: string; args: array<tuple<argname:string;argvalue:variant<tBool:bool;tInt:int;tUInt:uint;tInt64:int64;tUInt64:uint64;tFloat:float;tDouble:double;tString:string;nothing:any>>>) : smart_ptr<AnnotationDeclaration>()
- ast_boost::append_annotation(func: FunctionPtr; mod_name: string; ann_name: string)
- ast_boost::append_annotation(st: smart_ptr<Structure>; mod_name: string; ann_name: string)
10.3.10. Expression generation
10.3.10.1. convert_to_expression
- ast_boost::convert_to_expression(value: auto ==const) : auto()
Converts a runtime value of any supported type to an equivalent AST ExpressionPtr that would produce that value when compiled, using typeinfo for reflection.
- Arguments
value : auto!
- ast_boost::convert_to_expression(value: auto ==const; at: LineInfo) : auto()
- ast_boost::convert_to_expression(value: auto& ==const; at: LineInfo) : auto()
- ast_boost::convert_to_expression(value: auto ==const) : auto()
- ast_boost::make_static_assert_false(text: string; at: LineInfo) : smart_ptr<ExprStaticAssert>()
Creates an ExprStaticAssert expression node that always fails at compile time with the given error message text.
- Arguments
text : string
at : LineInfo
- ast_boost::override_method(str: StructurePtr; name: string; funcName: string) : bool()
Replaces the initializer of a field named name in the given structure with an @@funcName function address cast, effectively overriding that class method.
- Arguments
str : StructurePtr
name : string
funcName : string
- ast_boost::panic_expr_as() : void?()
Helper function that panics with "invalid 'as' expression or null pointer dereference" and returns null — used as the failure branch in as variant casts.
10.3.11. Visitors
- ast_boost::visit_finally(blk: ExprBlock?; adapter: smart_ptr<VisitorAdapter>)
Invokes the given VisitorAdapter on the finally section of an ExprBlock, allowing macro visitors to inspect or transform finally-block code.
- Arguments
blk : ExprBlock?
adapter : smart_ptr< VisitorAdapter>
10.3.12. Type generation
- ast_boost::function_to_type(fn: FunctionPtr) : TypeDeclPtr()
Constructs a TypeDeclPtr of tFunction base type from a FunctionPtr, capturing its argument types and names plus the return type.
- Arguments
fn : FunctionPtr
10.3.13. Type casts
Annotation?`as`FunctionAnnotation (foo: Annotation?) : FunctionAnnotation?
Annotation?`as`StructureAnnotation (foo: Annotation?) : StructureAnnotation?
Annotation?`is`StructureAnnotation (foo: Annotation?) : bool
Function?`as`BuiltInFunction (foo: Function?) : BuiltInFunction?
Function?`as`ExternalFnBase (foo: Function?) : ExternalFnBase?
smart_ptr<Annotation>`as`FunctionAnnotation (foo: smart_ptr<Annotation>) : FunctionAnnotation?
smart_ptr<Annotation>`as`StructureAnnotation (foo: smart_ptr<Annotation>) : StructureAnnotation?
smart_ptr<Annotation>`is`FunctionAnnotation (foo: smart_ptr<Annotation>) : bool
smart_ptr<Annotation>`is`StructureAnnotation (foo: smart_ptr<Annotation>) : bool
walk_and_convert (data: uint8 const?; info: TypeDeclPtr; at: LineInfo) : ExpressionPtr
- ast_boost::Annotation?`as`FunctionAnnotation(foo: Annotation?) : FunctionAnnotation?()
Casts an Annotation? or smart_ptr<Annotation> to FunctionAnnotation? via reinterpret, verifying the annotation kind first (panics otherwise).
- Arguments
foo : Annotation?
- ast_boost::Annotation?`as`StructureAnnotation(foo: Annotation?) : StructureAnnotation?()
Casts an Annotation? or smart_ptr<Annotation> to StructureAnnotation? via reinterpret, verifying the annotation kind first (panics otherwise).
- Arguments
foo : Annotation?
- ast_boost::Annotation?`is`FunctionAnnotation(foo: Annotation?) : bool()
Returns true if the given Annotation? or smart_ptr<Annotation> is a FunctionAnnotation according to its isFunctionAnnotation property.
- Arguments
foo : Annotation?
- ast_boost::Annotation?`is`StructureAnnotation(foo: Annotation?) : bool()
Returns true if the given Annotation? or smart_ptr<Annotation> is a StructureAnnotation according to its isStructureAnnotation property.
- Arguments
foo : Annotation?
- ast_boost::Function?`as`BuiltInFunction(foo: Function?) : BuiltInFunction?()
Casts a Function? to BuiltInFunction? via reinterpret, verifying the target is a built-in function first (panics otherwise).
- Arguments
foo : Function?
- ast_boost::Function?`as`ExternalFnBase(foo: Function?) : ExternalFnBase?()
Casts a Function? to ExternalFnBase? via reinterpret, verifying it is a property-flagged built-in function first (panics otherwise).
- Arguments
foo : Function?
- ast_boost::Function?`is`BuiltInFunction(foo: Function?) : bool()
Returns true if the given Function? has the builtIn flag set, indicating it is a BuiltInFunction; returns false for any other type.
- Arguments
foo : Function?
- ast_boost::Function?`is`ExternalFnBase(foo: Function?) : bool()
Returns true if the given Function? is both builtIn and has the propertyFunction flag, indicating it is an ExternalFnBase; returns false otherwise.
- Arguments
foo : Function?
- ast_boost::auto`is`BuiltInFunction(anything: auto) : auto()
Returns true if the given Function? has the builtIn flag set, indicating it is a BuiltInFunction; returns false for any other type.
- Arguments
anything : auto
- ast_boost::auto`is`ExternalFnBase(anything: auto) : auto()
Returns true if the given Function? is both builtIn and has the propertyFunction flag, indicating it is an ExternalFnBase; returns false otherwise.
- Arguments
anything : auto
- ast_boost::auto`is`FunctionAnnotation(anything: auto) : auto()
Returns true if the given Annotation? or smart_ptr<Annotation> is a FunctionAnnotation according to its isFunctionAnnotation property.
- Arguments
anything : auto
- ast_boost::auto`is`StructureAnnotation(anything: auto) : auto()
Returns true if the given Annotation? or smart_ptr<Annotation> is a StructureAnnotation according to its isStructureAnnotation property.
- Arguments
anything : auto
- ast_boost::smart_ptr<Annotation>`as`FunctionAnnotation(foo: smart_ptr<Annotation>) : FunctionAnnotation?()
Casts an Annotation? or smart_ptr<Annotation> to FunctionAnnotation? via reinterpret, verifying the annotation kind first (panics otherwise).
- Arguments
foo : smart_ptr< Annotation>
- ast_boost::smart_ptr<Annotation>`as`StructureAnnotation(foo: smart_ptr<Annotation>) : StructureAnnotation?()
Casts an Annotation? or smart_ptr<Annotation> to StructureAnnotation? via reinterpret, verifying the annotation kind first (panics otherwise).
- Arguments
foo : smart_ptr< Annotation>
- ast_boost::smart_ptr<Annotation>`is`FunctionAnnotation(foo: smart_ptr<Annotation>) : bool()
Returns true if the given Annotation? or smart_ptr<Annotation> is a FunctionAnnotation according to its isFunctionAnnotation property.
- Arguments
foo : smart_ptr< Annotation>
- ast_boost::smart_ptr<Annotation>`is`StructureAnnotation(foo: smart_ptr<Annotation>) : bool()
Returns true if the given Annotation? or smart_ptr<Annotation> is a StructureAnnotation according to its isStructureAnnotation property.
- Arguments
foo : smart_ptr< Annotation>
- ast_boost::walk_and_convert(data: uint8 const?; info: TypeDeclPtr; at: LineInfo) : ExpressionPtr()
Recursively walks raw data bytes using a TypeDeclPtr schema and builds an equivalent AST expression tree that would reproduce that data when compiled.
- Arguments
data : uint8?
info : TypeDeclPtr
at : LineInfo
10.3.14. Setup
10.3.14.1. setup_call_list
- ast_boost::setup_call_list(name: string; at: LineInfo; isInit: bool = false; isPrivate: bool = true; isLateInit: bool = false) : ExprBlock?()
Creates or locates a compilation-phase setup function (__setup_macros) and returns its body ExprBlock so callers can append registration calls to it.
- Arguments
name : string
at : LineInfo
isInit : bool
isPrivate : bool
isLateInit : bool
- ast_boost::setup_call_list(name: string; at: LineInfo; subblock: block<(var fn:FunctionPtr):void>) : ExprBlock?()
- ast_boost::setup_macro(name: string; at: LineInfo) : ExprBlock?()
Creates or locates a macro initialization function (__setup_macros) guarded by is_compiling_macros and returns its body block for appending macro registration code.
- Arguments
name : string
at : LineInfo
- ast_boost::setup_tag_annotation(name: string; tag: string; classPtr: auto) : auto()
Creates an AstFunctionAnnotation instance and automatically applies it to every function that carries a matching [tag_function(tag)] annotation in the module.
- Arguments
name : string
tag : string
classPtr : auto