10.7. Boost package for macro manipulations
The MACRO_BOOST module provides utility macros for macro authors, including pattern matching on AST nodes, code generation helpers, and common transformation patterns used when writing compile-time code.
All functions and symbols are in “macro_boost” module, use require to get access to it.
require daslib/macro_boost
10.7.1. Structures
- macro_boost::CapturedVariable
Stored captured variable together with the ExprVar which uses it
10.7.2. Function annotations
- macro_boost::MacroVerifyMacro
- This macro convert macro_verify(expr,message,prog,at) to the following code::
- if !expr
macro_error(prog,at,message) return [[ExpressionPtr]]
10.7.3. Call macros
- macro_boost::return_skip_lockcheck
this is similar to regular return <-, but it does not check for locks
10.7.4. Implementation details
- macro_boost::macro_verify(expr: bool; prog: ProgramPtr; at: LineInfo; message: string)
Same as verify, only the check will produce macro error, followed by return [[ExpressionPtr]]
- Arguments
expr : bool
prog : ProgramPtr
at : LineInfo
message : string
10.7.5. Block analysis
- macro_boost::capture_block(expr: ExpressionPtr) : array<CapturedVariable>()
Collect all captured variables in the expression.
- Arguments
expr : ExpressionPtr
- macro_boost::collect_finally(expr: ExpressionPtr; alwaysFor: bool = false) : array<ExprBlock?>()
Collect all finally blocks in the expression. Returns array of ExprBlock? with all the blocks which have finally section Does not go into ‘make_block’ expression, such as lambda, or ‘block’ expressions
- Arguments
expr : ExpressionPtr
alwaysFor : bool
- macro_boost::collect_labels(expr: ExpressionPtr) : array<int>()
Collect all labels in the expression. Returns array of integer with label indices Does not go into ‘make_block’ expression, such as lambda, or ‘block’ expressions
- Arguments
expr : ExpressionPtr