Allows type checking in a structured manner.
| 97 | |
| 98 | |
| 99 | class VariableType: |
| 100 | """ |
| 101 | Allows type checking in a structured manner. |
| 102 | """ |
| 103 | |
| 104 | def __init__(self, ckind: VariableCompKind, elem_ckind: VariableCompKind = VariableCompKind(VariableKind.INT64, VariableMetaKind.PRIM), name: str = '') -> None: |
| 105 | self.name = name |
| 106 | self.ckind = ckind |
| 107 | self.elem_ckind = elem_ckind |
| 108 | |
| 109 | def __eq__(self, other): |
| 110 | if isinstance(other, VariableType): |
| 111 | return (self.ckind, self.elem_ckind, self.name) == (other.ckind, other.elem_ckind, other.name) |
| 112 | return False |
| 113 | |
| 114 | def __str__(self) -> str: |
| 115 | attrs = [] |
| 116 | for key, value in vars(self).items(): |
| 117 | attrs.append(f"{key}={value}") |
| 118 | return f"{self.__class__.__name__}({', '.join(attrs)})" |
| 119 | |
| 120 | def kind(self): |
| 121 | return self.ckind.kind |
| 122 | |
| 123 | def meta_kind(self): |
| 124 | return self.ckind.meta_kind |
| 125 | |
| 126 | |
| 127 | @dataclass |
no outgoing calls
no test coverage detected