Native method call obj.method(arg, ...)
| 658 | |
| 659 | @final |
| 660 | class MethodCall(RegisterOp): |
| 661 | """Native method call obj.method(arg, ...)""" |
| 662 | |
| 663 | def __init__(self, obj: Value, method: str, args: list[Value], line: int = -1) -> None: |
| 664 | self.obj = obj |
| 665 | self.method = method |
| 666 | self.args = args |
| 667 | assert isinstance(obj.type, RInstance), "Methods can only be called on instances" |
| 668 | self.receiver_type = obj.type |
| 669 | method_ir = self.receiver_type.class_ir.method_sig(method) |
| 670 | assert method_ir is not None, "{} doesn't have method {}".format( |
| 671 | self.receiver_type.name, method |
| 672 | ) |
| 673 | ret_type = method_ir.ret_type |
| 674 | self.type = ret_type |
| 675 | if not ret_type.error_overlap: |
| 676 | self.error_kind = ERR_MAGIC |
| 677 | else: |
| 678 | self.error_kind = ERR_MAGIC_OVERLAPPING |
| 679 | super().__init__(line) |
| 680 | |
| 681 | def sources(self) -> list[Value]: |
| 682 | return self.args.copy() + [self.obj] |
| 683 | |
| 684 | def set_sources(self, new: list[Value]) -> None: |
| 685 | *self.args, self.obj = new |
| 686 | |
| 687 | def accept(self, visitor: OpVisitor[T]) -> T: |
| 688 | return visitor.visit_method_call(self) |
| 689 | |
| 690 | |
| 691 | @final |
no outgoing calls
no test coverage detected
searching dependent graphs…