3838
3939from pyTooling .Decorators import export
4040
41- from pyVHDLModel .Base import ModelEntity , LabeledEntityMixin , DocumentedEntityMixin , ExpressionUnion , Range , BaseChoice , BaseCase , IfBranchMixin , \
42- ElsifBranchMixin , ElseBranchMixin , AssertStatementMixin , BlockStatementMixin , WaveformElement
43- from pyVHDLModel .Namespace import Namespace
41+ from pyVHDLModel .Base import ModelEntity , LabeledEntityMixin , DocumentedEntityMixin , ExpressionUnion , Range , BaseChoice , BaseCase , IfBranchMixin
42+ from pyVHDLModel .Base import ElsifBranchMixin , ElseBranchMixin , AssertStatementMixin , BlockStatementMixin , WaveformElement
43+ from pyVHDLModel .Regions import ConcurrentDeclarationRegionMixin
44+ from pyVHDLModel .Namespace import Namespace
4445from pyVHDLModel .Symbol import ComponentInstantiationSymbol , EntityInstantiationSymbol , ArchitectureSymbol , ConfigurationInstantiationSymbol
4546from pyVHDLModel .Association import AssociationItem , ParameterAssociationItem
4647from pyVHDLModel .Interface import PortInterfaceItem
@@ -90,26 +91,16 @@ def IterateInstantiations(self) -> Generator['Instantiation', None, None]:
9091 yield from generate .IterateInstantiations ()
9192
9293 # TODO: move into _init__
93- def Index (self ):
94+ def IndexStatements (self ):
9495 for statement in self ._statements :
95- if isinstance (statement , EntityInstantiation ):
96+ if isinstance (statement , ( EntityInstantiation , ComponentInstantiation , ConfigurationInstantiation ) ):
9697 self ._instantiations [statement .NormalizedLabel ] = statement
97- elif isinstance (statement , ComponentInstantiation ):
98- self ._instantiations [statement .NormalizedLabel ] = statement
99- elif isinstance (statement , ConfigurationInstantiation ):
100- self ._instantiations [statement .NormalizedLabel ] = statement
101- elif isinstance (statement , ForGenerateStatement ):
102- self ._generates [statement .NormalizedLabel ] = statement
103- statement .Index ()
104- elif isinstance (statement , IfGenerateStatement ):
105- self ._generates [statement .NormalizedLabel ] = statement
106- statement .Index ()
107- elif isinstance (statement , CaseGenerateStatement ):
98+ elif isinstance (statement , (ForGenerateStatement , IfGenerateStatement , CaseGenerateStatement )):
10899 self ._generates [statement .NormalizedLabel ] = statement
109- statement .Index ()
100+ statement .IndexStatement ()
110101 elif isinstance (statement , ConcurrentBlockStatement ):
111102 self ._hierarchy [statement .NormalizedLabel ] = statement
112- statement .Index ()
103+ statement .IndexStatements ()
113104
114105
115106@export
@@ -234,26 +225,8 @@ def __init__(self, label: str, procedureName: 'Name', parameterMappings: Iterabl
234225 ProcedureCall .__init__ (self , procedureName , parameterMappings )
235226
236227
237- # FIXME: Why not used in package, package body
238- @export
239- class ConcurrentDeclarations :
240- _declaredItems : List # FIXME: define list prefix type e.g. via Union
241-
242- def __init__ (self , declaredItems : Iterable = None ):
243- # TODO: extract to mixin
244- self ._declaredItems = [] # TODO: convert to dict
245- if declaredItems is not None :
246- for item in declaredItems :
247- self ._declaredItems .append (item )
248- item ._parent = self
249-
250- @property
251- def DeclaredItems (self ) -> List :
252- return self ._declaredItems
253-
254-
255228@export
256- class ConcurrentBlockStatement (ConcurrentStatement , BlockStatementMixin , LabeledEntityMixin , ConcurrentDeclarations , ConcurrentStatements , DocumentedEntityMixin ):
229+ class ConcurrentBlockStatement (ConcurrentStatement , BlockStatementMixin , LabeledEntityMixin , ConcurrentDeclarationRegionMixin , ConcurrentStatements , DocumentedEntityMixin ):
257230 _portItems : List [PortInterfaceItem ]
258231
259232 def __init__ (
@@ -267,7 +240,7 @@ def __init__(
267240 super ().__init__ (label )
268241 BlockStatementMixin .__init__ (self )
269242 LabeledEntityMixin .__init__ (self , label )
270- ConcurrentDeclarations .__init__ (self , declaredItems )
243+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
271244 ConcurrentStatements .__init__ (self , statements )
272245 DocumentedEntityMixin .__init__ (self , documentation )
273246
@@ -284,7 +257,7 @@ def PortItems(self) -> List[PortInterfaceItem]:
284257
285258
286259@export
287- class GenerateBranch (ModelEntity , ConcurrentDeclarations , ConcurrentStatements ):
260+ class GenerateBranch (ModelEntity , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
288261 """A ``GenerateBranch`` is a base-class for all branches in a generate statements."""
289262
290263 _alternativeLabel : Nullable [str ]
@@ -294,7 +267,7 @@ class GenerateBranch(ModelEntity, ConcurrentDeclarations, ConcurrentStatements):
294267
295268 def __init__ (self , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
296269 super ().__init__ ()
297- ConcurrentDeclarations .__init__ (self , declaredItems )
270+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
298271 ConcurrentStatements .__init__ (self , statements )
299272
300273 self ._alternativeLabel = alternativeLabel
@@ -348,7 +321,7 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
348321 raise NotImplementedError ()
349322
350323 # @mustoverride
351- def Index (self ) -> None :
324+ def IndexStatement (self ) -> None :
352325 raise NotImplementedError ()
353326
354327
@@ -395,12 +368,12 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
395368 if self ._elseBranch is not None :
396369 yield from self ._ifBranch .IterateInstantiations ()
397370
398- def Index (self ) -> None :
399- self ._ifBranch .Index ()
371+ def IndexStatement (self ) -> None :
372+ self ._ifBranch .IndexStatements ()
400373 for branch in self ._elsifBranches :
401- branch .Index ()
374+ branch .IndexStatements ()
402375 if self ._elseBranch is not None :
403- self ._elseBranch .Index ()
376+ self ._elseBranch .IndexStatements ()
404377
405378
406379@export
@@ -409,11 +382,11 @@ class ConcurrentChoice(BaseChoice):
409382
410383
411384@export
412- class ConcurrentCase (BaseCase , LabeledEntityMixin , ConcurrentDeclarations , ConcurrentStatements ):
385+ class ConcurrentCase (BaseCase , LabeledEntityMixin , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
413386 def __init__ (self , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None , alternativeLabel : str = None ):
414387 super ().__init__ ()
415388 LabeledEntityMixin .__init__ (self , alternativeLabel )
416- ConcurrentDeclarations .__init__ (self , declaredItems )
389+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
417390 ConcurrentStatements .__init__ (self , statements )
418391
419392
@@ -476,19 +449,19 @@ def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
476449 for case in self ._cases :
477450 yield from case .IterateInstantiations ()
478451
479- def Index (self ):
452+ def IndexStatement (self ):
480453 for case in self ._cases :
481- case .Index ()
454+ case .IndexStatements ()
482455
483456
484457@export
485- class ForGenerateStatement (GenerateStatement , ConcurrentDeclarations , ConcurrentStatements ):
458+ class ForGenerateStatement (GenerateStatement , ConcurrentDeclarationRegionMixin , ConcurrentStatements ):
486459 _loopIndex : str
487460 _range : Range
488461
489462 def __init__ (self , label : str , loopIndex : str , rng : Range , declaredItems : Iterable = None , statements : Iterable [ConcurrentStatement ] = None ):
490463 super ().__init__ (label )
491- ConcurrentDeclarations .__init__ (self , declaredItems )
464+ ConcurrentDeclarationRegionMixin .__init__ (self , declaredItems )
492465 ConcurrentStatements .__init__ (self , statements )
493466
494467 self ._loopIndex = loopIndex
@@ -506,13 +479,15 @@ def Range(self) -> Range:
506479
507480 IterateInstantiations = ConcurrentStatements .IterateInstantiations
508481
509- Index = ConcurrentStatements .Index
482+ # IndexDeclaredItems = ConcurrentStatements.IndexDeclaredItems
483+
484+ def IndexStatement (self ) -> None :
485+ self .IndexStatements ()
486+
487+ IndexStatements = ConcurrentStatements .IndexStatements
510488
511489 # def IterateInstantiations(self) -> Generator[Instantiation, None, None]:
512490 # return ConcurrentStatements.IterateInstantiations(self)
513- #
514- # def Index(self) -> None:
515- # return ConcurrentStatements.Index(self)
516491
517492
518493@export
0 commit comments