From 5b42c05eab7656e0c1d0c3cce396fa9e07b244f9 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 23 May 2023 23:13:16 +0200 Subject: [PATCH] semantic: add Function semantic type, which is a special case of Type Also define display in builtin context --- compiler/semantic.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/semantic.py b/compiler/semantic.py index a15a1f9..b55e8b3 100644 --- a/compiler/semantic.py +++ b/compiler/semantic.py @@ -38,6 +38,10 @@ class Type(SymbolABC): super().__init__(context, name, value) +class Function(Type): + pass + + class Variable(SymbolABC): @typecheck 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) self.types = { "__unknown": Type(self, "__unknown", "builtin"), + "__function": Function(self, "__function", "builtin"), "uint32": Type(self, "uint32", "builtin") } + self.variables = { + "display": Variable(self, "display", None, self.types["__function"]) + }