diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-01-27 21:57:19 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-01-27 21:57:19 +0100 |
commit | 50a6561f76a15ab2492e4c9afcfdc601f7140002 (patch) | |
tree | 53bb8b96e16fe4189df4ab111fc76274d6ed0e53 | |
parent | 51d115c72b13507fa3e182f387651dc4aff98b5f (diff) | |
download | ghdl-50a6561f76a15ab2492e4c9afcfdc601f7140002.tar.gz ghdl-50a6561f76a15ab2492e4c9afcfdc601f7140002.tar.bz2 ghdl-50a6561f76a15ab2492e4c9afcfdc601f7140002.zip |
subprogram unnesting: fix upframe initialization and local id.
-rw-r--r-- | translate/translation.adb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/translate/translation.adb b/translate/translation.adb index 7f7945ca7..f159231c7 100644 --- a/translate/translation.adb +++ b/translate/translation.adb @@ -5174,6 +5174,7 @@ package body Translation is -- Set the identifier prefix with the subprogram identifier and -- overload number if any. Push_Subprg_Identifier (Spec, Mark); + Restore_Local_Identifier (Info.Subprg_Local_Id); if Has_Nested then -- Unnest subprograms. @@ -5216,18 +5217,29 @@ package body Translation is Rtis.Generate_Subprogram_Body (Subprg); + -- Local frame Chap2.Push_Subprg_Instance (Info.Subprg_Frame_Type, Frame_Ptr_Type, Wki_Upframe, Prev_Subprg_Instances); + -- Link to previous frame + Chap2.Start_Prev_Subprg_Instance_Use_Via_Field + (Prev_Subprg_Instances, Upframe_Field); + -- Result record if Info.Res_Record_Ptr /= O_Tnode_Null then Chap10.Push_Scope_Via_Field_Ptr (Info.Res_Record_Type, Res_Field, Info.Subprg_Frame_Type); end if; + Chap4.Translate_Declaration_Chain_Subprograms (Subprg, Null_Iir); + -- Result if Info.Res_Record_Ptr /= O_Tnode_Null then Chap10.Pop_Scope (Info.Res_Record_Type); end if; + -- Link to previous frame + Chap2.Finish_Prev_Subprg_Instance_Use_Via_Field + (Prev_Subprg_Instances, Upframe_Field); + -- Local frame Chap2.Pop_Subprg_Instance (Wki_Upframe, Prev_Subprg_Instances); end if; @@ -5241,8 +5253,6 @@ package body Translation is Push_Scope (Info.Res_Record_Type, Info.Res_Interface); end if; - Restore_Local_Identifier (Info.Subprg_Local_Id); - -- Variables will be created on the stack. Push_Local_Factory; @@ -5292,6 +5302,10 @@ package body Translation is New_Address (New_Obj (Frame), Frame_Ptr_Type)); Push_Scope (Info.Subprg_Frame_Type, Frame_Ptr); + -- Set UPFRAME. + Chap2.Set_Subprg_Instance_Field + (Frame_Ptr, Upframe_Field, Info.Subprg_Instance); + if Info.Res_Record_Type /= O_Tnode_Null then -- Initialize the RESULT field New_Assign_Stmt (New_Selected_Element (New_Obj (Frame), |