pyGHDL.dom.Type
This module implements derived type classes from pyVHDLModel.Type.
Classes
IncompleteType: This class implements apyGHDL.domobject derived frompyVHDLModel.Type.AnonymousType.EnumeratedType: Represents an enumerated type.IntegerType: Represents an integer type.RealType: Represents a real type (floating-point type).PhysicalUnit: This class implements apyGHDL.domobject derived frompyVHDLModel.Type.PhysicalUnit.PhysicalType: Represents a physical type.ArrayType: Represents an array type.RecordTypeElement: Represents a record element.RecordType: Represents a record type.ProtectedType: Represents a protected type.ProtectedTypeBody: Represents a protected type body.AccessType: Represents an access type.FileType: Represents a file type.Subtype: Represents a subtype.
Classes
- class pyGHDL.dom.Type.IncompleteType(node, identifier, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.AnonymousType.Represents a base-class for types without a type definition of their own.
An incomplete type is the typical case: it names a type (
Identifier) whose full definition follows later in the same declarative part.Example
type node; -- ^^^^ <- Identifier type ptr is access node; type node is record value : integer; nextNode : ptr; end record;
Inheritance
- classmethod parse(node, documentation=None)[source]
Translates an IIR node to an
IncompleteType.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Check that a full type declaration of the same name completes this incomplete type later in its region.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If no full type declaration follows in the region, and no
WarningCollectorcollects theIncompleteTypeWarning.- Return type:
- Visit(visitor)
Walk this incomplete type declaration with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the type declaration.
Format:
type myType- Return type:
- Returns:
Formatted type declaration.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.EnumeratedType(node, identifier, literals, documentation=None)[source]
Represents an enumerated type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.EnumeratedType.Example
type integer is (lit_1, lit2, ...);
Inheritance
- Parameters:
node (Iir)
identifier (str)
literals (List[EnumerationLiteral])
documentation (str)
- __init__(node, identifier, literals, documentation=None)[source]
Initializes an enumerated type definition.
- Parameters:
node (
Iir) – The IIR node this object was translated from.identifier (
str) – The enumeration type’s identifier.literals (
List[EnumerationLiteral]) – List of all enumeration literals, in declaration order.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses an enumerated type IIR and returns an
EnumeratedTypeinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()[source]
Iterate the enumeration literals this type declaration implies.
- Return type:
- Returns:
A generator to iterate (normalized designator, enumeration literal) pairs, in declaration order.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property Literals: list[EnumerationLiteral]
Read-only property to access the literals (
_literals).- Returns:
List of literals.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the enumerated type definition.
Format:
state is (idle, run)- Return type:
- Returns:
Formatted enumerated type definition.
- _literals: list[EnumerationLiteral]
List of all enumeration literals, in declaration order.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.IntegerType(node, typeName, rng, documentation=None)[source]
Represents an integer type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.IntegerType.Example
type integer is range -2147483648 to 2147483647;
Inheritance
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the integer type definition.
Format:
byte_count is range 0 to 7- Return type:
- Returns:
Formatted integer type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.RealType(node, typeName, rng, documentation=None)[source]
Represents a real type (floating-point type).
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.RealType.Example
type real is range -1.79769313486232E308 to 1.79769313486232E308;
Inheritance
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the floating-point type definition.
Format:
gain is range 0.0 to 1.0- Return type:
- Returns:
Formatted floating-point type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.PhysicalUnit(node, identifier, value=None, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.PhysicalUnit.Represents a unit declaration of a physical type: its primary unit or one of its secondary units.
A unit name is declared by the physical type’s declaration in the declarative region enclosing the type, so it’s visible like the type itself, e.g. imported by a use clause. The unit’s parent is its physical type; the unit is the parent of its value.
Example
type distance is range 0 to 1000000 units um; --^^ <- Identifier (primary unit) mm = 1000 um; --^^ <- Identifier (secondary unit) -- ^^^^^^^ <- Value end units;
Inheritance
- Parameters:
node (Iir)
identifier (str)
value (PhysicalIntegerLiteral)
documentation (str)
- __init__(node, identifier, value=None, documentation=None)[source]
Initializes a unit declaration of a physical type.
- Parameters:
node (
Iir) – The IIR node this object was translated from.identifier (
str) – The unit’s identifier.value (
PhysicalIntegerLiteral) – Optional, the unit’s value in a smaller unit,Nonefor the primary unit.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- DenoteBy(name, region, place, symbol)
Determine the model entity a name denoting this declaration denotes, as a part of a type mark (
Name.Denote).A declaration, which a name in a type mark can denote, overrides this method and returns itself: an object, an alias, a type or subtype, a record element, a package. Any other declaration (e.g. a subprogram) is reported.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
None, as a name in a type mark can’t denote this declaration (reported as a warning).- Raises:
UnhandledCriticalWarningError – Always, if no
WarningCollectorcollects theUnresolvedTypeMarkWarning.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- property Value: PhysicalIntegerLiteral | None
Read-only property to access the unit’s value (
_value).- Returns:
The unit’s value in a smaller unit, or
Nonefor the primary unit.
- Visit(visitor)
Walk this model element with a visitor.
A model class implements its walk; a class without one raises.
- Parameters:
visitor (
Visitor) – The visitor receiving the events.- Raises:
NotImplementedError – Always, because the element’s class has no walk of its own.
- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the unit declaration.
Format:
mm = 1000 um, orumfor the primary unit- Return type:
- Returns:
Formatted unit declaration.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- _value: PhysicalIntegerLiteral | None
The unit’s value in a smaller unit, or
Nonefor the primary unit.
- class pyGHDL.dom.Type.PhysicalType(node, typeName, rng, primaryUnit, secondaryUnits, documentation=None)[source]
Represents a physical type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.PhysicalType.Example
type time is range integer'low to integer'high units fs; ps = 1000 fs; -- ... end units;
Inheritance
- Parameters:
node (Iir)
typeName (str)
primaryUnit (PhysicalUnit)
secondaryUnits (List[PhysicalUnit])
documentation (str)
- __init__(node, typeName, rng, primaryUnit, secondaryUnits, documentation=None)[source]
Initializes a physical type definition.
- Parameters:
node (
Iir) – The IIR node this object was translated from.typeName (
str) – The type’s identifier.rng (
Range|Name) – The range constraining this scalar type.primaryUnit (
PhysicalUnit) – The type’s primary unit.secondaryUnits (
List[PhysicalUnit]) – The type’s secondary units.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses an physical type IIR and returns an
PhysicalTypeinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()[source]
Iterate the units this type declaration implies: the primary unit, then the secondary units.
- Return type:
- Returns:
A generator to iterate (normalized identifier, unit) pairs, in declaration order.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- property PrimaryUnit: PhysicalUnit
Read-only property to access the primary unit (
_primaryUnit).The primary unit has no value. Formatted, it’s the unit’s name.
- Returns:
The primary unit.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- property SecondaryUnits: list[PhysicalUnit]
Read-only property to access the secondary units (
_secondaryUnits).- Returns:
List of secondary units, in declaration order.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Units,)
Reserved words after
end.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the physical type definition.
Format:
distance is range 0 to 1000 units um; mm = 1000 um;- Return type:
- Returns:
Formatted physical type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- _primaryUnit: PhysicalUnit
The type’s primary unit, which has no value.
- _secondaryUnits: list[PhysicalUnit]
List of the type’s secondary units, in declaration order.
- class pyGHDL.dom.Type.ArrayType(node, identifier, indices, elementSubtype, documentation=None)[source]
Represents an array type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.ArrayType.Example
type bit_vector is array(natural range <>) of bit;
Inheritance
- __init__(node, identifier, indices, elementSubtype, documentation=None)[source]
Initializes an array type definition.
- Parameters:
node (
Iir) – The IIR node this object was translated from.identifier (
str) – The array type’s identifier.indices (
List) – List of all index ranges, one per dimension.elementSubtype (
Symbol) – Reference to the subtype of the array’s elements.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses an array type IIR and returns an
ArrayTypeinstance.An unconstrained array type (
array (natural range <>) of bit) is anArray_Type_Definition; a constrained array type (array (0 to 3) of bit) is anArray_Subtype_Definitioncarrying an index constraint per dimension.- Parameters:
- Return type:
- Returns:
The array type instance.
- Raises:
DOMException – If an index of an unconstrained array type is not a type mark.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Dimensions: list[Range]
Read-only property to access the dimensions (
_dimensions).- Returns:
List of dimensions.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- property ElementType: Symbol
Read-only property to access the element type (
_elementType).- Returns:
The element type.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)[source]
Iterate the type marks of this array type: its index subtypes, then its element subtype.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this type.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- Visit(visitor)[source]
Walk this array type, its index ranges and its element subtype with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the array type definition.
Format:
memory is array(0 to 7) of bit- Return type:
- Returns:
Formatted array type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.RecordTypeElement(node, identifiers, subtype, documentation=None)[source]
Represents a record element.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.RecordTypeElement.Example
-- type pt is record element : std_logic; -- ... -- end record;
Inheritance
- __init__(node, identifiers, subtype, documentation=None)[source]
Initializes a record type element.
- Parameters:
- Return type:
None
- classmethod parse(elementDeclarationNode, furtherIdentifiers=None)[source]
Parses a record element IIR and returns an
RecordTypeElementinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- Copy()[source]
Create a copy of this record type element.
The copy has no parent. Its subtype is a copy of this element’s subtype.
- Return type:
- Returns:
The new record type element.
- DenoteBy(name, region, place, symbol)[source]
Return this record element, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This record element.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for one of the model entity’s normalized identifiers.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifiers: tuple[str]
Read-only property to access the model entity’s identifiers (
_identifiers).- Returns:
Tuple of identifiers.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- property NormalizedIdentifiers: tuple[str]
Read-only property to access the model entity’s normalized identifiers (
_normalizedIdentifiers).See also
- Returns:
Tuple of normalized identifiers.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- Split()
Split this declaration into one declaration per identifier.
IEEE Std 1076 defines a declaration with an identifier list as equivalent to a sequence of single declarations, one per identifier, in list order:
signal a, b : bit;declares the same assignal a : bit; signal b : bit;. This declaration keeps its first identifier. For every other identifier, a new declaration is created byCopy(): it has its own copy of the subtype indication and of the default expression, and the same documentation. Single declarations created before are dropped.Without a parent, the new declarations have no parent either: the caller places them. With a parent, the parent’s mutator splits the declaration and inserts the new declarations right after it, e.g.
WithPortsMixin.SplitPortItemfor a port.A declaration with one identifier is unchanged.
- Return type:
- Returns:
Tuple of declarations, one per identifier in list order, starting with this declaration.
- Raises:
NotAChildError – If this declaration’s parent doesn’t list it.
NotInNamespaceError – If the parent is an indexed declarative region, and an identifier of this declaration refers to another element, e.g. a duplicate declaration.
- property Subtype: Symbol
Read-only property to access the subtype (
_subtype).- Returns:
The subtype.
- _KeepIdentifier(position)
Reduce the identifier list to the identifier at a position and drop the single declarations.
- _SplitCopies()
Create one parentless copy of this declaration per identifier after the first, each keeping its identifier.
- _SplitInParent()[source]
Split this element declaration by the mutator of its parent (
SplitElement()).
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the record element declaration.
Format:
a, b : bit- Return type:
- Returns:
Formatted record element declaration.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- _singleDeclarations: list[SingleDeclarationMixin] | None
Cached single declarations, or
None.
- class pyGHDL.dom.Type.RecordType(node, identifier, elements=None, documentation=None)[source]
Represents a record type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.RecordType.Example
type pt is record -- elements end record;
Inheritance
- Parameters:
node (Iir)
identifier (str)
elements (List[RecordTypeElement])
documentation (str)
- __init__(node, identifier, elements=None, documentation=None)[source]
Initializes a record type definition.
- Parameters:
node (
Iir) – The IIR node this object was translated from.identifier (
str) – The record type’s identifier.elements (
List[RecordTypeElement]) – Optional, list of all element declarations, in declaration order.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses a record type IIR and returns an
RecordTypeinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- property Elements: list[RecordTypeElement]
Read-only property to access the elements (
_elements).- Returns:
List of elements.
- property ElementsByIdentifier: dict[str, RecordTypeElement]
Read-only property to access the elements by identifier (
_elementsByIdentifier).An element declaring several identifiers (
a, b : bit) is indexed by each of them.- Returns:
Dictionary of elements, indexed by normalized identifier.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)[source]
Iterate the type marks of this record type: the element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this type.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- SplitElement(element)[source]
Split an element with an identifier list into one element per identifier.
The element keeps its first identifier. For every other identifier, a new element is created by its
Copy()and inserted right after it, in list order; its parent is set to this record type. An element declaring one identifier is unchanged.- Parameters:
element (
RecordTypeElement) – The element to split.- Return type:
- Returns:
Tuple of elements, one per identifier in list order, starting with the split element.
- Raises:
ValueError – If parameter ‘element’ is
None.TypeError – If parameter ‘element’ is not of type
RecordTypeElement.NotAChildError – If parameter ‘element’ is not an element of this record type.
See also
Split()→ Split a declaration with an identifier list.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Record,)
Reserved words after
end.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the record type definition.
Format:
frame is record a : bit;- Return type:
- Returns:
Formatted record type definition.
- _elements: list[RecordTypeElement]
List of all element declarations, in declaration order.
- _elementsByIdentifier: dict[str, RecordTypeElement]
All element declarations, indexed by normalized identifier.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.ProtectedType(node, identifier, methods=None, documentation=None)[source]
Represents a protected type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.ProtectedType.Example
type pt is protected -- public interface end protected;
Inheritance
- __init__(node, identifier, methods=None, documentation=None)[source]
Initializes a protected type declaration.
- Parameters:
node (
Iir) – The IIR node this object was translated from.identifier (
str) – The protected type’s identifier.methods (
List|Iterator) – Optional, list of the protected type’s methods, in declaration order.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses a protected type IIR and returns an
ProtectedTypeinstance.
- _iirNode
The IIR node in libghdl’s tree this DOM object was translated from.
- _position
The IIR node’s position in the source file, resolved on first access and then cached.
- AddDeclaredItem(declaredItem)
Add a declared item at the end of the declarative region.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to add.- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- property DeclaredItems: list
Read-only property to access the declared items (
_declaredItems).- Returns:
List of all declared items.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- property Functions: dict[str, list[Function]]
Read-only property to access the declared functions (
_functions).- Returns:
Dictionary of all functions, indexed by name; each entry is a list of overloads.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- IndexDeclaredItems()
Index declared items listed in the protected type declaration.
Both lookup tables are cleared and all declared items are removed from
_namespacefirst. Only subprogram declarations are legal here, so anything else is passed to_IndexOtherDeclaredItem(). Indexing again yields the same lookup tables and namespace.See also
IndexDeclaredItems()The same algorithm for the protected type’s body.
- Raises:
UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- InsertDeclaredItem(index, declaredItem)
Insert a declared item at a position of the declarative region.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.
- Parameters:
index (
int) – Position, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
AddDeclaredItem()→ Add a declared item at the end of the declarative region.
InsertDeclaredItemBefore()→ Insert a declared item before another declared item.
InsertDeclaredItemAfter()→ Insert a declared item after another declared item.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
- InsertDeclaredItemAfter(declaredItem, after)
Insert a declared item after another declared item.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to insert.after (
ModelEntity) – The declared item of this declarative region to insert after.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
InsertDeclaredItemBefore()→ Insert a declared item before another declared item.
- InsertDeclaredItemBefore(declaredItem, before)
Insert a declared item before another declared item.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to insert.before (
ModelEntity) – The declared item of this declarative region to insert before.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
InsertDeclaredItemAfter()→ Insert a declared item after another declared item.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateDeclarationRegions()
Iterate this declarative region and all declarative regions nested in it.
Nested regions are declarations (e.g. subprograms, generic subprograms, protected types, packages) and concurrent statements (blocks, processes, generate statements and their branches), each followed by the regions nested in it.
- Return type:
- Returns:
A generator to iterate the declarative regions, this region first.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- LookupName(place, symbol, name, warningType)
Look up the declarations a simple name or an expanded name denotes at a place in this region.
A simple name is looked up at the place (
Lookup()). An expanded namepkg.Torlib.pkg.Tresolves its prefix:pkgto a package visible at the place, else to an enclosing declarative region of that name (e.g. the package or entity containing the place);lib.pkgby the library (workor a library whose name is visible in the design unit containing the place,IsLibraryVisible()) and the package’s name. Then the suffix is searched among the declarations of the package or region (FindDeclarations()).A failure is reported as a warning of the given type, whose label names the kind of name in the message (e.g.
Type mark); then no declaration is returned. A name, which is a part of the symbol’s name (e.g. the prefixsof the type marks'subtype), is reported as a prefix of the symbol’s name.- Parameters:
place (
ModelEntity) – The declaration containing the name.symbol (
Symbol) – The symbol containing the name.name (
Name) – The simple name or expanded name: the symbol’s name or a part of it.warningType (
type[UnresolvedNameWarning]) – The warning class reporting a failure.
- Return type:
- Returns:
Tuple of the directly visible declarations, empty if none is.
- Raises:
UnhandledCriticalWarningError – If the name isn’t visible, is ambiguous, or has a prefix, which isn’t a visible package or an enclosing region, and no
WarningCollectorcollects the warning.
- property Methods: list[Procedure | Function]
Read-only property to return the declared methods, in declaration order.
A protected type declares nothing but subprograms, so this is every declared item (
_declaredItems). It is kept as a named view because “method” is the VHDL term for a protected type’s subprograms.- Returns:
List of methods, in declaration order.
- MoveDeclaredItem(declaredItem, index)
Move a declared item to a position of the declarative region.
The declared item stays a declared item of this declarative region: only the order of the declared items changes.
If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in
Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.index (
int) – Position of the declared item after the move, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves the declared item to the end.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveDeclaredItemBefore()→ Move a declared item before another declared item.
MoveDeclaredItemAfter()→ Move a declared item after another declared item.
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- MoveDeclaredItemAfter(declaredItem, after)
Move a declared item after another declared item.
The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for
MoveDeclaredItem(). Moving a declared item after itself keeps it in place.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.after (
ModelEntity) – The declared item of this declarative region to move after.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.
- Return type:
See also
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
MoveDeclaredItemBefore()→ Move a declared item before another declared item.
- MoveDeclaredItemBefore(declaredItem, before)
Move a declared item before another declared item.
The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for
MoveDeclaredItem(). Moving a declared item before itself keeps it in place.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.before (
ModelEntity) – The declared item of this declarative region to move before.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.
- Return type:
See also
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
MoveDeclaredItemAfter()→ Move a declared item after another declared item.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- Precedes(item, anchor, inclusive)
Check if an item precedes an anchor in this declarative region.
An item, which isn’t a declaration of this region (e.g. a use clause of the context clause), precedes every anchor.
- Parameters:
item (
ModelEntity|None) – The item in declaration order, orNonefor the implicit use clause.anchor (
ModelEntity) – A declaration of this region, e.g. the one containing the place of a lookup.inclusive (
bool) –True, if the anchor precedes itself, i.e. the place is nested inside the anchor.
- Return type:
- Returns:
True, if the item precedes the anchor.
- property Procedures: dict[str, list[Procedure]]
Read-only property to access the declared procedures (
_procedures).- Returns:
Dictionary of all procedures, indexed by name; each entry is a list of overloads.
- RemoveDeclaredItem(declaredItem)
Remove a declared item from the declarative region.
The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.
The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (
IndexDeclaredItems()) after the removal.- Parameters:
declaredItem (
ModelEntity) – The declared item to remove.- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.
- Return type:
See also
AddDeclaredItem()→ Add a declared item at the end of the declarative region.
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- ResolveTypeMark(place, symbol)
Resolve a type mark at its place in this region and set the symbol’s reference.
Algorithm
Clear the symbol’s reference.
Look up the type mark’s name (
LookupName()).An alias of a type is replaced by the type its name references.
If the declaration is a type, a subtype or a generic type, it becomes the symbol’s reference. A full type, which follows the place in the same region, is visible by its incomplete type declaration only to an access type.
An attribute name denoting a type (e.g.
s'subtype,A'element) is resolved part by part (Denote()); the type it denotes becomes the symbol’s reference.- Parameters:
place (
ModelEntity) – The declaration containing the type mark.symbol (
SubtypeSymbol) – The type mark.
- Raises:
UnhandledCriticalWarningError – If the type mark isn’t visible, is ambiguous, has a prefix, which isn’t a visible package, denotes no type, or denotes an incomplete type outside of an access type, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- SplitDeclaredItem(declaredItem)
Split a declared item with an identifier list into one declaration per identifier.
The declared item keeps its first identifier. For every other identifier, a new declaration is created by its
Copy()and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.- Parameters:
declaredItem (
ModelEntity) – The declared item to split.- Return type:
- Returns:
Tuple of declarations, one per identifier in list order, starting with the split declared item.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- _AddOverloadToNamespace(item)
Add a function or procedure to the namespace, if it’s the overload declared last.
The namespace keeps one entry per identifier: the overload declared last, as after
IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.- Return type:
- _AddToNamespace(element)
Add an element’s identifiers to this region’s namespace.
Nothing is added to a region not indexed yet:
IndexDeclaredItems()adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).- Parameters:
element (
NamedEntityMixin|MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.- Return type:
- _ClashingDeclarations(item)
Return the declarations sharing an identifier with the given item, which may not share it.
The declarations (
_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.- Parameters:
item (
ModelEntity) – The new declaration, or the new labeled statement.- Return type:
- Returns:
Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.
- _ConnectParentNamespace(parent)
Connect this region’s namespace to the namespace of the enclosing declarative region.
A declaration of this region then hides a same-named declaration of the enclosing region. A parent, which isn’t a declarative region (e.g. a subprogram of an interface list), has no namespace to connect to.
- Parameters:
parent (
ModelEntity) – The new parent of this region.- Return type:
- _DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Subprogram.Subprogram'>,)
Accepted classes of declared items (
pyVHDLModel).
- _Declarations()
Return all declarations of this declarative region.
A host class with interface items extends the list by its interface items, listed first.
- Return type:
- Returns:
Tuple of declarations: the declared items, in declaration order.
- _DeclaredItemsSharingIdentifiers(declaredItem)
Return the other declared items of this region sharing an identifier with the given declared item.
- Parameters:
declaredItem (
ModelEntity) – The declared item.- Return type:
- Returns:
List of declared items, in declaration order.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Protected,)
Reserved words after
end.
- _IndexDeclaredItem(item)
Add a declared item to the namespace and to the lookup table matching its kind.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _IndexOtherDeclaredItem(item)
Hook for declared items the region doesn’t handle itself. Derived classes may override it.
An alias, an attribute declaration and a package (also a package instantiation) declared in the region are added to the namespace, without a lookup table.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _IndexOverload(item)
Add an inserted function or procedure to its lookup table and to the namespace.
The list of overloads follows the declaration order. The namespace is updated by
_AddOverloadToNamespace().- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The inserted function or procedure.- Return type:
- _IterateStatementRegions()
Iterate the declarative regions nested in the statements of this declarative region.
- Return type:
- Returns:
An empty generator.
- _Labels()
Return the labeled statements, whose labels are declared in this declarative region.
- Return type:
- Returns:
An empty tuple.
Check if two declarations may share an identifier in one declarative region.
Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.
- Parameters:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- Returns:
True, if both declarations may share an identifier.
- _RemoveDeclaredItemEntries(lookupTable, item)
Remove a declared item’s entries from a lookup table and from the namespace.
Every identifier is checked before anything is removed.
- Parameters:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- Raises:
NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.
NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.
- Return type:
- _RemoveDeclaredItemsFromNamespace()
Remove all declared items of this region from its namespace.
Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.
- Return type:
- _RemoveFromNamespace(element)
Remove an element’s identifiers from this region’s namespace.
Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (
_RemoveOverloadFromNamespace()).- Parameters:
element (
NamedEntityMixin|MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.- Raises:
NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.
NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.
- Return type:
- _RemoveOverloadFromNamespace(item)
Remove a function or procedure from the namespace.
Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (
_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.- Raises:
NotInNamespaceError – If the identifier isn’t declared in the namespace.
NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
Return the other language constructs forming one declarative region with this one.
An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.
- Return type:
- Returns:
Tuple of declarative regions.
- _UnindexDeclaredItem(item)
Remove a declared item from the namespace and from the lookup table matching its kind.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _UnindexOtherDeclaredItem(item)
Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.
An alias, an attribute declaration and a package are removed from the namespace.
- Parameters:
item (
ModelEntity) – The declared item.- Raises:
NotInNamespaceError – If the item is an alias, an attribute declaration or a package, which isn’t declared in the namespace.
- Return type:
- _UnindexOverload(item)
Remove a function or procedure from its lookup table and from the namespace.
The namespace is updated first, by
_RemoveOverloadFromNamespace().- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.- Raises:
NotInNamespaceError – If the identifier isn’t declared in the namespace.
NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the type declaration.
Format:
type myType- Return type:
- Returns:
Formatted type declaration.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _declaredItems
List of all declared items in this protected type declaration.
- _documentation
The associated documentation of a model entity.
- _functions
All declared functions, indexed by name; each is a list of overloads.
- _identifier
The identifier of a model entity.
- _namespace
The namespace of this protected type declaration.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _objectVertex
The vertex representing this type in the design’s object graph.
- _parent
Reference to a parent entity in the logical model hierarchy.
- _procedures
All declared procedures by name; each is a list of overloads.
- class pyGHDL.dom.Type.ProtectedTypeBody(node, identifier, declaredItems=None, documentation=None)[source]
Represents a protected type body.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.ProtectedTypeBody.Example
type pt is protected body -- implementations end protected body;
Inheritance
- __init__(node, identifier, declaredItems=None, documentation=None)[source]
Initializes a protected type body.
- Parameters:
- Return type:
None
- classmethod parse(protectedBodyNode)[source]
Parses a protected type body IIR and returns an
ProtectedTypeBodyinstance.
- _iirNode
The IIR node in libghdl’s tree this DOM object was translated from.
- _position
The IIR node’s position in the source file, resolved on first access and then cached.
- AddDeclaredItem(declaredItem)
Add a declared item at the end of the declarative region.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to add.- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- property Constants: dict[str, Constant]
Read-only property to access the declared constants (
_constants).- Returns:
Dictionary of constants, indexed by normalized identifier.
- property DeclaredItems: list
Read-only property to access the declared items (
_declaredItems).- Returns:
List of declared items.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- property Files: dict[str, File]
Read-only property to access the declared files (
_files).- Returns:
Dictionary of files, indexed by normalized identifier.
- property Functions: dict[str, list[Function]]
Read-only property to access the declared functions (
_functions).- Returns:
Dictionary of functions, indexed by normalized identifier; each entry is a list of overloads.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- IndexDeclaredItems()
Index declared items listed in the sequential declaration region.
All lookup tables are cleared and all declared items are removed from
_namespacefirst. Then every declared item is added to_namespace, and additionally to the lookup table matching its kind. Items of an unhandled kind are passed to_IndexOtherDeclaredItem(). A protected type body completes its protected type, so it’s skipped. Indexing again yields the same lookup tables and namespace.See also
IndexDeclaredItems()The same algorithm for a concurrent declaration region.
- Raises:
UnhandledCriticalWarningError – If an identifier is declared twice in a declarative region and no
WarningCollectorcollects theDuplicateDeclarationWarning.- Return type:
- InsertDeclaredItem(index, declaredItem)
Insert a declared item at a position of the declarative region.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
An identifier is declared once per declarative region: interface items and declared items count, including those of the language construct sharing the declarative region (an entity and its architecture, a package and its body). Subprograms are overloadable: a subprogram may share its identifier with other subprograms. A protected type body may share its identifier with its protected type, a full type with its incomplete type declaration, and a constant with its deferred constant. Items imported into the namespace (e.g. by a use clause) are hidden.
- Parameters:
index (
int) – Position, from0(first) to the number of declared items (append). A negative index counts from the end, as forlist.insert():-1inserts before the last declared item.declaredItem (
ModelEntity) – The declared item to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
AddDeclaredItem()→ Add a declared item at the end of the declarative region.
InsertDeclaredItemBefore()→ Insert a declared item before another declared item.
InsertDeclaredItemAfter()→ Insert a declared item after another declared item.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
- InsertDeclaredItemAfter(declaredItem, after)
Insert a declared item after another declared item.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to insert.after (
ModelEntity) – The declared item of this declarative region to insert after.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
InsertDeclaredItemBefore()→ Insert a declared item before another declared item.
- InsertDeclaredItemBefore(declaredItem, before)
Insert a declared item before another declared item.
The declared item’s parent is set to this declarative region. If the region is indexed, its identifiers are added to the region’s namespace and to the lookup table matching its kind.
- Parameters:
declaredItem (
ModelEntity) – The declared item to insert.before (
ModelEntity) – The declared item of this declarative region to insert before.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not a declaration allowed in this declarative region.
AlreadyInDesignError – If parameter ‘declaredItem’ already has a parent.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.
DuplicateDeclarationError – If an existing declaration of the declarative region shares an identifier with the declared item.
- Return type:
See also
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
InsertDeclaredItemAfter()→ Insert a declared item after another declared item.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateDeclarationRegions()
Iterate this declarative region and all declarative regions nested in it.
Nested regions are declarations (e.g. subprograms, generic subprograms, protected types, packages) and concurrent statements (blocks, processes, generate statements and their branches), each followed by the regions nested in it.
- Return type:
- Returns:
A generator to iterate the declarative regions, this region first.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)
Iterate the type marks of this declaration, each with the region and the place to look it up.
The place of a type mark is the declaration containing it. Declarations with type marks override this method, e.g. an object yields the type mark of its subtype indication, an array type its index and element subtypes.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples, in declaration order: none.
- LookupName(place, symbol, name, warningType)
Look up the declarations a simple name or an expanded name denotes at a place in this region.
A simple name is looked up at the place (
Lookup()). An expanded namepkg.Torlib.pkg.Tresolves its prefix:pkgto a package visible at the place, else to an enclosing declarative region of that name (e.g. the package or entity containing the place);lib.pkgby the library (workor a library whose name is visible in the design unit containing the place,IsLibraryVisible()) and the package’s name. Then the suffix is searched among the declarations of the package or region (FindDeclarations()).A failure is reported as a warning of the given type, whose label names the kind of name in the message (e.g.
Type mark); then no declaration is returned. A name, which is a part of the symbol’s name (e.g. the prefixsof the type marks'subtype), is reported as a prefix of the symbol’s name.- Parameters:
place (
ModelEntity) – The declaration containing the name.symbol (
Symbol) – The symbol containing the name.name (
Name) – The simple name or expanded name: the symbol’s name or a part of it.warningType (
type[UnresolvedNameWarning]) – The warning class reporting a failure.
- Return type:
- Returns:
Tuple of the directly visible declarations, empty if none is.
- Raises:
UnhandledCriticalWarningError – If the name isn’t visible, is ambiguous, or has a prefix, which isn’t a visible package or an enclosing region, and no
WarningCollectorcollects the warning.
- property Methods: list[Procedure | Function]
Read-only property to return the implemented methods, in declaration order.
A protected type body may also declare variables, types, subtypes, aliases and files, so this is the subprogram subset of
_declaredItemsrather than all of them.- Returns:
List of methods, in declaration order.
- MoveDeclaredItem(declaredItem, index)
Move a declared item to a position of the declarative region.
The declared item stays a declared item of this declarative region: only the order of the declared items changes.
If the region is indexed, the lookup tables and the namespace follow the new order: a list of overloads (e.g. in
Functions) follows the declaration order, and the namespace refers to the overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (IndexDeclaredItems()) after the move.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.index (
int) – Position of the declared item after the move, from0(first) to the number of declared items minus one (last). A negative index counts from the end, as for alistindex:-1moves the declared item to the end.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveDeclaredItemBefore()→ Move a declared item before another declared item.
MoveDeclaredItemAfter()→ Move a declared item after another declared item.
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- MoveDeclaredItemAfter(declaredItem, after)
Move a declared item after another declared item.
The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for
MoveDeclaredItem(). Moving a declared item after itself keeps it in place.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.after (
ModelEntity) – The declared item of this declarative region to move after.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a declared item of this declarative region.
- Return type:
See also
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
MoveDeclaredItemBefore()→ Move a declared item before another declared item.
- MoveDeclaredItemBefore(declaredItem, before)
Move a declared item before another declared item.
The declared item stays a declared item of this declarative region: only the order of the declared items changes, as for
MoveDeclaredItem(). Moving a declared item before itself keeps it in place.- Parameters:
declaredItem (
ModelEntity) – The declared item to move.before (
ModelEntity) – The declared item of this declarative region to move before.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a declared item of this declarative region.
- Return type:
See also
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
MoveDeclaredItemAfter()→ Move a declared item after another declared item.
- property Namespace: Namespace
Read-only property to access this region’s namespace (
_namespace).- Returns:
The namespace.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- Precedes(item, anchor, inclusive)
Check if an item precedes an anchor in this declarative region.
An item, which isn’t a declaration of this region (e.g. a use clause of the context clause), precedes every anchor.
- Parameters:
item (
ModelEntity|None) – The item in declaration order, orNonefor the implicit use clause.anchor (
ModelEntity) – A declaration of this region, e.g. the one containing the place of a lookup.inclusive (
bool) –True, if the anchor precedes itself, i.e. the place is nested inside the anchor.
- Return type:
- Returns:
True, if the item precedes the anchor.
- property Procedures: dict[str, list[Procedure]]
Read-only property to access the declared procedures (
_procedures).- Returns:
Dictionary of procedures, indexed by normalized identifier; each entry is a list of overloads.
- RemoveDeclaredItem(declaredItem)
Remove a declared item from the declarative region.
The declared item is detached: its parent is cleared. If the region is indexed, the declared item’s identifiers are removed from the region’s namespace and from the lookup table matching its kind first; they are checked before anything is changed. The declared item itself is unchanged and can be added to another declarative region, or inserted at another position.
The namespace refers to the overload declared last: removing it, the namespace refers to the remaining overload declared last. If another declaration shares an identifier with the declared item (e.g. a duplicate declaration read by a parser), the region is indexed again (
IndexDeclaredItems()) after the removal.- Parameters:
declaredItem (
ModelEntity) – The declared item to remove.- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item isn’t declared in its namespace.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.
- Return type:
See also
AddDeclaredItem()→ Add a declared item at the end of the declarative region.
InsertDeclaredItem()→ Insert a declared item at a position of the declarative region.
MoveDeclaredItem()→ Move a declared item to a position of the declarative region.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- ResolveTypeMark(place, symbol)
Resolve a type mark at its place in this region and set the symbol’s reference.
Algorithm
Clear the symbol’s reference.
Look up the type mark’s name (
LookupName()).An alias of a type is replaced by the type its name references.
If the declaration is a type, a subtype or a generic type, it becomes the symbol’s reference. A full type, which follows the place in the same region, is visible by its incomplete type declaration only to an access type.
An attribute name denoting a type (e.g.
s'subtype,A'element) is resolved part by part (Denote()); the type it denotes becomes the symbol’s reference.- Parameters:
place (
ModelEntity) – The declaration containing the type mark.symbol (
SubtypeSymbol) – The type mark.
- Raises:
UnhandledCriticalWarningError – If the type mark isn’t visible, is ambiguous, has a prefix, which isn’t a visible package, denotes no type, or denotes an incomplete type outside of an access type, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- SplitDeclaredItem(declaredItem)
Split a declared item with an identifier list into one declaration per identifier.
The declared item keeps its first identifier. For every other identifier, a new declaration is created by its
Copy()and inserted right after it, in list order; its parent is set to this declarative region. If the region is indexed, the namespace and lookup table entries of the other identifiers refer to the new declarations; they are checked before anything is changed. A declared item declaring one identifier is unchanged.- Parameters:
declaredItem (
ModelEntity) – The declared item to split.- Return type:
- Returns:
Tuple of declarations, one per identifier in list order, starting with the split declared item.
- Raises:
ValueError – If parameter ‘declaredItem’ is
None.TypeError – If parameter ‘declaredItem’ is not of type
ModelEntity.NotAChildError – If parameter ‘declaredItem’ is not a declared item of this declarative region.
NotInNamespaceError – If the region is indexed, and an identifier of the declared item refers to another declaration, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveDeclaredItem()→ Remove a declared item from the declarative region.
- property Subtypes: dict[str, Subtype]
Read-only property to access the declared subtypes (
_subtypes).- Returns:
Dictionary of subtypes, indexed by normalized identifier.
- property Types: dict[str, FullType]
Read-only property to access the declared types (
_types).- Returns:
Dictionary of types, indexed by normalized identifier.
- property Variables: dict[str, Variable]
Read-only property to access the declared variables (
_variables).- Returns:
Dictionary of variables, indexed by normalized identifier.
- _AddOverloadToNamespace(item)
Add a function or procedure to the namespace, if it’s the overload declared last.
The namespace keeps one entry per identifier: the overload declared last, as after
IndexDeclaredItems(), which adds interface items first, then declared items (_Declarations()).- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure, already an interface item or declared item of this region.- Return type:
- _AddToNamespace(element)
Add an element’s identifiers to this region’s namespace.
Nothing is added to a region not indexed yet:
IndexDeclaredItems()adds the element later. A generic subprogram is an overload (_AddOverloadToNamespace()).- Parameters:
element (
NamedEntityMixin|MultipleNamedEntityMixin) – The named element to add, e.g. an interface item.- Return type:
- _ClashingDeclarations(item)
Return the declarations sharing an identifier with the given item, which may not share it.
The declarations (
_Declarations()) and the labeled statements (_Labels()) of this declarative region and of the language constructs sharing it (_SharedRegions()) are searched: a statement label is declared implicitly. Items imported into the namespace (e.g. by a use clause) are no declarations.- Parameters:
item (
ModelEntity) – The new declaration, or the new labeled statement.- Return type:
- Returns:
Tuple of clashing declarations, interface items first, then declared items in declaration order, then labeled statements.
- _ConnectParentNamespace(parent)
Connect this region’s namespace to the namespace of the enclosing declarative region.
A declaration of this region then hides a same-named declaration of the enclosing region. A parent, which isn’t a declarative region (e.g. a subprogram of an interface list), has no namespace to connect to.
- Parameters:
parent (
ModelEntity) – The new parent of this region.- Return type:
- _DECLARED_ITEM_TYPES = (<class 'pyVHDLModel.Type.BaseType'>, <class 'pyVHDLModel.Subprogram.Subprogram'>, <class 'pyVHDLModel.DesignUnit.Package'>, <class 'pyVHDLModel.DesignUnit.PackageBody'>, <class 'pyVHDLModel.Object.Constant'>, <class 'pyVHDLModel.Object.Variable'>, <class 'pyVHDLModel.Object.File'>, <class 'pyVHDLModel.Declaration.Alias'>, <class 'pyVHDLModel.Declaration.Attribute'>, <class 'pyVHDLModel.Declaration.AttributeSpecification'>, <class 'pyVHDLModel.DesignUnit.UseClause'>)
Accepted classes of declared items (
pyVHDLModel).
- _Declarations()
Return all declarations of this declarative region.
A host class with interface items extends the list by its interface items, listed first.
- Return type:
- Returns:
Tuple of declarations: the declared items, in declaration order.
- _DeclaredItemsSharingIdentifiers(declaredItem)
Return the other declared items of this region sharing an identifier with the given declared item.
- Parameters:
declaredItem (
ModelEntity) – The declared item.- Return type:
- Returns:
List of declared items, in declaration order.
- _END_KEYWORDS: ClassVar[tuple[ReservedWord, ...]] = (ReservedWord.Protected, ReservedWord.Body)
Reserved words after
end.
- _IndexDeclaredItem(item)
Add a declared item to the namespace and to the lookup table matching its kind.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _IndexOtherDeclaredItem(item)
Hook for declared items the region doesn’t handle itself. Derived classes may override it.
An alias, an attribute declaration and a package (also a package instantiation) declared in the region are added to the namespace, without a lookup table.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _IndexOverload(item)
Add an inserted function or procedure to its lookup table and to the namespace.
The list of overloads follows the declaration order. The namespace is updated by
_AddOverloadToNamespace().- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The inserted function or procedure.- Return type:
- _IterateStatementRegions()
Iterate the declarative regions nested in the statements of this declarative region.
- Return type:
- Returns:
An empty generator.
- _Labels()
Return the labeled statements, whose labels are declared in this declarative region.
- Return type:
- Returns:
An empty tuple.
Check if two declarations may share an identifier in one declarative region.
Subprograms are overloadable. A protected type body completes its protected type, a full type completes its incomplete type, and a constant completes its deferred constant.
- Parameters:
item (
ModelEntity) – The new declaration.existing (
ModelEntity) – The existing declaration.
- Return type:
- Returns:
True, if both declarations may share an identifier.
- _RemoveDeclaredItemEntries(lookupTable, item)
Remove a declared item’s entries from a lookup table and from the namespace.
Every identifier is checked before anything is removed.
- Parameters:
lookupTable (
dict[str,Any]) – The lookup table matching the declared item’s kind.item (
NamedEntityMixin|MultipleNamedEntityMixin) – The declared item.
- Raises:
NotInNamespaceError – If an identifier of the declared item isn’t declared in the namespace.
NotInNamespaceError – If an identifier of the declared item refers to another element, e.g. a duplicate declaration.
- Return type:
- _RemoveDeclaredItemsFromNamespace()
Remove all declared items of this region from its namespace.
Interface items of this region and items imported from elsewhere (e.g. by a use clause) are kept.
- Return type:
- _RemoveFromNamespace(element)
Remove an element’s identifiers from this region’s namespace.
Nothing is removed from a region not indexed yet, as its namespace doesn’t contain the element. A generic subprogram is an overload (
_RemoveOverloadFromNamespace()).- Parameters:
element (
NamedEntityMixin|MultipleNamedEntityMixin) – The named element to remove, e.g. an interface item.- Raises:
NotInNamespaceError – If the region is indexed, and an identifier of the element isn’t declared in the namespace.
NotInNamespaceError – If the region is indexed, and an identifier of the element refers to another element, e.g. a duplicate declaration.
- Return type:
- _RemoveOverloadFromNamespace(item)
Remove a function or procedure from the namespace.
Removing the overload the namespace refers to, the namespace refers to the remaining overload declared last (
_Declarations()), or the identifier is removed, if no overload remains. Removing another overload leaves the namespace unchanged. The namespace is checked before it’s changed.- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure, still an interface item or declared item of this region.- Raises:
NotInNamespaceError – If the identifier isn’t declared in the namespace.
NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
Return the other language constructs forming one declarative region with this one.
An entity and each of its architectures form one declarative region, as do a package and its body. Derived classes override it.
- Return type:
- Returns:
Tuple of declarative regions.
- _UnindexDeclaredItem(item)
Remove a declared item from the namespace and from the lookup table matching its kind.
- Parameters:
item (
ModelEntity) – The declared item.- Return type:
- _UnindexOtherDeclaredItem(item)
Hook to remove declared items the region doesn’t handle itself. Derived classes may override it.
An alias, an attribute declaration and a package are removed from the namespace.
- Parameters:
item (
ModelEntity) – The declared item.- Raises:
NotInNamespaceError – If the item is an alias, an attribute declaration or a package, which isn’t declared in the namespace.
- Return type:
- _UnindexOverload(item)
Remove a function or procedure from its lookup table and from the namespace.
The namespace is updated first, by
_RemoveOverloadFromNamespace().- Parameters:
item (
NamedEntityMixin|MultipleNamedEntityMixin) – The function or procedure to remove, still a declared item of this region.- Raises:
NotInNamespaceError – If the identifier isn’t declared in the namespace.
NotInNamespaceError – If the identifier refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()
Formats the type declaration.
Format:
type myType- Return type:
- Returns:
Formatted type declaration.
- _areDeclaredItemsIndexed
TrueifIndexDeclaredItems()filled the namespace.
- _constants
Dictionary of all constants declared in this sequential declaration region.
- _declaredItems
List of all declared items in this sequential declaration region.
- _documentation
The associated documentation of a model entity.
- _files
Dictionary of all files declared in this sequential declaration region.
- _functions
Dictionary of all functions declared in this sequential declaration region, indexed by name; each entry is a list of overloads.
- _identifier
The identifier of a model entity.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _objectVertex
The vertex representing this type in the design’s object graph.
- _parent
Reference to a parent entity in the logical model hierarchy.
- _procedures
Dictionary of all procedures declared in this sequential declaration region, indexed by name; each entry is a list of overloads.
- _subtypes
Dictionary of all subtypes declared in this sequential declaration region.
- _types
Dictionary of all types declared in this sequential declaration region.
- _variables
Dictionary of all variables declared in this sequential declaration region.
- class pyGHDL.dom.Type.AccessType(node, identifier, designatedSubtype, documentation=None)[source]
Represents an access type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.AccessType.Example
type line is access string;
Inheritance
- __init__(node, identifier, designatedSubtype, documentation=None)[source]
Initializes an access type definition.
- Parameters:
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses an access type IIR and returns an
AccessTypeinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property DesignatedSubtype: Symbol
Read-only property to access the designated subtype (
_designatedSubtype).- Returns:
The designated subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)[source]
Iterate the type marks of this access type: the subtype its values designate.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this type.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the designated subtype.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the access type definition.
Format:
ptr is access node- Return type:
- Returns:
Formatted access type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.FileType(node, identifier, designatedSubtype, documentation=None)[source]
Represents a file type.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.FileType.Example
type text is file of string;
Inheritance
- __init__(node, identifier, designatedSubtype, documentation=None)[source]
Initializes a file type definition.
- Parameters:
- Return type:
None
- classmethod parse(typeName, typeDefinitionNode, documentation=None)[source]
Parses a file type IIR and returns an
FileTypeinstance.
- _position: Position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to return the base type of this type: the type itself (IEEE Std 1076-2008, 5.1).
A subtype returns the base type of the type it is derived from (
BaseType).- Returns:
The base type.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property DesignatedSubtype: Symbol
Read-only property to access the designated subtype (
_designatedSubtype).- Returns:
The designated subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)[source]
Iterate the type marks of this file type: the subtype of its values.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this type.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the designated subtype.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)
Reset the references
ResolveReferences()derived: the references of this declaration’s type marks.A use clause, an alias and a subtype extend this method.
- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- ResolveReferences(designUnit, region)
Resolve the references of this declaration: its type marks (
IterateTypeMarks()).Each type mark is resolved at its place by the region it is looked up in (
ResolveTypeMark()). An incomplete type, an alias and a subtype extend this method.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the file type definition.
Format:
ft is file of character- Return type:
- Returns:
Formatted file type definition.
- _objectVertex: Vertex
The vertex representing this type in the design’s object graph.
- _parent: ModelEntity
Reference to a parent entity in the logical model hierarchy.
- class pyGHDL.dom.Type.Subtype(node, subtypeName, symbol, documentation=None)[source]
Represents a subtype.
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Type.Subtype.Inheritance
- __init__(node, subtypeName, symbol, documentation=None)[source]
Initializes a subtype declaration.
- Parameters:
- Return type:
None
- _iirNode
The IIR node in libghdl’s tree this DOM object was translated from.
- _position
The IIR node’s position in the source file, resolved on first access and then cached.
- property BaseType: BaseType
Read-only property to access the base type (
_baseType).It is set, when the subtype’s type mark is resolved (
ResolveReferences()).- Returns:
The base type, or
Noneif the type mark isn’t resolved.
- DenoteBy(name, region, place, symbol)
Return this type or subtype, the model entity a name in a type mark denotes.
- Parameters:
name (
Name) – The name denoting this declaration, a part of the type mark.region (
DeclarativeRegionMixin) – The declarative region containing the type mark.place (
ModelEntity) – The declaration containing the type mark.symbol (
Symbol) – The type mark.
- Return type:
- Returns:
This type or subtype.
- property Documentation: str | None
Read-only property to access the model entity’s documentation (
_documentation).- Returns:
Associated documentation of a model entity.
- GetAncestor(type)
Return the closest ancestor of the given
typefound by walking the parent chain upwards.Iterates the parent chain - starting at this model entity - upwards (toward the root of the model) until an ancestor of the requested type is found.
- Parameters:
type (
Type) – Class (type) of the ancestor to find.- Return type:
- Returns:
The closest ancestor of the requested type.
- Raises:
AncestorNotFoundError – If the root of the model is reached without finding an ancestor of the requested type.
- GetIdentifier(normalizedIdentifier)
Return the identifier as declared, for the model entity’s normalized identifier.
- classmethod GetMethodsWithAttributes(predicate=None)
Return the class’ methods that carry at least one matching attribute.
- Parameters:
predicate (
type[TAttr] |Iterable[type[TAttr]] |None) – Optional, an attribute class, an iterable of attribute classes, orNoneto accept every attribute.- Return type:
- Returns:
Dictionary of methods and the matching attributes attached to them.
- Raises:
ValueError – If an element of parameter ‘predicate’ is not a sub-class of
Attribute.ValueError – If parameter ‘predicate’ is neither an attribute class nor an iterable of those.
- property Identifier: str
Read-only property to access the model entity’s identifier (
_identifier).- Returns:
Name of a model entity.
- property IsOverloadable: bool
Check if this model entity is an overloadable declaration: it may share its designator with other overloadable declarations.
Subprograms, enumeration literals and aliases, which may denote one of them, are overloadable; they override this property.
- Returns:
True, if this model entity is an overloadable declaration.
- IterateImplicitDeclarations()
Iterate the declarations this declaration implies.
An enumerated type implies its enumeration literals, a physical type its units; they override this method.
- Return type:
- Returns:
A generator to iterate (normalized designator, declaration) pairs, in declaration order: none.
- IterateTypeMarks(region)[source]
Iterate the type marks of this subtype declaration: the type mark it is derived from.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this subtype.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the subtype’s type mark.
- property NormalizedIdentifier: str
Read-only property to access the model entity’s normalized identifier (
_normalizedIdentifier).See also
- Returns:
Normalized name of a model entity.
- property Parent: ModelEntity
Property to access the model entity’s parent element reference in a logical hierarchy (
_parent).- Returns:
Reference to the parent entity.
- property Position: Position
Cached read-only property to access an IIR’s position in source code (
_position).If
_positionis None, resolve the position object from_iirNode- Returns:
The IIR’s position in the source file.
- ResetReferences(designUnit, region)[source]
Reset the reference of this subtype’s type mark and its base type; a subtype of a predefined library (
IsPredefined) keeps its base type.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Return type:
- property ResolutionFunction: Function
Read-only property to access the resolution function (
_resolutionFunction).- Returns:
The resolution function.
- ResolveReferences(designUnit, region)[source]
Resolve the type mark of this subtype and set its base type (
BaseType): the resolved type, or the base type of the resolved subtype;None, if the type mark isn’t resolved.- Parameters:
designUnit (
DesignUnit) – The design unit containing this declaration.region (
DeclarativeRegionMixin) – The declarative region declaring this declaration.
- Raises:
UnhandledCriticalWarningError – If a type mark can’t be resolved, and no
WarningCollectorcollects theUnresolvedTypeMarkWarning.- Return type:
- __getstate__()
Return the object’s state for pickling, collecting every slot of the class hierarchy.
- __new__(**kwargs)
- __setstate__(state)
Restore the object’s state from unpickling, requiring exactly the slots of the class hierarchy.
- __str__()[source]
Formats the subtype declaration.
Format:
subtype byte is bit_vectorThe base type is rendered, so an unlinked subtype shows
None.- Return type:
- Returns:
Formatted subtype declaration.
- _documentation
The associated documentation of a model entity.
- _identifier
The identifier of a model entity.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _objectVertex
The vertex representing this type in the design’s object graph.
- _parent
Reference to a parent entity in the logical model hierarchy.