diff options
author | Patrick Lehmann <Patrick.Lehmann@plc2.de> | 2021-07-29 09:00:11 +0200 |
---|---|---|
committer | umarcor <unai.martinezcorral@ehu.eus> | 2021-08-23 16:35:33 +0200 |
commit | cfd625ab0a3d4df24bae77ed6143c44a53f26f49 (patch) | |
tree | 7aca39cabe4dee1e7804511fc108940168da2132 /pyGHDL/dom | |
parent | 50f65e4255f62e662d781d01f395c029426c1529 (diff) | |
download | ghdl-cfd625ab0a3d4df24bae77ed6143c44a53f26f49.tar.gz ghdl-cfd625ab0a3d4df24bae77ed6143c44a53f26f49.tar.bz2 ghdl-cfd625ab0a3d4df24bae77ed6143c44a53f26f49.zip |
Moved parsing into IfGenerateBranch.
Diffstat (limited to 'pyGHDL/dom')
-rw-r--r-- | pyGHDL/dom/Concurrent.py | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/pyGHDL/dom/Concurrent.py b/pyGHDL/dom/Concurrent.py index d4e7cf6ff..c9a67f1e1 100644 --- a/pyGHDL/dom/Concurrent.py +++ b/pyGHDL/dom/Concurrent.py @@ -48,6 +48,7 @@ from pyVHDLModel.SyntaxModel import ( Name, SequentialStatement, IfGenerateBranch, + Expression, ) from pyGHDL.libghdl import Iir @@ -199,13 +200,40 @@ class IfGenerateBranch(VHDLModel_IfGenerateBranch): def __init__( self, branchNode: Iir, + condition: Expression, alternativeLabel: str = None, declaredItems: Iterable = None, statements: Iterable[ConcurrentStatement] = None, ): - super().__init__(declaredItems, statements) + super().__init__(condition, declaredItems, statements) DOMMixin.__init__(self, branchNode) + @classmethod + def parse(cls, generateNode: Iir) -> "IfGenerateBranch": + from pyGHDL.dom._Translate import ( + GetDeclaredItemsFromChainedNodes, + GetStatementsFromChainedNodes, + GetExpressionFromNode, + ) + + condition = GetExpressionFromNode(nodes.Get_Condition(generateNode)) + body = nodes.Get_Generate_Statement_Body(generateNode) + + alternativeLabelId = nodes.Get_Alternative_Label(body) + alternativeLabel = "" + + declarationChain = nodes.Get_Declaration_Chain(body) + declaredItems = GetDeclaredItemsFromChainedNodes( + declarationChain, "if-generate branch", alternativeLabel + ) + + statementChain = nodes.Get_Concurrent_Statement_Chain(body) + statements = GetStatementsFromChainedNodes( + statementChain, "if-generate branch", alternativeLabel + ) + + return cls(body, condition, alternativeLabel, declaredItems, statements) + @export class IfGenerateStatement(VHDLModel_IfGenerateStatement, DOMMixin): @@ -218,25 +246,21 @@ class IfGenerateStatement(VHDLModel_IfGenerateStatement, DOMMixin): from pyGHDL.dom._Translate import ( GetDeclaredItemsFromChainedNodes, GetStatementsFromChainedNodes, + GetExpressionFromNode, ) # TODO: get branches # TODO: get declared items # TODO: get concurrent statements - body = nodes.Get_Generate_Statement_Body(generateNode) - alternativeLabelId = nodes.Get_Alternative_Label(body) - alternativeLabel = "" - - declarationChain = nodes.Get_Declaration_Chain(body) - declaredItems = GetDeclaredItemsFromChainedNodes( - declarationChain, "if-generate", label - ) - - statementChain = nodes.Get_Concurrent_Statement_Chain(body) - statements = GetStatementsFromChainedNodes(statementChain, "if-generate", label) + print(generateNode, GetIirKindOfNode(generateNode)) + ifBranch = IfGenerateBranch.parse(generateNode) - ifBranch = IfGenerateBranch(body, alternativeLabel, declaredItems, statements) + elseClause = generateNode + while ( + elseClause := nodes.Get_Generate_Else_Clause(elseClause) + ) != nodes.Null_Iir: + print(elseClause, GetIirKindOfNode(elseClause)) return cls(generateNode, label, ifBranch) |