Impl
AttributeImplDef dataclass
AttributeImplDef(signature: SigType, impl: ImplType)
Def dataclass
Def(signature: SigType, impl: ImplType)
Bases: Generic[SigType, ImplType]
Base class of an interpreter implementation definition.
ImplDef dataclass
ImplDef(
signature: SigType,
impl: ImplType,
parent: Type[Statement],
)
Signature dataclass
Signature(
stmt: Type[Statement],
args: tuple[types.TypeAttribute, ...] | None = None,
)
Signature of a statement.
impl
impl(
stmt_or_attribute: Type[HeadType],
*args: types.TypeAttribute
)
Bases: Generic[HeadType]
Decorator to define an interpreter implementation for a statement or attribute.
Note
While the impl
decorator accepts both statements and attributes, and optionally statements with its type signature, unlike a programming language, the actual dispatch behavior given an instance of a statement or attribute is defined by the implementation of the interpreter (via lookup_registry
).
Example
@dialect.register
class MyMethods(interp.MethodTable):
@impl(Add)
def interp_add(
self,
interp: Interpreter,
frame: Frame,
stmt: Add,
) -> StatementResult:
...
Source code in src/kirin/interp/impl.py
120 121 122 123 124 125 126 |
|