43
43
# load dependencies
44
44
from enum import Enum
45
45
from pathlib import Path
46
- from typing import List , Tuple , Union
46
+ from typing import List , Tuple , Union
47
+ try :
48
+ from typing import Protocol
49
+ except ImportError :
50
+ class Protocol :
51
+ pass
47
52
48
53
from pydecor .decorators import export
49
54
@@ -251,6 +256,19 @@ def Architecture(self) -> 'Architecture':
251
256
return self ._architecture
252
257
253
258
259
+ @export
260
+ class ComponentSymbol (Symbol ):
261
+ _component : 'Component'
262
+
263
+ def __init__ (self ):
264
+ super ().__init__ ()
265
+ self ._component = None
266
+
267
+ @property
268
+ def Component (self ) -> 'Component' :
269
+ return self ._component
270
+
271
+
254
272
@export
255
273
class ConfigurationSymbol (Symbol ):
256
274
_configuration : 'Configuration'
@@ -329,16 +347,35 @@ class EnumerationLiteralSymbol(Symbol):
329
347
class ObjectSymbol (Symbol ):
330
348
pass
331
349
350
+
332
351
@export
333
- class SimpleObjectSymbol (Symbol ):
334
- _object : Union ['Constant' , 'Signal' , 'Variable' ]
352
+ class SimpleObjectOrFunctionCallSymbol (Symbol ):
353
+ _object : Union ['Constant' , 'Signal' , 'Variable' , 'Function' ]
335
354
336
355
def __init__ (self , objectName : str ):
337
356
super ().__init__ (objectName )
338
357
self ._object = None
339
358
340
359
@property
341
- def Object (self ) -> Union ['Constant' , 'Signal' , 'Variable' ]:
360
+ def Object (self ) -> Union ['Constant' , 'Signal' , 'Variable' , 'Function' ]:
361
+ return self ._object
362
+
363
+ def __str__ (self ) -> str :
364
+ if self ._object is not None :
365
+ return str (self ._object )
366
+ return super ().__str__ ()
367
+
368
+
369
+ @export
370
+ class IndexedObjectOrFunctionCallSymbol (Symbol ):
371
+ _object : Union ['Constant' , 'Signal' , 'Variable' , 'Function' ]
372
+
373
+ def __init__ (self , objectName : str ):
374
+ super ().__init__ (objectName )
375
+ self ._object = None
376
+
377
+ @property
378
+ def Object (self ) -> Union ['Constant' , 'Signal' , 'Variable' , 'Function' ]:
342
379
return self ._object
343
380
344
381
def __str__ (self ) -> str :
@@ -527,6 +564,18 @@ def PackageBodies(self) -> List['PackageBody']:
527
564
return self ._packageBodies
528
565
529
566
567
+ @export
568
+ class Alias (ModelEntity , NamedEntity ):
569
+ def __init__ (self , name : str ):
570
+ """
571
+ Initializes underlying ``BaseType``.
572
+
573
+ :param name: Name of the type.
574
+ """
575
+ super ().__init__ ()
576
+ NamedEntity .__init__ (self , name )
577
+
578
+
530
579
@export
531
580
class BaseType (ModelEntity , NamedEntity ):
532
581
"""``BaseType`` is the base class of all type entities in this model."""
@@ -798,7 +847,45 @@ def __str__(self) -> str:
798
847
799
848
@export
800
849
class PhysicalLiteral (NumericLiteral ):
801
- pass
850
+ _unitName : str
851
+
852
+ def __init__ (self , unitName : str ):
853
+ super ().__init__ ()
854
+ self ._unitName = unitName
855
+
856
+ @property
857
+ def UnitName (self ) -> str :
858
+ return self ._unitName
859
+
860
+ def __str__ (self ) -> str :
861
+ return "{value} {unit}" .format (value = self ._value , unit = self ._unitName )
862
+
863
+
864
+ @export
865
+ class PhysicalIntegerLiteral (PhysicalLiteral ):
866
+ _value : int
867
+ _unitName : str
868
+
869
+ def __init__ (self , value : int , unitName : str ):
870
+ super ().__init__ (unitName )
871
+ self ._value = value
872
+
873
+ @property
874
+ def Value (self ) -> int :
875
+ return self ._value
876
+
877
+
878
+ @export
879
+ class PhysicalFloatingLiteral (PhysicalLiteral ):
880
+ _value : float
881
+
882
+ def __init__ (self , value : float , unitName : str ):
883
+ super ().__init__ (unitName )
884
+ self ._value = value
885
+
886
+ @property
887
+ def Value (self ) -> float :
888
+ return self ._value
802
889
803
890
804
891
@export
@@ -849,6 +936,13 @@ def __str__(self) -> str:
849
936
return "\" " + self ._value + "\" "
850
937
851
938
939
+ @export
940
+ class ParenthesisExpression (Protocol ):
941
+ @property
942
+ def Operand (self ) -> Expression :
943
+ pass
944
+
945
+
852
946
@export
853
947
class UnaryExpression (BaseExpression ):
854
948
"""
@@ -873,15 +967,15 @@ def __str__(self) -> str:
873
967
)
874
968
875
969
@export
876
- class InverseExpression (UnaryExpression ):
970
+ class NegationExpression (UnaryExpression ):
877
971
_FORMAT = ("-" , "" )
878
972
879
973
@export
880
974
class IdentityExpression (UnaryExpression ):
881
975
_FORMAT = ("+" , "" )
882
976
883
977
@export
884
- class NegationExpression (UnaryExpression ):
978
+ class InverseExpression (UnaryExpression ):
885
979
_FORMAT = ("not " , "" )
886
980
887
981
@export
@@ -896,8 +990,9 @@ class TypeConversion(UnaryExpression):
896
990
class FunctionCall (UnaryExpression ):
897
991
pass
898
992
993
+
899
994
@export
900
- class ParenthesisExpression (UnaryExpression ):
995
+ class SubExpression (UnaryExpression , ParenthesisExpression ):
901
996
_FORMAT = ("(" , ")" )
902
997
903
998
@@ -932,10 +1027,6 @@ def __str__(self) -> str:
932
1027
)
933
1028
934
1029
935
- @export
936
- class QualifiedExpression (BinaryExpression ):
937
- pass
938
-
939
1030
@export
940
1031
class AddingExpression (BinaryExpression ):
941
1032
"""
@@ -1083,6 +1174,30 @@ class RotateRightExpression(RotateExpression):
1083
1174
class RotateLeftExpression (RotateExpression ):
1084
1175
_FORMAT = ("" , " rol " , "" )
1085
1176
1177
+
1178
+ @export
1179
+ class QualifiedExpression (BaseExpression , ParenthesisExpression ):
1180
+ _operand : Expression
1181
+ _subtype : SubTypeOrSymbol
1182
+
1183
+ def __init__ (self ):
1184
+ super ().__init__ ()
1185
+
1186
+ @property
1187
+ def Operand (self ):
1188
+ return self ._operand
1189
+
1190
+ @property
1191
+ def SubTyped (self ):
1192
+ return self ._subtype
1193
+
1194
+ def __str__ (self ) -> str :
1195
+ return "{subtype}'({operand!s})" .format (
1196
+ subtype = self ._subtype ,
1197
+ operand = self ._operand ,
1198
+ )
1199
+
1200
+
1086
1201
@export
1087
1202
class TernaryExpression (BaseExpression ):
1088
1203
"""
@@ -1207,7 +1322,7 @@ def Elements(self) -> List[AggregateElement]:
1207
1322
return self ._elements
1208
1323
1209
1324
def __str__ (self ) -> str :
1210
- choices = [self . formatAggregateElement (element ) for element in self ._elements ]
1325
+ choices = [str (element ) for element in self ._elements ]
1211
1326
return "({choices})" .format (
1212
1327
choices = ", " .join (choices )
1213
1328
)
@@ -1711,6 +1826,27 @@ def BodyItems(self) -> List['ConcurrentStatement']:
1711
1826
return self ._bodyItems
1712
1827
1713
1828
1829
+ @export
1830
+ class Component (ModelEntity , NamedEntity ):
1831
+ _genericItems : List [GenericInterfaceItem ]
1832
+ _portItems : List [PortInterfaceItem ]
1833
+
1834
+ def __init__ (self , name : str ):
1835
+ super ().__init__ ()
1836
+ NamedEntity .__init__ (self , name )
1837
+
1838
+ self ._genericItems = []
1839
+ self ._portItems = []
1840
+
1841
+ @property
1842
+ def GenericItems (self ) -> List [GenericInterfaceItem ]:
1843
+ return self ._genericItems
1844
+
1845
+ @property
1846
+ def PortItems (self ) -> List [PortInterfaceItem ]:
1847
+ return self ._portItems
1848
+
1849
+
1714
1850
@export
1715
1851
class Configuration (PrimaryUnit , MixinDesignUnitWithContext ):
1716
1852
def __init__ (self , name : str ):
0 commit comments