Coverage for pyVHDLModel/Instantiation.py: 77%
43 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 23:46 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-10 23:46 +0000
1# ==================================================================================================================== #
2# __ ___ _ ____ _ __ __ _ _ #
3# _ __ _ \ \ / / | | | _ \| | | \/ | ___ __| | ___| | #
4# | '_ \| | | \ \ / /| |_| | | | | | | |\/| |/ _ \ / _` |/ _ \ | #
5# | |_) | |_| |\ V / | _ | |_| | |___| | | | (_) | (_| | __/ | #
6# | .__/ \__, | \_/ |_| |_|____/|_____|_| |_|\___/ \__,_|\___|_| #
7# |_| |___/ #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2017-2024 Patrick Lehmann - Boetzingen, Germany #
15# Copyright 2016-2017 Patrick Lehmann - Dresden, Germany #
16# #
17# Licensed under the Apache License, Version 2.0 (the "License"); #
18# you may not use this file except in compliance with the License. #
19# You may obtain a copy of the License at #
20# #
21# http://www.apache.org/licenses/LICENSE-2.0 #
22# #
23# Unless required by applicable law or agreed to in writing, software #
24# distributed under the License is distributed on an "AS IS" BASIS, #
25# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
26# See the License for the specific language governing permissions and #
27# limitations under the License. #
28# #
29# SPDX-License-Identifier: Apache-2.0 #
30# ==================================================================================================================== #
31#
32"""
33This module contains parts of an abstract document language model for VHDL.
35Instantiations of packages, procedures, functions and protected types.
36"""
37from typing import List, Optional as Nullable
39from pyTooling.Decorators import export, readonly
40from pyTooling.MetaClasses import ExtendedType
42from pyVHDLModel.Base import ModelEntity
43from pyVHDLModel.DesignUnit import PrimaryUnit
44from pyVHDLModel.Association import GenericAssociationItem
45from pyVHDLModel.Subprogram import Procedure, Function, Subprogram
46from pyVHDLModel.Symbol import PackageReferenceSymbol
49@export
50class GenericInstantiationMixin(metaclass=ExtendedType, mixin=True):
51 def __init__(self) -> None:
52 pass
55@export
56class GenericEntityInstantiationMixin(GenericInstantiationMixin, mixin=True):
57 def __init__(self) -> None:
58 pass
61@export
62class SubprogramInstantiationMixin(GenericInstantiationMixin, mixin=True):
63 _subprogramReference: Subprogram # FIXME: is this a subprogram symbol?
65 def __init__(self) -> None:
66 super().__init__()
67 self._subprogramReference = None
70@export
71class ProcedureInstantiation(Procedure, SubprogramInstantiationMixin):
72 pass
75@export
76class FunctionInstantiation(Function, SubprogramInstantiationMixin):
77 pass
80@export
81class PackageInstantiation(PrimaryUnit, GenericInstantiationMixin):
82 _packageReference: PackageReferenceSymbol
83 _genericAssociations: List[GenericAssociationItem]
85 def __init__(self, identifier: str, uninstantiatedPackage: PackageReferenceSymbol, documentation: Nullable[str] = None, parent: ModelEntity = None) -> None:
86 super().__init__(identifier, documentation, parent)
87 GenericEntityInstantiationMixin.__init__(self)
89 self._packageReference = uninstantiatedPackage
90 # uninstantiatedPackage._parent = self # FIXME: uninstantiatedPackage is provided as int
92 # TODO: extract to mixin
93 self._genericAssociations = []
95 @readonly
96 def PackageReference(self) -> PackageReferenceSymbol:
97 return self._packageReference
99 @readonly
100 def GenericAssociations(self) -> List[GenericAssociationItem]:
101 return self._genericAssociations