diff options
Diffstat (limited to 'src/vhdl/translate/trans-chap4.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index d9feeb16d..f1db4d40b 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -3123,6 +3123,7 @@ package body Trans.Chap4 is Entity : Iir) is pragma Unreferenced (Num); + use Trans.Chap5; Formal : constant Iir := Get_Association_Formal (Assoc, Inter); Actual : constant Iir := Get_Actual (Assoc); Block_Info : constant Block_Info_Acc := Get_Info (Base_Block); @@ -3131,6 +3132,7 @@ package body Trans.Chap4 is Entity_Info : Ortho_Info_Acc; Targ : Mnode; Val : Mnode; + Act_Env : Map_Env; begin -- Declare the subprogram. Assoc_Info := Add_Info (Assoc, Kind_Inertial_Assoc); @@ -3153,6 +3155,7 @@ package body Trans.Chap4 is Open_Temp; -- Access for formals. + Act_Env.Scope_Ptr := null; if Entity /= Null_Iir then Entity_Info := Get_Info (Entity); declare @@ -3177,9 +3180,13 @@ package body Trans.Chap4 is Inst_Info.Block_Link_Field), Rtis.Ghdl_Component_Link_Instance)), Entity_Info.Block_Decls_Ptr_Type)); + -- Save previous scope for recursive instantiation. + Save_Map_Env (Act_Env, Entity_Info.Block_Scope'Access); + if not Is_Null (Entity_Info.Block_Scope) then + Clear_Scope (Entity_Info.Block_Scope); + end if; Set_Scope_Via_Param_Ptr (Entity_Info.Block_Scope, V); end if; - end; end if; @@ -3187,6 +3194,11 @@ package body Trans.Chap4 is -- 1. Translate target (translate_name) Targ := Chap6.Translate_Name (Formal, Mode_Signal); + if Act_Env.Scope_Ptr /= null then + -- Switch to the actual environment (if any). + Set_Map_Env (Act_Env); + end if; + -- 2. Translate expression Val := Chap7.Translate_Expression (Actual, Get_Type (Formal)); @@ -3201,9 +3213,10 @@ package body Trans.Chap4 is if Entity /= Null_Iir then if Entity_Info.Kind = Kind_Component then + pragma Assert (Act_Env.Scope_Ptr = null); Clear_Scope (Entity_Info.Comp_Scope); else - Clear_Scope (Entity_Info.Block_Scope); + Restore_Map_Env (Act_Env); end if; end if; |