Codegen
opulse.definition.codegen ¶
Compile a :class:~opulse.definition.ast.Definition into Python source.
Each operator becomes three functions (docs/reference/semantics.md, sections 4-5):
_e_<id>(a[, b])returns(value, base_ops, calls);op_<id>(a[, b])returns the value;op_count_<id>(a[, b])returnsbase_ops.
op_compute_func holds the first two, op_count_func the third, so the
JSON fields keep their legacy meaning. The source is plain Python that Cython
also accepts. It expects NAN and every base operation's op_<id> in its
global namespace (see :mod:opulse.runtime).
Inside one function, identical calls are evaluated once and their result is reused, but every occurrence still adds its counts, so the counts equal those of the reference interpreter, which evaluates every occurrence. Reuse never crosses out of a conditional block: a value first computed under a short-circuit is only visible inside that block.
registry_resolver ¶
registry_resolver(
registry, self_operator: Operator | None = None
) -> Resolver
Resolve against registry; self_operator (not yet registered) is also visible.