class Savi::Compiler::Macros
- Savi::Compiler::Macros
- Savi::AST::CopyOnMutateVisitor
- Reference
- Object
Overview
The purpose of the Macros pass is to parse and expand semantic forms that may be more context-sensitive/dynamic than those parsed in the parser itself. Eventually we wish to allow the user code to register this macro logic in the earlier passes of evaluation in the compiler, to make them fully dynamic. This is not possible yet, as all macros are hard-coded here in the compiler.
This pass uses copy-on-mutate patterns to "mutate" the Program topology. This pass uses copy-on-mutate patterns to "mutate" the AST. This pass may raise a compilation error. This pass keeps temporary state at the per-function level. This pass produces no output state.
Defined in:
savi/compiler/macros.crConstructors
Class Method Summary
Instance Method Summary
- #build_assert_has_error(node : AST::Relate, expr : AST::Node, expects_error : Bool)
- #func : Savi::Program::Function
- #maybe_compiler_intrinsic
- #next_local_name
- #run(ctx)
-
#visit_assert(node : AST::Relate, expr : AST::Relate)
The
#visit_assert
methods compiles different forms of theassert
macro. - #visit_assert(node : AST::Relate, expr : AST::Node)
- #visit_assert_error(node : AST::Relate, expr : AST::Node)
- #visit_assert_no_error(node : AST::Relate, expr : AST::Node)
- #visit_assert_type_relation(node : AST::Relate, expr : AST::Relate)
- #visit_case(node : AST::Group)
- #visit_case_relate(orig : AST::Node, node : AST::Relate)
- #visit_conditional_jump(node : AST::Group, kind : AST::Jump::Kind, cond : AST::Term, term : AST::Term | Nil = nil, negate : Bool = false)
- #visit_conditional_yield(node : AST::Group, cond : AST::Term, negate : Bool = false)
- #visit_identity_digest_of(node : AST::Group)
- #visit_if(node : AST::Group)
- #visit_jump(node : AST::Group, kind : AST::Jump::Kind)
- #visit_pre(ctx, node : AST::Group)
- #visit_pre(ctx, node : AST::Call)
- #visit_pre(ctx, node : AST::Relate)
- #visit_pre(ctx, node : AST::ComposeString)
- #visit_reflection_of_runtime_type_name(node : AST::Group)
- #visit_reflection_of_type(node : AST::Group)
- #visit_source_code_position_of_argument(node : AST::Group)
- #visit_stack_address_of_variable(node : AST::Group)
- #visit_static_address_of_function(node : AST::Group)
- #visit_try(node : AST::Group)
- #visit_unconditional_jump(node : AST::Group, kind : AST::Jump::Kind)
- #visit_unconditional_yield(node : AST::Group)
- #visit_while(node : AST::Group)
- #visit_yield(node : AST::Group)
Instance methods inherited from class Savi::AST::CopyOnMutateVisitor
visit(ctx : Compiler::Context, node : Node)
visit,
visit_any?(ctx : Compiler::Context, node : Node)
visit_any?,
visit_children?(ctx : Compiler::Context, node : Node)
visit_children?,
visit_pre(ctx : Compiler::Context, node : Node)
visit_pre
Constructor Detail
Class Method Detail
Instance Method Detail
The #visit_assert
methods compiles different forms of the assert
macro.
The expression to evaluate is the rhs
of the assert: expr
Relate node.
When the expression itself contains operators it will compile into Spec.Assert.relation
.
assert: True == True assert: foo || bar && baz
When the relation uses the <:
and !<:
operator the assert is compiled into a special
Spec.Assert.type_relation
method.
When the expression is any other kind of node it will compile into a Spec.Assert.condition
.
assert: True assert: Something.foo