diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-11-25 20:07:00 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-11-26 20:19:15 +0100 |
commit | 44404214d370d226428e315da946d41ccf141507 (patch) | |
tree | 5741a66f5e0def695965664dbe0397e309a2cfad | |
parent | d570ee98eaa200cc1bbf481035aa3bb1680504db (diff) | |
download | ghdl-44404214d370d226428e315da946d41ccf141507.tar.gz ghdl-44404214d370d226428e315da946d41ccf141507.tar.bz2 ghdl-44404214d370d226428e315da946d41ccf141507.zip |
Keep source file entry in design file to avoid searching the file.
-rw-r--r-- | src/files_map.adb | 4 | ||||
-rw-r--r-- | src/ghdldrv/ghdllocal.adb | 17 | ||||
-rw-r--r-- | src/ghdldrv/ghdlprint.adb | 6 | ||||
-rw-r--r-- | src/vhdl/iirs.adb | 16 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 6 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 549 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/sem_lib.adb | 43 |
8 files changed, 349 insertions, 294 deletions
diff --git a/src/files_map.adb b/src/files_map.adb index 5f16983ed..999b0468d 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -716,10 +716,10 @@ package body Files_Map is Buffer : File_Buffer_Acc; begin - -- If the file is already loaded, nothing to do! + -- The file is not supposed to be already loaded, but this could happen + -- if the same file is compiled in two libraries. Res := Find_Source_File (Directory, Name); if Res /= No_Source_File_Entry then - pragma Assert (Source_Files.Table (Res).Source /= null); return Res; end if; diff --git a/src/ghdldrv/ghdllocal.adb b/src/ghdldrv/ghdllocal.adb index 2f7cf1f54..1c3059b73 100644 --- a/src/ghdldrv/ghdllocal.adb +++ b/src/ghdldrv/ghdllocal.adb @@ -1218,8 +1218,12 @@ package body Ghdllocal is File := Get_Design_File_Chain (Lib); while File /= Null_Iir loop Next_File := Get_Chain (File); - Fe := Read_Source_File (Get_Design_File_Directory (File), - Get_Design_File_Filename (File)); + Fe := Get_Design_File_Source (File); + if Fe = No_Source_File_Entry then + Fe := Read_Source_File (Get_Design_File_Directory (File), + Get_Design_File_Filename (File)); + Set_Design_File_Source (File, Fe); + end if; if Fe = No_Source_File_Entry then -- FIXME: should remove all the design file from the library. null; @@ -1230,6 +1234,7 @@ package body Ghdllocal is -- Extract libraries. -- Note: we can't parse it only, since we need to keep the -- date. + Set_Design_File_Source (File, Fe); Unit := Get_First_Design_Unit (File); while Unit /= Null_Iir loop Sem_Lib.Load_Parse_Design_Unit (Unit, Null_Iir); @@ -1427,8 +1432,12 @@ package body Ghdllocal is Fe : Source_File_Entry; begin -- 2) file has been modified. - Fe := Read_Source_File (Get_Design_File_Directory (File), - Get_Design_File_Filename (File)); + Fe := Get_Design_File_Source (File); + if Fe = No_Source_File_Entry then + Fe := Read_Source_File (Get_Design_File_Directory (File), + Get_Design_File_Filename (File)); + Set_Design_File_Source (File, Fe); + end if; if not Is_Eq (Get_File_Checksum (Fe), Get_File_Checksum (File)) then diff --git a/src/ghdldrv/ghdlprint.adb b/src/ghdldrv/ghdlprint.adb index 29d7f7e29..ce0433204 100644 --- a/src/ghdldrv/ghdlprint.adb +++ b/src/ghdldrv/ghdlprint.adb @@ -559,6 +559,8 @@ package body Ghdlprint is pragma Unreferenced (Cmd); use Ada.Characters.Latin_1; + Files : Iir_Array (Args'Range); + function Build_File_Name_Length (Lib : Iir) return Natural is Id : constant Name_Id := Get_Identifier (Lib); @@ -682,6 +684,7 @@ package body Ghdlprint is if Design_File = Null_Iir then raise Compile_Error; end if; + Files (I) := Design_File; Unit := Get_First_Design_Unit (Design_File); while Unit /= Null_Iir loop Lib := Get_Library_Unit (Unit); @@ -707,8 +710,7 @@ package body Ghdlprint is -- Second loop: do the real work. for I in Args'Range loop - Id := Get_Identifier (Args (I).all); - Design_File := Load_File (Id); + Design_File := Files (I); Unit := Get_First_Design_Unit (Design_File); declare use Files_Map; diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 70fea3be9..aa7c067c1 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -603,6 +603,22 @@ package body Iirs is Set_Field3 (Design, Time_Stamp_Id_To_Iir (Stamp)); end Set_Analysis_Time_Stamp; + function Get_Design_File_Source (Design : Iir) return Source_File_Entry is + begin + pragma Assert (Design /= Null_Iir); + pragma Assert (Has_Design_File_Source (Get_Kind (Design)), + "no field Design_File_Source"); + return Iir_To_Source_File_Entry (Get_Field7 (Design)); + end Get_Design_File_Source; + + procedure Set_Design_File_Source (Design : Iir; Sfe : Source_File_Entry) is + begin + pragma Assert (Design /= Null_Iir); + pragma Assert (Has_Design_File_Source (Get_Kind (Design)), + "no field Design_File_Source"); + Set_Field7 (Design, Source_File_Entry_To_Iir (Sfe)); + end Set_Design_File_Source; + function Get_Library (File : Iir_Design_File) return Iir is begin pragma Assert (File /= Null_Iir); diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index 7e3479421..1214237b0 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -204,6 +204,8 @@ package Iirs is -- -- Get/Set_Last_Design_Unit (Field6) -- + -- Get/Set_Design_File_Source (Field7) + -- -- Identifier for the design file file name and dirname. -- Get/Set_Design_File_Filename (Field12) -- Get/Set_Design_File_Directory (Field11) @@ -5871,6 +5873,10 @@ package Iirs is function Get_Analysis_Time_Stamp (Design : Iir) return Time_Stamp_Id; procedure Set_Analysis_Time_Stamp (Design : Iir; Stamp : Time_Stamp_Id); + -- Field: Field7 (uc) + function Get_Design_File_Source (Design : Iir) return Source_File_Entry; + procedure Set_Design_File_Source (Design : Iir; Sfe : Source_File_Entry); + -- The library which FILE belongs to. -- Field: Field0 Ref function Get_Library (File : Iir_Design_File) return Iir; diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index f865ce8c1..96e3e7180 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -24,6 +24,7 @@ package body Nodes_Meta is Field_Library_Declaration => Type_Iir, Field_File_Checksum => Type_File_Checksum_Id, Field_Analysis_Time_Stamp => Type_Time_Stamp_Id, + Field_Design_File_Source => Type_Source_File_Entry, Field_Library => Type_Iir, Field_File_Dependence_List => Type_Iir_List, Field_Design_File_Filename => Type_Name_Id, @@ -366,6 +367,8 @@ package body Nodes_Meta is return "file_checksum"; when Field_Analysis_Time_Stamp => return "analysis_time_stamp"; + when Field_Design_File_Source => + return "design_file_source"; when Field_Library => return "library"; when Field_File_Dependence_List => @@ -1570,6 +1573,8 @@ package body Nodes_Meta is return Attr_None; when Field_Analysis_Time_Stamp => return Attr_None; + when Field_Design_File_Source => + return Attr_None; when Field_Library => return Attr_Ref; when Field_File_Dependence_List => @@ -2234,6 +2239,7 @@ package body Nodes_Meta is Field_Design_File_Filename, Field_Analysis_Time_Stamp, Field_File_Checksum, + Field_Design_File_Source, Field_Elab_Flag, Field_Library, Field_File_Dependence_List, @@ -4425,273 +4431,273 @@ package body Nodes_Meta is ( Iir_Kind_Unused => -1, Iir_Kind_Error => 7, - Iir_Kind_Design_File => 17, - Iir_Kind_Design_Unit => 33, - Iir_Kind_Library_Clause => 38, - Iir_Kind_Use_Clause => 42, - Iir_Kind_Context_Reference => 46, - Iir_Kind_Integer_Literal => 50, - Iir_Kind_Floating_Point_Literal => 54, - Iir_Kind_Null_Literal => 56, - Iir_Kind_String_Literal8 => 66, - Iir_Kind_Physical_Int_Literal => 72, - Iir_Kind_Physical_Fp_Literal => 78, - Iir_Kind_Simple_Aggregate => 83, - Iir_Kind_Overflow_Literal => 86, - Iir_Kind_Unaffected_Waveform => 87, - Iir_Kind_Waveform_Element => 90, - Iir_Kind_Conditional_Waveform => 94, - Iir_Kind_Conditional_Expression => 98, - Iir_Kind_Association_Element_By_Expression => 106, - Iir_Kind_Association_Element_By_Individual => 115, - Iir_Kind_Association_Element_Open => 121, - Iir_Kind_Association_Element_Package => 127, - Iir_Kind_Association_Element_Type => 135, - Iir_Kind_Association_Element_Subprogram => 141, - Iir_Kind_Choice_By_Range => 151, - Iir_Kind_Choice_By_Expression => 161, - Iir_Kind_Choice_By_Others => 169, - Iir_Kind_Choice_By_None => 177, - Iir_Kind_Choice_By_Name => 186, - Iir_Kind_Entity_Aspect_Entity => 188, - Iir_Kind_Entity_Aspect_Configuration => 189, - Iir_Kind_Entity_Aspect_Open => 189, - Iir_Kind_Block_Configuration => 195, - Iir_Kind_Block_Header => 199, - Iir_Kind_Component_Configuration => 206, - Iir_Kind_Binding_Indication => 210, - Iir_Kind_Entity_Class => 212, - Iir_Kind_Attribute_Value => 220, - Iir_Kind_Signature => 223, - Iir_Kind_Aggregate_Info => 230, - Iir_Kind_Procedure_Call => 234, - Iir_Kind_Record_Element_Constraint => 241, - Iir_Kind_Array_Element_Resolution => 243, - Iir_Kind_Record_Resolution => 244, - Iir_Kind_Record_Element_Resolution => 247, - Iir_Kind_Attribute_Specification => 255, - Iir_Kind_Disconnection_Specification => 261, - Iir_Kind_Configuration_Specification => 267, - Iir_Kind_Access_Type_Definition => 275, - Iir_Kind_Incomplete_Type_Definition => 283, - Iir_Kind_Interface_Type_Definition => 290, - Iir_Kind_File_Type_Definition => 297, - Iir_Kind_Protected_Type_Declaration => 306, - Iir_Kind_Record_Type_Definition => 316, - Iir_Kind_Array_Type_Definition => 328, - Iir_Kind_Array_Subtype_Definition => 343, - Iir_Kind_Record_Subtype_Definition => 354, - Iir_Kind_Access_Subtype_Definition => 362, - Iir_Kind_Physical_Subtype_Definition => 372, - Iir_Kind_Floating_Subtype_Definition => 383, - Iir_Kind_Integer_Subtype_Definition => 393, - Iir_Kind_Enumeration_Subtype_Definition => 403, - Iir_Kind_Enumeration_Type_Definition => 414, - Iir_Kind_Integer_Type_Definition => 422, - Iir_Kind_Floating_Type_Definition => 430, - Iir_Kind_Physical_Type_Definition => 441, - Iir_Kind_Range_Expression => 449, - Iir_Kind_Protected_Type_Body => 456, - Iir_Kind_Wildcard_Type_Definition => 461, - Iir_Kind_Subtype_Definition => 466, - Iir_Kind_Scalar_Nature_Definition => 470, - Iir_Kind_Overload_List => 471, - Iir_Kind_Type_Declaration => 478, - Iir_Kind_Anonymous_Type_Declaration => 484, - Iir_Kind_Subtype_Declaration => 491, - Iir_Kind_Nature_Declaration => 497, - Iir_Kind_Subnature_Declaration => 503, - Iir_Kind_Entity_Declaration => 515, - Iir_Kind_Configuration_Declaration => 524, - Iir_Kind_Context_Declaration => 530, - Iir_Kind_Package_Declaration => 545, - Iir_Kind_Package_Instantiation_Declaration => 559, - Iir_Kind_Package_Body => 567, - Iir_Kind_Architecture_Body => 579, - Iir_Kind_Package_Header => 581, - Iir_Kind_Unit_Declaration => 590, - Iir_Kind_Library_Declaration => 597, - Iir_Kind_Component_Declaration => 607, - Iir_Kind_Attribute_Declaration => 614, - Iir_Kind_Group_Template_Declaration => 620, - Iir_Kind_Group_Declaration => 627, - Iir_Kind_Element_Declaration => 635, - Iir_Kind_Non_Object_Alias_Declaration => 643, - Iir_Kind_Psl_Declaration => 651, - Iir_Kind_Psl_Endpoint_Declaration => 665, - Iir_Kind_Terminal_Declaration => 671, - Iir_Kind_Free_Quantity_Declaration => 680, - Iir_Kind_Across_Quantity_Declaration => 692, - Iir_Kind_Through_Quantity_Declaration => 704, - Iir_Kind_Enumeration_Literal => 715, - Iir_Kind_Function_Declaration => 740, - Iir_Kind_Procedure_Declaration => 764, - Iir_Kind_Function_Body => 774, - Iir_Kind_Procedure_Body => 785, - Iir_Kind_Object_Alias_Declaration => 796, - Iir_Kind_File_Declaration => 810, - Iir_Kind_Guard_Signal_Declaration => 823, - Iir_Kind_Signal_Declaration => 840, - Iir_Kind_Variable_Declaration => 853, - Iir_Kind_Constant_Declaration => 867, - Iir_Kind_Iterator_Declaration => 878, - Iir_Kind_Interface_Constant_Declaration => 894, - Iir_Kind_Interface_Variable_Declaration => 910, - Iir_Kind_Interface_Signal_Declaration => 931, - Iir_Kind_Interface_File_Declaration => 947, - Iir_Kind_Interface_Type_Declaration => 957, - Iir_Kind_Interface_Package_Declaration => 969, - Iir_Kind_Interface_Function_Declaration => 986, - Iir_Kind_Interface_Procedure_Declaration => 999, - Iir_Kind_Signal_Attribute_Declaration => 1002, - Iir_Kind_Identity_Operator => 1006, - Iir_Kind_Negation_Operator => 1010, - Iir_Kind_Absolute_Operator => 1014, - Iir_Kind_Not_Operator => 1018, - Iir_Kind_Implicit_Condition_Operator => 1022, - Iir_Kind_Condition_Operator => 1026, - Iir_Kind_Reduction_And_Operator => 1030, - Iir_Kind_Reduction_Or_Operator => 1034, - Iir_Kind_Reduction_Nand_Operator => 1038, - Iir_Kind_Reduction_Nor_Operator => 1042, - Iir_Kind_Reduction_Xor_Operator => 1046, - Iir_Kind_Reduction_Xnor_Operator => 1050, - Iir_Kind_And_Operator => 1055, - Iir_Kind_Or_Operator => 1060, - Iir_Kind_Nand_Operator => 1065, - Iir_Kind_Nor_Operator => 1070, - Iir_Kind_Xor_Operator => 1075, - Iir_Kind_Xnor_Operator => 1080, - Iir_Kind_Equality_Operator => 1085, - Iir_Kind_Inequality_Operator => 1090, - Iir_Kind_Less_Than_Operator => 1095, - Iir_Kind_Less_Than_Or_Equal_Operator => 1100, - Iir_Kind_Greater_Than_Operator => 1105, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1110, - Iir_Kind_Match_Equality_Operator => 1115, - Iir_Kind_Match_Inequality_Operator => 1120, - Iir_Kind_Match_Less_Than_Operator => 1125, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1130, - Iir_Kind_Match_Greater_Than_Operator => 1135, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1140, - Iir_Kind_Sll_Operator => 1145, - Iir_Kind_Sla_Operator => 1150, - Iir_Kind_Srl_Operator => 1155, - Iir_Kind_Sra_Operator => 1160, - Iir_Kind_Rol_Operator => 1165, - Iir_Kind_Ror_Operator => 1170, - Iir_Kind_Addition_Operator => 1175, - Iir_Kind_Substraction_Operator => 1180, - Iir_Kind_Concatenation_Operator => 1185, - Iir_Kind_Multiplication_Operator => 1190, - Iir_Kind_Division_Operator => 1195, - Iir_Kind_Modulus_Operator => 1200, - Iir_Kind_Remainder_Operator => 1205, - Iir_Kind_Exponentiation_Operator => 1210, - Iir_Kind_Function_Call => 1218, - Iir_Kind_Aggregate => 1225, - Iir_Kind_Parenthesis_Expression => 1228, - Iir_Kind_Qualified_Expression => 1232, - Iir_Kind_Type_Conversion => 1237, - Iir_Kind_Allocator_By_Expression => 1241, - Iir_Kind_Allocator_By_Subtype => 1246, - Iir_Kind_Selected_Element => 1253, - Iir_Kind_Dereference => 1258, - Iir_Kind_Implicit_Dereference => 1263, - Iir_Kind_Slice_Name => 1270, - Iir_Kind_Indexed_Name => 1276, - Iir_Kind_Psl_Expression => 1278, - Iir_Kind_Sensitized_Process_Statement => 1299, - Iir_Kind_Process_Statement => 1319, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1331, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1343, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1356, - Iir_Kind_Concurrent_Assertion_Statement => 1364, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1371, - Iir_Kind_Psl_Assert_Statement => 1384, - Iir_Kind_Psl_Cover_Statement => 1397, - Iir_Kind_Block_Statement => 1410, - Iir_Kind_If_Generate_Statement => 1421, - Iir_Kind_Case_Generate_Statement => 1430, - Iir_Kind_For_Generate_Statement => 1439, - Iir_Kind_Component_Instantiation_Statement => 1450, - Iir_Kind_Psl_Default_Clock => 1454, - Iir_Kind_Simple_Simultaneous_Statement => 1461, - Iir_Kind_Generate_Statement_Body => 1472, - Iir_Kind_If_Generate_Else_Clause => 1478, - Iir_Kind_Simple_Signal_Assignment_Statement => 1488, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1498, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1509, - Iir_Kind_Null_Statement => 1513, - Iir_Kind_Assertion_Statement => 1520, - Iir_Kind_Report_Statement => 1526, - Iir_Kind_Wait_Statement => 1534, - Iir_Kind_Variable_Assignment_Statement => 1541, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1548, - Iir_Kind_Return_Statement => 1554, - Iir_Kind_For_Loop_Statement => 1563, - Iir_Kind_While_Loop_Statement => 1572, - Iir_Kind_Next_Statement => 1579, - Iir_Kind_Exit_Statement => 1586, - Iir_Kind_Case_Statement => 1594, - Iir_Kind_Procedure_Call_Statement => 1600, - Iir_Kind_If_Statement => 1610, - Iir_Kind_Elsif => 1616, - Iir_Kind_Character_Literal => 1624, - Iir_Kind_Simple_Name => 1632, - Iir_Kind_Selected_Name => 1641, - Iir_Kind_Operator_Symbol => 1647, - Iir_Kind_Reference_Name => 1650, - Iir_Kind_External_Constant_Name => 1659, - Iir_Kind_External_Signal_Name => 1668, - Iir_Kind_External_Variable_Name => 1677, - Iir_Kind_Selected_By_All_Name => 1683, - Iir_Kind_Parenthesis_Name => 1688, - Iir_Kind_Package_Pathname => 1692, - Iir_Kind_Absolute_Pathname => 1693, - Iir_Kind_Relative_Pathname => 1694, - Iir_Kind_Pathname_Element => 1699, - Iir_Kind_Base_Attribute => 1701, - Iir_Kind_Subtype_Attribute => 1706, - Iir_Kind_Element_Attribute => 1711, - Iir_Kind_Left_Type_Attribute => 1716, - Iir_Kind_Right_Type_Attribute => 1721, - Iir_Kind_High_Type_Attribute => 1726, - Iir_Kind_Low_Type_Attribute => 1731, - Iir_Kind_Ascending_Type_Attribute => 1736, - Iir_Kind_Image_Attribute => 1742, - Iir_Kind_Value_Attribute => 1748, - Iir_Kind_Pos_Attribute => 1754, - Iir_Kind_Val_Attribute => 1760, - Iir_Kind_Succ_Attribute => 1766, - Iir_Kind_Pred_Attribute => 1772, - Iir_Kind_Leftof_Attribute => 1778, - Iir_Kind_Rightof_Attribute => 1784, - Iir_Kind_Delayed_Attribute => 1793, - Iir_Kind_Stable_Attribute => 1802, - Iir_Kind_Quiet_Attribute => 1811, - Iir_Kind_Transaction_Attribute => 1820, - Iir_Kind_Event_Attribute => 1824, - Iir_Kind_Active_Attribute => 1828, - Iir_Kind_Last_Event_Attribute => 1832, - Iir_Kind_Last_Active_Attribute => 1836, - Iir_Kind_Last_Value_Attribute => 1840, - Iir_Kind_Driving_Attribute => 1844, - Iir_Kind_Driving_Value_Attribute => 1848, - Iir_Kind_Behavior_Attribute => 1848, - Iir_Kind_Structure_Attribute => 1848, - Iir_Kind_Simple_Name_Attribute => 1855, - Iir_Kind_Instance_Name_Attribute => 1860, - Iir_Kind_Path_Name_Attribute => 1865, - Iir_Kind_Left_Array_Attribute => 1872, - Iir_Kind_Right_Array_Attribute => 1879, - Iir_Kind_High_Array_Attribute => 1886, - Iir_Kind_Low_Array_Attribute => 1893, - Iir_Kind_Length_Array_Attribute => 1900, - Iir_Kind_Ascending_Array_Attribute => 1907, - Iir_Kind_Range_Array_Attribute => 1914, - Iir_Kind_Reverse_Range_Array_Attribute => 1921, - Iir_Kind_Attribute_Name => 1930 + Iir_Kind_Design_File => 18, + Iir_Kind_Design_Unit => 34, + Iir_Kind_Library_Clause => 39, + Iir_Kind_Use_Clause => 43, + Iir_Kind_Context_Reference => 47, + Iir_Kind_Integer_Literal => 51, + Iir_Kind_Floating_Point_Literal => 55, + Iir_Kind_Null_Literal => 57, + Iir_Kind_String_Literal8 => 67, + Iir_Kind_Physical_Int_Literal => 73, + Iir_Kind_Physical_Fp_Literal => 79, + Iir_Kind_Simple_Aggregate => 84, + Iir_Kind_Overflow_Literal => 87, + Iir_Kind_Unaffected_Waveform => 88, + Iir_Kind_Waveform_Element => 91, + Iir_Kind_Conditional_Waveform => 95, + Iir_Kind_Conditional_Expression => 99, + Iir_Kind_Association_Element_By_Expression => 107, + Iir_Kind_Association_Element_By_Individual => 116, + Iir_Kind_Association_Element_Open => 122, + Iir_Kind_Association_Element_Package => 128, + Iir_Kind_Association_Element_Type => 136, + Iir_Kind_Association_Element_Subprogram => 142, + Iir_Kind_Choice_By_Range => 152, + Iir_Kind_Choice_By_Expression => 162, + Iir_Kind_Choice_By_Others => 170, + Iir_Kind_Choice_By_None => 178, + Iir_Kind_Choice_By_Name => 187, + Iir_Kind_Entity_Aspect_Entity => 189, + Iir_Kind_Entity_Aspect_Configuration => 190, + Iir_Kind_Entity_Aspect_Open => 190, + Iir_Kind_Block_Configuration => 196, + Iir_Kind_Block_Header => 200, + Iir_Kind_Component_Configuration => 207, + Iir_Kind_Binding_Indication => 211, + Iir_Kind_Entity_Class => 213, + Iir_Kind_Attribute_Value => 221, + Iir_Kind_Signature => 224, + Iir_Kind_Aggregate_Info => 231, + Iir_Kind_Procedure_Call => 235, + Iir_Kind_Record_Element_Constraint => 242, + Iir_Kind_Array_Element_Resolution => 244, + Iir_Kind_Record_Resolution => 245, + Iir_Kind_Record_Element_Resolution => 248, + Iir_Kind_Attribute_Specification => 256, + Iir_Kind_Disconnection_Specification => 262, + Iir_Kind_Configuration_Specification => 268, + Iir_Kind_Access_Type_Definition => 276, + Iir_Kind_Incomplete_Type_Definition => 284, + Iir_Kind_Interface_Type_Definition => 291, + Iir_Kind_File_Type_Definition => 298, + Iir_Kind_Protected_Type_Declaration => 307, + Iir_Kind_Record_Type_Definition => 317, + Iir_Kind_Array_Type_Definition => 329, + Iir_Kind_Array_Subtype_Definition => 344, + Iir_Kind_Record_Subtype_Definition => 355, + Iir_Kind_Access_Subtype_Definition => 363, + Iir_Kind_Physical_Subtype_Definition => 373, + Iir_Kind_Floating_Subtype_Definition => 384, + Iir_Kind_Integer_Subtype_Definition => 394, + Iir_Kind_Enumeration_Subtype_Definition => 404, + Iir_Kind_Enumeration_Type_Definition => 415, + Iir_Kind_Integer_Type_Definition => 423, + Iir_Kind_Floating_Type_Definition => 431, + Iir_Kind_Physical_Type_Definition => 442, + Iir_Kind_Range_Expression => 450, + Iir_Kind_Protected_Type_Body => 457, + Iir_Kind_Wildcard_Type_Definition => 462, + Iir_Kind_Subtype_Definition => 467, + Iir_Kind_Scalar_Nature_Definition => 471, + Iir_Kind_Overload_List => 472, + Iir_Kind_Type_Declaration => 479, + Iir_Kind_Anonymous_Type_Declaration => 485, + Iir_Kind_Subtype_Declaration => 492, + Iir_Kind_Nature_Declaration => 498, + Iir_Kind_Subnature_Declaration => 504, + Iir_Kind_Entity_Declaration => 516, + Iir_Kind_Configuration_Declaration => 525, + Iir_Kind_Context_Declaration => 531, + Iir_Kind_Package_Declaration => 546, + Iir_Kind_Package_Instantiation_Declaration => 560, + Iir_Kind_Package_Body => 568, + Iir_Kind_Architecture_Body => 580, + Iir_Kind_Package_Header => 582, + Iir_Kind_Unit_Declaration => 591, + Iir_Kind_Library_Declaration => 598, + Iir_Kind_Component_Declaration => 608, + Iir_Kind_Attribute_Declaration => 615, + Iir_Kind_Group_Template_Declaration => 621, + Iir_Kind_Group_Declaration => 628, + Iir_Kind_Element_Declaration => 636, + Iir_Kind_Non_Object_Alias_Declaration => 644, + Iir_Kind_Psl_Declaration => 652, + Iir_Kind_Psl_Endpoint_Declaration => 666, + Iir_Kind_Terminal_Declaration => 672, + Iir_Kind_Free_Quantity_Declaration => 681, + Iir_Kind_Across_Quantity_Declaration => 693, + Iir_Kind_Through_Quantity_Declaration => 705, + Iir_Kind_Enumeration_Literal => 716, + Iir_Kind_Function_Declaration => 741, + Iir_Kind_Procedure_Declaration => 765, + Iir_Kind_Function_Body => 775, + Iir_Kind_Procedure_Body => 786, + Iir_Kind_Object_Alias_Declaration => 797, + Iir_Kind_File_Declaration => 811, + Iir_Kind_Guard_Signal_Declaration => 824, + Iir_Kind_Signal_Declaration => 841, + Iir_Kind_Variable_Declaration => 854, + Iir_Kind_Constant_Declaration => 868, + Iir_Kind_Iterator_Declaration => 879, + Iir_Kind_Interface_Constant_Declaration => 895, + Iir_Kind_Interface_Variable_Declaration => 911, + Iir_Kind_Interface_Signal_Declaration => 932, + Iir_Kind_Interface_File_Declaration => 948, + Iir_Kind_Interface_Type_Declaration => 958, + Iir_Kind_Interface_Package_Declaration => 970, + Iir_Kind_Interface_Function_Declaration => 987, + Iir_Kind_Interface_Procedure_Declaration => 1000, + Iir_Kind_Signal_Attribute_Declaration => 1003, + Iir_Kind_Identity_Operator => 1007, + Iir_Kind_Negation_Operator => 1011, + Iir_Kind_Absolute_Operator => 1015, + Iir_Kind_Not_Operator => 1019, + Iir_Kind_Implicit_Condition_Operator => 1023, + Iir_Kind_Condition_Operator => 1027, + Iir_Kind_Reduction_And_Operator => 1031, + Iir_Kind_Reduction_Or_Operator => 1035, + Iir_Kind_Reduction_Nand_Operator => 1039, + Iir_Kind_Reduction_Nor_Operator => 1043, + Iir_Kind_Reduction_Xor_Operator => 1047, + Iir_Kind_Reduction_Xnor_Operator => 1051, + Iir_Kind_And_Operator => 1056, + Iir_Kind_Or_Operator => 1061, + Iir_Kind_Nand_Operator => 1066, + Iir_Kind_Nor_Operator => 1071, + Iir_Kind_Xor_Operator => 1076, + Iir_Kind_Xnor_Operator => 1081, + Iir_Kind_Equality_Operator => 1086, + Iir_Kind_Inequality_Operator => 1091, + Iir_Kind_Less_Than_Operator => 1096, + Iir_Kind_Less_Than_Or_Equal_Operator => 1101, + Iir_Kind_Greater_Than_Operator => 1106, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1111, + Iir_Kind_Match_Equality_Operator => 1116, + Iir_Kind_Match_Inequality_Operator => 1121, + Iir_Kind_Match_Less_Than_Operator => 1126, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1131, + Iir_Kind_Match_Greater_Than_Operator => 1136, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1141, + Iir_Kind_Sll_Operator => 1146, + Iir_Kind_Sla_Operator => 1151, + Iir_Kind_Srl_Operator => 1156, + Iir_Kind_Sra_Operator => 1161, + Iir_Kind_Rol_Operator => 1166, + Iir_Kind_Ror_Operator => 1171, + Iir_Kind_Addition_Operator => 1176, + Iir_Kind_Substraction_Operator => 1181, + Iir_Kind_Concatenation_Operator => 1186, + Iir_Kind_Multiplication_Operator => 1191, + Iir_Kind_Division_Operator => 1196, + Iir_Kind_Modulus_Operator => 1201, + Iir_Kind_Remainder_Operator => 1206, + Iir_Kind_Exponentiation_Operator => 1211, + Iir_Kind_Function_Call => 1219, + Iir_Kind_Aggregate => 1226, + Iir_Kind_Parenthesis_Expression => 1229, + Iir_Kind_Qualified_Expression => 1233, + Iir_Kind_Type_Conversion => 1238, + Iir_Kind_Allocator_By_Expression => 1242, + Iir_Kind_Allocator_By_Subtype => 1247, + Iir_Kind_Selected_Element => 1254, + Iir_Kind_Dereference => 1259, + Iir_Kind_Implicit_Dereference => 1264, + Iir_Kind_Slice_Name => 1271, + Iir_Kind_Indexed_Name => 1277, + Iir_Kind_Psl_Expression => 1279, + Iir_Kind_Sensitized_Process_Statement => 1300, + Iir_Kind_Process_Statement => 1320, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1332, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1344, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1357, + Iir_Kind_Concurrent_Assertion_Statement => 1365, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1372, + Iir_Kind_Psl_Assert_Statement => 1385, + Iir_Kind_Psl_Cover_Statement => 1398, + Iir_Kind_Block_Statement => 1411, + Iir_Kind_If_Generate_Statement => 1422, + Iir_Kind_Case_Generate_Statement => 1431, + Iir_Kind_For_Generate_Statement => 1440, + Iir_Kind_Component_Instantiation_Statement => 1451, + Iir_Kind_Psl_Default_Clock => 1455, + Iir_Kind_Simple_Simultaneous_Statement => 1462, + Iir_Kind_Generate_Statement_Body => 1473, + Iir_Kind_If_Generate_Else_Clause => 1479, + Iir_Kind_Simple_Signal_Assignment_Statement => 1489, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1499, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1510, + Iir_Kind_Null_Statement => 1514, + Iir_Kind_Assertion_Statement => 1521, + Iir_Kind_Report_Statement => 1527, + Iir_Kind_Wait_Statement => 1535, + Iir_Kind_Variable_Assignment_Statement => 1542, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1549, + Iir_Kind_Return_Statement => 1555, + Iir_Kind_For_Loop_Statement => 1564, + Iir_Kind_While_Loop_Statement => 1573, + Iir_Kind_Next_Statement => 1580, + Iir_Kind_Exit_Statement => 1587, + Iir_Kind_Case_Statement => 1595, + Iir_Kind_Procedure_Call_Statement => 1601, + Iir_Kind_If_Statement => 1611, + Iir_Kind_Elsif => 1617, + Iir_Kind_Character_Literal => 1625, + Iir_Kind_Simple_Name => 1633, + Iir_Kind_Selected_Name => 1642, + Iir_Kind_Operator_Symbol => 1648, + Iir_Kind_Reference_Name => 1651, + Iir_Kind_External_Constant_Name => 1660, + Iir_Kind_External_Signal_Name => 1669, + Iir_Kind_External_Variable_Name => 1678, + Iir_Kind_Selected_By_All_Name => 1684, + Iir_Kind_Parenthesis_Name => 1689, + Iir_Kind_Package_Pathname => 1693, + Iir_Kind_Absolute_Pathname => 1694, + Iir_Kind_Relative_Pathname => 1695, + Iir_Kind_Pathname_Element => 1700, + Iir_Kind_Base_Attribute => 1702, + Iir_Kind_Subtype_Attribute => 1707, + Iir_Kind_Element_Attribute => 1712, + Iir_Kind_Left_Type_Attribute => 1717, + Iir_Kind_Right_Type_Attribute => 1722, + Iir_Kind_High_Type_Attribute => 1727, + Iir_Kind_Low_Type_Attribute => 1732, + Iir_Kind_Ascending_Type_Attribute => 1737, + Iir_Kind_Image_Attribute => 1743, + Iir_Kind_Value_Attribute => 1749, + Iir_Kind_Pos_Attribute => 1755, + Iir_Kind_Val_Attribute => 1761, + Iir_Kind_Succ_Attribute => 1767, + Iir_Kind_Pred_Attribute => 1773, + Iir_Kind_Leftof_Attribute => 1779, + Iir_Kind_Rightof_Attribute => 1785, + Iir_Kind_Delayed_Attribute => 1794, + Iir_Kind_Stable_Attribute => 1803, + Iir_Kind_Quiet_Attribute => 1812, + Iir_Kind_Transaction_Attribute => 1821, + Iir_Kind_Event_Attribute => 1825, + Iir_Kind_Active_Attribute => 1829, + Iir_Kind_Last_Event_Attribute => 1833, + Iir_Kind_Last_Active_Attribute => 1837, + Iir_Kind_Last_Value_Attribute => 1841, + Iir_Kind_Driving_Attribute => 1845, + Iir_Kind_Driving_Value_Attribute => 1849, + Iir_Kind_Behavior_Attribute => 1849, + Iir_Kind_Structure_Attribute => 1849, + Iir_Kind_Simple_Name_Attribute => 1856, + Iir_Kind_Instance_Name_Attribute => 1861, + Iir_Kind_Path_Name_Attribute => 1866, + Iir_Kind_Left_Array_Attribute => 1873, + Iir_Kind_Right_Array_Attribute => 1880, + Iir_Kind_High_Array_Attribute => 1887, + Iir_Kind_Low_Array_Attribute => 1894, + Iir_Kind_Length_Array_Attribute => 1901, + Iir_Kind_Ascending_Array_Attribute => 1908, + Iir_Kind_Range_Array_Attribute => 1915, + Iir_Kind_Reverse_Range_Array_Attribute => 1922, + Iir_Kind_Attribute_Name => 1931 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -6506,6 +6512,8 @@ package body Nodes_Meta is begin pragma Assert (Fields_Type (F) = Type_Source_File_Entry); case F is + when Field_Design_File_Source => + return Get_Design_File_Source (N); when Field_Instance_Source_File => return Get_Instance_Source_File (N); when others => @@ -6518,6 +6526,8 @@ package body Nodes_Meta is begin pragma Assert (Fields_Type (F) = Type_Source_File_Entry); case F is + when Field_Design_File_Source => + Set_Design_File_Source (N, V); when Field_Instance_Source_File => Set_Instance_Source_File (N, V); when others => @@ -6674,6 +6684,11 @@ package body Nodes_Meta is return K = Iir_Kind_Design_File; end Has_Analysis_Time_Stamp; + function Has_Design_File_Source (K : Iir_Kind) return Boolean is + begin + return K = Iir_Kind_Design_File; + end Has_Design_File_Source; + function Has_Library (K : Iir_Kind) return Boolean is begin return K = Iir_Kind_Design_File; diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads index 25faea793..98dd65a46 100644 --- a/src/vhdl/nodes_meta.ads +++ b/src/vhdl/nodes_meta.ads @@ -65,6 +65,7 @@ package Nodes_Meta is Field_Library_Declaration, Field_File_Checksum, Field_Analysis_Time_Stamp, + Field_Design_File_Source, Field_Library, Field_File_Dependence_List, Field_Design_File_Filename, @@ -594,6 +595,7 @@ package Nodes_Meta is function Has_Library_Declaration (K : Iir_Kind) return Boolean; function Has_File_Checksum (K : Iir_Kind) return Boolean; function Has_Analysis_Time_Stamp (K : Iir_Kind) return Boolean; + function Has_Design_File_Source (K : Iir_Kind) return Boolean; function Has_Library (K : Iir_Kind) return Boolean; function Has_File_Dependence_List (K : Iir_Kind) return Boolean; function Has_Design_File_Filename (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/sem_lib.adb b/src/vhdl/sem_lib.adb index 0a6fce10d..5f1c0b367 100644 --- a/src/vhdl/sem_lib.adb +++ b/src/vhdl/sem_lib.adb @@ -53,6 +53,7 @@ package body Sem_Lib is if Res /= Null_Iir then Set_Parent (Res, Work_Library); Set_Design_File_Filename (Res, Files_Map.Get_File_Name (File)); + Set_Design_File_Source (Res, File); end if; return Res; end Load_File; @@ -159,41 +160,45 @@ package body Sem_Lib is procedure Load_Parse_Design_Unit (Design_Unit: Iir_Design_Unit; Loc : Iir) is use Scanner; + Design_File : constant Iir_Design_File := Get_Design_File (Design_Unit); + Fe : Source_File_Entry; Line, Off: Natural; Pos: Source_Ptr; Res: Iir; - Design_File : Iir_Design_File; - Fe : Source_File_Entry; begin -- The unit must not be loaded. pragma Assert (Get_Date_State (Design_Unit) = Date_Disk); - -- Load the file in memory. - Design_File := Get_Design_File (Design_Unit); - Fe := Files_Map.Read_Source_File - (Get_Design_File_Directory (Design_File), - Get_Design_File_Filename (Design_File)); + Fe := Get_Design_File_Source (Design_File); if Fe = No_Source_File_Entry then - Error_Lib_Msg ("cannot load %n", +Get_Library_Unit (Design_Unit)); - raise Compilation_Error; + -- Load the file in memory. + Fe := Files_Map.Read_Source_File + (Get_Design_File_Directory (Design_File), + Get_Design_File_Filename (Design_File)); + if Fe = No_Source_File_Entry then + Error_Lib_Msg ("cannot load %n", +Get_Library_Unit (Design_Unit)); + raise Compilation_Error; + end if; + Set_Design_File_Source (Design_File, Fe); + + -- Check if the file has changed. + if not Files_Map.Is_Eq + (Files_Map.Get_File_Checksum (Fe), Get_File_Checksum (Design_File)) + then + Error_Msg_Sem (+Loc, "file %i has changed and must be reanalysed", + +Get_Design_File_Filename (Design_File)); + raise Compilation_Error; + end if; end if; - Set_File (Fe); - -- Check if the file has changed. - if not Files_Map.Is_Eq - (Files_Map.Get_File_Checksum (Get_Current_Source_File), - Get_File_Checksum (Design_File)) - then - Error_Msg_Sem (+Loc, "file %i has changed and must be reanalysed", - +Get_Design_File_Filename (Design_File)); - raise Compilation_Error; - elsif Get_Date (Design_Unit) = Date_Obsolete then + if Get_Date (Design_Unit) = Date_Obsolete then Error_Msg_Sem (+Design_Unit, "%n has been obsoleted", +Get_Library_Unit (Design_Unit)); raise Compilation_Error; end if; -- Set the position of the lexer + Set_File (Fe); Pos := Get_Design_Unit_Source_Pos (Design_Unit); Line := Natural (Get_Design_Unit_Source_Line (Design_Unit)); Off := Natural (Get_Design_Unit_Source_Col (Design_Unit)); |