diff options
-rw-r--r-- | src/ghdldrv/ghdlprint.adb | 2 | ||||
-rw-r--r-- | src/libraries.adb | 16 | ||||
-rw-r--r-- | src/std_names.adb | 2 | ||||
-rw-r--r-- | src/std_names.ads | 33 | ||||
-rw-r--r-- | src/vhdl/canon.adb | 8 | ||||
-rw-r--r-- | src/vhdl/configuration.adb | 14 | ||||
-rw-r--r-- | src/vhdl/errorout.adb | 4 | ||||
-rw-r--r-- | src/vhdl/iirs.adb | 22 | ||||
-rw-r--r-- | src/vhdl/iirs.ads | 53 | ||||
-rw-r--r-- | src/vhdl/iirs_utils.adb | 3 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb | 530 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/parse.adb | 231 | ||||
-rw-r--r-- | src/vhdl/post_sems.adb | 12 | ||||
-rw-r--r-- | src/vhdl/scanner.adb | 9 | ||||
-rw-r--r-- | src/vhdl/sem.adb | 139 | ||||
-rw-r--r-- | src/vhdl/sem_names.adb | 1 | ||||
-rw-r--r-- | src/vhdl/sem_scopes.adb | 49 | ||||
-rw-r--r-- | src/vhdl/sem_scopes.ads | 3 | ||||
-rw-r--r-- | src/vhdl/tokens.adb | 4 | ||||
-rw-r--r-- | src/vhdl/tokens.ads | 5 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap12.adb | 5 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap2.adb | 3 |
23 files changed, 824 insertions, 326 deletions
diff --git a/src/ghdldrv/ghdlprint.adb b/src/ghdldrv/ghdlprint.adb index 3668b0f..d0d2d3a 100644 --- a/src/ghdldrv/ghdlprint.adb +++ b/src/ghdldrv/ghdlprint.adb @@ -386,6 +386,8 @@ package body Ghdlprint is Disp_Reserved; when Tok_Protected => Disp_Reserved; + when Tok_Context => + Disp_Reserved; when Tok_Across .. Tok_Tolerance => Disp_Reserved; when Tok_Psl_Default diff --git a/src/libraries.adb b/src/libraries.adb index e01a9bc..39e5039 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -144,7 +144,8 @@ package body Libraries is | Iir_Kind_Configuration_Declaration | Iir_Kind_Package_Declaration | Iir_Kind_Package_Body - | Iir_Kind_Package_Instantiation_Declaration => + | Iir_Kind_Package_Instantiation_Declaration + | Iir_Kind_Context_Declaration => Id := Get_Identifier (Lib_Unit); when Iir_Kind_Architecture_Body => -- Architectures are put with the entity identifier. @@ -242,6 +243,7 @@ package body Libraries is -- | package_format -- | package_body_format -- | configuration_format + -- | context_format -- position_format ::= LINE(POS) + OFF on DATE -- entity_format ::= -- ENTITY identifier AT position_format ; @@ -253,6 +255,8 @@ package body Libraries is -- PACKAGE BODY identifier AT position_format ; -- configuration_format ::= -- CONFIGURATION identifier AT position_format ; + -- context_format ::= + -- CONTEXT identifier AT position_format ; -- -- The position_format meaning is: -- LINE is the line number (first line is number 1), @@ -481,6 +485,10 @@ package body Libraries is Scan; Set_Dependence_List (Design_Unit, Scan_Unit_List); goto Next_Line; + when Tok_Context => + Library_Unit := + Create_Iir (Iir_Kind_Context_Declaration); + Scan; when others => Put_Line ("load_library: line must start with " & @@ -1224,6 +1232,9 @@ package body Libraries is when Iir_Kind_Configuration_Declaration => WR ("configuration "); WR (Image_Identifier (Library_Unit)); + when Iir_Kind_Context_Declaration => + WR ("context "); + WR (Image_Identifier (Library_Unit)); when others => Error_Kind ("save_library", Library_Unit); end case; @@ -1585,7 +1596,8 @@ package body Libraries is when Iir_Kind_Package_Declaration | Iir_Kind_Package_Instantiation_Declaration | Iir_Kind_Entity_Declaration - | Iir_Kind_Configuration_Declaration => + | Iir_Kind_Configuration_Declaration + | Iir_Kind_Context_Declaration => -- Only return a primary unit. return Unit; when Iir_Kind_Package_Body diff --git a/src/std_names.adb b/src/std_names.adb index 3fa1b9d..c933839 100644 --- a/src/std_names.adb +++ b/src/std_names.adb @@ -154,6 +154,8 @@ package body Std_Names is Def ("protected", Name_Protected); + Def ("context", Name_Context); + Def ("across", Name_Across); Def ("break", Name_Break); Def ("limit", Name_Limit); diff --git a/src/std_names.ads b/src/std_names.ads index 0a44c91..d830499 100644 --- a/src/std_names.ads +++ b/src/std_names.ads @@ -172,19 +172,26 @@ package Std_Names is subtype Name_Id_Vhdl00_Reserved_Words is Name_Id range Name_Protected .. Name_Protected; - Name_Across : constant Name_Id := Name_First_Keyword + 098; - Name_Break : constant Name_Id := Name_First_Keyword + 099; - Name_Limit : constant Name_Id := Name_First_Keyword + 100; - Name_Nature : constant Name_Id := Name_First_Keyword + 101; - Name_Noise : constant Name_Id := Name_First_Keyword + 102; - Name_Procedural : constant Name_Id := Name_First_Keyword + 103; - Name_Quantity : constant Name_Id := Name_First_Keyword + 104; - Name_Reference : constant Name_Id := Name_First_Keyword + 105; - Name_Spectrum : constant Name_Id := Name_First_Keyword + 106; - Name_Subnature : constant Name_Id := Name_First_Keyword + 107; - Name_Terminal : constant Name_Id := Name_First_Keyword + 108; - Name_Through : constant Name_Id := Name_First_Keyword + 109; - Name_Tolerance : constant Name_Id := Name_First_Keyword + 110; + Name_Context : constant Name_Id := Name_First_Keyword + 098; + + Name_Last_Vhdl08 : constant Name_Id := Name_Context; + subtype Name_Id_Vhdl08_Reserved_Words is + Name_Id range Name_Context .. Name_Context; + + Name_First_Ams_Keyword : constant Name_Id := Name_Last_Vhdl08 + 1; + Name_Across : constant Name_Id := Name_First_Ams_Keyword + 000; + Name_Break : constant Name_Id := Name_First_Ams_Keyword + 001; + Name_Limit : constant Name_Id := Name_First_Ams_Keyword + 002; + Name_Nature : constant Name_Id := Name_First_Ams_Keyword + 003; + Name_Noise : constant Name_Id := Name_First_Ams_Keyword + 004; + Name_Procedural : constant Name_Id := Name_First_Ams_Keyword + 005; + Name_Quantity : constant Name_Id := Name_First_Ams_Keyword + 006; + Name_Reference : constant Name_Id := Name_First_Ams_Keyword + 007; + Name_Spectrum : constant Name_Id := Name_First_Ams_Keyword + 008; + Name_Subnature : constant Name_Id := Name_First_Ams_Keyword + 009; + Name_Terminal : constant Name_Id := Name_First_Ams_Keyword + 010; + Name_Through : constant Name_Id := Name_First_Ams_Keyword + 011; + Name_Tolerance : constant Name_Id := Name_First_Ams_Keyword + 012; Name_Last_AMS_Vhdl : constant Name_Id := Name_Tolerance; diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb index 5eef955..b8c9d3d 100644 --- a/src/vhdl/canon.adb +++ b/src/vhdl/canon.adb @@ -2652,9 +2652,9 @@ package body Canon is El := Get_Context_Items (Unit); while El /= Null_Iir loop case Get_Kind (El) is - when Iir_Kind_Use_Clause => - null; - when Iir_Kind_Library_Clause => + when Iir_Kind_Use_Clause + | Iir_Kind_Library_Clause + | Iir_Kind_Context_Reference => null; when others => Error_Kind ("canonicalize1", El); @@ -2692,6 +2692,8 @@ package body Canon is (Get_Generic_Chain (Hdr), Get_Generic_Map_Aspect_Chain (El), El)); end; + when Iir_Kind_Context_Declaration => + null; when others => Error_Kind ("canonicalize2", El); end case; diff --git a/src/vhdl/configuration.adb b/src/vhdl/configuration.adb index 37817da..8533921 100644 --- a/src/vhdl/configuration.adb +++ b/src/vhdl/configuration.adb @@ -105,10 +105,16 @@ package body Configuration is El := Libraries.Find_Design_Unit (El); if El /= Null_Iir then Lib_Unit := Get_Library_Unit (El); - if Flag_Build_File_Dependence - or else Get_Kind (Lib_Unit) in Iir_Kinds_Package_Declaration - then + if Flag_Build_File_Dependence then Add_Design_Unit (El, Unit); + else + case Get_Kind (Lib_Unit) is + when Iir_Kinds_Package_Declaration + | Iir_Kind_Context_Declaration => + Add_Design_Unit (El, Unit); + when others => + null; + end case; end if; end if; end loop; @@ -153,6 +159,8 @@ package body Configuration is null; when Iir_Kind_Package_Body => null; + when Iir_Kind_Context_Declaration => + null; when others => Error_Kind ("add_design_unit", Lib_Unit); end case; diff --git a/src/vhdl/errorout.adb b/src/vhdl/errorout.adb index a364120..b5fe537 100644 --- a/src/vhdl/errorout.adb +++ b/src/vhdl/errorout.adb @@ -621,6 +621,8 @@ package body Errorout is & '(' & Image_Identifier (Arch) & ')'; end if; end; + when Iir_Kind_Context_Declaration => + return Disp_Identifier (Node, "context"); when Iir_Kind_Package_Instantiation_Declaration => return Disp_Identifier (Node, "instantiation package"); @@ -634,6 +636,8 @@ package body Errorout is return Disp_Node (Get_Library_Unit (Node)); when Iir_Kind_Use_Clause => return "use clause"; + when Iir_Kind_Context_Reference => + return "context reference"; when Iir_Kind_Disconnection_Specification => return "disconnection specification"; diff --git a/src/vhdl/iirs.adb b/src/vhdl/iirs.adb index 4340b9c..99b8756 100644 --- a/src/vhdl/iirs.adb +++ b/src/vhdl/iirs.adb @@ -243,6 +243,7 @@ package body Iirs is | Iir_Kind_Error | Iir_Kind_Library_Clause | Iir_Kind_Use_Clause + | Iir_Kind_Context_Reference | Iir_Kind_Null_Literal | Iir_Kind_String_Literal8 | Iir_Kind_Simple_Aggregate @@ -297,6 +298,7 @@ package body Iirs is | Iir_Kind_Package_Declaration | Iir_Kind_Package_Body | Iir_Kind_Configuration_Declaration + | Iir_Kind_Context_Declaration | Iir_Kind_Unit_Declaration | Iir_Kind_Library_Declaration | Iir_Kind_Attribute_Declaration @@ -2311,7 +2313,23 @@ package body Iirs is Set_Field3 (Target, Chain); end Set_Use_Clause_Chain; - function Get_Selected_Name (Target : Iir_Use_Clause) return Iir is + function Get_Context_Reference_Chain (Target : Iir) return Iir is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Context_Reference_Chain (Get_Kind (Target)), + "no field Context_Reference_Chain"); + return Get_Field3 (Target); + end Get_Context_Reference_Chain; + + procedure Set_Context_Reference_Chain (Target : Iir; Chain : Iir) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Context_Reference_Chain (Get_Kind (Target)), + "no field Context_Reference_Chain"); + Set_Field3 (Target, Chain); + end Set_Context_Reference_Chain; + + function Get_Selected_Name (Target : Iir) return Iir is begin pragma Assert (Target /= Null_Iir); pragma Assert (Has_Selected_Name (Get_Kind (Target)), @@ -2319,7 +2337,7 @@ package body Iirs is return Get_Field1 (Target); end Get_Selected_Name; - procedure Set_Selected_Name (Target : Iir_Use_Clause; Name : Iir) is + procedure Set_Selected_Name (Target : Iir; Name : Iir) is begin pragma Assert (Target /= Null_Iir); pragma Assert (Has_Selected_Name (Get_Kind (Target)), diff --git a/src/vhdl/iirs.ads b/src/vhdl/iirs.ads index db3826f..33b79e2 100644 --- a/src/vhdl/iirs.ads +++ b/src/vhdl/iirs.ads @@ -864,6 +864,22 @@ package Iirs is -- -- Get/Set_End_Has_Identifier (Flag9) + -- Iir_Kind_Context_Declaration (Short) + -- + -- Get/Set_Parent (Field0) + -- Get/Set_Design_Unit (Alias Field0) + -- + -- Get the chain of context clause. + -- Get/Set_Context_Items (Field1) + -- + -- Get/Set_Identifier (Field3) + -- + -- Get/Set_Visible_Flag (Flag4) + -- + -- Get/Set_End_Has_Reserved_Id (Flag8) + -- + -- Get/Set_End_Has_Identifier (Flag9) + -- Iir_Kind_Library_Declaration (Short) -- -- Design files in the library. @@ -1693,6 +1709,21 @@ package Iirs is -- -- Get/Set_Use_Clause_Chain (Field3) + -- Iir_Kind_Context_Reference (Short) + -- + -- LRM08 13.4 Context clauses + -- + -- context_reference ::= + -- CONTEXT selected_name { , selected_name } + -- + -- Get/Set_Parent (Field0) + -- + -- Get/Set_Selected_Name (Field1) + -- + -- Get/Set_Chain (Field2) + -- + -- Get/Set_Context_Reference_Chain (Field3) + ----------------------- -- type definitions -- @@ -3416,6 +3447,7 @@ package Iirs is Iir_Kind_Design_Unit, Iir_Kind_Library_Clause, Iir_Kind_Use_Clause, + Iir_Kind_Context_Reference, -- Literals. Iir_Kind_Integer_Literal, @@ -3502,6 +3534,7 @@ package Iirs is Iir_Kind_Configuration_Declaration, Iir_Kind_Entity_Declaration, Iir_Kind_Architecture_Body, + Iir_Kind_Context_Declaration, Iir_Kind_Package_Header, Iir_Kind_Unit_Declaration, Iir_Kind_Library_Declaration, @@ -4152,7 +4185,8 @@ package Iirs is --Iir_Kind_Package_Body --Iir_Kind_Configuration_Declaration --Iir_Kind_Entity_Declaration - Iir_Kind_Architecture_Body; + --Iir_Kind_Architecture_Body + Iir_Kind_Context_Declaration; subtype Iir_Kinds_Package_Declaration is Iir_Kind range Iir_Kind_Package_Declaration .. @@ -4506,7 +4540,8 @@ package Iirs is subtype Iir_Kinds_Clause is Iir_Kind range Iir_Kind_Library_Clause .. - Iir_Kind_Use_Clause; + --Iir_Kind_Use_Clause + Iir_Kind_Context_Reference; subtype Iir_Kinds_Specification is Iir_Kind range Iir_Kind_Attribute_Specification .. @@ -4525,6 +4560,7 @@ package Iirs is --Iir_Kind_Configuration_Declaration --Iir_Kind_Entity_Declaration --Iir_Kind_Architecture_Body + --Iir_Kind_Context_Declaration --Iir_Kind_Package_Header --Iir_Kind_Unit_Declaration --Iir_Kind_Library_Declaration @@ -4962,7 +4998,7 @@ package Iirs is procedure Set_Last_Design_Unit (Design : Iir; Chain : Iir); -- Library declaration of a library clause. - -- Field: Field1 + -- Field: Field1 Ref function Get_Library_Declaration (Design : Iir) return Iir; procedure Set_Library_Declaration (Design : Iir; Library : Iir); @@ -5547,10 +5583,15 @@ package Iirs is function Get_Use_Clause_Chain (Target : Iir) return Iir; procedure Set_Use_Clause_Chain (Target : Iir; Chain : Iir); - -- Selected name of an use_clause. + -- Selected names of a context_reference are chained. + -- Field: Field3 + function Get_Context_Reference_Chain (Target : Iir) return Iir; + procedure Set_Context_Reference_Chain (Target : Iir; Chain : Iir); + + -- Selected name of an use_clause or context_reference -- Field: Field1 - function Get_Selected_Name (Target : Iir_Use_Clause) return Iir; - procedure Set_Selected_Name (Target : Iir_Use_Clause; Name : Iir); + function Get_Selected_Name (Target : Iir) return Iir; + procedure Set_Selected_Name (Target : Iir; Name : Iir); -- The type declarator which declares the type definition DEF. -- Field: Field3 Ref diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb index b492a91..5fa9987 100644 --- a/src/vhdl/iirs_utils.adb +++ b/src/vhdl/iirs_utils.adb @@ -530,7 +530,8 @@ package body Iirs_Utils is when Iir_Kind_Package_Declaration | Iir_Kind_Package_Body | Iir_Kind_Entity_Declaration - | Iir_Kind_Configuration_Declaration => + | Iir_Kind_Configuration_Declaration + | Iir_Kind_Context_Declaration => null; when Iir_Kind_File_Type_Definition | Iir_Kind_Access_Type_Definition diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb index 4795441..13422cb 100644 --- a/src/vhdl/nodes_meta.adb +++ b/src/vhdl/nodes_meta.adb @@ -132,6 +132,7 @@ package body Nodes_Meta is Field_Element_Declaration => Type_Iir, Field_Selected_Element => Type_Iir, Field_Use_Clause_Chain => Type_Iir, + Field_Context_Reference_Chain => Type_Iir, Field_Selected_Name => Type_Iir, Field_Type_Declarator => Type_Iir, Field_Enumeration_Literal_List => Type_Iir_List, @@ -546,6 +547,8 @@ package body Nodes_Meta is return "selected_element"; when Field_Use_Clause_Chain => return "use_clause_chain"; + when Field_Context_Reference_Chain => + return "context_reference_chain"; when Field_Selected_Name => return "selected_name"; when Field_Type_Declarator => @@ -920,6 +923,8 @@ package body Nodes_Meta is return "library_clause"; when Iir_Kind_Use_Clause => return "use_clause"; + when Iir_Kind_Context_Reference => + return "context_reference"; when Iir_Kind_Integer_Literal => return "integer_literal"; when Iir_Kind_Floating_Point_Literal => @@ -1062,6 +1067,8 @@ package body Nodes_Meta is return "entity_declaration"; when Iir_Kind_Architecture_Body => return "architecture_body"; + when Iir_Kind_Context_Declaration => + return "context_declaration"; when Iir_Kind_Package_Header => return "package_header"; when Iir_Kind_Unit_Declaration => @@ -1399,7 +1406,7 @@ package body Nodes_Meta is when Field_Last_Design_Unit => return Attr_Ref; when Field_Library_Declaration => - return Attr_None; + return Attr_Ref; when Field_File_Time_Stamp => return Attr_None; when Field_Analysis_Time_Stamp => @@ -1620,6 +1627,8 @@ package body Nodes_Meta is return Attr_Ref; when Field_Use_Clause_Chain => return Attr_None; + when Field_Context_Reference_Chain => + return Attr_None; when Field_Selected_Name => return Attr_None; when Field_Type_Declarator => @@ -2021,14 +2030,19 @@ package body Nodes_Meta is -- Iir_Kind_Library_Clause Field_Identifier, Field_Has_Identifier_List, - Field_Library_Declaration, Field_Chain, Field_Parent, + Field_Library_Declaration, -- Iir_Kind_Use_Clause Field_Selected_Name, Field_Chain, Field_Use_Clause_Chain, Field_Parent, + -- Iir_Kind_Context_Reference + Field_Selected_Name, + Field_Chain, + Field_Context_Reference_Chain, + Field_Parent, -- Iir_Kind_Integer_Literal Field_Value, Field_Expr_Staticness, @@ -2543,6 +2557,13 @@ package body Nodes_Meta is Field_Concurrent_Statement_Chain, Field_Default_Configuration_Declaration, Field_Parent, + -- Iir_Kind_Context_Declaration + Field_Identifier, + Field_Visible_Flag, + Field_End_Has_Reserved_Id, + Field_End_Has_Identifier, + Field_Context_Items, + Field_Parent, -- Iir_Kind_Package_Header Field_Generic_Chain, Field_Generic_Map_Aspect_Chain, @@ -3858,240 +3879,242 @@ package body Nodes_Meta is Iir_Kind_Design_Unit => 32, Iir_Kind_Library_Clause => 37, Iir_Kind_Use_Clause => 41, - Iir_Kind_Integer_Literal => 45, - Iir_Kind_Floating_Point_Literal => 49, - Iir_Kind_Null_Literal => 51, - Iir_Kind_String_Literal8 => 61, - Iir_Kind_Physical_Int_Literal => 66, - Iir_Kind_Physical_Fp_Literal => 71, - Iir_Kind_Simple_Aggregate => 76, - Iir_Kind_Overflow_Literal => 79, - Iir_Kind_Waveform_Element => 82, - Iir_Kind_Conditional_Waveform => 85, - Iir_Kind_Association_Element_By_Expression => 92, - Iir_Kind_Association_Element_By_Individual => 98, - Iir_Kind_Association_Element_Open => 103, - Iir_Kind_Association_Element_Package => 109, - Iir_Kind_Choice_By_Others => 114, - Iir_Kind_Choice_By_Expression => 121, - Iir_Kind_Choice_By_Range => 128, - Iir_Kind_Choice_By_None => 133, - Iir_Kind_Choice_By_Name => 139, - Iir_Kind_Entity_Aspect_Entity => 141, - Iir_Kind_Entity_Aspect_Configuration => 142, - Iir_Kind_Entity_Aspect_Open => 142, - Iir_Kind_Block_Configuration => 148, - Iir_Kind_Block_Header => 152, - Iir_Kind_Component_Configuration => 158, - Iir_Kind_Binding_Indication => 164, - Iir_Kind_Entity_Class => 166, - Iir_Kind_Attribute_Value => 174, - Iir_Kind_Signature => 177, - Iir_Kind_Aggregate_Info => 184, - Iir_Kind_Procedure_Call => 188, - Iir_Kind_Record_Element_Constraint => 194, - Iir_Kind_Array_Element_Resolution => 195, - Iir_Kind_Record_Resolution => 196, - Iir_Kind_Record_Element_Resolution => 199, - Iir_Kind_Attribute_Specification => 207, - Iir_Kind_Disconnection_Specification => 212, - Iir_Kind_Configuration_Specification => 217, - Iir_Kind_Access_Type_Definition => 224, - Iir_Kind_Incomplete_Type_Definition => 231, - Iir_Kind_File_Type_Definition => 238, - Iir_Kind_Protected_Type_Declaration => 247, - Iir_Kind_Record_Type_Definition => 257, - Iir_Kind_Array_Type_Definition => 269, - Iir_Kind_Array_Subtype_Definition => 284, - Iir_Kind_Record_Subtype_Definition => 295, - Iir_Kind_Access_Subtype_Definition => 303, - Iir_Kind_Physical_Subtype_Definition => 312, - Iir_Kind_Floating_Subtype_Definition => 322, - Iir_Kind_Integer_Subtype_Definition => 331, - Iir_Kind_Enumeration_Subtype_Definition => 340, - Iir_Kind_Enumeration_Type_Definition => 349, - Iir_Kind_Integer_Type_Definition => 355, - Iir_Kind_Floating_Type_Definition => 361, - Iir_Kind_Physical_Type_Definition => 370, - Iir_Kind_Range_Expression => 376, - Iir_Kind_Protected_Type_Body => 383, - Iir_Kind_Subtype_Definition => 387, - Iir_Kind_Scalar_Nature_Definition => 391, - Iir_Kind_Overload_List => 392, - Iir_Kind_Type_Declaration => 398, - Iir_Kind_Anonymous_Type_Declaration => 403, - Iir_Kind_Subtype_Declaration => 411, - Iir_Kind_Nature_Declaration => 417, - Iir_Kind_Subnature_Declaration => 423, - Iir_Kind_Package_Declaration => 433, - Iir_Kind_Package_Instantiation_Declaration => 444, - Iir_Kind_Package_Body => 451, - Iir_Kind_Configuration_Declaration => 460, - Iir_Kind_Entity_Declaration => 472, - Iir_Kind_Architecture_Body => 484, - Iir_Kind_Package_Header => 486, - Iir_Kind_Unit_Declaration => 495, - Iir_Kind_Library_Declaration => 502, - Iir_Kind_Component_Declaration => 512, - Iir_Kind_Attribute_Declaration => 519, - Iir_Kind_Group_Template_Declaration => 525, - Iir_Kind_Group_Declaration => 532, - Iir_Kind_Element_Declaration => 539, - Iir_Kind_Non_Object_Alias_Declaration => 547, - Iir_Kind_Psl_Declaration => 555, - Iir_Kind_Terminal_Declaration => 561, - Iir_Kind_Free_Quantity_Declaration => 570, - Iir_Kind_Across_Quantity_Declaration => 582, - Iir_Kind_Through_Quantity_Declaration => 594, - Iir_Kind_Enumeration_Literal => 605, - Iir_Kind_Function_Declaration => 629, - Iir_Kind_Procedure_Declaration => 651, - Iir_Kind_Function_Body => 661, - Iir_Kind_Procedure_Body => 671, - Iir_Kind_Object_Alias_Declaration => 683, - Iir_Kind_File_Declaration => 698, - Iir_Kind_Guard_Signal_Declaration => 711, - Iir_Kind_Signal_Declaration => 728, - Iir_Kind_Variable_Declaration => 741, - Iir_Kind_Constant_Declaration => 755, - Iir_Kind_Iterator_Declaration => 767, - Iir_Kind_Interface_Constant_Declaration => 783, - Iir_Kind_Interface_Variable_Declaration => 799, - Iir_Kind_Interface_Signal_Declaration => 820, - Iir_Kind_Interface_File_Declaration => 836, - Iir_Kind_Interface_Package_Declaration => 845, - Iir_Kind_Identity_Operator => 849, - Iir_Kind_Negation_Operator => 853, - Iir_Kind_Absolute_Operator => 857, - Iir_Kind_Not_Operator => 861, - Iir_Kind_Condition_Operator => 865, - Iir_Kind_Reduction_And_Operator => 869, - Iir_Kind_Reduction_Or_Operator => 873, - Iir_Kind_Reduction_Nand_Operator => 877, - Iir_Kind_Reduction_Nor_Operator => 881, - Iir_Kind_Reduction_Xor_Operator => 885, - Iir_Kind_Reduction_Xnor_Operator => 889, - Iir_Kind_And_Operator => 894, - Iir_Kind_Or_Operator => 899, - Iir_Kind_Nand_Operator => 904, - Iir_Kind_Nor_Operator => 909, - Iir_Kind_Xor_Operator => 914, - Iir_Kind_Xnor_Operator => 919, - Iir_Kind_Equality_Operator => 924, - Iir_Kind_Inequality_Operator => 929, - Iir_Kind_Less_Than_Operator => 934, - Iir_Kind_Less_Than_Or_Equal_Operator => 939, - Iir_Kind_Greater_Than_Operator => 944, - Iir_Kind_Greater_Than_Or_Equal_Operator => 949, - Iir_Kind_Match_Equality_Operator => 954, - Iir_Kind_Match_Inequality_Operator => 959, - Iir_Kind_Match_Less_Than_Operator => 964, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 969, - Iir_Kind_Match_Greater_Than_Operator => 974, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 979, - Iir_Kind_Sll_Operator => 984, - Iir_Kind_Sla_Operator => 989, - Iir_Kind_Srl_Operator => 994, - Iir_Kind_Sra_Operator => 999, - Iir_Kind_Rol_Operator => 1004, - Iir_Kind_Ror_Operator => 1009, - Iir_Kind_Addition_Operator => 1014, - Iir_Kind_Substraction_Operator => 1019, - Iir_Kind_Concatenation_Operator => 1024, - Iir_Kind_Multiplication_Operator => 1029, - Iir_Kind_Division_Operator => 1034, - Iir_Kind_Modulus_Operator => 1039, - Iir_Kind_Remainder_Operator => 1044, - Iir_Kind_Exponentiation_Operator => 1049, - Iir_Kind_Function_Call => 1057, - Iir_Kind_Aggregate => 1063, - Iir_Kind_Parenthesis_Expression => 1066, - Iir_Kind_Qualified_Expression => 1070, - Iir_Kind_Type_Conversion => 1075, - Iir_Kind_Allocator_By_Expression => 1079, - Iir_Kind_Allocator_By_Subtype => 1083, - Iir_Kind_Selected_Element => 1089, - Iir_Kind_Dereference => 1094, - Iir_Kind_Implicit_Dereference => 1099, - Iir_Kind_Slice_Name => 1106, - Iir_Kind_Indexed_Name => 1112, - Iir_Kind_Psl_Expression => 1114, - Iir_Kind_Sensitized_Process_Statement => 1134, - Iir_Kind_Process_Statement => 1153, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1164, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1176, - Iir_Kind_Concurrent_Assertion_Statement => 1184, - Iir_Kind_Psl_Default_Clock => 1188, - Iir_Kind_Psl_Assert_Statement => 1197, - Iir_Kind_Psl_Cover_Statement => 1206, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1212, - Iir_Kind_Block_Statement => 1225, - Iir_Kind_If_Generate_Statement => 1235, - Iir_Kind_For_Generate_Statement => 1244, - Iir_Kind_Component_Instantiation_Statement => 1254, - Iir_Kind_Simple_Simultaneous_Statement => 1261, - Iir_Kind_Generate_Statement_Body => 1272, - Iir_Kind_If_Generate_Else_Clause => 1277, - Iir_Kind_Signal_Assignment_Statement => 1286, - Iir_Kind_Null_Statement => 1290, - Iir_Kind_Assertion_Statement => 1297, - Iir_Kind_Report_Statement => 1303, - Iir_Kind_Wait_Statement => 1310, - Iir_Kind_Variable_Assignment_Statement => 1316, - Iir_Kind_Return_Statement => 1322, - Iir_Kind_For_Loop_Statement => 1330, - Iir_Kind_While_Loop_Statement => 1337, - Iir_Kind_Next_Statement => 1343, - Iir_Kind_Exit_Statement => 1349, - Iir_Kind_Case_Statement => 1356, - Iir_Kind_Procedure_Call_Statement => 1361, - Iir_Kind_If_Statement => 1369, - Iir_Kind_Elsif => 1374, - Iir_Kind_Character_Literal => 1381, - Iir_Kind_Simple_Name => 1388, - Iir_Kind_Selected_Name => 1396, - Iir_Kind_Operator_Symbol => 1401, - Iir_Kind_Selected_By_All_Name => 1406, - Iir_Kind_Parenthesis_Name => 1410, - Iir_Kind_Base_Attribute => 1412, - Iir_Kind_Left_Type_Attribute => 1417, - Iir_Kind_Right_Type_Attribute => 1422, - Iir_Kind_High_Type_Attribute => 1427, - Iir_Kind_Low_Type_Attribute => 1432, - Iir_Kind_Ascending_Type_Attribute => 1437, - Iir_Kind_Image_Attribute => 1443, - Iir_Kind_Value_Attribute => 1449, - Iir_Kind_Pos_Attribute => 1455, - Iir_Kind_Val_Attribute => 1461, - Iir_Kind_Succ_Attribute => 1467, - Iir_Kind_Pred_Attribute => 1473, - Iir_Kind_Leftof_Attribute => 1479, - Iir_Kind_Rightof_Attribute => 1485, - Iir_Kind_Delayed_Attribute => 1493, - Iir_Kind_Stable_Attribute => 1501, - Iir_Kind_Quiet_Attribute => 1509, - Iir_Kind_Transaction_Attribute => 1517, - Iir_Kind_Event_Attribute => 1521, - Iir_Kind_Active_Attribute => 1525, - Iir_Kind_Last_Event_Attribute => 1529, - Iir_Kind_Last_Active_Attribute => 1533, - Iir_Kind_Last_Value_Attribute => 1537, - Iir_Kind_Driving_Attribute => 1541, - Iir_Kind_Driving_Value_Attribute => 1545, - Iir_Kind_Behavior_Attribute => 1545, - Iir_Kind_Structure_Attribute => 1545, - Iir_Kind_Simple_Name_Attribute => 1552, - Iir_Kind_Instance_Name_Attribute => 1557, - Iir_Kind_Path_Name_Attribute => 1562, - Iir_Kind_Left_Array_Attribute => 1569, - Iir_Kind_Right_Array_Attribute => 1576, - Iir_Kind_High_Array_Attribute => 1583, - Iir_Kind_Low_Array_Attribute => 1590, - Iir_Kind_Length_Array_Attribute => 1597, - Iir_Kind_Ascending_Array_Attribute => 1604, - Iir_Kind_Range_Array_Attribute => 1611, - Iir_Kind_Reverse_Range_Array_Attribute => 1618, - Iir_Kind_Attribute_Name => 1626 + Iir_Kind_Context_Reference => 45, + Iir_Kind_Integer_Literal => 49, + Iir_Kind_Floating_Point_Literal => 53, + Iir_Kind_Null_Literal => 55, + Iir_Kind_String_Literal8 => 65, + Iir_Kind_Physical_Int_Literal => 70, + Iir_Kind_Physical_Fp_Literal => 75, + Iir_Kind_Simple_Aggregate => 80, + Iir_Kind_Overflow_Literal => 83, + Iir_Kind_Waveform_Element => 86, + Iir_Kind_Conditional_Waveform => 89, + Iir_Kind_Association_Element_By_Expression => 96, + Iir_Kind_Association_Element_By_Individual => 102, + Iir_Kind_Association_Element_Open => 107, + Iir_Kind_Association_Element_Package => 113, + Iir_Kind_Choice_By_Others => 118, + Iir_Kind_Choice_By_Expression => 125, + Iir_Kind_Choice_By_Range => 132, + Iir_Kind_Choice_By_None => 137, + Iir_Kind_Choice_By_Name => 143, + Iir_Kind_Entity_Aspect_Entity => 145, + Iir_Kind_Entity_Aspect_Configuration => 146, + Iir_Kind_Entity_Aspect_Open => 146, + Iir_Kind_Block_Configuration => 152, + Iir_Kind_Block_Header => 156, + Iir_Kind_Component_Configuration => 162, + Iir_Kind_Binding_Indication => 168, + Iir_Kind_Entity_Class => 170, + Iir_Kind_Attribute_Value => 178, + Iir_Kind_Signature => 181, + Iir_Kind_Aggregate_Info => 188, + Iir_Kind_Procedure_Call => 192, + Iir_Kind_Record_Element_Constraint => 198, + Iir_Kind_Array_Element_Resolution => 199, + Iir_Kind_Record_Resolution => 200, + Iir_Kind_Record_Element_Resolution => 203, + Iir_Kind_Attribute_Specification => 211, + Iir_Kind_Disconnection_Specification => 216, + Iir_Kind_Configuration_Specification => 221, + Iir_Kind_Access_Type_Definition => 228, + Iir_Kind_Incomplete_Type_Definition => 235, + Iir_Kind_File_Type_Definition => 242, + Iir_Kind_Protected_Type_Declaration => 251, + Iir_Kind_Record_Type_Definition => 261, + Iir_Kind_Array_Type_Definition => 273, + Iir_Kind_Array_Subtype_Definition => 288, + Iir_Kind_Record_Subtype_Definition => 299, + Iir_Kind_Access_Subtype_Definition => 307, + Iir_Kind_Physical_Subtype_Definition => 316, + Iir_Kind_Floating_Subtype_Definition => 326, + Iir_Kind_Integer_Subtype_Definition => 335, + Iir_Kind_Enumeration_Subtype_Definition => 344, + Iir_Kind_Enumeration_Type_Definition => 353, + Iir_Kind_Integer_Type_Definition => 359, + Iir_Kind_Floating_Type_Definition => 365, + Iir_Kind_Physical_Type_Definition => 374, + Iir_Kind_Range_Expression => 380, + Iir_Kind_Protected_Type_Body => 387, + Iir_Kind_Subtype_Definition => 391, + Iir_Kind_Scalar_Nature_Definition => 395, + Iir_Kind_Overload_List => 396, + Iir_Kind_Type_Declaration => 402, + Iir_Kind_Anonymous_Type_Declaration => 407, + Iir_Kind_Subtype_Declaration => 415, + Iir_Kind_Nature_Declaration => 421, + Iir_Kind_Subnature_Declaration => 427, + Iir_Kind_Package_Declaration => 437, + Iir_Kind_Package_Instantiation_Declaration => 448, + Iir_Kind_Package_Body => 455, + Iir_Kind_Configuration_Declaration => 464, + Iir_Kind_Entity_Declaration => 476, + Iir_Kind_Architecture_Body => 488, + Iir_Kind_Context_Declaration => 494, + Iir_Kind_Package_Header => 496, + Iir_Kind_Unit_Declaration => 505, + Iir_Kind_Library_Declaration => 512, + Iir_Kind_Component_Declaration => 522, + Iir_Kind_Attribute_Declaration => 529, + Iir_Kind_Group_Template_Declaration => 535, + Iir_Kind_Group_Declaration => 542, + Iir_Kind_Element_Declaration => 549, + Iir_Kind_Non_Object_Alias_Declaration => 557, + Iir_Kind_Psl_Declaration => 565, + Iir_Kind_Terminal_Declaration => 571, + Iir_Kind_Free_Quantity_Declaration => 580, + Iir_Kind_Across_Quantity_Declaration => 592, + Iir_Kind_Through_Quantity_Declaration => 604, + Iir_Kind_Enumeration_Literal => 615, + Iir_Kind_Function_Declaration => 639, + Iir_Kind_Procedure_Declaration => 661, + Iir_Kind_Function_Body => 671, + Iir_Kind_Procedure_Body => 681, + Iir_Kind_Object_Alias_Declaration => 693, + Iir_Kind_File_Declaration => 708, + Iir_Kind_Guard_Signal_Declaration => 721, + Iir_Kind_Signal_Declaration => 738, + Iir_Kind_Variable_Declaration => 751, + Iir_Kind_Constant_Declaration => 765, + Iir_Kind_Iterator_Declaration => 777, + Iir_Kind_Interface_Constant_Declaration => 793, + Iir_Kind_Interface_Variable_Declaration => 809, + Iir_Kind_Interface_Signal_Declaration => 830, + Iir_Kind_Interface_File_Declaration => 846, + Iir_Kind_Interface_Package_Declaration => 855, + Iir_Kind_Identity_Operator => 859, + Iir_Kind_Negation_Operator => 863, + Iir_Kind_Absolute_Operator => 867, + Iir_Kind_Not_Operator => 871, + Iir_Kind_Condition_Operator => 875, + Iir_Kind_Reduction_And_Operator => 879, + Iir_Kind_Reduction_Or_Operator => 883, + Iir_Kind_Reduction_Nand_Operator => 887, + Iir_Kind_Reduction_Nor_Operator => 891, + Iir_Kind_Reduction_Xor_Operator => 895, + Iir_Kind_Reduction_Xnor_Operator => 899, + Iir_Kind_And_Operator => 904, + Iir_Kind_Or_Operator => 909, + Iir_Kind_Nand_Operator => 914, + Iir_Kind_Nor_Operator => 919, + Iir_Kind_Xor_Operator => 924, + Iir_Kind_Xnor_Operator => 929, + Iir_Kind_Equality_Operator => 934, + Iir_Kind_Inequality_Operator => 939, + Iir_Kind_Less_Than_Operator => 944, + Iir_Kind_Less_Than_Or_Equal_Operator => 949, + Iir_Kind_Greater_Than_Operator => 954, + Iir_Kind_Greater_Than_Or_Equal_Operator => 959, + Iir_Kind_Match_Equality_Operator => 964, + Iir_Kind_Match_Inequality_Operator => 969, + Iir_Kind_Match_Less_Than_Operator => 974, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 979, + Iir_Kind_Match_Greater_Than_Operator => 984, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 989, + Iir_Kind_Sll_Operator => 994, + Iir_Kind_Sla_Operator => 999, + Iir_Kind_Srl_Operator => 1004, + Iir_Kind_Sra_Operator => 1009, + Iir_Kind_Rol_Operator => 1014, + Iir_Kind_Ror_Operator => 1019, + Iir_Kind_Addition_Operator => 1024, + Iir_Kind_Substraction_Operator => 1029, + Iir_Kind_Concatenation_Operator => 1034, + Iir_Kind_Multiplication_Operator => 1039, + Iir_Kind_Division_Operator => 1044, + Iir_Kind_Modulus_Operator => 1049, + Iir_Kind_Remainder_Operator => 1054, + Iir_Kind_Exponentiation_Operator => 1059, + Iir_Kind_Function_Call => 1067, + Iir_Kind_Aggregate => 1073, + Iir_Kind_Parenthesis_Expression => 1076, + Iir_Kind_Qualified_Expression => 1080, + Iir_Kind_Type_Conversion => 1085, + Iir_Kind_Allocator_By_Expression => 1089, + Iir_Kind_Allocator_By_Subtype => 1093, + Iir_Kind_Selected_Element => 1099, + Iir_Kind_Dereference => 1104, + Iir_Kind_Implicit_Dereference => 1109, + Iir_Kind_Slice_Name => 1116, + Iir_Kind_Indexed_Name => 1122, + Iir_Kind_Psl_Expression => 1124, + Iir_Kind_Sensitized_Process_Statement => 1144, + Iir_Kind_Process_Statement => 1163, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1174, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1186, + Iir_Kind_Concurrent_Assertion_Statement => 1194, + Iir_Kind_Psl_Default_Clock => 1198, + Iir_Kind_Psl_Assert_Statement => 1207, + Iir_Kind_Psl_Cover_Statement => 1216, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1222, + Iir_Kind_Block_Statement => 1235, + Iir_Kind_If_Generate_Statement => 1245, + Iir_Kind_For_Generate_Statement => 1254, + Iir_Kind_Component_Instantiation_Statement => 1264, + Iir_Kind_Simple_Simultaneous_Statement => 1271, + Iir_Kind_Generate_Statement_Body => 1282, + Iir_Kind_If_Generate_Else_Clause => 1287, + Iir_Kind_Signal_Assignment_Statement => 1296, + Iir_Kind_Null_Statement => 1300, + Iir_Kind_Assertion_Statement => 1307, + Iir_Kind_Report_Statement => 1313, + Iir_Kind_Wait_Statement => 1320, + Iir_Kind_Variable_Assignment_Statement => 1326, + Iir_Kind_Return_Statement => 1332, + Iir_Kind_For_Loop_Statement => 1340, + Iir_Kind_While_Loop_Statement => 1347, + Iir_Kind_Next_Statement => 1353, + Iir_Kind_Exit_Statement => 1359, + Iir_Kind_Case_Statement => 1366, + Iir_Kind_Procedure_Call_Statement => 1371, + Iir_Kind_If_Statement => 1379, + Iir_Kind_Elsif => 1384, + Iir_Kind_Character_Literal => 1391, + Iir_Kind_Simple_Name => 1398, + Iir_Kind_Selected_Name => 1406, + Iir_Kind_Operator_Symbol => 1411, + Iir_Kind_Selected_By_All_Name => 1416, + Iir_Kind_Parenthesis_Name => 1420, + Iir_Kind_Base_Attribute => 1422, + Iir_Kind_Left_Type_Attribute => 1427, + Iir_Kind_Right_Type_Attribute => 1432, + Iir_Kind_High_Type_Attribute => 1437, + Iir_Kind_Low_Type_Attribute => 1442, + Iir_Kind_Ascending_Type_Attribute => 1447, + Iir_Kind_Image_Attribute => 1453, + Iir_Kind_Value_Attribute => 1459, + Iir_Kind_Pos_Attribute => 1465, + Iir_Kind_Val_Attribute => 1471, + Iir_Kind_Succ_Attribute => 1477, + Iir_Kind_Pred_Attribute => 1483, + Iir_Kind_Leftof_Attribute => 1489, + Iir_Kind_Rightof_Attribute => 1495, + Iir_Kind_Delayed_Attribute => 1503, + Iir_Kind_Stable_Attribute => 1511, + Iir_Kind_Quiet_Attribute => 1519, + Iir_Kind_Transaction_Attribute => 1527, + Iir_Kind_Event_Attribute => 1531, + Iir_Kind_Active_Attribute => 1535, + Iir_Kind_Last_Event_Attribute => 1539, + Iir_Kind_Last_Active_Attribute => 1543, + Iir_Kind_Last_Value_Attribute => 1547, + Iir_Kind_Driving_Attribute => 1551, + Iir_Kind_Driving_Value_Attribute => 1555, + Iir_Kind_Behavior_Attribute => 1555, + Iir_Kind_Structure_Attribute => 1555, + Iir_Kind_Simple_Name_Attribute => 1562, + Iir_Kind_Instance_Name_Attribute => 1567, + Iir_Kind_Path_Name_Attribute => 1572, + Iir_Kind_Left_Array_Attribute => 1579, + Iir_Kind_Right_Array_Attribute => 1586, + Iir_Kind_High_Array_Attribute => 1593, + Iir_Kind_Low_Array_Attribute => 1600, + Iir_Kind_Length_Array_Attribute => 1607, + Iir_Kind_Ascending_Array_Attribute => 1614, + Iir_Kind_Range_Array_Attribute => 1621, + Iir_Kind_Reverse_Range_Array_Attribute => 1628, + Iir_Kind_Attribute_Name => 1636 ); function Get_Fields (K : Iir_Kind) return Fields_Array @@ -4533,6 +4556,8 @@ package body Nodes_Meta is return Get_Selected_Element (N); when Field_Use_Clause_Chain => return Get_Use_Clause_Chain (N); + when Field_Context_Reference_Chain => + return Get_Context_Reference_Chain (N); when Field_Selected_Name => return Get_Selected_Name (N); when Field_Type_Declarator => @@ -4891,6 +4916,8 @@ package body Nodes_Meta is Set_Selected_Element (N, V); when Field_Use_Clause_Chain => Set_Use_Clause_Chain (N, V); + when Field_Context_Reference_Chain => + Set_Context_Reference_Chain (N, V); when Field_Selected_Name => Set_Selected_Name (N, V); when Field_Type_Declarator => @@ -5925,7 +5952,13 @@ package body Nodes_Meta is function Has_Context_Items (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Design_Unit; + case K is + when Iir_Kind_Design_Unit + | Iir_Kind_Context_Declaration => + return True; + when others => + return False; + end case; end Has_Context_Items; function Has_Dependence_List (K : Iir_Kind) return Boolean is @@ -6396,6 +6429,7 @@ package body Nodes_Meta is | Iir_Kind_Design_Unit | Iir_Kind_Library_Clause | Iir_Kind_Use_Clause + | Iir_Kind_Context_Reference | Iir_Kind_Waveform_Element | Iir_Kind_Conditional_Waveform | Iir_Kind_Association_Element_By_Expression @@ -6970,7 +7004,8 @@ package body Nodes_Meta is | Iir_Kind_Package_Body | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration - | Iir_Kind_Architecture_Body => + | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration => return True; when others => return False; @@ -7049,9 +7084,20 @@ package body Nodes_Meta is return K = Iir_Kind_Use_Clause; end Has_Use_Clause_Chain; + function Has_Context_Reference_Chain (K : Iir_Kind) return Boolean is + begin + return K = Iir_Kind_Context_Reference; + end Has_Context_Reference_Chain; + function Has_Selected_Name (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Use_Clause; + case K is + when Iir_Kind_Use_Clause + | Iir_Kind_Context_Reference => + return True; + when others => + return False; + end case; end Has_Selected_Name; function Has_Type_Declarator (K : Iir_Kind) return Boolean is @@ -7125,6 +7171,7 @@ package body Nodes_Meta is | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration | Iir_Kind_Unit_Declaration | Iir_Kind_Library_Declaration | Iir_Kind_Component_Declaration @@ -7243,6 +7290,7 @@ package body Nodes_Meta is | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration | Iir_Kind_Unit_Declaration | Iir_Kind_Library_Declaration | Iir_Kind_Component_Declaration @@ -8139,6 +8187,7 @@ package body Nodes_Meta is | Iir_Kind_Design_Unit | Iir_Kind_Library_Clause | Iir_Kind_Use_Clause + | Iir_Kind_Context_Reference | Iir_Kind_Choice_By_Others | Iir_Kind_Choice_By_Expression | Iir_Kind_Choice_By_Range @@ -8162,6 +8211,7 @@ package body Nodes_Meta is | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration | Iir_Kind_Unit_Declaration | Iir_Kind_Component_Declaration | Iir_Kind_Attribute_Declaration @@ -9153,6 +9203,7 @@ package body Nodes_Meta is | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration | Iir_Kind_Component_Declaration | Iir_Kind_Function_Body | Iir_Kind_Procedure_Body @@ -9180,6 +9231,7 @@ package body Nodes_Meta is | Iir_Kind_Configuration_Declaration | Iir_Kind_Entity_Declaration | Iir_Kind_Architecture_Body + | Iir_Kind_Context_Declaration | Iir_Kind_Component_Declaration | Iir_Kind_Function_Body | Iir_Kind_Procedure_Body diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads index 1a18f22..f1b874b 100644 --- a/src/vhdl/nodes_meta.ads +++ b/src/vhdl/nodes_meta.ads @@ -171,6 +171,7 @@ package Nodes_Meta is Field_Element_Declaration, Field_Selected_Element, Field_Use_Clause_Chain, + Field_Context_Reference_Chain, Field_Selected_Name, Field_Type_Declarator, Field_Enumeration_Literal_List, @@ -639,6 +640,7 @@ package Nodes_Meta is function Has_Element_Declaration (K : Iir_Kind) return Boolean; function Has_Selected_Element (K : Iir_Kind) return Boolean; function Has_Use_Clause_Chain (K : Iir_Kind) return Boolean; + function Has_Context_Reference_Chain (K : Iir_Kind) return Boolean; function Has_Selected_Name (K : Iir_Kind) return Boolean; function Has_Type_Declarator (K : Iir_Kind) return Boolean; function Has_Enumeration_Literal_List (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/parse.adb b/src/vhdl/parse.adb index d94f4bb..61df598 100644 --- a/src/vhdl/parse.adb +++ b/src/vhdl/parse.adb @@ -7495,18 +7495,173 @@ package body Parse is end if; end Parse_Package; + procedure Parse_Context_Declaration_Or_Reference + (Unit : Iir_Design_Unit; Clause : out Iir); + + -- Precond: next token + -- Postcond: next token + -- + -- LRM93 11.3 + -- LRM08 13.4 Context clauses + -- context_clause ::= { context_item } + -- + -- context_item ::= library_clause | use_clause | context_reference + procedure Parse_Context_Clause (Unit : Iir) + is + use Context_Items_Chain_Handling; + Last : Iir; + Els : Iir; + begin + Build_Init (Last); + + loop + case Current_Token is + when Tok_Library => + Els := Parse_Library_Clause; + when Tok_Use => + Els := Parse_Use_Clause; + Scan; + when Tok_Context => + Parse_Context_Declaration_Or_Reference (Unit, Els); + if Els = Null_Iir then + -- This was a context declaration. No more clause. + + -- LRM08 13.1 Design units + -- It is an error if the context clause preceding a library + -- unit that is a context declaration is not empty. + if Get_Context_Items (Unit) /= Null_Iir then + Error_Msg_Sem + ("context declaration does not allow context " + & "clauses before it", Get_Context_Items (Unit)); + end if; + + return; + else + -- Skip ';'. + Scan; + end if; + when Tok_With => + -- Be Ada friendly. + Error_Msg_Parse ("'with' not allowed in context clause " + & "(try 'use' or 'library')"); + Els := Parse_Use_Clause; + Scan; + when others => + exit; + end case; + Append_Subchain (Last, Unit, Els); + end loop; + end Parse_Context_Clause; + + -- Precond: IS + -- + -- LRM08 13.13 Context declarations + -- context_declaration ::= + -- CONTEXT identifier IS + -- context_clause + -- END [ CONTEXT ] [ /context/_simple_name ] ; + procedure Parse_Context_Declaration (Unit : Iir; Decl : Iir) is + begin + Set_Library_Unit (Unit, Decl); + + -- Skip 'is' + Scan; + + Parse_Context_Clause (Decl); + + Expect (Tok_End); + Set_End_Location (Unit); + + -- Skip 'end' + Scan; + + if Current_Token = Tok_Context then + Set_End_Has_Reserved_Id (Decl, True); + + -- Skip 'context'. + Scan; + end if; + + Check_End_Name (Decl); + Expect (Tok_Semi_Colon); + end Parse_Context_Declaration; + + -- Precond: next token after selected_name. + -- Postcond: ; + -- + -- LRM08 13.4 Context clauses + -- + -- context_reference ::= + -- CONTEXT selected_name { , selected_name } + function Parse_Context_Reference + (Loc : Location_Type; Name : Iir) return Iir + is + Ref : Iir; + First, Last : Iir; + begin + Ref := Create_Iir (Iir_Kind_Context_Reference); + Set_Location (Ref, Loc); + Set_Selected_Name (Ref, Name); + First := Ref; + Last := Ref; + + loop + exit when Current_Token = Tok_Semi_Colon; + Expect (Tok_Comma); + + -- Skip ','. + Scan; + + Ref := Create_Iir (Iir_Kind_Context_Reference); + Set_Location (Ref, Loc); + Set_Selected_Name (Ref, Parse_Name); + + Set_Context_Reference_Chain (Last, Ref); + Last := Ref; + end loop; + + return First; + end Parse_Context_Reference; + + -- Precond: CONTEXT + -- + procedure Parse_Context_Declaration_Or_Reference + (Unit : Iir_Design_Unit; Clause : out Iir) + is + Loc : Location_Type; + Name : Iir; + Res : Iir; + begin + Loc := Get_Token_Location; + + -- Skip 'context'. + Scan; + + Name := Parse_Name; + + if Current_Token = Tok_Is then + Res := Create_Iir (Iir_Kind_Context_Declaration); + Set_Location (Res, Loc); + if Get_Kind (Name) = Iir_Kind_Simple_Name then + Set_Identifier (Res, Get_Identifier (Name)); + else + Error_Msg_Parse ("identifier for context expected", Name); + end if; + Free_Iir (Name); + + Parse_Context_Declaration (Unit, Res); + Clause := Null_Iir; + else + Clause := Parse_Context_Reference (Loc, Name); + end if; + end Parse_Context_Declaration_Or_Reference; + -- Parse a design_unit. -- The lexical scanner must have been initialized, but without a -- current_token. -- -- [ §11.1 ] -- design_unit ::= context_clause library_unit - -- - -- [ §11.3 ] - -- context_clause ::= { context_item } - -- - -- [ §11.3 ] - -- context_item ::= library_clause | use_clause function Parse_Design_Unit return Iir_Design_Unit is Res: Iir_Design_Unit; @@ -7526,49 +7681,27 @@ package body Parse is Set_Location (Res); Set_Date_State (Res, Date_Extern); - -- Parse context clauses - declare - use Context_Items_Chain_Handling; - Last : Iir; - Els : Iir; - begin - Build_Init (Last); + Parse_Context_Clause (Res); - loop - case Current_Token is - when Tok_Library => - Els := Parse_Library_Clause; - when Tok_Use => - Els := Parse_Use_Clause; - Scan; - when Tok_With => - -- Be Ada friendly. - Error_Msg_Parse ("'with' not allowed in context clause " - & "(try 'use' or 'library')"); - Els := Parse_Use_Clause; - Scan; - when others => - exit; - end case; - Append_Subchain (Last, Res, Els); - end loop; - end; + if Get_Library_Unit (Res) = Null_Iir then + -- Parse library unit. Context declaration are already parsed. + case Current_Token is + when Tok_Entity => + Parse_Entity_Declaration (Res); + when Tok_Architecture => + Parse_Architecture_Body (Res); + when Tok_Package => + Parse_Package (Res); + when Tok_Configuration => + Parse_Configuration_Declaration (Res); + when others => + Error_Msg_Parse + ("entity, architecture, package or configuration " + & "keyword expected"); + return Null_Iir; + end case; + end if; - -- Parse library unit - case Current_Token is - when Tok_Entity => - Parse_Entity_Declaration (Res); - when Tok_Architecture => - Parse_Architecture_Body (Res); - when Tok_Package => - Parse_Package (Res); - when Tok_Configuration => - Parse_Configuration_Declaration (Res); - when others => - Error_Msg_Parse ("entity, architecture, package or configuration " - & "keyword expected"); - return Null_Iir; - end case; Unit := Get_Library_Unit (Res); Set_Design_Unit (Unit, Res); Set_Identifier (Res, Get_Identifier (Unit)); @@ -7595,6 +7728,8 @@ package body Parse is Design := Parse.Parse_Design_Unit; exit when Design = Null_Iir; Set_Design_File (Design, Res); + + -- Append unit to the design file. if Last_Design = Null_Iir then Set_First_Design_Unit (Res, Design); else @@ -7603,9 +7738,11 @@ package body Parse is Last_Design := Design; Set_Last_Design_Unit (Res, Last_Design); end loop; + if Last_Design = Null_Iir then Error_Msg_Parse ("design file is empty (no design unit found)"); end if; + return Res; exception when Parse_Error => diff --git a/src/vhdl/post_sems.adb b/src/vhdl/post_sems.adb index 2e42e45..69e40f9 100644 --- a/src/vhdl/post_sems.adb +++ b/src/vhdl/post_sems.adb @@ -33,10 +33,14 @@ package body Post_Sems is Spec : Iir_Attribute_Specification; Attr_Decl : Iir_Attribute_Declaration; begin - -- No checks on package bodies. - if Get_Kind (Lib_Unit) = Iir_Kind_Package_Body then - return; - end if; + -- No checks on package bodies or context declaration + case Get_Kind (Lib_Unit) is + when Iir_Kind_Package_Body + | Iir_Kind_Context_Declaration => + return; + when others => + null; + end case; Id := Get_Identifier (Lib_Unit); Lib := Get_Library (Get_Design_File (Unit)); diff --git a/src/vhdl/scanner.adb b/src/vhdl/scanner.adb index 26dff5e..544cc74 100644 --- a/src/vhdl/scanner.adb +++ b/src/vhdl/scanner.adb @@ -915,6 +915,15 @@ package body Scanner is end if; Current_Token := Tok_Identifier; end if; + when Std_Names.Name_Id_Vhdl08_Reserved_Words => + if Vhdl_Std < Vhdl_08 then + if Flags.Warn_Reserved_Word then + Warning_Msg_Scan + ("using """ & Nam_Buffer (1 .. Nam_Length) + & """ vhdl-2008 reserved word as an identifier"); + end if; + Current_Token := Tok_Identifier; + end if; when Std_Names.Name_Id_Vhdl00_Reserved_Words => if Vhdl_Std < Vhdl_00 then if Flags.Warn_Reserved_Word then diff --git a/src/vhdl/sem.adb b/src/vhdl/sem.adb index b1d1015..e4790bd 100644 --- a/src/vhdl/sem.adb +++ b/src/vhdl/sem.adb @@ -38,7 +38,7 @@ with Xrefs; use Xrefs; package body Sem is -- Forward declarations. - procedure Sem_Context_Clauses (Design_Unit: Iir_Design_Unit); + procedure Sem_Context_Clauses (Unit: Iir); procedure Sem_Block_Configuration (Block_Conf : Iir_Block_Configuration; Father: Iir); procedure Sem_Component_Configuration @@ -2721,18 +2721,66 @@ package body Sem is end if; end Sem_Library_Clause; + -- LRM08 13.4 Context clauses. + procedure Sem_One_Context_Reference (Ref : Iir) + is + Name : Iir; + Ent : Iir; + begin + Name := Get_Selected_Name (Ref); + if Get_Kind (Name) /= Iir_Kind_Selected_Name then + Error_Msg_Sem + ("context reference only allows selected names", Name); + return; + end if; + + Name := Sem_Denoting_Name (Name); + Set_Selected_Name (Ref, Name); + Ent := Get_Named_Entity (Name); + if Is_Error (Ent) then + return; + end if; + + -- LRM08 13.4 Context clauses + -- It is an error if a selected name in a context reference does not + -- denote a context declaration. + if Get_Kind (Ent) /= Iir_Kind_Context_Declaration then + Error_Msg_Sem ("name must denote a context declaration", Name); + Set_Named_Entity (Name, Null_Iir); + return; + end if; + end Sem_One_Context_Reference; + + -- LRM08 13.4 Context clauses. + procedure Sem_Context_Reference (Ctxt : Iir) + is + Ref : Iir; + begin + Ref := Ctxt; + loop + Sem_One_Context_Reference (Ref); + Ref := Get_Context_Reference_Chain (Ref); + exit when Ref = Null_Iir; + end loop; + + -- FIXME: must be done clause after clause ? + Add_Context_Reference (Ctxt); + end Sem_Context_Reference; + -- LRM 11.3 Context Clauses. - procedure Sem_Context_Clauses (Design_Unit: Iir_Design_Unit) + procedure Sem_Context_Clauses (Unit: Iir) is El: Iir; begin - El := Get_Context_Items (Design_Unit); + El := Get_Context_Items (Unit); while El /= Null_Iir loop case Get_Kind (El) is when Iir_Kind_Use_Clause => Sem_Use_Clause (El); when Iir_Kind_Library_Clause => Sem_Library_Clause (El); + when Iir_Kind_Context_Reference => + Sem_Context_Reference (El); when others => Error_Kind ("sem_context_clauses", El); end case; @@ -2740,6 +2788,89 @@ package body Sem is end loop; end Sem_Context_Clauses; + -- LRM08 13.3 Context declarations + procedure Sem_Context_Declaration (Decl: Iir) + is + -- Return TRUE iff the first prefix of NAME denotes library WORK. + function Has_Work_Library_Prefix (Name : Iir) return Boolean + is + Prefix : Iir; + begin + Prefix := Name; + while Get_Kind (Prefix) = Iir_Kind_Selected_Name + or else Get_Kind (Prefix) = Iir_Kind_Selected_By_All_Name + loop + Prefix := Get_Prefix (Prefix); + end loop; + return Get_Kind (Prefix) = Iir_Kind_Simple_Name + and then Get_Identifier (Prefix) = Std_Names.Name_Work + and then (Get_Kind (Get_Named_Entity (Prefix)) + = Iir_Kind_Library_Declaration); + end Has_Work_Library_Prefix; + + procedure Error_Work_Prefix (Loc : Iir) is + begin + Error_Msg_Sem + ("'work' not allowed as prefix in context declaration", Loc); + end Error_Work_Prefix; + + El : Iir; + El1 : Iir; + begin + Sem_Scopes.Add_Name (Decl); + Xref_Decl (Decl); + + Sem_Context_Clauses (Decl); + + El := Get_Context_Items (Decl); + while El /= Null_Iir loop + case Get_Kind (El) is + when Iir_Kind_Library_Clause => + -- LRM08 13.3 Context declarations + -- It is an error if a library clause in a context declaration + -- defines the library logical name WORK, [...] + if Get_Identifier (El) = Std_Names.Name_Work then + Error_Msg_Sem + ("'library work' not allowed in context declaration", El); + end if; + when Iir_Kind_Use_Clause => + -- LRM08 13.3 Context declarations + -- [...] or if a selected name in a use clause [or a context + -- reference] in a context declaration has the library logic + -- name WORK as a prefix. + El1 := El; + while El1 /= Null_Iir loop + if Has_Work_Library_Prefix (Get_Selected_Name (El1)) then + Error_Work_Prefix (El1); + exit; + end if; + El1 := Get_Use_Clause_Chain (El1); + end loop; + when Iir_Kind_Context_Reference => + -- LRM08 13.3 Context declarations + -- [...] or if a selected name in [a use clause or] a context + -- reference in a context declaration has the library logic + -- name WORK as a prefix. + El1 := El; + while El1 /= Null_Iir loop + if Has_Work_Library_Prefix (Get_Selected_Name (El1)) then + Error_Work_Prefix (El1); + exit; + end if; + El1 := Get_Context_Reference_Chain (El1); + end loop; + when others => + raise Internal_Error; + end case; + El := Get_Chain (El); + end loop; + + -- GHDL: forbid self-reference by making declaration visible at the end. + -- This violates LRM08 12.3 Visibility: A declaration is visible only + -- within a certain part of its scope; ... + Set_Visible_Flag (Decl, True); + end Sem_Context_Declaration; + -- Access to the current design unit. This is set, saved, restored, cleared -- by the procedure semantic. Current_Design_Unit: Iir_Design_Unit := Null_Iir; @@ -2827,6 +2958,8 @@ package body Sem is Sem_Configuration_Declaration (El); when Iir_Kind_Package_Instantiation_Declaration => Sem_Package_Instantiation_Declaration (El); + when Iir_Kind_Context_Declaration => + Sem_Context_Declaration (El); when others => Error_Kind ("semantic", El); end case; diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb index ad1b17d..e74a0f3 100644 --- a/src/vhdl/sem_names.adb +++ b/src/vhdl/sem_names.adb @@ -3777,6 +3777,7 @@ package body Sem_Names is | Iir_Kind_Entity_Declaration | Iir_Kind_Configuration_Declaration | Iir_Kind_Package_Declaration + | Iir_Kind_Context_Declaration | Iir_Kind_Package_Instantiation_Declaration | Iir_Kind_Interface_Package_Declaration | Iir_Kind_Library_Declaration diff --git a/src/vhdl/sem_scopes.adb b/src/vhdl/sem_scopes.adb index cdc35af..2922ea9 100644 --- a/src/vhdl/sem_scopes.adb +++ b/src/vhdl/sem_scopes.adb @@ -927,6 +927,7 @@ package body Sem_Scopes is | Iir_Kind_Entity_Declaration | Iir_Kind_Package_Declaration | Iir_Kind_Configuration_Declaration + | Iir_Kind_Context_Declaration | Iir_Kinds_Concurrent_Statement | Iir_Kinds_Sequential_Statement => Handle_Decl (Decl, Arg); @@ -976,7 +977,8 @@ package body Sem_Scopes is end loop; end if; end; - when Iir_Kind_Use_Clause => + when Iir_Kind_Use_Clause + | Iir_Kind_Context_Reference => Handle_Decl (Decl, Arg); when Iir_Kind_Library_Clause => Handle_Decl (Decl, Arg); @@ -1007,6 +1009,48 @@ package body Sem_Scopes is end case; end Iterator_Decl; + -- Handle context_clause of context reference CTXT. + procedure Add_One_Context_Reference (Ctxt : Iir) + is + Name : constant Iir := Get_Selected_Name (Ctxt); + Ent : constant Iir := Get_Named_Entity (Name); + Item : Iir; + begin + if Ent = Null_Iir or else Is_Error (Ent) then + -- Stop now in case of error. + return; + end if; + pragma Assert (Get_Kind (Ent) = Iir_Kind_Context_Declaration); + + Item := Get_Context_Items (Ent); + while Item /= Null_Iir loop + case Get_Kind (Item) is + when Iir_Kind_Use_Clause => + Add_Use_Clause (Item); + when Iir_Kind_Library_Clause => + Add_Name (Get_Library_Declaration (Item), + Get_Identifier (Item), False); + when Iir_Kind_Context_Reference => + Add_Context_Reference (Item); + when others => + Error_Kind ("add_context_reference", Item); + end case; + Item := Get_Chain (Item); + end loop; + end Add_One_Context_Reference; + + procedure Add_Context_Reference (Ref : Iir) + is + Ctxt : Iir; + begin + Ctxt := Ref; + loop + Add_One_Context_Reference (Ctxt); + Ctxt := Get_Context_Reference_Chain (Ctxt); + exit when Ctxt = Null_Iir; + end loop; + end Add_Context_Reference; + -- Make POTENTIALLY (or not) visible DECL. procedure Add_Name_Decl (Decl : Iir; Potentially : Boolean) is begin @@ -1015,6 +1059,9 @@ package body Sem_Scopes is if not Potentially then Add_Use_Clause (Decl); end if; + when Iir_Kind_Context_Reference => + pragma Assert (not Potentially); + Add_Context_Reference (Decl); when Iir_Kind_Library_Clause => Add_Name (Get_Library_Declaration (Decl), Get_Identifier (Decl), Potentially); diff --git a/src/vhdl/sem_scopes.ads b/src/vhdl/sem_scopes.ads index 3539e31..6942c54 100644 --- a/src/vhdl/sem_scopes.ads +++ b/src/vhdl/sem_scopes.ads @@ -121,6 +121,9 @@ package Sem_Scopes is -- Achieves visibility of the selected_name of use clause CLAUSE. procedure Add_Use_Clause (Clause : Iir_Use_Clause); + -- Add declarations for context clause in REF. + procedure Add_Context_Reference (Ref : Iir); + -- Add declarations for a context clause into the current declarative -- regions. procedure Add_Context_Clauses (Unit : Iir_Design_Unit); diff --git a/src/vhdl/tokens.adb b/src/vhdl/tokens.adb index 904bd7d..e1bdfef 100644 --- a/src/vhdl/tokens.adb +++ b/src/vhdl/tokens.adb @@ -341,6 +341,10 @@ package body Tokens is when Tok_Protected => return "protected"; + -- VHDL 08 + when Tok_Context => + return "context"; + -- AMS-VHDL when Tok_Across => return "across"; diff --git a/src/vhdl/tokens.ads b/src/vhdl/tokens.ads index adbccb2..fc4b77f 100644 --- a/src/vhdl/tokens.ads +++ b/src/vhdl/tokens.ads @@ -225,9 +225,12 @@ package Tokens is Tok_Rol, Tok_Ror, - -- Added by Vhdl 2000: + -- Added by Vhdl 2000: Tok_Protected, + -- Added by vhdl 2008: + Tok_Context, + -- AMS reserved words Tok_Across, Tok_Break, diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb index 0861852..6366131 100644 --- a/src/vhdl/translate/trans-chap12.adb +++ b/src/vhdl/translate/trans-chap12.adb @@ -590,6 +590,8 @@ package body Trans.Chap12 is -- Mark the spec with 'body is present' flag. Set_Elab_Flag (Get_Design_Unit (Get_Package (Lib_Unit)), True); Translate (Unit, Whole); + when Iir_Kind_Context_Declaration => + null; when others => Error_Kind ("elaborate", Lib_Unit); end case; @@ -614,7 +616,8 @@ package body Trans.Chap12 is when Iir_Kind_Architecture_Body | Iir_Kind_Package_Body | Iir_Kind_Configuration_Declaration - | Iir_Kind_Package_Instantiation_Declaration => + | Iir_Kind_Package_Instantiation_Declaration + | Iir_Kind_Context_Declaration => null; when others => Error_Kind ("elaborate(2)", Lib_Unit); diff --git a/src/vhdl/translate/trans-chap2.adb b/src/vhdl/translate/trans-chap2.adb index 51d64d2..875e4a0 100644 --- a/src/vhdl/translate/trans-chap2.adb +++ b/src/vhdl/translate/trans-chap2.adb @@ -1244,6 +1244,9 @@ package body Trans.Chap2 is when Iir_Kind_Package_Body => -- A package instantiation depends on the body. null; + when Iir_Kind_Context_Declaration => + -- Elab referenced packages. + Elab_Dependence (Design); when others => Error_Kind ("elab_dependence", Library_Unit); end case; |