Skip to content

Commit

Permalink
Added ConstrainedArraySubtypeSymbol and ConstrainedRecordSubtypeSymbol.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Feb 17, 2025
1 parent b453494 commit 64924f1
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions pyVHDLModel/Symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,20 +455,57 @@ class ConstrainedScalarSubtypeSymbol(SubtypeSymbol):


@export
class ConstrainedCompositeSubtypeSymbol(SubtypeSymbol):
class Constraint:
pass


@export
class ConstrainedArraySubtypeSymbol(ConstrainedCompositeSubtypeSymbol):
pass
class ArrayConstraint(Constraint):
_constraints: List[Range]

def __init__(self, constraints: Iterable[Range]) -> None:
self._constraints = [constraint for constraint in constraints]

@readonly
def Constraints(self) -> List[Range]:
return self._constraints


@export
class RecordConstraint(Constraint):
_constraints: Dict[RecordElementSymbol, Range]

def __init__(self, constraints: Mapping[RecordElementSymbol, Range]) -> None:
self._constraints = {key: value for key, value in constraints.items()}

@readonly
def Constraints(self) -> Dict[RecordElementSymbol, Range]:
return self._constraints


@export
class ConstrainedRecordSubtypeSymbol(ConstrainedCompositeSubtypeSymbol):
class ConstrainedCompositeSubtypeSymbol(SubtypeSymbol):
pass


@export
class ConstrainedArraySubtypeSymbol(ConstrainedCompositeSubtypeSymbol, ArrayConstraint):
_constraints: List

def __init__(self, name: Name, constraints: Iterable) -> None:
super().__init__(name)
ArrayConstraint.__init__(self, constraints)


@export
class ConstrainedRecordSubtypeSymbol(ConstrainedCompositeSubtypeSymbol, RecordConstraint):
_constraints: Dict[RecordElementSymbol, Any]

def __init__(self, name: Name, constraints: Mapping) -> None:
super().__init__(name)
RecordConstraint.__init__(self, constraints)


@export
class SimpleObjectOrFunctionCallSymbol(Symbol):
def __init__(self, name: Name) -> None:
Expand Down

0 comments on commit 64924f1

Please sign in to comment.