Source code for pyGHDL.dom.InterfaceItem

# =============================================================================
#               ____ _   _ ____  _          _
#  _ __  _   _ / ___| | | |  _ \| |      __| | ___  _ __ ___
# | '_ \| | | | |  _| |_| | | | | |     / _` |/ _ \| '_ ` _ \
# | |_) | |_| | |_| |  _  | |_| | |___ | (_| | (_) | | | | | |
# | .__/ \__, |\____|_| |_|____/|_____(_)__,_|\___/|_| |_| |_|
# |_|    |___/
# =============================================================================
# Authors:
#   Patrick Lehmann
#
# Package module:   DOM: Interface items (e.g. generic or port)
#
# License:
# ============================================================================
#  Copyright (C) 2019-2022 Tristan Gingold
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ============================================================================
"""
This module implements derived interface item classes from :mod:`pyVHDLModel.Interface`.
"""

from typing import List, Iterable

from pyTooling.Decorators import export, InheritDocString

from pyVHDLModel.Base import Mode, ExpressionUnion
from pyVHDLModel.Symbol import Symbol
from pyVHDLModel.Interface import GenericConstantInterfaceItem as VHDLModel_GenericConstantInterfaceItem
from pyVHDLModel.Interface import GenericTypeInterfaceItem as VHDLModel_GenericTypeInterfaceItem
from pyVHDLModel.Interface import GenericProcedureInterfaceItem as VHDLModel_GenericProcedureInterfaceItem
from pyVHDLModel.Interface import GenericFunctionInterfaceItem as VHDLModel_GenericFunctionInterfaceItem
from pyVHDLModel.Interface import GenericPackageInterfaceItem as VHDLModel_GenericPackageInterfaceItem
from pyVHDLModel.Interface import PortSignalInterfaceItem as VHDLModel_PortSignalInterfaceItem
from pyVHDLModel.Interface import PortSimpleSignalInterfaceItem as VHDLModel_PortSimpleSignalInterfaceItem
from pyVHDLModel.Interface import PortViewSignalInterfaceItem as VHDLModel_PortViewSignalInterfaceItem
from pyVHDLModel.Interface import ParameterConstantInterfaceItem as VHDLModel_ParameterConstantInterfaceItem
from pyVHDLModel.Interface import ParameterVariableInterfaceItem as VHDLModel_ParameterVariableInterfaceItem
from pyVHDLModel.Interface import ParameterSignalInterfaceItem as VHDLModel_ParameterSignalInterfaceItem
from pyVHDLModel.Interface import ParameterSimpleSignalInterfaceItem as VHDLModel_ParameterSimpleSignalInterfaceItem
from pyVHDLModel.Interface import ParameterViewSignalInterfaceItem as VHDLModel_ParameterViewSignalInterfaceItem
from pyVHDLModel.Interface import ParameterFileInterfaceItem as VHDLModel_ParameterFileInterfaceItem
from pyVHDLModel.Interface import ModeViewDeclaration as VHDLModel_ModeViewDeclaration
from pyVHDLModel.Interface import SimpleModeViewElement as VHDLModel_SimpleModeViewElement
from pyVHDLModel.Interface import CompositeModeViewElement as VHDLModel_CompositeModeViewElement

from pyGHDL.libghdl._types import Iir
from pyGHDL.libghdl.vhdl import nodes
from pyGHDL.dom import DOMMixin
from pyGHDL.dom._Utils import GetNameOfNode, GetModeOfNode, GetDocumentationOfNode
from pyGHDL.dom._Translate import GetSubtypeIndicationFromNode, GetExpressionFromNode, GetName
from pyGHDL.dom.Symbol import ModeViewSymbol, SimpleSubtypeSymbol


[docs] @export @InheritDocString(VHDLModel_GenericConstantInterfaceItem, merge=True) class GenericConstantInterfaceItem(VHDLModel_GenericConstantInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.GenericConstantInterfaceItem`. """
[docs] def __init__( self, node: Iir, identifiers: List[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion, documentation: str = None, ) -> None: """ Initializes a constant in a generic clause. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The interface item's mode. :param subtype: Reference to the object's subtype. :param defaultExpression: The default value, or ``None`` if none was given. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, genericNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "GenericConstantInterfaceItem": """ Translates the IIR node of the generic declaration to a :class:`GenericConstantInterfaceItem`. :param genericNode: The IIR node of the generic declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated generic declaration. """ name = GetNameOfNode(genericNode) documentation = GetDocumentationOfNode(genericNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(genericNode) subtypeIndication = GetSubtypeIndicationFromNode(genericNode, "generic", name) default = nodes.Get_Default_Value(genericNode) value = GetExpressionFromNode(default) if default else None return cls(genericNode, identifiers, mode, subtypeIndication, value, documentation)
[docs] @export @InheritDocString(VHDLModel_GenericTypeInterfaceItem, merge=True) class GenericTypeInterfaceItem(VHDLModel_GenericTypeInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.GenericTypeInterfaceItem`. """
[docs] def __init__(self, node: Iir, identifier: str, documentation: str = None) -> None: """ Initializes a type in a generic clause. :param node: The IIR node this object was translated from. :param identifier: The generic type's identifier. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifier, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, genericNode: Iir) -> "GenericTypeInterfaceItem": """ Translates the IIR node of the generic declaration to a :class:`GenericTypeInterfaceItem`. :param genericNode: The IIR node of the generic declaration. :returns: The translated generic declaration. """ name = GetNameOfNode(genericNode) documentation = GetDocumentationOfNode(genericNode) return cls(genericNode, name, documentation)
[docs] @export @InheritDocString(VHDLModel_GenericPackageInterfaceItem, merge=True) class GenericPackageInterfaceItem(VHDLModel_GenericPackageInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.GenericPackageInterfaceItem`. """
[docs] def __init__(self, node: Iir, name: str, documentation: str = None) -> None: """ Initializes a package in a generic clause. :param node: The IIR node this object was translated from. :param name: The generic package's identifier. :param documentation: The documentation comment associated with this declaration. """ super().__init__(name, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, genericNode: Iir) -> "GenericPackageInterfaceItem": """ Translates the IIR node of the generic declaration to a :class:`GenericPackageInterfaceItem`. :param genericNode: The IIR node of the generic declaration. :returns: The translated generic declaration. """ name = GetNameOfNode(genericNode) documentation = GetDocumentationOfNode(genericNode) return cls(genericNode, name, documentation)
[docs] @export @InheritDocString(VHDLModel_GenericProcedureInterfaceItem, merge=True) class GenericProcedureInterfaceItem(VHDLModel_GenericProcedureInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.GenericProcedureInterfaceItem`. """
[docs] def __init__(self, node: Iir, identifier: str, documentation: str = None) -> None: """ Initializes a procedure in a generic clause. :param node: The IIR node this object was translated from. :param identifier: The generic procedure's identifier. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifier, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, genericNode: Iir) -> "GenericProcedureInterfaceItem": """ Translates the IIR node of the generic declaration to a :class:`GenericProcedureInterfaceItem`. :param genericNode: The IIR node of the generic declaration. :returns: The translated generic declaration. """ name = GetNameOfNode(genericNode) documentation = GetDocumentationOfNode(genericNode) return cls(genericNode, name, documentation)
[docs] @export @InheritDocString(VHDLModel_GenericFunctionInterfaceItem, merge=True) class GenericFunctionInterfaceItem(VHDLModel_GenericFunctionInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.GenericFunctionInterfaceItem`. """
[docs] def __init__(self, node: Iir, identifier: str, returnType: Symbol, documentation: str = None) -> None: """ Initializes a function in a generic clause. :param node: The IIR node this object was translated from. :param identifier: The generic function's identifier. :param returnType: Reference to the subtype of the function's return value. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifier, returnType, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, genericNode: Iir) -> "GenericFunctionInterfaceItem": """ Translates the IIR node of the generic declaration to a :class:`GenericFunctionInterfaceItem`. :param genericNode: The IIR node of the generic declaration. :returns: The translated generic declaration. """ name = GetNameOfNode(genericNode) documentation = GetDocumentationOfNode(genericNode) returnType = nodes.Get_Return_Type_Mark(genericNode) returnTypeName = GetName(returnType) returnTypeSymbol = SimpleSubtypeSymbol(returnType, returnTypeName) return cls(genericNode, name, returnTypeSymbol, documentation)
[docs] @export @InheritDocString(VHDLModel_PortSimpleSignalInterfaceItem, merge=True) class PortSimpleSignalInterfaceItem(VHDLModel_PortSimpleSignalInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.PortSimpleSignalInterfaceItem`. """
[docs] def __init__( self, node: Iir, identifiers: List[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None, ) -> None: """ Initializes a port declared with a simple mode. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The interface item's mode. :param subtype: Reference to the object's subtype. :param defaultExpression: The default value, or ``None`` if none was given. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, portNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "PortSimpleSignalInterfaceItem": """ Translates the IIR node of the port declaration to a :class:`PortSimpleSignalInterfaceItem`. :param portNode: The IIR node of the port declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated port declaration. """ name = GetNameOfNode(portNode) documentation = GetDocumentationOfNode(portNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(portNode) subtypeIndication = GetSubtypeIndicationFromNode(portNode, "port", name) defaultValue = nodes.Get_Default_Value(portNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None return cls(portNode, identifiers, mode, subtypeIndication, value, documentation)
[docs] @export class PortViewSignalInterfaceItem(VHDLModel_PortViewSignalInterfaceItem, DOMMixin): """ .. admonition:: Example .. code-block:: VHDL port (p : view MyView); .. note:: ``Get_Subtype_Indication`` on an ``Interface_View_Declaration`` node is only populated after semantic analysis has resolved the referenced mode view; since translation here is parse-only, ``Subtype`` stays ``None`` - the type is only implied by the referenced mode view. """
[docs] def __init__( self, node: Iir, identifiers: List[str], modeViewIndication: ModeViewSymbol, documentation: str = None, ) -> None: """ Initializes a port declared with a mode view (VHDL-2019). :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param modeViewIndication: Reference to the mode view applied to this port. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, modeViewIndication, documentation=documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, portNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "PortViewSignalInterfaceItem": """ Translates the IIR node of the port declaration to a :class:`PortViewSignalInterfaceItem`. :param portNode: The IIR node of the port declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated port declaration. """ name = GetNameOfNode(portNode) documentation = GetDocumentationOfNode(portNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) modeViewIndicationNode = nodes.Get_Mode_View_Indication(portNode) modeViewNameNode = nodes.Get_Name(modeViewIndicationNode) modeViewIndication = ModeViewSymbol(modeViewNameNode, GetName(modeViewNameNode)) return cls(portNode, identifiers, modeViewIndication, documentation)
[docs] @export @InheritDocString(VHDLModel_ParameterConstantInterfaceItem, merge=True) class ParameterConstantInterfaceItem(VHDLModel_ParameterConstantInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.ParameterConstantInterfaceItem`. """
[docs] def __init__( self, node: Iir, identifiers: List[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None, ) -> None: """ Initializes a constant parameter of a subprogram. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The interface item's mode. :param subtype: Reference to the object's subtype. :param defaultExpression: The default value, or ``None`` if none was given. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, parameterNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "ParameterConstantInterfaceItem": """ Translates the IIR node of the parameter declaration to a :class:`ParameterConstantInterfaceItem`. :param parameterNode: The IIR node of the parameter declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated parameter declaration. """ name = GetNameOfNode(parameterNode) documentation = GetDocumentationOfNode(parameterNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None return cls(parameterNode, identifiers, mode, subtypeIndication, value, documentation)
[docs] @export @InheritDocString(VHDLModel_ParameterVariableInterfaceItem, merge=True) class ParameterVariableInterfaceItem(VHDLModel_ParameterVariableInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.ParameterVariableInterfaceItem`. """
[docs] def __init__( self, node: Iir, identifiers: List[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None, ) -> None: """ Initializes a variable parameter of a subprogram. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The interface item's mode. :param subtype: Reference to the object's subtype. :param defaultExpression: The default value, or ``None`` if none was given. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, parameterNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "ParameterVariableInterfaceItem": """ Translates the IIR node of the parameter declaration to a :class:`ParameterVariableInterfaceItem`. :param parameterNode: The IIR node of the parameter declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated parameter declaration. """ name = GetNameOfNode(parameterNode) documentation = GetDocumentationOfNode(parameterNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None return cls(parameterNode, identifiers, mode, subtypeIndication, value, documentation)
[docs] @export @InheritDocString(VHDLModel_ParameterSimpleSignalInterfaceItem, merge=True) class ParameterSimpleSignalInterfaceItem(VHDLModel_ParameterSimpleSignalInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.ParameterSimpleSignalInterfaceItem`. """
[docs] def __init__( self, node: Iir, identifiers: List[str], mode: Mode, subtype: Symbol, defaultExpression: ExpressionUnion = None, documentation: str = None, ) -> None: """ Initializes a signal parameter declared with a simple mode. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The interface item's mode. :param subtype: Reference to the object's subtype. :param defaultExpression: The default value, or ``None`` if none was given. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, subtype, defaultExpression, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse( cls, parameterNode: Iir, furtherIdentifiers: Iterable[str] = None ) -> "ParameterSimpleSignalInterfaceItem": """ Translates the IIR node of the parameter declaration to a :class:`ParameterSimpleSignalInterfaceItem`. :param parameterNode: The IIR node of the parameter declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated parameter declaration. """ name = GetNameOfNode(parameterNode) documentation = GetDocumentationOfNode(parameterNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(parameterNode) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) defaultValue = nodes.Get_Default_Value(parameterNode) value = GetExpressionFromNode(defaultValue) if defaultValue != nodes.Null_Iir else None return cls(parameterNode, identifiers, mode, subtypeIndication, value, documentation)
[docs] @export class ParameterViewSignalInterfaceItem(VHDLModel_ParameterViewSignalInterfaceItem, DOMMixin): """ .. admonition:: Example .. code-block:: VHDL procedure proc(signal s : view MyView); .. note:: See :class:`PortViewSignalInterfaceItem` for why ``Subtype`` stays ``None`` here. """
[docs] def __init__( self, node: Iir, identifiers: List[str], modeViewIndication: ModeViewSymbol, documentation: str = None, ) -> None: """ Initializes a signal parameter declared with a mode view (VHDL-2019). :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param modeViewIndication: Reference to the mode view applied to this parameter. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, modeViewIndication, documentation=documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, parameterNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "ParameterViewSignalInterfaceItem": """ Translates the IIR node of the parameter declaration to a :class:`ParameterViewSignalInterfaceItem`. :param parameterNode: The IIR node of the parameter declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated parameter declaration. """ name = GetNameOfNode(parameterNode) documentation = GetDocumentationOfNode(parameterNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) modeViewIndicationNode = nodes.Get_Mode_View_Indication(parameterNode) modeViewNameNode = nodes.Get_Name(modeViewIndicationNode) modeViewIndication = ModeViewSymbol(modeViewNameNode, GetName(modeViewNameNode)) return cls(parameterNode, identifiers, modeViewIndication, documentation)
[docs] @export @InheritDocString(VHDLModel_ParameterFileInterfaceItem, merge=True) class ParameterFileInterfaceItem(VHDLModel_ParameterFileInterfaceItem, DOMMixin): """ This class implements a :mod:`pyGHDL.dom` object derived from :class:`pyVHDLModel.Interface.ParameterFileInterfaceItem`. """
[docs] def __init__(self, node: Iir, identifiers: List[str], subtype: Symbol, documentation: str = None) -> None: """ Initializes a file parameter of a subprogram. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param subtype: Reference to the object's subtype. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, subtype, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, parameterNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "ParameterFileInterfaceItem": """ Translates the IIR node of the parameter declaration to a :class:`ParameterFileInterfaceItem`. :param parameterNode: The IIR node of the parameter declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated parameter declaration. """ name = GetNameOfNode(parameterNode) documentation = GetDocumentationOfNode(parameterNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) subtypeIndication = GetSubtypeIndicationFromNode(parameterNode, "parameter", name) return cls(parameterNode, identifiers, subtypeIndication, documentation)
[docs] @export class SimpleModeViewElement(VHDLModel_SimpleModeViewElement, DOMMixin): """ .. admonition:: Example .. code-block:: VHDL view MyView of RecordType is a, b : out; end view; """
[docs] def __init__(self, node: Iir, identifiers: List[str], mode: Mode, documentation: str = None) -> None: """ Initializes a simple mode view element. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param mode: The element's mode. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, mode, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, elementNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "SimpleModeViewElement": """ Translates the IIR node of the element declaration to a :class:`SimpleModeViewElement`. :param elementNode: The IIR node of the element declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated element declaration. """ name = GetNameOfNode(elementNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) mode = GetModeOfNode(elementNode) documentation = GetDocumentationOfNode(elementNode) return cls(elementNode, identifiers, mode, documentation)
[docs] @export class CompositeModeViewElement(VHDLModel_CompositeModeViewElement, DOMMixin): """ .. admonition:: Example .. code-block:: VHDL view OuterView of OuterRecord is b : view InnerView; end view; """
[docs] def __init__( self, node: Iir, identifiers: List[str], modeViewName: ModeViewSymbol, documentation: str = None ) -> None: """ Initializes a composite mode view element. :param node: The IIR node this object was translated from. :param identifiers: A list of identifiers. :param modeViewName: Reference to the mode view applied to this element. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifiers, modeViewName, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, elementNode: Iir, furtherIdentifiers: Iterable[str] = None) -> "CompositeModeViewElement": """ Translates the IIR node of the element declaration to a :class:`CompositeModeViewElement`. :param elementNode: The IIR node of the element declaration. :param furtherIdentifiers: The remaining identifiers, when one declaration names several. :returns: The translated element declaration. """ name = GetNameOfNode(elementNode) identifiers = [name] if furtherIdentifiers is not None: identifiers.extend(furtherIdentifiers) modeViewNameNode = nodes.Get_Mode_View_Name(elementNode) modeViewName = ModeViewSymbol(modeViewNameNode, GetName(modeViewNameNode)) documentation = GetDocumentationOfNode(elementNode) return cls(elementNode, identifiers, modeViewName, documentation)
[docs] @export class ModeViewDeclaration(VHDLModel_ModeViewDeclaration, DOMMixin): """ .. admonition:: Example .. code-block:: VHDL view MyView of RecordType is a : out; b : in; end view; """
[docs] def __init__( self, node: Iir, identifier: str, subtype: Symbol, elements: List = None, documentation: str = None, ) -> None: """ Initializes a mode view declaration (VHDL-2019). :param node: The IIR node this object was translated from. :param identifier: The mode view's identifier. :param subtype: Reference to the subtype this mode view applies to. :param elements: List of all mode view elements, in declaration order. :param documentation: The documentation comment associated with this declaration. """ super().__init__(identifier, subtype, elements, documentation) DOMMixin.__init__(self, node)
[docs] @classmethod def parse(cls, modeViewNode: Iir) -> "ModeViewDeclaration": """ Translates the IIR node of the mode view declaration to a :class:`ModeViewDeclaration`. :param modeViewNode: The IIR node of the mode view declaration. :returns: The translated mode view declaration. """ from pyGHDL.dom._Translate import GetModeViewElementsFromChainedNodes name = GetNameOfNode(modeViewNode) documentation = GetDocumentationOfNode(modeViewNode) subtypeIndication = GetSubtypeIndicationFromNode(modeViewNode, "mode view", name) elements = GetModeViewElementsFromChainedNodes(nodes.Get_Elements_Definition_Chain(modeViewNode)) return cls(modeViewNode, name, subtypeIndication, elements, documentation)