From ee6a244880f2d4fff429118ccbce043b342fae4d Mon Sep 17 00:00:00 2001 From: Patrick Lehmann Date: Fri, 30 Jul 2021 09:00:16 +0200 Subject: PrettyPrint deferred constants. --- pyGHDL/dom/formatting/prettyprint.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'pyGHDL/dom') diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py index 20355db24..8ab854212 100644 --- a/pyGHDL/dom/formatting/prettyprint.py +++ b/pyGHDL/dom/formatting/prettyprint.py @@ -41,7 +41,7 @@ from pyVHDLModel.SyntaxModel import ( WithDefaultExpressionMixin, Function, BaseType, - FullType, + FullType, BaseConstant, ) from pyGHDL import GHDLBaseException @@ -79,7 +79,7 @@ from pyGHDL.dom.InterfaceItem import ( PortSignalInterfaceItem, GenericTypeInterfaceItem, ) -from pyGHDL.dom.Object import Constant, Signal, SharedVariable, File +from pyGHDL.dom.Object import Constant, Signal, SharedVariable, File, DeferredConstant from pyGHDL.dom.Attribute import Attribute, AttributeSpecification from pyGHDL.dom.Subprogram import Procedure from pyGHDL.dom.Misc import Alias @@ -415,15 +415,20 @@ class PrettyPrint: buffer = [] prefix = " " * level - if isinstance(item, Constant): + if isinstance(item, BaseConstant): + if isinstance(item, Constant): + default = " := {expr}".format(expr=str(item.DefaultExpression)) + else: + default = "" + buffer.append( - "{prefix}- constant {name} : {subtype} := {expr}".format( + "{prefix}- constant {name} : {subtype}{default}".format( prefix=prefix, name=", ".join(item.Identifiers), subtype=self.formatSubtypeIndication( item.Subtype, "constant", item.Identifiers[0] ), - expr=str(item.DefaultExpression), + default=default, ) ) elif isinstance(item, SharedVariable): -- cgit v1.2.3