Skip to content

Method

Method dataclass

Method(
    mod: ModuleType | None,
    py_func: typing.Callable[Param, RetType] | None,
    sym_name: str,
    arg_names: list[str],
    dialects: DialectGroup,
    code: Statement,
    fields: tuple = tuple(),
    file: str = "",
    lineno_begin: int = 0,
    inferred: bool = False,
)

Bases: Printable, Generic[Param, RetType]

arg_types property

arg_types

Return the types of the arguments of the method. (excluding self)

args property

args

Return the arguments of the method. (excluding self)

inferred class-attribute instance-attribute

inferred: bool = False

if typeinfer has been run on this method

self_type property

self_type

Return the type of the self argument of the method.

verify

verify() -> None

verify the method body.

This will raise a ValidationError if the method body is not valid.

Source code in src/kirin/ir/method.py
 95
 96
 97
 98
 99
100
101
102
103
104
def verify(self) -> None:
    """verify the method body.

    This will raise a ValidationError if the method body is not valid.
    """
    try:
        self.code.verify()
    except ValidationError as e:
        e.attach(self)
        raise e

verify_type

verify_type() -> None

verify the method type.

This will raise a ValidationError if the method type is not valid.

Source code in src/kirin/ir/method.py
106
107
108
109
110
111
112
113
114
115
116
117
118
def verify_type(self) -> None:
    """verify the method type.

    This will raise a ValidationError if the method type is not valid.
    """
    # NOTE: verify the method body
    self.verify()

    try:
        self.code.verify_type()
    except ValidationError as e:
        e.attach(self)
        raise e