30 lines
819 B
Python
30 lines
819 B
Python
from typing import Any, List
|
|
|
|
from .valuetype import ValueType
|
|
|
|
|
|
class Method:
|
|
__slots__ = ('name', 'arg_types', 'return_type', )
|
|
|
|
name: str
|
|
arg_types: List[ValueType]
|
|
return_type: ValueType
|
|
|
|
def __init__(self, name: str, arg_types: List[ValueType], return_type: ValueType) -> None:
|
|
self.name = name
|
|
self.arg_types = arg_types
|
|
self.return_type = return_type
|
|
|
|
def __eq__(self, other: Any) -> bool:
|
|
if not isinstance(other, Method):
|
|
raise NotImplementedError
|
|
|
|
return (
|
|
self.name == other.name
|
|
and self.arg_types == other.arg_types
|
|
and self.return_type == other.return_type
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f'Method({repr(self.name)}, {repr(self.arg_types)}, {repr(self.return_type)})'
|