diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-09-20 08:07:54 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-09-20 08:07:54 +0200 |
commit | f0815de199ae3835d2555c1b85732977e8d72afe (patch) | |
tree | d9f769f7de2486b255b29350b654f4ceef5d6b62 | |
parent | 06328816aa9cda1137b5dd0bd59c3075bd40f810 (diff) | |
download | ghdl-f0815de199ae3835d2555c1b85732977e8d72afe.tar.gz ghdl-f0815de199ae3835d2555c1b85732977e8d72afe.tar.bz2 ghdl-f0815de199ae3835d2555c1b85732977e8d72afe.zip |
Create a pseudo source file for instantiation.
-rw-r--r-- | src/files_map.adb | 299 | ||||
-rw-r--r-- | src/files_map.ads | 49 | ||||
-rw-r--r-- | src/vhdl/disp_tree.adb | 16 | ||||
-rw-r--r-- | src/vhdl/sem.adb | 10 | ||||
-rw-r--r-- | src/vhdl/sem_decls.adb | 3 | ||||
-rw-r--r-- | src/vhdl/sem_inst.adb | 39 |
6 files changed, 306 insertions, 110 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index 1ccdca5af..a1844cbb2 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -38,8 +38,22 @@ package body Files_Map is type Lines_Table_Type is array (Positive) of Source_Ptr; type Lines_Table_Ptr is access all Lines_Table_Type; + -- There are several kinds of source file. + type Source_File_Kind is + ( + -- A *real* source file, read from the filesystem. + Source_File_File, + + -- A virtual source file, created from a string. + Source_File_String, + + -- A duplicated source file (there is no copy however), created by + -- an instantiation. + Source_File_Instance); + -- Data associed with a file. - type Source_File_Record is record + type Source_File_Record (Kind : Source_File_Kind := Source_File_File) is + record -- All location between first and last belong to this file. First_Location : Location_Type; Last_Location : Location_Type; @@ -58,19 +72,34 @@ package body Files_Map is Checksum : File_Checksum_Id; - -- Line table + case Kind is + when Source_File_File => + -- Line table + + -- Current number of line in Lines_Table. + Nbr_Lines : Natural; + + Lines_Table : Lines_Table_Ptr; - -- Current number of line in Lines_Table. - Nbr_Lines : Natural; + -- Current size of Lines_Table. + Lines_Table_Max : Natural; - Lines_Table : Lines_Table_Ptr; + -- Cache for line table. + Cache_Line : Natural; + Cache_Pos : Source_Ptr; - -- Current size of Lines_Table. - Lines_Table_Max : Natural; + when Source_File_String => + -- There is only one line. + null; - -- Cache. - Cache_Line : Natural; - Cache_Pos : Source_Ptr; + when Source_File_Instance => + -- The instance was created from REF. + Ref : Source_File_Entry; + -- The ultimate non-instance is BASE. + Base : Source_File_Entry; + + Instance_Loc : Location_Type; + end case; end record; -- Next location to use. @@ -100,8 +129,7 @@ package body Files_Map is procedure Location_To_File_Pos (Location : Location_Type; File : out Source_File_Entry; - Pos : out Source_Ptr) - is + Pos : out Source_Ptr) is begin -- FIXME: use a cache -- FIXME: dicotomy @@ -123,18 +151,17 @@ package body Files_Map is end Location_To_File_Pos; function File_Pos_To_Location (File : Source_File_Entry; Pos : Source_Ptr) - return Location_Type is + return Location_Type + is + pragma Assert (File <= Source_Files.Last); begin - if Source_Files.Table (File).Source = null then - raise Internal_Error; - else - return Source_Files.Table (File).First_Location + Location_Type (Pos); - end if; + return Source_Files.Table (File).First_Location + Location_Type (Pos); end File_Pos_To_Location; function Source_File_To_Location (File : Source_File_Entry) - return Location_Type + return Location_Type is + pragma Assert (File <= Source_Files.Last); begin return Source_Files.Table (File).First_Location; end Source_File_To_Location; @@ -185,6 +212,9 @@ package body Files_Map is Source_File: Source_File_Record renames Source_Files.Table (File); begin + -- Can only add line number to a real file. + pragma Assert (Source_File.Kind = Source_File_File); + -- Debug trace. if False then Put_Line ("file" & Source_File_Entry'Image (File) @@ -233,12 +263,11 @@ package body Files_Map is -- A logical column is the position of the character when displayed. -- A HT (tabulation) moves the cursor to the next position multiple of 8. -- The first character is at position 1 and at offset 0. - procedure Coord_To_Position - (File : Source_File_Entry; - Line_Pos : Source_Ptr; - Offset : Natural; - Name : out Name_Id; - Col : out Natural) + procedure Coord_To_Position (File : Source_File_Entry; + Line_Pos : Source_Ptr; + Offset : Natural; + Name : out Name_Id; + Col : out Natural) is Source_File: Source_File_Record renames Source_Files.Table (File); Res : Positive := 1; @@ -260,8 +289,7 @@ package body Files_Map is -- Should only be called by Location_To_Coord. function Location_To_Line - (Source_File : Source_File_Record; Pos : Source_Ptr) - return Natural + (Source_File : Source_File_Record; Pos : Source_Ptr) return Natural is Lines_Table : constant Lines_Table_Ptr := Source_File.Lines_Table; Low, Hi, Mid : Natural; @@ -354,12 +382,12 @@ package body Files_Map is end loop; end Location_To_Line; - procedure Location_To_Coord - (Source_File : in out Source_File_Record; - Pos : Source_Ptr; - Line_Pos : out Source_Ptr; - Line : out Natural; - Offset : out Natural) + -- Internal procedure + procedure Location_To_Coord (Source_File : in out Source_File_Record; + Pos : Source_Ptr; + Line_Pos : out Source_Ptr; + Line : out Natural; + Offset : out Natural) is Line_P : Source_Ptr; Line_Threshold : constant Natural := 4; @@ -399,11 +427,10 @@ package body Files_Map is Source_File.Cache_Line := Line; end Location_To_Coord; - procedure Location_To_Position - (Location : Location_Type; - Name : out Name_Id; - Line : out Natural; - Col : out Natural) + procedure Location_To_Position (Location : Location_Type; + Name : out Name_Id; + Line : out Natural; + Col : out Natural) is File : Source_File_Entry; Line_Pos : Source_Ptr; @@ -413,18 +440,34 @@ package body Files_Map is Coord_To_Position (File, Line_Pos, Offset, Name, Col); end Location_To_Position; - procedure Location_To_Coord - (Location : Location_Type; - File : out Source_File_Entry; - Line_Pos : out Source_Ptr; - Line : out Natural; - Offset : out Natural) + procedure Location_To_Coord (Location : Location_Type; + File : out Source_File_Entry; + Line_Pos : out Source_Ptr; + Line : out Natural; + Offset : out Natural) is Pos : Source_Ptr; begin + -- Get FILE and position POS in the file. Location_To_File_Pos (Location, File, Pos); - Location_To_Coord (Source_Files.Table (File), Pos, - Line_Pos, Line, Offset); + + case Source_Files.Table (File).Kind is + when Source_File_File => + Location_To_Coord (Source_Files.Table (File), Pos, + Line_Pos, Line, Offset); + when Source_File_String => + Line_Pos := Source_Ptr_Org; + Line := 1; + Offset := Natural (Pos - Source_Ptr_Org); + when Source_File_Instance => + declare + Base : constant Source_File_Entry := + Source_Files.Table (File).Base; + begin + Location_To_Coord (Source_Files.Table (Base), Pos, + Line_Pos, Line, Offset); + end; + end case; end Location_To_Coord; -- Convert the first digit of VAL into a character (base 10). @@ -569,7 +612,8 @@ package body Files_Map is -- Create a new entry. Res := Source_Files.Allocate; - Source_Files.Table (Res) := (First_Location => Next_Location, + Source_Files.Table (Res) := (Kind => Source_File_File, + First_Location => Next_Location, Last_Location => Next_Location, File_Name => Name, Directory => Directory, @@ -592,8 +636,7 @@ package body Files_Map is Res : Source_File_Entry; Buffer: File_Buffer_Acc; begin - Res := Create_Source_File_Entry (Null_Identifier, Name); - + -- Fill buffer. Buffer := new File_Buffer (Source_Ptr_Org .. Source_Ptr_Org + Len + 1); @@ -604,11 +647,19 @@ package body Files_Map is Buffer (Source_Ptr_Org + Len) := EOT; Buffer (Source_Ptr_Org + Len + 1) := EOT; - Source_Files.Table (Res).Last_Location := - Next_Location + Location_Type (Len) + 1; + -- Create entry. + Res := Source_Files.Allocate; + Source_Files.Table (Res) := + (Kind => Source_File_String, + First_Location => Next_Location, + Last_Location => Next_Location + Location_Type (Len) + 1, + File_Name => Name, + Directory => Null_Identifier, + Checksum => No_File_Checksum_Id, + Source => Buffer, + File_Length => Natural (Len)); + Next_Location := Source_Files.Table (Res).Last_Location + 1; - Source_Files.Table (Res).Source := Buffer; - Source_Files.Table (Res).File_Length := Natural (Len); return Res; end Create_Source_File_From_String; @@ -619,6 +670,79 @@ package body Files_Map is return Create_Source_File_From_String (Name, ""); end Create_Virtual_Source_File; + function Create_Instance_Source_File + (Ref : Source_File_Entry; Loc : Location_Type; Inst : Nodes.Node_Type) + return Source_File_Entry + is + pragma Unreferenced (Inst); + Base : Source_File_Entry; + Res : Source_File_Entry; + begin + if Source_Files.Table (Ref).Kind = Source_File_Instance then + Base := Source_Files.Table (Ref).Base; + else + Base := Ref; + end if; + + -- Create entry. + Res := Source_Files.Allocate; + + declare + F : Source_File_Record renames Source_Files.Table (Base); + begin + Source_Files.Table (Res) := + (Kind => Source_File_Instance, + First_Location => Next_Location, + Last_Location => Next_Location + Location_Type (F.File_Length) + 1, + File_Name => F.File_Name, + Directory => F.Directory, + Checksum => F.Checksum, + Source => F.Source, + File_Length => F.File_Length, + Ref => Ref, + Base => Base, + Instance_Loc => Loc); + + Next_Location := Source_Files.Table (Res).Last_Location + 1; + end; + + return Res; + end Create_Instance_Source_File; + + function Instance_Relocate + (Inst_File : Source_File_Entry; Loc : Location_Type) + return Location_Type + is + pragma Assert (Inst_File <= Source_Files.Last); + F : Source_File_Record renames Source_Files.Table (Inst_File); + pragma Assert (F.Kind = Source_File_Instance); + R : Source_File_Record renames Source_Files.Table (F.Ref); + begin + if Loc >= R.First_Location and Loc <= R.Last_Location then + return F.First_Location + (Loc - R.First_Location); + else + return Loc; + end if; + end Instance_Relocate; + + function Location_Instance_To_Location + (Loc : Location_Type) return Location_Type + is + File : Source_File_Entry; + Pos : Source_Ptr; + begin + if Loc = No_Location then + return No_Location; + end if; + + Location_To_File_Pos (Loc, File, Pos); + if Source_Files.Table (File).Kind = Source_File_Instance then + return Source_Files.Table (File).Instance_Loc; + else + return No_Location; + end if; + end Location_Instance_To_Location; + -- Return an entry for a filename. -- Load the filename if necessary. function Load_Source_File (Directory : Name_Id; Name: Name_Id) @@ -744,13 +868,25 @@ package body Files_Map is function Line_To_Position (File : Source_File_Entry; Line : Natural) return Source_Ptr is + pragma Assert (File <= Source_Files.Last); + Source_File: Source_File_Record renames Source_Files.Table (File); begin - Check_File (File); - if Line > Source_Files.Table (File).Nbr_Lines then - return Source_Ptr_Bad; - else - return Source_Files.Table (File).Lines_Table (Line); - end if; + case Source_File.Kind is + when Source_File_File => + if Line > Source_File.Nbr_Lines then + return Source_Ptr_Bad; + else + return Source_File.Lines_Table (Line); + end if; + when Source_File_String => + if Line /= 1 then + return Source_Ptr_Bad; + else + return Source_Ptr_Org; + end if; + when Source_File_Instance => + return Line_To_Position (Source_File.Base, Line); + end case; end Line_To_Position; function Is_Eq (L : Time_Stamp_Id; R : Time_Stamp_Id) return Boolean @@ -828,22 +964,22 @@ package body Files_Map is if Loc = Location_Nil then -- Avoid a crash. return "??:??:??"; - else - Location_To_Position (Loc, Name, Line, Col); - declare - Line_Str : constant String := Natural'Image (Line); - Col_Str : constant String := Natural'Image (Col); - begin - if Filename then - return Name_Table.Image (Name) - & ':' & Line_Str (Line_Str'First + 1 .. Line_Str'Last) - & ':' & Col_Str (Col_Str'First + 1 .. Col_Str'Last); - else - return Line_Str (Line_Str'First + 1 .. Line_Str'Last) - & ':' & Col_Str (Col_Str'First + 1 .. Col_Str'Last); - end if; - end; end if; + + Location_To_Position (Loc, Name, Line, Col); + declare + Line_Str : constant String := Natural'Image (Line); + Col_Str : constant String := Natural'Image (Col); + begin + if Filename then + return Name_Table.Image (Name) + & ':' & Line_Str (Line_Str'First + 1 .. Line_Str'Last) + & ':' & Col_Str (Col_Str'First + 1 .. Col_Str'Last); + else + return Line_Str (Line_Str'First + 1 .. Line_Str'Last) + & ':' & Col_Str (Col_Str'First + 1 .. Col_Str'Last); + end if; + end; end Image; -- Debug procedures. @@ -894,8 +1030,19 @@ package body Files_Map is (File_Buffer, File_Buffer_Acc); begin for I in Source_Files.First .. Source_Files.Last loop - free (Source_Files.Table (I).Lines_Table); - Free (Source_Files.Table (I).Source); + declare + F : Source_File_Record renames Source_Files.Table (I); + begin + case F.Kind is + when Source_File_File => + free (F.Lines_Table); + Free (F.Source); + when Source_File_String => + Free (F.Source); + when Source_File_Instance => + null; + end case; + end; end loop; Source_Files.Free; Source_Files.Init; diff --git a/src/files_map.ads b/src/files_map.ads index 861d0a5a8..d36442419 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -16,11 +16,11 @@ -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with Types; use Types; +with Nodes; -package Files_Map is +-- Source file handling - -- Source file handling - ----------------------- +package Files_Map is -- Create the path from DIRECTORY and NAME: -- If NAME is an absolute pathname, then return NAME. @@ -44,7 +44,7 @@ package Files_Map is -- Each file in memory has two terminal EOT. EOT : constant Character := Character'Val (4); - -- Create a Source_File for a virtual file name. Used for implicit, + -- Create an empty Source_File for a virtual file name. Used for implicit, -- command-line and std.standard library. function Create_Virtual_Source_File (Name : Name_Id) return Source_File_Entry; @@ -54,16 +54,36 @@ package Files_Map is function Create_Source_File_From_String (Name : Name_Id; Content : String) return Source_File_Entry; - -- Return a buffer (access to the contents of the file) for a file entry. + -- Create a pseudo source file from REF for instance INST (created at + -- location LOC). The content of this file is the same as REF, but with + -- new locations so that it is possible to retrieve the instance from + -- the new locations. + function Create_Instance_Source_File + (Ref : Source_File_Entry; Loc : Location_Type; Inst : Nodes.Node_Type) + return Source_File_Entry; + + -- Relocate location LOC (which must be in the reference of INST_FILE) + -- for instrnace INST_FILE. + function Instance_Relocate + (Inst_File : Source_File_Entry; Loc : Location_Type) + return Location_Type; + + -- If LOC is a location of an instance (in a file created by + -- create_instance_source_file), return the location where the instance + -- has been created. Otherwise, return No_Location. + function Location_Instance_To_Location + (Loc : Location_Type) return Location_Type; + + -- Return a buffer (access to the contents of the file) for a file entry. function Get_File_Source (File : Source_File_Entry) return File_Buffer_Acc; - -- Return the length of the file (which is the size of the file buffer). + -- Return the length of the file (which is the size of the file buffer). function Get_File_Length (File : Source_File_Entry) return Source_Ptr; - -- Return the name of the file. + -- Return the name of the file. function Get_File_Name (File : Source_File_Entry) return Name_Id; - -- Return the directory of the file. + -- Return the directory of the file. function Get_Source_File_Directory (File : Source_File_Entry) return Name_Id; @@ -87,17 +107,14 @@ package Files_Map is function Get_File_Checksum_String (Checksum : File_Checksum_Id) return String; - -- Return the current date of the system. + -- Return the current date of the system. function Get_Os_Time_Stamp return Time_Stamp_Id; - -- Return the home directory (current directory). + -- Return the home directory (current directory). function Get_Home_Directory return Name_Id; - -- Get the path of directory DIR. - --function Get_Directory_Path (Dir : Directory_Index) return String; - - -- Add a new entry in the lines_table. - -- The new entry must be the next one after the last entry. + -- Add a new entry in the lines_table. + -- The new entry must be the next one after the last entry. procedure File_Add_Line_Number (File : Source_File_Entry; Line : Natural; Pos : Source_Ptr); @@ -106,9 +123,11 @@ package Files_Map is procedure Location_To_File_Pos (Location : Location_Type; File : out Source_File_Entry; Pos : out Source_Ptr); + -- Convert a FILE and an offset POS in the file into a location. function File_Pos_To_Location (File : Source_File_Entry; Pos : Source_Ptr) return Location_Type; + -- Convert a FILE into a location. function Source_File_To_Location (File : Source_File_Entry) return Location_Type; diff --git a/src/vhdl/disp_tree.adb b/src/vhdl/disp_tree.adb index d506ae23f..b840d4603 100644 --- a/src/vhdl/disp_tree.adb +++ b/src/vhdl/disp_tree.adb @@ -29,9 +29,6 @@ with Nodes_Meta; -- trees, which is annoying while debugging. package body Disp_Tree is - -- function Is_Anonymous_Type_Definition (Def : Iir) return Boolean - -- renames Iirs_Utils.Is_Anonymous_Type_Definition; - -- Max depth for Disp_Iir. Can be modified from a debugger. pragma Warnings (Off); Max_Depth : Natural := 10; @@ -377,7 +374,18 @@ package body Disp_Tree is end if; Header ("location", Indent); - Put_Line (Image_Location_Type (Get_Location (N))); + declare + L : Location_Type; + begin + L := Get_Location (N); + loop + Put (Image_Location_Type (L)); + L := Files_Map.Location_Instance_To_Location (L); + exit when L = No_Location; + Put (" instantiated at "); + end loop; + New_Line; + end; declare use Nodes_Meta; diff --git a/src/vhdl/sem.adb b/src/vhdl/sem.adb index 711b2c7ee..8de3f149c 100644 --- a/src/vhdl/sem.adb +++ b/src/vhdl/sem.adb @@ -2854,11 +2854,9 @@ package body Sem is -- the actuals are associated with the instantiated formal. -- FIXME: do it in Instantiate_Package_Declaration ? Hdr := Get_Package_Header (Pkg); - if Sem_Generic_Association_Chain (Hdr, Decl) then - Sem_Inst.Instantiate_Package_Declaration (Decl, Pkg); - else + if not Sem_Generic_Association_Chain (Hdr, Decl) then -- FIXME: stop analysis here ? - null; + return; end if; -- FIXME: unless the parent is a package declaration library unit, the @@ -2872,6 +2870,10 @@ package body Sem is Add_Dependence (Bod); end if; end if; + + -- Instantiate the declaration after analyse of the body. So that + -- the use_flag on the declaration can be propagated to the instance. + Sem_Inst.Instantiate_Package_Declaration (Decl, Pkg); end Sem_Package_Instantiation_Declaration; -- LRM 10.4 Use Clauses. diff --git a/src/vhdl/sem_decls.adb b/src/vhdl/sem_decls.adb index 99523232f..aaafcf023 100644 --- a/src/vhdl/sem_decls.adb +++ b/src/vhdl/sem_decls.adb @@ -1178,11 +1178,14 @@ package body Sem_Decls is begin Deallocate_Proc := Create_Iir (Iir_Kind_Procedure_Declaration); + Location_Copy (Deallocate_Proc, Decl); Set_Identifier (Deallocate_Proc, Std_Names.Name_Deallocate); Set_Implicit_Definition (Deallocate_Proc, Iir_Predefined_Deallocate); + Var_Interface := Create_Iir (Iir_Kind_Interface_Variable_Declaration); + Location_Copy (Var_Interface, Decl); Set_Identifier (Var_Interface, Std_Names.Name_P); Set_Type (Var_Interface, Type_Definition); Set_Mode (Var_Interface, Iir_Inout_Mode); diff --git a/src/vhdl/sem_inst.adb b/src/vhdl/sem_inst.adb index 80a7fe2f4..996eb06f2 100644 --- a/src/vhdl/sem_inst.adb +++ b/src/vhdl/sem_inst.adb @@ -18,6 +18,7 @@ with Tables; with Nodes; with Nodes_Meta; with Types; use Types; +with Files_Map; use Files_Map; with Iirs_Utils; use Iirs_Utils; with Errorout; use Errorout; @@ -143,8 +144,8 @@ package body Sem_Inst is Prev_Instance_Table.Set_Last (Mark); end Restore_Origin; - -- The location to be used while instantiated nodes. - Instantiate_Loc : Location_Type; + -- The virtual file for the instance. + Instance_File : Source_File_Entry; function Instantiate_Iir (N : Iir; Is_Ref : Boolean) return Iir; @@ -286,7 +287,9 @@ package body Sem_Inst is when Type_Iir_Direction => Set_Iir_Direction (Res, F, Get_Iir_Direction (N, F)); when Type_Location_Type => - Set_Location_Type (Res, F, Instantiate_Loc); + Set_Location_Type + (Res, F, Instance_Relocate (Instance_File, + Get_Location_Type (N, F))); when Type_Iir_Int32 => Set_Iir_Int32 (Res, F, Get_Iir_Int32 (N, F)); when Type_Int32 => @@ -349,7 +352,8 @@ package body Sem_Inst is -- And the instance of N is RES. Set_Instance (N, Res); - Set_Location (Res, Instantiate_Loc); + Set_Location + (Res, Instance_Relocate (Instance_File, Get_Location (N))); for I in Fields'Range loop F := Fields (I); @@ -420,7 +424,9 @@ package body Sem_Inst is while Inter /= Null_Iir loop -- Create a copy of the interface. FIXME: is it really needed ? Res := Create_Iir (Get_Kind (Inter)); - Set_Location (Res, Instantiate_Loc); + Set_Location + (Res, Instance_Relocate (Instance_File, Get_Location (Inter))); + Set_Parent (Res, Inst); Set_Identifier (Res, Get_Identifier (Inter)); Set_Visible_Flag (Res, Get_Visible_Flag (Inter)); @@ -655,13 +661,23 @@ package body Sem_Inst is end loop; end Instantiate_Generic_Map_Chain; + procedure Create_Relocation (Inst : Iir; Orig : Iir) + is + Orig_File : Source_File_Entry; + Pos : Source_Ptr; + begin + Location_To_File_Pos (Get_Location (Orig), Orig_File, Pos); + Instance_File := Create_Instance_Source_File + (Orig_File, Get_Location (Inst), Inst); + end Create_Relocation; + procedure Instantiate_Package_Declaration (Inst : Iir; Pkg : Iir) is Header : constant Iir := Get_Package_Header (Pkg); - Prev_Loc : constant Location_Type := Instantiate_Loc; + Prev_Instance_File : constant Source_File_Entry := Instance_File; Mark : constant Instance_Index_Type := Prev_Instance_Table.Last; begin - Instantiate_Loc := Get_Location (Inst); + Create_Relocation (Inst, Pkg); -- Be sure Get_Origin_Priv can be called on existing nodes. Expand_Origin_Table; @@ -677,7 +693,7 @@ package body Sem_Inst is Set_Origin (Pkg, Null_Iir); - Instantiate_Loc := Prev_Loc; + Instance_File := Prev_Instance_File; Restore_Origin (Mark); end Instantiate_Package_Declaration; @@ -686,11 +702,11 @@ package body Sem_Inst is Inst_Decl : constant Iir := Get_Package_Origin (Inst); Pkg : constant Iir := Get_Named_Entity (Get_Uninstantiated_Package_Name (Inst_Decl)); - Prev_Loc : constant Location_Type := Instantiate_Loc; + Prev_Instance_File : constant Source_File_Entry := Instance_File; Mark : constant Instance_Index_Type := Prev_Instance_Table.Last; Res : Iir; begin - Instantiate_Loc := Get_Location (Inst); + Create_Relocation (Inst, Pkg); -- Be sure Get_Origin_Priv can be called on existing nodes. Expand_Origin_Table; @@ -742,9 +758,10 @@ package body Sem_Inst is -- Instantiate the body. Res := Instantiate_Iir (Get_Package_Body (Pkg), False); + Set_Identifier (Res, Get_Identifier (Inst)); -- Restore. - Instantiate_Loc := Prev_Loc; + Instance_File := Prev_Instance_File; Restore_Origin (Mark); return Res; |