@@ -446,22 +446,32 @@ Note how the name is provided in the ``[call_macro]`` annotation.
446446AstPassMacro
447447------------
448448
449- ``AstPassMacro `` is one macro to rule them all. It gets entire module as an input,
450- and can be invoked at numerous passes:
449+ ``AstPassMacro `` is one macro to rule them all. It gets the entire program as
450+ input and can be invoked at numerous passes:
451451
452452.. code-block :: das
453453
454454 class AstPassMacro {
455- def abstract apply ( prog: ProgramPtr; mod: Module? ) : bool
455+ def abstract apply( prog : ProgramPtr; mod : Module?) : bool
456456 }
457457
458+ Five annotations control when a pass macro runs:
459+
460+ - ``[infer_macro] `` — after clean type inference. Returning ``true `` re-infers.
461+ - ``[dirty_infer_macro] `` — during each dirty inference pass.
462+ - ``[lint_macro] `` — after successful compilation (lint phase, read-only).
463+ - ``[global_lint_macro] `` — same as ``[lint_macro] `` but for all modules.
464+ - ``[optimization_macro] `` — during the optimisation loop.
465+
458466``make_pass_macro `` registers a class as a pass macro.
459467
460- ``add_new_infer_macro `` adds a pass macro to the infer pass. The ``[infer] `` annotation accomplishes the same thing.
468+ Typically, such macros create an ``AstVisitor `` which performs the necessary
469+ transformations via ``visit(prog, adapter) ``.
461470
462- `` add_new_dirty_infer_macro `` adds a pass macro to the `` dirty `` section of infer pass. The `` [dirty_infer] `` annotation accomplishes the same thing.
471+ .. seealso ::
463472
464- Typically, such macros create an ``AstVisitor `` which performs the necessary transformations.
473+ :ref: `tutorial_macro_pass_macro ` — step-by-step tutorial with lint and
474+ infer macro examples.
465475
466476----------------
467477AstTypeInfoMacro
0 commit comments