diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-09-26 08:13:09 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-09-26 08:13:09 +0200 |
commit | 8269262a63906c16f4fc2fd3c17fc91216eb7f09 (patch) | |
tree | 6d0bb3c3e1488510ba00bf7df81c35825a216e2e /src/vhdl/vhdl-sem_inst.adb | |
parent | 73d2b4ce553340c576a85c8d3d9461ddfd95ea0f (diff) | |
download | ghdl-8269262a63906c16f4fc2fd3c17fc91216eb7f09.tar.gz ghdl-8269262a63906c16f4fc2fd3c17fc91216eb7f09.tar.bz2 ghdl-8269262a63906c16f4fc2fd3c17fc91216eb7f09.zip |
vhdl: analyze subprogram instantiations. WIP. For #1470
Diffstat (limited to 'src/vhdl/vhdl-sem_inst.adb')
-rw-r--r-- | src/vhdl/vhdl-sem_inst.adb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_inst.adb b/src/vhdl/vhdl-sem_inst.adb index d8ee3bdf6..07ce3f88d 100644 --- a/src/vhdl/vhdl-sem_inst.adb +++ b/src/vhdl/vhdl-sem_inst.adb @@ -1028,6 +1028,37 @@ package body Vhdl.Sem_Inst is return Res; end Copy_Tree; + procedure Instantiate_Subprogram_Declaration (Inst : Iir; Subprg : Iir) + is + Prev_Instance_File : constant Source_File_Entry := Instance_File; + Mark : constant Instance_Index_Type := Prev_Instance_Table.Last; + begin + Create_Relocation (Inst, Subprg); + Set_Instance_Source_File (Inst, Instance_File); + + -- Be sure Get_Origin_Priv can be called on existing nodes. + Expand_Origin_Table; + + -- For Parent: the instance of PKG is INST. + Set_Origin (Subprg, Inst); + + -- Manually instantiate the package declaration. + Set_Generic_Chain + (Inst, Instantiate_Generic_Chain (Inst, Get_Generic_Chain (Subprg))); + Instantiate_Generic_Map_Chain (Inst, Subprg); + if Get_Kind (Subprg) = Iir_Kind_Function_Instantiation_Declaration then + Set_Return_Type (Inst, Instantiate_Iir (Subprg, True)); + end if; + Set_Interface_Declaration_Chain + (Inst, + Instantiate_Iir_Chain (Get_Interface_Declaration_Chain (Subprg))); + + Set_Origin (Subprg, Null_Iir); + + Instance_File := Prev_Instance_File; + Restore_Origin (Mark); + end Instantiate_Subprogram_Declaration; + procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir) is Header : constant Iir := Get_Package_Header (Pkg); |