Declaration of a function in IR (without body or implementation). A function can be a regular module-level function, a method, a static method, a class method, or a property getter/setter.
| 136 | |
| 137 | |
| 138 | class FuncDecl: |
| 139 | """Declaration of a function in IR (without body or implementation). |
| 140 | |
| 141 | A function can be a regular module-level function, a method, a |
| 142 | static method, a class method, or a property getter/setter. |
| 143 | """ |
| 144 | |
| 145 | def __init__( |
| 146 | self, |
| 147 | name: str, |
| 148 | class_name: str | None, |
| 149 | module_name: str, |
| 150 | sig: FuncSignature, |
| 151 | kind: int = FUNC_NORMAL, |
| 152 | *, |
| 153 | is_prop_setter: bool = False, |
| 154 | is_prop_getter: bool = False, |
| 155 | is_generator: bool = False, |
| 156 | is_coroutine: bool = False, |
| 157 | implicit: bool = False, |
| 158 | internal: bool = False, |
| 159 | ) -> None: |
| 160 | self.name = name |
| 161 | self.class_name = class_name |
| 162 | self.module_name = module_name |
| 163 | self.sig = sig |
| 164 | self.kind = kind |
| 165 | self.is_prop_setter = is_prop_setter |
| 166 | self.is_prop_getter = is_prop_getter |
| 167 | self.is_generator = is_generator |
| 168 | self.is_coroutine = is_coroutine |
| 169 | if class_name is None: |
| 170 | self.bound_sig: FuncSignature | None = None |
| 171 | else: |
| 172 | if kind == FUNC_STATICMETHOD: |
| 173 | self.bound_sig = sig |
| 174 | else: |
| 175 | self.bound_sig = sig.bound_sig() |
| 176 | |
| 177 | # If True, not present in the mypy AST and must be synthesized during irbuild |
| 178 | # Currently only supported for property getters/setters |
| 179 | self.implicit = implicit |
| 180 | |
| 181 | # If True, only direct C level calls are supported (no wrapper function) |
| 182 | self.internal = internal |
| 183 | |
| 184 | # This is optional because this will be set to the line number when the corresponding |
| 185 | # FuncIR is created |
| 186 | self._line: int | None = None |
| 187 | |
| 188 | @property |
| 189 | def line(self) -> int: |
| 190 | assert self._line is not None |
| 191 | return self._line |
| 192 | |
| 193 | @line.setter |
| 194 | def line(self, line: int) -> None: |
| 195 | self._line = line |
no outgoing calls
searching dependent graphs…