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
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
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)
backedges class-attribute instance-attribute
backedges: set[Method] = set()
Cache for the backedges. (who calls this method)
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.
update_backedges
update_backedges()
Update the backedges of callee methods. (if they are static calls)
Source code in src/kirin/ir/method.py
203 204 205 206 207 208 209 210 211 | |
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
178 179 180 181 182 183 184 185 186 187 | |
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
189 190 191 192 193 194 195 196 197 198 199 200 201 | |