semantic: add Function semantic type, which is a special case of Type
Also define display in builtin context
This commit is contained in:
parent
5252f772ed
commit
5b42c05eab
1 changed files with 8 additions and 0 deletions
|
|
@ -38,6 +38,10 @@ class Type(SymbolABC):
|
||||||
super().__init__(context, name, value)
|
super().__init__(context, name, value)
|
||||||
|
|
||||||
|
|
||||||
|
class Function(Type):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Variable(SymbolABC):
|
class Variable(SymbolABC):
|
||||||
@typecheck
|
@typecheck
|
||||||
def __init__(self, context: Context, name: str, value: nodes.Value | None = None, typedef: Type | None = None):
|
def __init__(self, context: Context, name: str, value: nodes.Value | None = None, typedef: Type | None = None):
|
||||||
|
|
@ -160,5 +164,9 @@ class BuiltinContext(Context):
|
||||||
super().__init__(name="builtins", parent=None)
|
super().__init__(name="builtins", parent=None)
|
||||||
self.types = {
|
self.types = {
|
||||||
"__unknown": Type(self, "__unknown", "builtin"),
|
"__unknown": Type(self, "__unknown", "builtin"),
|
||||||
|
"__function": Function(self, "__function", "builtin"),
|
||||||
"uint32": Type(self, "uint32", "builtin")
|
"uint32": Type(self, "uint32", "builtin")
|
||||||
}
|
}
|
||||||
|
self.variables = {
|
||||||
|
"display": Variable(self, "display", None, self.types["__function"])
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue