From 5252f772ed5a40fc2036a279c5d0cda4352ec011 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 23 May 2023 23:12:28 +0200 Subject: [PATCH] semantic: display Types in context pretty-printing --- compiler/semantic.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/semantic.py b/compiler/semantic.py index b419dc9..a15a1f9 100644 --- a/compiler/semantic.py +++ b/compiler/semantic.py @@ -28,7 +28,7 @@ class SymbolABC(abc.ABC): if self._repr_guard: return str(self) self._repr_guard = True - definitions = [str(d.location().begin) for d in self.definitions if d is not None] + definitions = [str(d.location().begin) for d in self.writes if isinstance(d, nodes.Node)] self._repr_guard = False return f"{str(self)} [definitions: {', '.join(definitions)}]" @@ -136,6 +136,10 @@ class Context: result = [str(self)] if self.parent is not None: result += [f"\tParent ID: {self.parent.name}"] + if len(self.types) > 0: + result += [f"\tTypes ({len(self.types)}):"] + for key, value in self.types.items(): + result += [f"\t\t- {repr(value)}"] if len(self.variables) > 0: result += [f"\tVariables ({len(self.variables)}):"] for key, value in self.variables.items():