aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/translate/trans-chap4.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl/translate/trans-chap4.adb')
-rw-r--r--src/vhdl/translate/trans-chap4.adb60
1 files changed, 21 insertions, 39 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb
index 07e3f9030..2c33231c4 100644
--- a/src/vhdl/translate/trans-chap4.adb
+++ b/src/vhdl/translate/trans-chap4.adb
@@ -2598,22 +2598,18 @@ package body Trans.Chap4 is
Create_Union_Scope (State_Scope.all, Scope_Type);
end Translate_Statements_Chain_State_Declaration;
- -- PKG is a nested package declaration or package body
- -- Translate only if non-generic or non-macro expanded.
- -- SPEC is the corresponding package declaration.
- procedure Translate_Declaration_Chain_Subprograms_Package
- (Pkg : Iir; Spec : Iir; What : Subprg_Translate_Kind)
+ procedure Translate_Declaration_Chain_Subprograms_Spec_Body (Parent : Iir)
is
- Mark : Id_Mark_Type;
+ What : Subprg_Translate_Kind;
begin
- if Get_Package_Header (Spec) = Null_Iir
- or else not Get_Macro_Expanded_Flag (Spec)
- then
- Push_Identifier_Prefix (Mark, Get_Identifier (Pkg));
- Translate_Declaration_Chain_Subprograms (Pkg, What);
- Pop_Identifier_Prefix (Mark);
+ if Global_Storage /= O_Storage_External then
+ What := Subprg_Translate_Spec_And_Body;
+ else
+ -- No need and incorrect to generate bodies when external storage.
+ What := Subprg_Translate_Only_Spec;
end if;
- end Translate_Declaration_Chain_Subprograms_Package;
+ Translate_Declaration_Chain_Subprograms (Parent, What);
+ end Translate_Declaration_Chain_Subprograms_Spec_Body;
procedure Translate_Declaration_Chain_Subprograms
(Parent : Iir; What : Subprg_Translate_Kind)
@@ -2622,9 +2618,9 @@ package body Trans.Chap4 is
Do_Specs : constant Boolean := What in Subprg_Translate_Spec;
-- True iff bodies must be translated.
- Do_Bodies : constant Boolean :=
- (What in Subprg_Translate_Body
- and then Global_Storage /= O_Storage_External);
+ Do_Bodies : constant Boolean := What in Subprg_Translate_Body;
+ pragma Assert
+ (not (Do_Bodies and then Global_Storage = O_Storage_External));
El : Iir;
Infos : Chap7.Implicit_Subprogram_Infos;
@@ -2697,29 +2693,12 @@ package body Trans.Chap4 is
Chap3.Translate_Protected_Type_Body_Subprograms_Body (El);
end if;
when Iir_Kind_Package_Declaration =>
- Translate_Declaration_Chain_Subprograms_Package (El, El, What);
+ Chap2.Translate_Package_Declaration_Subprograms (El, What);
when Iir_Kind_Package_Body =>
- Translate_Declaration_Chain_Subprograms_Package
- (El, Get_Package (El), What);
+ Chap2.Translate_Package_Body_Subprograms (El, What);
when Iir_Kind_Package_Instantiation_Declaration =>
- if Get_Macro_Expanded_Flag
- (Get_Uninstantiated_Package_Decl (El))
- then
- declare
- Bod : constant Iir := Get_Instance_Package_Body (El);
- Mark : Id_Mark_Type;
- begin
- Push_Identifier_Prefix (Mark, Get_Identifier (El));
- Translate_Declaration_Chain_Subprograms (El, What);
- if Is_Valid (Bod)
- and then Global_Storage /= O_Storage_External
- and then Get_Immediate_Body_Flag (El)
- then
- Translate_Declaration_Chain_Subprograms (Bod, What);
- end if;
- Pop_Identifier_Prefix (Mark);
- end;
- end if;
+ Chap2.Translate_Package_Instantiation_Declaration_Subprograms
+ (El, What);
when Iir_Kind_Package_Instantiation_Body =>
declare
Mark : Id_Mark_Type;
@@ -2832,8 +2811,11 @@ package body Trans.Chap4 is
null;
when Iir_Kind_Package_Declaration =>
- Chap2.Elab_Package (Decl, Get_Package_Header (Decl));
- -- FIXME: finalizer
+ if not Is_Uninstantiated_Package (Decl) then
+ -- Elaborate nested package (unless it is uninstantiated).
+ Chap2.Elab_Package_Declaration (Decl);
+ -- FIXME: finalizer
+ end if;
when Iir_Kind_Package_Body =>
declare
Nested_Final : Boolean;