diff options
Diffstat (limited to 'src/vhdl/translate/trans-chap2.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 5ff3ee3c7..d5837d304 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -754,13 +754,19 @@ package body Trans.Chap2 is procedure Translate_Package_Declaration (Decl : Iir_Package_Declaration) is - Header : constant Iir := Get_Package_Header (Decl); + Is_Nested : constant Boolean := Is_Nested_Package (Decl); + Header : constant Iir := Get_Package_Header (Decl); + Mark : Id_Mark_Type; Info : Ortho_Info_Acc; Interface_List : O_Inter_List; Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack; begin Info := Add_Info (Decl, Kind_Package); + if Is_Nested then + Push_Identifier_Prefix (Mark, Get_Identifier (Decl)); + end if; + -- Translate declarations. if Is_Uninstantiated_Package (Decl) then -- Create an instance for the spec. @@ -788,20 +794,24 @@ package body Trans.Chap2 is Wki_Instance, Prev_Subprg_Instance); else Chap4.Translate_Declaration_Chain (Decl); - Info.Package_Elab_Var := Create_Var - (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); + if not Is_Nested then + Info.Package_Elab_Var := Create_Var + (Create_Var_Identifier ("ELABORATED"), Ghdl_Bool_Type); + end if; end if; -- Translate subprograms declarations. Chap4.Translate_Declaration_Chain_Subprograms (Decl); -- Declare elaborator for the body. - Start_Procedure_Decl - (Interface_List, Create_Identifier ("ELAB_BODY"), Global_Storage); - Subprgs.Add_Subprg_Instance_Interfaces - (Interface_List, Info.Package_Elab_Body_Instance); - Finish_Subprogram_Decl - (Interface_List, Info.Package_Elab_Body_Subprg); + if not Is_Nested then + Start_Procedure_Decl + (Interface_List, Create_Identifier ("ELAB_BODY"), Global_Storage); + Subprgs.Add_Subprg_Instance_Interfaces + (Interface_List, Info.Package_Elab_Body_Instance); + Finish_Subprogram_Decl + (Interface_List, Info.Package_Elab_Body_Subprg); + end if; if Is_Uninstantiated_Package (Decl) then Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance); @@ -812,21 +822,24 @@ package body Trans.Chap2 is Wki_Instance, Prev_Subprg_Instance); end if; - Start_Procedure_Decl - (Interface_List, Create_Identifier ("ELAB_SPEC"), Global_Storage); - Subprgs.Add_Subprg_Instance_Interfaces - (Interface_List, Info.Package_Elab_Spec_Instance); - Finish_Subprogram_Decl - (Interface_List, Info.Package_Elab_Spec_Subprg); - - if Flag_Rti then - -- Generate RTI. - Rtis.Generate_Unit (Decl); - end if; + -- Declare elaborator for the spec. + if not Is_Nested then + Start_Procedure_Decl + (Interface_List, Create_Identifier ("ELAB_SPEC"), Global_Storage); + Subprgs.Add_Subprg_Instance_Interfaces + (Interface_List, Info.Package_Elab_Spec_Instance); + Finish_Subprogram_Decl + (Interface_List, Info.Package_Elab_Spec_Subprg); + + if Flag_Rti then + -- Generate RTI. + Rtis.Generate_Unit (Decl); + end if; - if Global_Storage = O_Storage_Public then - -- Create elaboration procedure for the spec - Elab_Package (Decl); + if Global_Storage = O_Storage_Public then + -- Create elaboration procedure for the spec + Elab_Package (Decl); + end if; end if; if Is_Uninstantiated_Package (Decl) then @@ -843,6 +856,11 @@ package body Trans.Chap2 is Push_Package_Instance_Factory (Decl); Pop_Package_Instance_Factory (Decl); end if; + + if Is_Nested then + Pop_Identifier_Prefix (Mark); + end if; + end Translate_Package_Declaration; procedure Translate_Package_Body (Bod : Iir_Package_Body) |