Skip to content

Method

Method dataclass

Method(
    mod,
    py_func,
    sym_name,
    arg_names,
    dialects,
    code,
    fields=tuple(),
    file="",
    lineno=list(),
    backedges=list(),
    return_type=None,
    inferred=False,
    verified=False,
)

Bases: Printable, Generic[Param, RetType]

inferred class-attribute instance-attribute

inferred = False

if typeinfer has been run on this method

lineno class-attribute instance-attribute

lineno = field(default_factory=list)

(, ) at the start of the statement call.

verified class-attribute instance-attribute

verified = False

if code.verify has been run on this method

verify

verify()

verify the method body.

Source code in src/kirin/ir/method.py
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def verify(self) -> None:
    """verify the method body."""
    try:
        self.code.verify()
    except VerificationError as e:
        msg = f'File "{self.file}"'
        if isinstance(e.node, Statement):
            if e.node.source:
                msg += f", line {e.node.source.lineno}"
            msg += f", in {e.node.name}"

        msg += f":\n    Verification failed for {self.sym_name}: {e.args[0]}"
        raise Exception(msg) from e
    self.verified = True
    return