pyGHDL.dom.Subprogram
This module implements derived subprogram classes from pyVHDLModel.Subprogram.
Classes
FunctionParserMixin: Mixin translating the IIR node of a function declaration, shared byFunctionandFunctionMethod.Function: This class implements apyGHDL.domobject derived frompyVHDLModel.Subprogram.Function.FunctionMethod: This class implements apyGHDL.domobject derived frompyVHDLModel.Subprogram.FunctionMethod.ProcedureParserMixin: Mixin translating the IIR node of a procedure declaration, shared byProcedureandProcedure: This class implements apyGHDL.domobject derived frompyVHDLModel.Subprogram.Procedure.ProcedureMethod: This class implements apyGHDL.domobject derived frompyVHDLModel.Subprogram.ProcedureMethod.FunctionInstantiation: .. admonition:: ExampleProcedureInstantiation: .. admonition:: Example
Classes
- class pyGHDL.dom.Subprogram.FunctionParserMixin[source]
Mixin translating the IIR node of a function declaration, shared by
FunctionandFunctionMethod.Inheritance
- classmethod parse(functionNode)[source]
Translates the IIR node of the function declaration to an object of this class.
- 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.
- class pyGHDL.dom.Subprogram.Function(node, functionName, returnType, isPure=True, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Subprogram.Function.Represents a function.
A function returns a value of its return type (
ReturnType) and is either pure or impure (IsPure). Besides its parameters, it has its own declarative part (DeclaredItems) and statements (Statements).Example
function fun(constant c : in positive) return integer is -- ^^^ <- Identifier -- ^^^^^^^^^^^^^^^^^^^^^^^^ <- ParameterItems -- ^^^^^^^ <- ReturnType variable tmp : integer; --^^^^^^^^^^^^^^^^^^^^^^^ <- DeclaredItems begin tmp := c; --^^^^^^^^^ <- Statements return tmp; end function;
Inheritance
- Parameters:
- __init__(node, functionName, returnType, isPure=True, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
Initializes a function.
- Parameters:
node (
Iir) – The IIR node this object was translated from.functionName (
str) – The function’s identifier.returnType (
Symbol) – Reference to the subtype of the function’s return value.isPure (
bool) – Optional,Trueif the subprogram was declared pure.genericItems (
List[GenericInterfaceItemMixin]) – Optional, list of all generics, in declaration order.parameterItems (
List[ParameterInterfaceItemMixin]) – Optional, list of all parameters, in declaration order.declaredItems (
List) – Optional, list of all declared items in this sequential declaration region.statements (List[SequentialStatement]) – Optional, list of all sequential statements in the subprogram’s body.
documentation (
str) – Optional, the documentation comment associated with this declaration.
- 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.
- 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.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- IterateTypeMarks(region)[source]
Iterate the type marks of this function: its return type.
The return type is looked up in the function’s own region, before the function’s declared items: at its first declared item, or at the function itself. The function’s parameters are declarations of its own region.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this function.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the return type.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property ReturnType: SubtypeSymbol
Read-only property to access the return type (
_returnType).- Returns:
The return type.
- property Signature: SubprogramSignature
Read-only property to access the function’s signature (
_signature): the type marks of its parameters and of its return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- 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.
- Visit(visitor)[source]
Walk this function, its generic clause, its parameters, its return type, its declared items and its statements with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Function,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _returnType: SubtypeSymbol
Reference to the subtype of the function’s return value.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _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.Subprogram.FunctionMethod(node, functionName, returnType, isPure=True, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Subprogram.FunctionMethod.Represents a function declared as a method of a protected type.
The protected type is available as
ProtectedType.See also
Inheritance
- Parameters:
- __init__(node, functionName, returnType, isPure=True, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
Initializes a function declared as a method of a protected type.
- Parameters:
node (
Iir) – The IIR node this object was translated from.functionName (
str) – The function’s identifier.returnType (
Symbol) – Reference to the subtype of the function’s return value.isPure (
bool) – Optional,Trueif the subprogram was declared pure.genericItems (
List[GenericInterfaceItemMixin]) – Optional, list of all generics, in declaration order.parameterItems (
List[ParameterInterfaceItemMixin]) – Optional, list of all parameters, in declaration order.declaredItems (
List) – Optional, list of all declared items in this sequential declaration region.statements (List[SequentialStatement]) – Optional, list of all sequential statements in the subprogram’s body.
documentation (
str) – Optional, the documentation comment associated with this declaration.
- 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.
- 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.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- IterateTypeMarks(region)
Iterate the type marks of this function: its return type.
The return type is looked up in the function’s own region, before the function’s declared items: at its first declared item, or at the function itself. The function’s parameters are declarations of its own region.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this function.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the return type.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- property ProtectedType: ProtectedType
Read-only property to access the protected type (
_protectedType).- Returns:
The protected type.
- 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.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property ReturnType: SubtypeSymbol
Read-only property to access the return type (
_returnType).- Returns:
The return type.
- property Signature: SubprogramSignature
Read-only property to access the function’s signature (
_signature): the type marks of its parameters and of its return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- 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.
- Visit(visitor)
Walk this function, its generic clause, its parameters, its return type, its declared items and its statements with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Function,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _protectedType
Reference to the protected type this method belongs to.
- _returnType: SubtypeSymbol
Reference to the subtype of the function’s return value.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _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.Subprogram.ProcedureParserMixin[source]
Mixin translating the IIR node of a procedure declaration, shared by
ProcedureandProcedureMethod.Inheritance
- classmethod parse(procedureNode)[source]
Translates the IIR node of the procedure declaration to an object of this class.
- 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.
- class pyGHDL.dom.Subprogram.Procedure(node, procedureName, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Subprogram.Procedure.Represents a procedure.
Unlike a function, a procedure returns no value. Besides its parameters, it has its own declarative part (
DeclaredItems) and statements (Statements).Example
procedure proc(signal s : in bit; variable v : out bit) is -- ^^^^ <- Identifier -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <- ParameterItems variable tmp : bit; --^^^^^^^^^^^^^^^^^^^ <- DeclaredItems begin tmp := s; --^^^^^^^^^ <- Statements v := tmp; end procedure;
Inheritance
- Parameters:
- __init__(node, procedureName, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
Initializes a procedure.
- Parameters:
node (
Iir) – The IIR node this object was translated from.procedureName (
str) – The procedure’s identifier.genericItems (
List[GenericInterfaceItemMixin]) – Optional, list of all generics, in declaration order.parameterItems (
List[ParameterInterfaceItemMixin]) – Optional, list of all parameters, in declaration order.declaredItems (
List) – Optional, list of all declared items in this sequential declaration region.statements (List[SequentialStatement]) – Optional, list of all sequential statements in the subprogram’s body.
documentation (
str) – Optional, the documentation comment associated with this declaration.
- 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.
- 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.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property Signature: SubprogramSignature
Read-only property to access the subprogram’s signature (
_signature): the type marks of its parameters, and of a function’s return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- 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.
- Visit(visitor)[source]
Walk this procedure, its generic clause, its parameters, its declared items and its statements with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Procedure,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _SUBPROGRAM_KEYWORD: ClassVar[str] = 'procedure'
The VHDL keyword introducing this subprogram kind.
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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _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.Subprogram.ProcedureMethod(node, procedureName, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
This class implements a
pyGHDL.domobject derived frompyVHDLModel.Subprogram.ProcedureMethod.Represents a procedure declared as a method of a protected type.
The protected type is available as
ProtectedType.See also
Inheritance
- Parameters:
- __init__(node, procedureName, genericItems=None, parameterItems=None, declaredItems=None, statements=None, documentation=None)[source]
Initializes a procedure declared as a method of a protected type.
- Parameters:
node (
Iir) – The IIR node this object was translated from.procedureName (
str) – The procedure’s identifier.genericItems (
List[GenericInterfaceItemMixin]) – Optional, list of all generics, in declaration order.parameterItems (
List[ParameterInterfaceItemMixin]) – Optional, list of all parameters, in declaration order.declaredItems (
List) – Optional, list of all declared items in this sequential declaration region.statements (List[SequentialStatement]) – Optional, list of all sequential statements in the subprogram’s body.
documentation (
str) – Optional, the documentation comment associated with this declaration.
- 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.
- 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.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- property ProtectedType: ProtectedType
Read-only property to access the protected type (
_protectedType).- Returns:
The protected type.
- 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.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property Signature: SubprogramSignature
Read-only property to access the subprogram’s signature (
_signature): the type marks of its parameters, and of a function’s return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- 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.
- Visit(visitor)
Walk this procedure, its generic clause, its parameters, its declared items and its statements with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Procedure,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _SUBPROGRAM_KEYWORD: ClassVar[str] = 'procedure'
The VHDL keyword introducing this subprogram kind.
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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _protectedType
Reference to the protected type this method belongs to.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _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.Subprogram.FunctionInstantiation(node, functionName, subprogramReference, genericAssociationItems=None, documentation=None)[source]
Example
function add_int is new work.pkg.generic_add generic map (T => integer);
Note
Neither
ReturnTypenorIsPurecan be read here: verified against real GHDL thatGet_Return_Type/Get_Pure_Flagon aFunction_Instantiation_Declarationare not resolved at the parse-only level this project operates at (Get_Pure_FlagreturnsFalseeven for an actually-pure referenced function) - both are properties of the referenced uninstantiated function, not the instantiation itself, and can only be known by resolving it.Inheritance
- Parameters:
- __init__(node, functionName, subprogramReference, genericAssociationItems=None, documentation=None)[source]
Initializes a function instantiation.
- Parameters:
node (
Iir) – The IIR node this object was translated from.functionName (
str) – The function’s identifier.subprogramReference (
Symbol) – Reference to the instantiated generic subprogram.genericAssociationItems (
List) – Optional, list of all generic associations in the generic map aspect.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(functionNode)[source]
Translates the IIR node of the function declaration to a
FunctionInstantiation.
- _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.
- AddGenericAssociationItem(genericAssociationItem)
Add a generic association at the end of the generic map aspect.
The association’s parent is set to this language construct.
- Parameters:
genericAssociationItem (
GenericAssociationItem) – The generic association to add.- Raises:
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.
DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.
AssociationOrderError – If the association is positional, and the generic map aspect has a named association.
- Return type:
See also
InsertGenericAssociationItem()→ Insert a generic association at a position of the generic map aspect.
RemoveGenericAssociationItem()→ Remove a generic association from the generic map aspect.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericAssociationItems: list[GenericAssociationItem]
Read-only property to access the generic associations (
_genericAssociationItems).- Returns:
List of generic association items.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericAssociationItem(index, genericAssociationItem)
Insert a generic association at a position of the generic map aspect.
The association’s parent is set to this language construct.
A named association (
formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.- Parameters:
index (
int) – Position, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.
DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.
AssociationOrderError – If the association is positional, and a named association precedes the position.
AssociationOrderError – If the association is named, and a positional association follows the position.
- Return type:
See also
AddGenericAssociationItem()→ Add a generic association at the end of the generic map aspect.
RemoveGenericAssociationItem()→ Remove a generic association from the generic map aspect.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- IterateTypeMarks(region)
Iterate the type marks of this function: its return type.
The return type is looked up in the function’s own region, before the function’s declared items: at its first declared item, or at the function itself. The function’s parameters are declarations of its own region.
- Parameters:
region (
DeclarativeRegionMixin) – The declarative region declaring this function.- Return type:
Generator[tuple[DeclarativeRegionMixin,ModelEntity,SubtypeSymbol]]- Returns:
A generator to iterate (region, place, type mark) tuples: the return type.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- RemoveGenericAssociationItem(genericAssociationItem)
Remove a generic association from the generic map aspect.
The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.
- Parameters:
genericAssociationItem (
GenericAssociationItem) – The generic association to remove.- Raises:
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.
- Return type:
See also
AddGenericAssociationItem()→ Add a generic association at the end of the generic map aspect.
InsertGenericAssociationItem()→ Insert a generic association at a position of the generic map aspect.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property ReturnType: SubtypeSymbol | None
Read-only property to access the return type (
_returnType).- Returns:
The return type, or
Noneif not set.
- property Signature: SubprogramSignature
Read-only property to access the function’s signature (
_signature): the type marks of its parameters and of its return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- property SubprogramReference: SubprogramReferenceSymbol
Read-only property to access the subprogram reference (
_subprogramReference).- Returns:
The subprogram reference.
- 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.
- Visit(visitor)[source]
Walk this function instantiation, its generic function and its generic map aspect with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Function,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericAssociationItems
List of all generic associations.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _returnType: SubtypeSymbol
Reference to the subtype of the function’s return value.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _subprogramReference
Reference to the instantiated generic subprogram.
- _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.Subprogram.ProcedureInstantiation(node, procedureName, subprogramReference, genericAssociationItems=None, documentation=None)[source]
Example
procedure my_proc is new work.pkg.generic_proc generic map (T => integer);
Inheritance
- Parameters:
- __init__(node, procedureName, subprogramReference, genericAssociationItems=None, documentation=None)[source]
Initializes a procedure instantiation.
- Parameters:
node (
Iir) – The IIR node this object was translated from.procedureName (
str) – The procedure’s identifier.subprogramReference (
Symbol) – Reference to the instantiated generic subprogram.genericAssociationItems (
List) – Optional, list of all generic associations in the generic map aspect.documentation (
str) – Optional, the documentation comment associated with this declaration.
- Return type:
None
- classmethod parse(procedureNode)[source]
Translates the IIR node of the procedure declaration to a
ProcedureInstantiation.
- _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.
- AddGenericAssociationItem(genericAssociationItem)
Add a generic association at the end of the generic map aspect.
The association’s parent is set to this language construct.
- Parameters:
genericAssociationItem (
GenericAssociationItem) – The generic association to add.- Raises:
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.
DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.
AssociationOrderError – If the association is positional, and the generic map aspect has a named association.
- Return type:
See also
InsertGenericAssociationItem()→ Insert a generic association at a position of the generic map aspect.
RemoveGenericAssociationItem()→ Remove a generic association from the generic map aspect.
- AddGenericItem(genericItem, group=None)
Add a generic at the end of the generic clause, or at the end of a generic group.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a generic group, the generic joins the last generic group, or forms a new unnamed generic group if there are no generics.
- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to add.group (
GenericGroup|None) – Optional, the generic group of this language construct to add the generic to, at its end. Default:None, the end of the generic clause.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- AddParameterItem(parameterItem, group=None)
Add a parameter at the end of the parameter list, or at the end of a parameter group.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one. Without a parameter group, the parameter joins the last parameter group, or forms a new unnamed parameter group if there are no parameters.
- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to add.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to add the parameter to, at its end. Default:None, the end of the parameter list.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- AddStatement(statement)
Add a sequential statement at the end of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to add.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- 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)
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.
- 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.
- property GenericAssociationItems: list[GenericAssociationItem]
Read-only property to access the generic associations (
_genericAssociationItems).- Returns:
List of generic association items.
- property GenericCount: int
Read-only property to return the number of generics declared by
_genericItems.A generic constant item with several identifiers (
generic (A, B : natural)) declares several generics.- Returns:
The number of generics.
- property GenericGroups: list[GenericGroup]
Read-only property to access the generic groups (
_genericGroups).The generic groups partition the generic clause: concatenated in order, they list every generic exactly once, in declaration order.
- Returns:
List of generic groups, in declaration order.
- property GenericItems: list[GenericInterfaceItemMixin]
Read-only property to access the generic items (
_genericItems).- Returns:
List of generic items.
- 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()
A subprogram’s generics and parameters share the declarative region of its declarative part.
- 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.
- InsertGenericAssociationItem(index, genericAssociationItem)
Insert a generic association at a position of the generic map aspect.
The association’s parent is set to this language construct.
A named association (
formal => actual) can’t repeat the formal of another named association of the generic map aspect. Only formals given as a simple name are compared: a partial association (a(0) => x) or a conversion function (to_integer(a) => x) is accepted. All positional associations precede the named associations.- Parameters:
index (
int) – Position, from0(first) to the number of generic associations (append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic association.genericAssociationItem (
GenericAssociationItem) – The generic association to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.AlreadyInDesignError – If parameter ‘genericAssociationItem’ already has a parent.
DuplicateGenericAssociationError – If the association is named, and another named association of the generic map aspect has the same formal.
AssociationOrderError – If the association is positional, and a named association precedes the position.
AssociationOrderError – If the association is named, and a positional association follows the position.
- Return type:
See also
AddGenericAssociationItem()→ Add a generic association at the end of the generic map aspect.
RemoveGenericAssociationItem()→ Remove a generic association from the generic map aspect.
- InsertGenericItem(index, genericItem, group=None)
Insert a generic at a position of the generic clause.
The generic’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a generic group, the generic joins the generic group of the generic before
index; at index0, the generic group of the first generic. If there are no generics, the generic forms a new unnamed generic group. A generic group given must containindexor end at it, so the generic groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofGenericItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last generic.genericItem (
GenericInterfaceItemMixin) – The generic to insert.group (
GenericGroup|None) – Optional, the generic group of this language construct to insert the generic into. Default:None, the generic group of the generic beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.AlreadyInDesignError – If parameter ‘genericItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
GenericGroup.NotAChildError – If parameter ‘group’ is not a generic group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateGenericError – If an existing declaration of the language construct shares an identifier with the generic.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- InsertParameterItem(index, parameterItem, group=None)
Insert a parameter at a position of the parameter list.
The parameter’s parent is set to this language construct, and its identifiers are added to the language construct’s namespace, if it has one.
Without a parameter group, the parameter joins the parameter group of the parameter before
index; at index0, the parameter group of the first parameter. If there are no parameters, the parameter forms a new unnamed parameter group. A parameter group given must containindexor end at it, so the parameter groups stay contiguous.- Parameters:
index (
int) – Position, from0(first) to the length ofParameterItems(append). A negative index counts from the end, as forlist.insert():-1inserts before the last parameter.parameterItem (
ParameterInterfaceItemMixin) – The parameter to insert.group (
ParameterGroup|None) – Optional, the parameter group of this language construct to insert the parameter into. Default:None, the parameter group of the parameter beforeindex.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.AlreadyInDesignError – If parameter ‘parameterItem’ already has a parent.
TypeError – If parameter ‘group’ is not of type
ParameterGroup.NotAChildError – If parameter ‘group’ is not a parameter group of this language construct.
ValueError – If parameter ‘group’ neither contains nor ends at parameter ‘index’.
DuplicateParameterError – If an existing declaration of the language construct shares an identifier with the parameter.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- InsertStatement(index, statement)
Insert a sequential statement at a position of this construct.
The statement’s parent is set to this construct.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region: the statement’s label and the labels of statements nested in it (in branches, case alternatives and loops) may neither repeat another label of the body, nor an identifier declared in the region. A construct not in a process or subprogram (yet) checks the labels of its own statements. An unlabeled statement declares nothing.
- Parameters:
index (
int) – Position, from0(first) to the number of statements (append). A negative index counts from the end, as forlist.insert():-1inserts before the last statement.statement (
SequentialStatement) – The sequential statement to insert.
- Raises:
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ already has a parent.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
InsertStatementAfter()→ Insert a sequential statement after another statement.
RemoveStatement()→ Remove a sequential statement from this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- InsertStatementAfter(statement, after)
Insert a sequential statement after another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.after (
SequentialStatement) – The statement of this construct to insert after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementBefore()→ Insert a sequential statement before another statement.
- InsertStatementBefore(statement, before)
Insert a sequential statement before another statement of this construct.
The statement’s parent is set to this construct.
- Parameters:
statement (
SequentialStatement) – The sequential statement to insert.before (
SequentialStatement) – The statement of this construct to insert before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
SequentialStatement.AlreadyInDesignError – If parameter ‘statement’ 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 statement of this construct.
DuplicateLabelError – If the declarative region already declares a label of the statement.
- Return type:
See also
InsertStatement()→ Insert a sequential statement at a position of this construct.
InsertStatementAfter()→ Insert a sequential statement after another statement.
- property IsOverloadable: bool
Check if this subprogram is overloadable: always, it may share its designator with other subprograms and enumeration literals.
- Returns:
True.
- property IsPure: bool
Check if the subprogram is pure (
_isPure).- Returns:
True, if the subprogram is pure.
- 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.
- IterateSingleGenericDeclarations(predicate=None)
Iterate all generics per declared identifier, in declaration order.
A generic constant yields one single declaration per identifier:
generic (A, B : positive)yields two. A generic type, subprogram or package declares exactly one identifier and is yielded itself.- Parameters:
predicate (
Callable[[SingleGenericDeclarationMixin|GenericInterfaceItemMixin],bool] |None) – Optional, filter function to select the yielded generics. Default: all.- Return type:
Generator[SingleGenericDeclarationMixin|GenericInterfaceItemMixin]- Returns:
A generator to iterate all (selected) generics.
- IterateSingleParameterDeclarations(predicate=None)
Iterate all parameters per declared identifier, in declaration order.
A parameter yields one single declaration per identifier:
(a, b : in integer)yields two.- Parameters:
predicate (
Callable[[SingleParameterDeclarationMixin],bool] |None) – Optional, filter function to select the yielded parameters. Default: all.- Return type:
- Returns:
A generator to iterate all (selected) parameters.
- 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.
- 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.
- MoveGenericItem(genericItem, index)
Move a generic to a position of the generic clause.
The generic stays a generic of this language construct: only the order of the generic clause changes. A generic subprogram is an overload: if the language construct’s namespace is indexed, it refers to the overload declared last afterwards.
The generic leaves its generic group, like
RemoveGenericItem(), and joins a generic group, likeInsertGenericItem()without a generic group: the generic group of the generic before its new position; at index0, the generic group of the first generic. A move to the generic’s current position changes nothing.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to move.index (
int) – Position of the generic after the move, from0(first) to the length ofGenericItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the generic to the end.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
NotInNamespaceError – If the namespace is indexed, and the identifier of a generic subprogram refers to an element, which is no overload, e.g. a duplicate declaration.
- Return type:
See also
InsertGenericItem()→ Insert a generic at a position of the generic clause.
RemoveGenericItem()→ Remove a generic from the generic clause.
- MoveParameterItem(parameterItem, index)
Move a parameter to a position of the parameter list.
The parameter stays a parameter of this language construct: only the order of the parameter list changes.
The parameter leaves its parameter group, like
RemoveParameterItem(), and joins a parameter group, likeInsertParameterItem()without a parameter group: the parameter group of the parameter before its new position; at index0, the parameter group of the first parameter. A move to the parameter’s current position changes nothing.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to move.index (
int) – Position of the parameter after the move, from0(first) to the length ofParameterItemsminus one (last). A negative index counts from the end, as for alistindex:-1moves the parameter to the end.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- MoveStatement(statement, index)
Move a sequential statement to a position of this construct.
The statement stays a statement of this construct: only the order of the statements changes.
- Parameters:
statement (
SequentialStatement) – The sequential statement to move.index (
int) – Position of the statement after the move, from0(first) to the number of statements minus one (last). A negative index counts from the end, as for alistindex:-1moves the statement to the end.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘index’ is
None.ValueError – If parameter ‘index’ is out of range.
- Return type:
See also
MoveStatementBefore()→ Move a sequential statement before another statement.
MoveStatementAfter()→ Move a sequential statement after another statement.
InsertStatement()→ Insert a sequential statement at a position of this construct.
RemoveStatement()→ Remove a sequential statement from this construct.
- MoveStatementAfter(statement, after)
Move a sequential statement after another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement after itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.after (
SequentialStatement) – The statement of this construct to move after.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘after’ is
None.TypeError – If parameter ‘after’ is not of type
ModelEntity.NotAChildError – If parameter ‘after’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementBefore()→ Move a sequential statement before another statement.
- MoveStatementBefore(statement, before)
Move a sequential statement before another statement of this construct.
The statement stays a statement of this construct: only the order of the statements changes, as for
MoveStatement(). Moving a statement before itself keeps it in place.- Parameters:
statement (
SequentialStatement) – The sequential statement to move.before (
SequentialStatement) – The statement of this construct to move before.
- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
ValueError – If parameter ‘before’ is
None.TypeError – If parameter ‘before’ is not of type
ModelEntity.NotAChildError – If parameter ‘before’ is not a statement of this construct.
- Return type:
See also
MoveStatement()→ Move a sequential statement to a position of this construct.
MoveStatementAfter()→ Move a sequential statement after another statement.
- 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 ParameterCount: int
Read-only property to return the number of parameters declared by
_parameterItems.A parameter item with several identifiers (
procedure p(a, b : in bit)) declares several parameters.- Returns:
The number of parameters.
- property ParameterGroups: list[ParameterGroup]
Read-only property to access the parameter groups (
_parameterGroups).The parameter groups partition the parameter list: concatenated in order, they list every parameter exactly once, in declaration order.
- Returns:
List of parameter groups, in declaration order.
- property ParameterItems: list[ParameterInterfaceItemMixin]
Read-only property to access the parameter items (
_parameterItems).- Returns:
List of parameter items.
- 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.
- RemoveGenericAssociationItem(genericAssociationItem)
Remove a generic association from the generic map aspect.
The association is detached: its parent is cleared. The association itself is unchanged and can be added to another language construct, or inserted at another position.
- Parameters:
genericAssociationItem (
GenericAssociationItem) – The generic association to remove.- Raises:
ValueError – If parameter ‘genericAssociationItem’ is
None.TypeError – If parameter ‘genericAssociationItem’ is not of type
GenericAssociationItem.NotAChildError – If parameter ‘genericAssociationItem’ is not a generic association of this language construct.
- Return type:
See also
AddGenericAssociationItem()→ Add a generic association at the end of the generic map aspect.
InsertGenericAssociationItem()→ Insert a generic association at a position of the generic map aspect.
- RemoveGenericItem(genericItem)
Remove a generic from the generic clause.
The generic is detached: its parent and generic group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared. The generic itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove.- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddGenericItem()→ Add a generic at the end of the generic clause.
InsertGenericItem()→ Insert a generic at a position of the generic clause.
MoveGenericItem()→ Move a generic to a position of the generic clause.
- RemoveParameterItem(parameterItem)
Remove a parameter from the parameter list.
The parameter is detached: its parent and parameter group are cleared and its identifiers are removed from the language construct’s namespace, if it has one. A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared. The parameter itself is unchanged and can be added to another language construct, or inserted at another position.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove.- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter isn’t declared in it.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
- Return type:
See also
AddParameterItem()→ Add a parameter at the end of the parameter list.
InsertParameterItem()→ Insert a parameter at a position of the parameter list.
MoveParameterItem()→ Move a parameter to a position of the parameter list.
- RemoveStatement(statement)
Remove a sequential statement from this construct.
The statement is detached: its parent is cleared. The statement itself is unchanged and can be added to another construct, or inserted at another position; its labels are free again in this construct’s declarative region.
- Parameters:
statement (
SequentialStatement) – The sequential statement to remove.- Raises:
ValueError – If parameter ‘statement’ is
None.TypeError – If parameter ‘statement’ is not of type
ModelEntity.NotAChildError – If parameter ‘statement’ is not a statement of this construct.
- Return type:
See also
AddStatement()→ Add a sequential statement at the end of this construct.
InsertStatement()→ Insert a sequential statement at a position of this construct.
MoveStatement()→ Move a sequential statement to a position of this construct.
- 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:
- property Signature: SubprogramSignature
Read-only property to access the subprogram’s signature (
_signature): the type marks of its parameters, and of a function’s return value.The signature is computed on the first access and kept, until a parameter is added, inserted, removed or moved.
- Returns:
The signature.
- 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.
- SplitGenericItem(genericItem)
Split a generic with an identifier list into one generic per identifier.
The generic keeps its first identifier. For every other identifier, a new generic is created by its
Copy()and inserted right after it, in list order, in the generic clause and in the generic’s generic group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new generics. A generic declaring one identifier is unchanged.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to split.- Return type:
- Returns:
Tuple of generics, one per identifier in list order, starting with the split generic.
- Raises:
ValueError – If parameter ‘genericItem’ is
None.TypeError – If parameter ‘genericItem’ is not of type
GenericInterfaceItemMixin.NotAChildError – If parameter ‘genericItem’ is not a generic of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the generic refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveGenericItem()→ Remove a generic from the generic clause.
- SplitParameterItem(parameterItem)
Split a parameter with an identifier list into one parameter per identifier.
The parameter keeps its first identifier. For every other identifier, a new parameter is created by its
Copy()and inserted right after it, in list order, in the parameter list and in the parameter’s parameter group; its parent is set to this language construct. If the language construct has a namespace, the entries of the other identifiers refer to the new parameters. A parameter declaring one identifier is unchanged.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to split.- Return type:
- Returns:
Tuple of parameters, one per identifier in list order, starting with the split parameter.
- Raises:
ValueError – If parameter ‘parameterItem’ is
None.TypeError – If parameter ‘parameterItem’ is not of type
ParameterInterfaceItemMixin.NotAChildError – If parameter ‘parameterItem’ is not a parameter of this language construct.
NotInNamespaceError – If the namespace is indexed, and an identifier of the parameter refers to another element, e.g. a duplicate declaration.
See also
Split()→ Split a declaration with an identifier list.
RemoveParameterItem()→ Remove a parameter from the parameter list.
- property Statements: list[SequentialStatement]
Read-only property to access the list of sequential statements (
_statements).- Returns:
A list of sequential statements.
- property SubprogramReference: SubprogramReferenceSymbol
Read-only property to access the subprogram reference (
_subprogramReference).- Returns:
The subprogram reference.
- 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.
- Visit(visitor)[source]
Walk this procedure instantiation, its generic procedure and its generic map aspect with a visitor.
- _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:
- _AddToGenericGroup(position, genericItem)
Add a generic to the generic group of the generic before
position.At position
0, the generic joins the generic group of the first generic. If there are no generic groups, the generic forms a new unnamed generic group.- Parameters:
position (
int) – Position of the generic in the generic clause, from0(first) to the length ofGenericItems(last).genericItem (
GenericInterfaceItemMixin) – The generic to add, which isn’t in a generic group.
- 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:
- _AddToParameterGroup(position, parameterItem)
Add a parameter to the parameter group of the parameter before
position.At position
0, the parameter joins the parameter group of the first parameter. If there are no parameter groups, the parameter forms a new unnamed parameter group.- Parameters:
position (
int) – Position of the parameter in the parameter list, from0(first) to the length ofParameterItems(last).parameterItem (
ParameterInterfaceItemMixin) – The parameter to add, which isn’t in a parameter group.
- 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 subprogram: its generics and parameters share the declarative region.
- Return type:
- Returns:
Tuple of declarations: the generics, the parameters, then the declared items.
- _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.Procedure,)
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:
- _IndexGenericItems()
Add the generics to the host’s namespace; a generic subprogram is an overload.
- 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 sequential statements of this construct.
- Return type:
- Returns:
An empty generator: a sequential statement has no declarative region.
- _LabelRegion()
Return the subprogram, whose declarative region declares the labels of its statements.
- Return type:
- Returns:
The subprogram itself.
- _Labels()
Return the labeled statements of this construct, including the statements nested in compound statements.
Every label of a process or subprogram body is declared in the process’ or subprogram’s declarative region, also a label inside an if branch, a case alternative or a loop.
- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
- static _LabelsOf(statement)
Return a statement, if it’s labeled, and the labeled statements nested in it.
- Parameters:
statement (
SequentialStatement) – The sequential statement.- Return type:
- Returns:
Tuple of labeled statements, depth-first in statement order.
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.
- _ParameterItemsChanged()
Clear the kept signature (
_signature), because the parameter list changed.- Return type:
- _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:
- _RemoveFromGenericGroup(genericItem)
Remove a generic from its generic group and clear the generic’s group.
A generic group, which becomes empty, is removed from
GenericGroupsand its parent is cleared.- Parameters:
genericItem (
GenericInterfaceItemMixin) – The generic to remove from its generic group.- 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:
- _RemoveFromParameterGroup(parameterItem)
Remove a parameter from its parameter group and clear the parameter’s group.
A parameter group, which becomes empty, is removed from
ParameterGroupsand its parent is cleared.- Parameters:
parameterItem (
ParameterInterfaceItemMixin) – The parameter to remove from its parameter group.- 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:
- _SUBPROGRAM_KEYWORD: ClassVar[str] = 'procedure'
The VHDL keyword introducing this subprogram kind.
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:
- _VisitDeclarativeAndStatementPart(visitor)
Walk the declarative part and the statement part of this subprogram with a visitor.
The reserved word
isprecedes the declared items, the reserved wordbeginthe statements.
- _VisitDeclaredItems(visitor)
Walk the declared items in declaration order with a visitor.
- _VisitFormalParameterList(visitor)
Walk the formal parameter list, if there are parameters, with a visitor.
The parameters are separated by semicolons.
- _VisitGenericClause(visitor)
Walk the generic clause, if there are generics, with a visitor.
The generics are separated by semicolons.
- _VisitGenericMapAspect(visitor)
Walk the generic map aspect, if there are generic associations, with a visitor.
The associations are separated by commas.
- _VisitStatements(visitor)
Walk the sequential statements in statement 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 subprogram declaration.
Format:
procedure myProcedure(a, b)- Return type:
- Returns:
Formatted subprogram 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.
- _genericAssociationItems
List of all generic associations.
- _genericGroups
List of all generic groups, in declaration order.
- _genericItems
List of all generics, in declaration order.
- _identifier
The identifier of a model entity.
- _isPure
Trueif the subprogram was declared pure.
- _namespace
The namespace of this sequential declaration region.
- _normalizedIdentifier
The normalized (lower case) identifier of a model entity.
- _parameterGroups
List of all parameter groups, in declaration order.
- _parameterItems
List of all parameters, in declaration order.
- _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.
- _signature
The kept signature, or
Noneuntil computed.
- _statements
List of all sequential statements in this construct.
- _subprogramReference
Reference to the instantiated generic subprogram.
- _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.