Method
Method dataclass
Method(
dialects: DialectGroup,
code: Statement,
*,
nargs: int | None = None,
mod: ModuleType | None = None,
py_func: typing.Callable[Param, RetType] | None = None,
sym_name: str | None = None,
arg_names: list[str] | None = None,
fields: tuple = (),
file: str = "",
lineno_begin: int = 0,
inferred: bool = False
)
Bases: Printable
, Generic[Param, RetType]
Source code in src/kirin/ir/method.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
arg_names class-attribute
instance-attribute
arg_names: list[str] | None = arg_names or [
name or f"arg{i}" for (i, arg) in enumerate(args)
]
The argument names of the callable statement. None if no keyword arguments allowed.
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)
code instance-attribute
code: Statement = code
The code of the method. This should be a statement with CallableStmtInterface trait.
dialects instance-attribute
dialects: 'DialectGroup' = dialects
The dialects that creates the method. This should be a DialectGroup.
fields class-attribute
instance-attribute
fields: tuple = fields
values captured in the method if it is a closure.
file class-attribute
instance-attribute
file: str = file
The file where the method is defined. Empty string if no file.
inferred class-attribute
instance-attribute
inferred: bool = inferred
if typeinfer has been run on this method
lineno_begin class-attribute
instance-attribute
lineno_begin: int = lineno_begin
The line number where the method is defined. 0 if no line number.
mod class-attribute
instance-attribute
mod: ModuleType | None = mod
The module where the method is defined. None if no module.
nargs instance-attribute
nargs: int = nargs if nargs is not None else len(args)
The number of arguments of the method. 0 if no arguments.
py_func class-attribute
instance-attribute
py_func: Callable[Param, RetType] | None = py_func
The original Python function. None if no Python function.
self_type property
self_type
Return the type of the self argument of the method.
sym_name class-attribute
instance-attribute
sym_name: str | None = sym_name
The name of the method. None if no name.
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
164 165 166 167 168 169 170 171 172 173 |
|
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
175 176 177 178 179 180 181 182 183 184 185 186 187 |
|