diff options
Diffstat (limited to 'compilador/astree/unit.py')
-rw-r--r-- | compilador/astree/unit.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/compilador/astree/unit.py b/compilador/astree/unit.py index 8ffdf19..c089214 100644 --- a/compilador/astree/unit.py +++ b/compilador/astree/unit.py @@ -1,9 +1,21 @@ +import uuid +import graphviz as gv from dataclasses import dataclass from typing import List +from astree.graphable import Graphable from astree.decl import Decl # A single compilation unit, representing all of the members of a namespace. @dataclass -class Unit: +class Unit(Graphable): decls: List[Decl] + + def graph(self, dot: gv.Digraph, parent: str = None, edge: str = None) -> None: + name = uuid.uuid1().hex + dot.node(name, 'Unit') + if parent: + dot.edge(name, parent, label = edge) + for d in self.decls: + if isinstance(d, Graphable): + d.graph(dot, name, 'decl') |