diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-06-21 19:19:11 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-06-22 12:26:59 +0200 |
commit | ba097bd3118db3135e75b913cae81973995777cd (patch) | |
tree | 294cf09448709635d71920e9ca939fed52bd89b9 /pyGHDL/dom/formatting | |
parent | ed99fae7f13db8d5c3e95e935e32db825313b56a (diff) | |
download | ghdl-ba097bd3118db3135e75b913cae81973995777cd.tar.gz ghdl-ba097bd3118db3135e75b913cae81973995777cd.tar.bz2 ghdl-ba097bd3118db3135e75b913cae81973995777cd.zip |
Handle component declarations.
Diffstat (limited to 'pyGHDL/dom/formatting')
-rw-r--r-- | pyGHDL/dom/formatting/prettyprint.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py index afbcbb851..7d07abcfe 100644 --- a/pyGHDL/dom/formatting/prettyprint.py +++ b/pyGHDL/dom/formatting/prettyprint.py @@ -8,7 +8,8 @@ from pyVHDLModel.VHDLModel import ( GenericInterfaceItem, NamedEntity, PortInterfaceItem, - WithDefaultExpression, Function, + WithDefaultExpression, + Function, ) from pyGHDL import GHDLBaseException @@ -19,7 +20,7 @@ from pyGHDL.dom.DesignUnit import ( Package, PackageBody, Configuration, - Context, + Context, Component, ) from pyGHDL.dom.Object import Constant, Signal from pyGHDL.dom.InterfaceItem import ( @@ -163,6 +164,21 @@ class PrettyPrint: return buffer + def formatComponent(self, component: Component, level: int = 0) -> StringBuffer: + buffer = [] + prefix = " " * level + buffer.append("{prefix}- Component: {name}".format(name=component.Name, prefix=prefix)) + buffer.append("{prefix} Generics:".format(prefix=prefix)) + for generic in component.GenericItems: + for line in self.formatGeneric(generic, level + 1): + buffer.append(line) + buffer.append("{prefix} Ports:".format(prefix=prefix)) + for port in component.PortItems: + for line in self.formatPort(port, level + 1): + buffer.append(line) + + return buffer + def formatPackage(self, package: Package, level: int = 0) -> StringBuffer: buffer = [] prefix = " " * level @@ -326,6 +342,9 @@ class PrettyPrint: name=item.Name, ) ) + elif isinstance(item, Component): + for line in self.formatComponent(item, level): + buffer.append(line) else: raise PrettyPrintException("Unhandled declared item kind.") |