Intermediate representation of a function with contextual information. Unlike FuncDecl, this includes the IR of the body (basic blocks).
| 257 | |
| 258 | |
| 259 | class FuncIR: |
| 260 | """Intermediate representation of a function with contextual information. |
| 261 | |
| 262 | Unlike FuncDecl, this includes the IR of the body (basic blocks). |
| 263 | """ |
| 264 | |
| 265 | def __init__( |
| 266 | self, |
| 267 | decl: FuncDecl, |
| 268 | arg_regs: list[Register], |
| 269 | blocks: list[BasicBlock], |
| 270 | line: int = -1, |
| 271 | traceback_name: str | None = None, |
| 272 | ) -> None: |
| 273 | # Declaration of the function, including the signature |
| 274 | self.decl = decl |
| 275 | # Registers for all the arguments to the function |
| 276 | self.arg_regs = arg_regs |
| 277 | # Body of the function |
| 278 | self.blocks = blocks |
| 279 | self.decl.line = line |
| 280 | # The name that should be displayed for tracebacks that |
| 281 | # include this function. Function will be omitted from |
| 282 | # tracebacks if None. |
| 283 | self.traceback_name = traceback_name |
| 284 | |
| 285 | @property |
| 286 | def line(self) -> int: |
| 287 | return self.decl.line |
| 288 | |
| 289 | @property |
| 290 | def args(self) -> Sequence[RuntimeArg]: |
| 291 | return self.decl.sig.args |
| 292 | |
| 293 | @property |
| 294 | def ret_type(self) -> RType: |
| 295 | return self.decl.sig.ret_type |
| 296 | |
| 297 | @property |
| 298 | def class_name(self) -> str | None: |
| 299 | return self.decl.class_name |
| 300 | |
| 301 | @property |
| 302 | def sig(self) -> FuncSignature: |
| 303 | return self.decl.sig |
| 304 | |
| 305 | @property |
| 306 | def name(self) -> str: |
| 307 | return self.decl.name |
| 308 | |
| 309 | @property |
| 310 | def fullname(self) -> str: |
| 311 | return self.decl.fullname |
| 312 | |
| 313 | @property |
| 314 | def id(self) -> str: |
| 315 | return self.decl.id |
| 316 |
no outgoing calls
searching dependent graphs…