def parse(cls, loopNode: Iir, label: str) -> "ForLoopStatement": from pyGHDL.dom._Utils import GetIirKindOfNode from pyGHDL.dom._Translate import ( GetSequentialStatementsFromChainedNodes, GetRangeFromNode, GetNameFromNode, ) spec = nodes.Get_Parameter_Specification(loopNode) loopIndex = GetNameOfNode(spec) discreteRange = nodes.Get_Discrete_Range(spec) rangeKind = GetIirKindOfNode(discreteRange) if rangeKind == nodes.Iir_Kind.Range_Expression: rng = GetRangeFromNode(discreteRange) elif rangeKind in ( nodes.Iir_Kind.Attribute_Name, nodes.Iir_Kind.Parenthesis_Name, ): rng = GetNameFromNode(discreteRange) else: pos = Position.parse(loopNode) raise DOMException( "Unknown discete range kind '{kind}' in for...loop statement at line {line}.".format( kind=rangeKind.name, line=pos.Line ) ) statementChain = nodes.Get_Sequential_Statement_Chain(loopNode) statements = GetSequentialStatementsFromChainedNodes(statementChain, "for", label) return cls(loopNode, loopIndex, rng, statements, label)
def parse(cls, caseNode: Iir, choices: Iterable[SequentialChoice], label: str) -> "Case": from pyGHDL.dom._Translate import GetSequentialStatementsFromChainedNodes statementChain = nodes.Get_Associated_Chain(caseNode) statements = GetSequentialStatementsFromChainedNodes(statementChain, "case", label) return cls(caseNode, choices, statements)
def parse(cls, branchNode: Iir, label: str) -> "ElseBranch": from pyGHDL.dom._Translate import ( GetSequentialStatementsFromChainedNodes, ) statementChain = nodes.Get_Sequential_Statement_Chain(branchNode) statements = GetSequentialStatementsFromChainedNodes(statementChain, "else branch", label) return cls(branchNode, statements)
def parse(cls, branchNode: Iir, label: str) -> "IfBranch": from pyGHDL.dom._Translate import ( GetSequentialStatementsFromChainedNodes, GetExpressionFromNode, ) condition = GetExpressionFromNode(nodes.Get_Condition(branchNode)) statementChain = nodes.Get_Sequential_Statement_Chain(branchNode) statements = GetSequentialStatementsFromChainedNodes(statementChain, "if branch", label) return cls(branchNode, condition, statements)
def parse(cls, caseNode: Iir, label: str = None) -> "OthersCase": from pyGHDL.dom._Translate import GetSequentialStatementsFromChainedNodes body = nodes.Get_Associated_Block(caseNode) if body is nodes.Null_Iir: return cls(caseNode) statementChain = nodes.Get_Concurrent_Statement_Chain(body) statements = GetSequentialStatementsFromChainedNodes(statementChain, "case others", label) return cls(caseNode, statements)
def parse(cls, processNode: Iir, label: str, hasSensitivityList: bool) -> "ProcessStatement": from pyGHDL.dom._Translate import ( GetDeclaredItemsFromChainedNodes, GetSequentialStatementsFromChainedNodes, ) sensitivityList = None if hasSensitivityList: sensitivityList = [] for item in utils.list_iter(nodes.Get_Sensitivity_List(processNode)): sensitivityList.append(GetNameOfNode(item)) declaredItems = GetDeclaredItemsFromChainedNodes(nodes.Get_Declaration_Chain(processNode), "process", label) statements = GetSequentialStatementsFromChainedNodes( nodes.Get_Sequential_Statement_Chain(processNode), "process", label ) return cls(processNode, label, declaredItems, statements, sensitivityList)