tvm_tirx.script.parser.make_macro_decorator#
- tvm_tirx.script.parser.make_macro_decorator(builder, *, namespace_path, preserve_return=True, late_binding=False)#
Create a decorator for helpers executed in a caller’s builder frames.
- Parameters:
builder (object) – Namespace implementing construction operations for the helper body.
namespace_path (str) – Canonical registered syntax key, such as “tirx.inline”.
preserve_return (bool, optional) – Keep helper returns as ordinary Python control flow. Default is True.
late_binding (bool, optional) – Refresh captured closure cells on each call. Default is False.
- Returns:
decorator (callable) – Accepts definition-site applications through a registered namespace, with optional keyword options. The
hygienicoption defaults to True and snapshots the definition environment; False captures the calling environment on each invocation. Other keyword options are accepted but do not affect helper construction.- Raises:
ValueError – When the returned decorator receives a non-function positional value.
TypeError – When a helper invocation cannot bind its Python signature.
SyntaxError – When application is not a qualified definition-site decorator, or source violates a parser restriction.
OSError – When the decorated helper’s source cannot be recovered.
- Return type:
Callable[[…], Callable[[…], Any]]
Notes
Each invocation binds arguments and defaults, transpiles the original body, and returns its result. It shares the caller’s active construction frames instead of declaring an IR function. Source acquisition, compilation, and builder exceptions propagate to the caller.