diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-24 07:49:02 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-24 07:51:17 +0100 |
commit | 91cf6d0fbf8ab78910f74271525d9663f45e44e0 (patch) | |
tree | 03403d2bfb6b894ccad819e3d08205ccc3147dd1 | |
parent | 8982646305a71ab14057f84e80ee504c8b7d2c67 (diff) | |
download | ghdl-91cf6d0fbf8ab78910f74271525d9663f45e44e0.tar.gz ghdl-91cf6d0fbf8ab78910f74271525d9663f45e44e0.tar.bz2 ghdl-91cf6d0fbf8ab78910f74271525d9663f45e44e0.zip |
vhdl: move get_subprogram_body_origin to vhdl-sem_inst.
-rw-r--r-- | src/vhdl/simulate/simul-execution.adb | 19 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 11 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_inst.adb | 13 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_inst.ads | 5 |
4 files changed, 30 insertions, 18 deletions
diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb index d7391ef95..a70d920c7 100644 --- a/src/vhdl/simulate/simul-execution.adb +++ b/src/vhdl/simulate/simul-execution.adb @@ -3311,23 +3311,6 @@ package body Simul.Execution is Unshare (Val, Instance_Pool); end Execute_Monadic_Association; - -- Like Get_Subprogram_Body, but also works for instances, where - -- instantiated nodes have no bodies. - -- FIXME: maybe fix the issue directly in Sem_Inst ? - function Get_Subprogram_Body_Origin (Spec : Iir) return Iir - is - Res : constant Iir := Get_Subprogram_Body (Spec); - Orig : Iir; - begin - if Res /= Null_Iir then - return Res; - else - Orig := Vhdl.Sem_Inst.Get_Origin (Spec); - pragma Assert (Orig /= Null_Iir); - return Get_Subprogram_Body_Origin (Orig); - end if; - end Get_Subprogram_Body_Origin; - -- Like Get_Protected_Type_Body, but also works for instances, where -- instantiated nodes have no bodies. -- FIXME: maybe fix the issue directly in Sem_Inst ? @@ -3360,7 +3343,7 @@ package body Simul.Execution is begin case Get_Kind (Imp) is when Iir_Kinds_Subprogram_Declaration => - Bod := Get_Subprogram_Body_Origin (Imp); + Bod := Vhdl.Sem_Inst.Get_Subprogram_Body_Origin (Imp); Parent := Get_Parent (Imp); Label := Get_Subprogram_Specification (Bod); when Iir_Kind_Protected_Type_Declaration => diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index d27e1aed9..fb3084616 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -7540,6 +7540,17 @@ package Vhdl.Nodes is function Get_Simultaneous_Statement_Chain (Target : Iir) return Iir; procedure Set_Simultaneous_Statement_Chain (Target : Iir; Chain : Iir); + -- The body of a subprogram (from the subprogram specification). + -- Note that this field is only set when the body has been analyzed (ok, + -- that's obvious). For subprogram specifications in instantiated package, + -- this field is in general not set because the package specification may + -- be instantiated before the package body is analyzed and there is no + -- tracking of all instantiated packages. So when the package body is + -- analyzed, there is no way to set this field for the subprograms in all + -- instantiated specifications. + -- You could use Get_Subprogram_Body_Origin to extract the body. It uses + -- the Origin link to find the original specification which has this field + -- set. -- Field: Field9 Forward_Ref function Get_Subprogram_Body (Target : Iir) return Iir; procedure Set_Subprogram_Body (Target : Iir; A_Body : Iir); diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb index d920f4943..526c4224f 100644 --- a/src/vhdl/vhdl-sem_inst.adb +++ b/src/vhdl/vhdl-sem_inst.adb @@ -1220,4 +1220,17 @@ package body Vhdl.Sem_Inst is end loop; end Substitute_On_Chain; + function Get_Subprogram_Body_Origin (Spec : Iir) return Iir + is + Res : constant Iir := Get_Subprogram_Body (Spec); + Orig : Iir; + begin + if Res /= Null_Iir then + return Res; + else + Orig := Get_Origin (Spec); + pragma Assert (Orig /= Null_Iir); + return Get_Subprogram_Body_Origin (Orig); + end if; + end Get_Subprogram_Body_Origin; end Vhdl.Sem_Inst; diff --git a/src/vhdl/vhdl-sem_inst.ads b/src/vhdl/vhdl-sem_inst.ads index 8ec8aa195..eb87994d2 100644 --- a/src/vhdl/vhdl-sem_inst.ads +++ b/src/vhdl/vhdl-sem_inst.ads @@ -33,4 +33,9 @@ package Vhdl.Sem_Inst is -- Deep copy of ORIG. Doesn't change location. function Copy_Tree (Orig : Iir) return Iir; + + -- Like Get_Subprogram_Body, but also works for instances, where + -- instantiated nodes have no bodies. + -- See comment about Get/Set_Subprogram_body in vhdl-nodes. + function Get_Subprogram_Body_Origin (Spec : Iir) return Iir; end Vhdl.Sem_Inst; |