MCPcopy Create free account
hub / github.com/NICUP14/MiniLang / VariableType

Class VariableType

src/Def.py:99–124  ·  view source on GitHub ↗

Allows type checking in a structured manner.

Source from the content-addressed store, hash-verified

97
98
99class 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

Callers 15

gen_treeFunction · 0.90
_process_fun_argsMethod · 0.90
_fun_callMethod · 0.90
parse_typeMethod · 0.90
for_statementMethod · 0.90
fun_declarationMethod · 0.90
struct_declarationMethod · 0.90
alias_definitionMethod · 0.90
declareMethod · 0.90
declarationMethod · 0.90
type_of_castFunction · 0.85
type_of_identFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected