@@ -13,6 +13,31 @@ use crate::ast::WithRef;
1313use crate :: named_entity:: visibility:: Visibility ;
1414use crate :: Diagnostic ;
1515
16+ /// LRM 6.5.5: Discriminates the three forms an interface-package's
17+ /// `generic_map_aspect` may take.
18+ /// [`crate::ast::InterfacePackageGenericMapAspect`].
19+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
20+ pub enum InterfacePackageMapKind {
21+ /// `generic map (a => x, ...)` - fully bound at declaration; the enclosing
22+ /// generic clause is the only place the package's generics are associated.
23+ Map ,
24+ /// `generic map (<>)` - unbound; the enclosing entity/package/subprogram's
25+ /// instantiation must associate this interface package.
26+ Box ,
27+ /// `generic map (default)` - bound via the named package's default values
28+ /// for its generics.
29+ Default ,
30+ }
31+
32+ impl InterfacePackageMapKind {
33+ /// Returns whether the enclosing instantiation is *not* required to
34+ /// associate this interface package - i.e., it is fully bound at the
35+ /// declaration site.
36+ pub fn has_default ( self ) -> bool {
37+ matches ! ( self , Self :: Map | Self :: Default )
38+ }
39+ }
40+
1641#[ derive( Clone ) ]
1742pub enum Design < ' a > {
1843 Entity ( Visibility < ' a > , Region < ' a > ) ,
@@ -34,7 +59,10 @@ pub enum Design<'a> {
3459 /// package foo is new bar generic map (<>)
3560 /// )
3661 /// ```
37- InterfacePackageInstance ( Region < ' a > ) ,
62+ /// The [`InterfacePackageMapKind`] records which of the three forms of
63+ /// `generic_map_aspect` was used; this drives whether the enclosing
64+ /// instantiation must associate the interface package.
65+ InterfacePackageInstance ( InterfacePackageMapKind , Region < ' a > ) ,
3866 Context ( Region < ' a > ) ,
3967}
4068
@@ -48,7 +76,7 @@ impl Design<'_> {
4876 Package ( ..) => "package" ,
4977 PackageBody ( ..) => "package body" ,
5078 UninstPackage ( ..) => "uninstantiated package" ,
51- PackageInstance ( _) | InterfacePackageInstance ( _ ) => "package instance" ,
79+ PackageInstance ( _) | InterfacePackageInstance ( .. ) => "package instance" ,
5280 Context ( ..) => "context" ,
5381 }
5482 }
@@ -88,7 +116,7 @@ impl<'a> DesignEnt<'a> {
88116 match self . kind ( ) {
89117 Design :: Package ( _, ref region)
90118 | Design :: PackageInstance ( ref region)
91- | Design :: InterfacePackageInstance ( ref region) => {
119+ | Design :: InterfacePackageInstance ( _ , ref region) => {
92120 if let Some ( decl) = region. lookup_immediate ( suffix. designator ( ) ) {
93121 Ok ( decl. clone ( ) )
94122 } else {
0 commit comments