aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/dom/formatting/prettyprint.py
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-18 18:26:19 +0200
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2021-06-19 15:25:07 +0200
commitbc693d0a5a725a2806656117d65b926150e71cb4 (patch)
tree6f951c1552ff2b172a5fc192533047b347d9a7f2 /pyGHDL/dom/formatting/prettyprint.py
parent4e227b02c6ff0c12ce586295a88176a9af2c3889 (diff)
downloadghdl-bc693d0a5a725a2806656117d65b926150e71cb4.tar.gz
ghdl-bc693d0a5a725a2806656117d65b926150e71cb4.tar.bz2
ghdl-bc693d0a5a725a2806656117d65b926150e71cb4.zip
Better aggregate handling
Diffstat (limited to 'pyGHDL/dom/formatting/prettyprint.py')
-rw-r--r--pyGHDL/dom/formatting/prettyprint.py17
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)