diff options
Diffstat (limited to 'pyGHDL/dom/formatting')
-rw-r--r-- | pyGHDL/dom/formatting/prettyprint.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/pyGHDL/dom/formatting/prettyprint.py b/pyGHDL/dom/formatting/prettyprint.py index 1167d41f4..a2ad6e949 100644 --- a/pyGHDL/dom/formatting/prettyprint.py +++ b/pyGHDL/dom/formatting/prettyprint.py @@ -4,6 +4,7 @@ from pydecor import export from pyGHDL.dom.Aggregates import SimpleAggregateElement, IndexedAggregateElement, RangedAggregateElement, NamedAggregateElement, OthersAggregateElement from pyGHDL.dom.Object import Constant, Signal +from pyGHDL.dom.Range import Range from pyVHDLModel.VHDLModel import ( GenericInterfaceItem, Expression, @@ -322,14 +323,7 @@ class PrettyPrint: return "{type}".format(type=subTypeIndication.SymbolName) elif isinstance(subTypeIndication, ConstrainedSubTypeSymbol): constraints = ", ".join( - [ - "{left} {dir} {right}".format( - left=self.formatExpression(constraint.Range.LeftBound), - right=self.formatExpression(constraint.Range.RightBound), - dir=DirectionTranslation[constraint.Range.Direction], - ) - for constraint in subTypeIndication.Constraints - ] + [self.formatRange(constraint.Range) for constraint in subTypeIndication.Constraints] ) return "{type}({constraints})".format( @@ -348,6 +342,13 @@ class PrettyPrint: return " := {expr}".format(expr=self.formatExpression(item.DefaultExpression)) + def formatRange(self, r: Range) -> str: + return "{left} {dir} {right}".format( + left=self.formatExpression(r.LeftBound), + right=self.formatExpression(r.RightBound), + dir=DirectionTranslation[r.Direction], + ) + def formatExpression(self, expression: Expression) -> str: if isinstance(expression, SimpleObjectSymbol): return "{name}".format(name=expression.SymbolName) |