diff options
-rw-r--r-- | pyGHDL/libghdl/vhdl/nodes.py | 13 | ||||
-rw-r--r-- | pyGHDL/libghdl/vhdl/nodes_meta.py | 463 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 16 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 7 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 438 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.ads | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 31 |
7 files changed, 532 insertions, 438 deletions
diff --git a/pyGHDL/libghdl/vhdl/nodes.py b/pyGHDL/libghdl/vhdl/nodes.py index 45b6d1ee6..eba36f86c 100644 --- a/pyGHDL/libghdl/vhdl/nodes.py +++ b/pyGHDL/libghdl/vhdl/nodes.py @@ -3712,6 +3712,19 @@ def Set_Label(obj: Iir, value: NameId) -> None: @export +@BindToLibGHDL("vhdl__nodes__get_return_identifier") +def Get_Return_Identifier(obj: Iir) -> Iir: + """""" + return 0 + + +@export +@BindToLibGHDL("vhdl__nodes__set_return_identifier") +def Set_Return_Identifier(obj: Iir, value: Iir) -> None: + """""" + + +@export @BindToLibGHDL("vhdl__nodes__get_visible_flag") def Get_Visible_Flag(obj: Iir) -> Boolean: """""" diff --git a/pyGHDL/libghdl/vhdl/nodes_meta.py b/pyGHDL/libghdl/vhdl/nodes_meta.py index 4602d0ac2..3a5f7e2b8 100644 --- a/pyGHDL/libghdl/vhdl/nodes_meta.py +++ b/pyGHDL/libghdl/vhdl/nodes_meta.py @@ -261,234 +261,235 @@ class fields(IntEnum): Primary_Unit = 141 Identifier = 142 Label = 143 - Visible_Flag = 144 - Range_Constraint = 145 - Direction = 146 - Left_Limit = 147 - Right_Limit = 148 - Left_Limit_Expr = 149 - Right_Limit_Expr = 150 - Parent_Type = 151 - Simple_Nature = 152 - Base_Nature = 153 - Resolution_Indication = 154 - Record_Element_Resolution_Chain = 155 - Tolerance = 156 - Plus_Terminal_Name = 157 - Minus_Terminal_Name = 158 - Plus_Terminal = 159 - Minus_Terminal = 160 - Magnitude_Expression = 161 - Phase_Expression = 162 - Power_Expression = 163 - Simultaneous_Left = 164 - Simultaneous_Right = 165 - Text_File_Flag = 166 - Only_Characters_Flag = 167 - Is_Character_Type = 168 - Nature_Staticness = 169 - Type_Staticness = 170 - Constraint_State = 171 - Index_Subtype_List = 172 - Index_Subtype_Definition_List = 173 - Element_Subtype_Indication = 174 - Element_Subtype = 175 - Element_Subnature_Indication = 176 - Element_Subnature = 177 - Index_Constraint_List = 178 - Array_Element_Constraint = 179 - Has_Array_Constraint_Flag = 180 - Has_Element_Constraint_Flag = 181 - Elements_Declaration_List = 182 - Owned_Elements_Chain = 183 - Designated_Type = 184 - Designated_Subtype_Indication = 185 - Index_List = 186 - Reference = 187 - Nature_Declarator = 188 - Across_Type_Mark = 189 - Through_Type_Mark = 190 - Across_Type_Definition = 191 - Through_Type_Definition = 192 - Across_Type = 193 - Through_Type = 194 - Target = 195 - Waveform_Chain = 196 - Guard = 197 - Delay_Mechanism = 198 - Reject_Time_Expression = 199 - Force_Mode = 200 - Has_Force_Mode = 201 - Sensitivity_List = 202 - Process_Origin = 203 - Package_Origin = 204 - Condition_Clause = 205 - Break_Element = 206 - Selector_Quantity = 207 - Break_Quantity = 208 - Timeout_Clause = 209 - Postponed_Flag = 210 - Callees_List = 211 - Passive_Flag = 212 - Resolution_Function_Flag = 213 - Wait_State = 214 - All_Sensitized_State = 215 - Seen_Flag = 216 - Pure_Flag = 217 - Foreign_Flag = 218 - Resolved_Flag = 219 - Signal_Type_Flag = 220 - Has_Signal_Flag = 221 - Purity_State = 222 - Elab_Flag = 223 - Vendor_Library_Flag = 224 - Configuration_Mark_Flag = 225 - Configuration_Done_Flag = 226 - Index_Constraint_Flag = 227 - Hide_Implicit_Flag = 228 - Assertion_Condition = 229 - Report_Expression = 230 - Severity_Expression = 231 - Instantiated_Unit = 232 - Generic_Map_Aspect_Chain = 233 - Port_Map_Aspect_Chain = 234 - Configuration_Name = 235 - Component_Configuration = 236 - Configuration_Specification = 237 - Default_Binding_Indication = 238 - Default_Configuration_Declaration = 239 - Expression = 240 - Conditional_Expression_Chain = 241 - Allocator_Designated_Type = 242 - Selected_Waveform_Chain = 243 - Conditional_Waveform_Chain = 244 - Guard_Expression = 245 - Guard_Decl = 246 - Guard_Sensitivity_List = 247 - Signal_Attribute_Chain = 248 - Block_Block_Configuration = 249 - Package_Header = 250 - Block_Header = 251 - Uninstantiated_Package_Name = 252 - Uninstantiated_Package_Decl = 253 - Instance_Source_File = 254 - Generate_Block_Configuration = 255 - Generate_Statement_Body = 256 - Alternative_Label = 257 - Generate_Else_Clause = 258 - Condition = 259 - Else_Clause = 260 - Parameter_Specification = 261 - Parent = 262 - Loop_Label = 263 - Exit_Flag = 264 - Next_Flag = 265 - Component_Name = 266 - Instantiation_List = 267 - Entity_Aspect = 268 - Default_Entity_Aspect = 269 - Binding_Indication = 270 - Named_Entity = 271 - Referenced_Name = 272 - Expr_Staticness = 273 - Scalar_Size = 274 - Error_Origin = 275 - Operand = 276 - Left = 277 - Right = 278 - Unit_Name = 279 - Name = 280 - Group_Template_Name = 281 - Name_Staticness = 282 - Prefix = 283 - Signature_Prefix = 284 - External_Pathname = 285 - Pathname_Suffix = 286 - Pathname_Expression = 287 - In_Formal_Flag = 288 - Slice_Subtype = 289 - Suffix = 290 - Index_Subtype = 291 - Parameter = 292 - Parameter_2 = 293 - Parameter_3 = 294 - Parameter_4 = 295 - Attr_Chain = 296 - Signal_Attribute_Declaration = 297 - Actual_Type = 298 - Actual_Type_Definition = 299 - Association_Chain = 300 - Individual_Association_Chain = 301 - Subprogram_Association_Chain = 302 - Aggregate_Info = 303 - Sub_Aggregate_Info = 304 - Aggr_Dynamic_Flag = 305 - Aggr_Min_Length = 306 - Aggr_Low_Limit = 307 - Aggr_High_Limit = 308 - Aggr_Others_Flag = 309 - Aggr_Named_Flag = 310 - Aggregate_Expand_Flag = 311 - Association_Choices_Chain = 312 - Case_Statement_Alternative_Chain = 313 - Matching_Flag = 314 - Choice_Staticness = 315 - Procedure_Call = 316 - Implementation = 317 - Parameter_Association_Chain = 318 - Method_Object = 319 - Subtype_Type_Mark = 320 - Subnature_Nature_Mark = 321 - Type_Conversion_Subtype = 322 - Type_Mark = 323 - File_Type_Mark = 324 - Return_Type_Mark = 325 - Has_Disconnect_Flag = 326 - Has_Active_Flag = 327 - Is_Within_Flag = 328 - Type_Marks_List = 329 - Implicit_Alias_Flag = 330 - Alias_Signature = 331 - Attribute_Signature = 332 - Overload_List = 333 - Simple_Name_Identifier = 334 - Simple_Name_Subtype = 335 - Protected_Type_Body = 336 - Protected_Type_Declaration = 337 - Use_Flag = 338 - End_Has_Reserved_Id = 339 - End_Has_Identifier = 340 - End_Has_Postponed = 341 - Has_Label = 342 - Has_Begin = 343 - Has_End = 344 - Has_Is = 345 - Has_Pure = 346 - Has_Body = 347 - Has_Parameter = 348 - Has_Component = 349 - Has_Identifier_List = 350 - Has_Mode = 351 - Has_Class = 352 - Has_Delay_Mechanism = 353 - Suspend_Flag = 354 - Is_Ref = 355 - Is_Forward_Ref = 356 - Psl_Property = 357 - Psl_Sequence = 358 - Psl_Declaration = 359 - Psl_Expression = 360 - Psl_Boolean = 361 - PSL_Clock = 362 - PSL_NFA = 363 - PSL_Nbr_States = 364 - PSL_Clock_Sensitivity = 365 - PSL_EOS_Flag = 366 - PSL_Abort_Flag = 367 - Count_Expression = 368 - Clock_Expression = 369 - Default_Clock = 370 - Foreign_Node = 371 + Return_Identifier = 144 + Visible_Flag = 145 + Range_Constraint = 146 + Direction = 147 + Left_Limit = 148 + Right_Limit = 149 + Left_Limit_Expr = 150 + Right_Limit_Expr = 151 + Parent_Type = 152 + Simple_Nature = 153 + Base_Nature = 154 + Resolution_Indication = 155 + Record_Element_Resolution_Chain = 156 + Tolerance = 157 + Plus_Terminal_Name = 158 + Minus_Terminal_Name = 159 + Plus_Terminal = 160 + Minus_Terminal = 161 + Magnitude_Expression = 162 + Phase_Expression = 163 + Power_Expression = 164 + Simultaneous_Left = 165 + Simultaneous_Right = 166 + Text_File_Flag = 167 + Only_Characters_Flag = 168 + Is_Character_Type = 169 + Nature_Staticness = 170 + Type_Staticness = 171 + Constraint_State = 172 + Index_Subtype_List = 173 + Index_Subtype_Definition_List = 174 + Element_Subtype_Indication = 175 + Element_Subtype = 176 + Element_Subnature_Indication = 177 + Element_Subnature = 178 + Index_Constraint_List = 179 + Array_Element_Constraint = 180 + Has_Array_Constraint_Flag = 181 + Has_Element_Constraint_Flag = 182 + Elements_Declaration_List = 183 + Owned_Elements_Chain = 184 + Designated_Type = 185 + Designated_Subtype_Indication = 186 + Index_List = 187 + Reference = 188 + Nature_Declarator = 189 + Across_Type_Mark = 190 + Through_Type_Mark = 191 + Across_Type_Definition = 192 + Through_Type_Definition = 193 + Across_Type = 194 + Through_Type = 195 + Target = 196 + Waveform_Chain = 197 + Guard = 198 + Delay_Mechanism = 199 + Reject_Time_Expression = 200 + Force_Mode = 201 + Has_Force_Mode = 202 + Sensitivity_List = 203 + Process_Origin = 204 + Package_Origin = 205 + Condition_Clause = 206 + Break_Element = 207 + Selector_Quantity = 208 + Break_Quantity = 209 + Timeout_Clause = 210 + Postponed_Flag = 211 + Callees_List = 212 + Passive_Flag = 213 + Resolution_Function_Flag = 214 + Wait_State = 215 + All_Sensitized_State = 216 + Seen_Flag = 217 + Pure_Flag = 218 + Foreign_Flag = 219 + Resolved_Flag = 220 + Signal_Type_Flag = 221 + Has_Signal_Flag = 222 + Purity_State = 223 + Elab_Flag = 224 + Vendor_Library_Flag = 225 + Configuration_Mark_Flag = 226 + Configuration_Done_Flag = 227 + Index_Constraint_Flag = 228 + Hide_Implicit_Flag = 229 + Assertion_Condition = 230 + Report_Expression = 231 + Severity_Expression = 232 + Instantiated_Unit = 233 + Generic_Map_Aspect_Chain = 234 + Port_Map_Aspect_Chain = 235 + Configuration_Name = 236 + Component_Configuration = 237 + Configuration_Specification = 238 + Default_Binding_Indication = 239 + Default_Configuration_Declaration = 240 + Expression = 241 + Conditional_Expression_Chain = 242 + Allocator_Designated_Type = 243 + Selected_Waveform_Chain = 244 + Conditional_Waveform_Chain = 245 + Guard_Expression = 246 + Guard_Decl = 247 + Guard_Sensitivity_List = 248 + Signal_Attribute_Chain = 249 + Block_Block_Configuration = 250 + Package_Header = 251 + Block_Header = 252 + Uninstantiated_Package_Name = 253 + Uninstantiated_Package_Decl = 254 + Instance_Source_File = 255 + Generate_Block_Configuration = 256 + Generate_Statement_Body = 257 + Alternative_Label = 258 + Generate_Else_Clause = 259 + Condition = 260 + Else_Clause = 261 + Parameter_Specification = 262 + Parent = 263 + Loop_Label = 264 + Exit_Flag = 265 + Next_Flag = 266 + Component_Name = 267 + Instantiation_List = 268 + Entity_Aspect = 269 + Default_Entity_Aspect = 270 + Binding_Indication = 271 + Named_Entity = 272 + Referenced_Name = 273 + Expr_Staticness = 274 + Scalar_Size = 275 + Error_Origin = 276 + Operand = 277 + Left = 278 + Right = 279 + Unit_Name = 280 + Name = 281 + Group_Template_Name = 282 + Name_Staticness = 283 + Prefix = 284 + Signature_Prefix = 285 + External_Pathname = 286 + Pathname_Suffix = 287 + Pathname_Expression = 288 + In_Formal_Flag = 289 + Slice_Subtype = 290 + Suffix = 291 + Index_Subtype = 292 + Parameter = 293 + Parameter_2 = 294 + Parameter_3 = 295 + Parameter_4 = 296 + Attr_Chain = 297 + Signal_Attribute_Declaration = 298 + Actual_Type = 299 + Actual_Type_Definition = 300 + Association_Chain = 301 + Individual_Association_Chain = 302 + Subprogram_Association_Chain = 303 + Aggregate_Info = 304 + Sub_Aggregate_Info = 305 + Aggr_Dynamic_Flag = 306 + Aggr_Min_Length = 307 + Aggr_Low_Limit = 308 + Aggr_High_Limit = 309 + Aggr_Others_Flag = 310 + Aggr_Named_Flag = 311 + Aggregate_Expand_Flag = 312 + Association_Choices_Chain = 313 + Case_Statement_Alternative_Chain = 314 + Matching_Flag = 315 + Choice_Staticness = 316 + Procedure_Call = 317 + Implementation = 318 + Parameter_Association_Chain = 319 + Method_Object = 320 + Subtype_Type_Mark = 321 + Subnature_Nature_Mark = 322 + Type_Conversion_Subtype = 323 + Type_Mark = 324 + File_Type_Mark = 325 + Return_Type_Mark = 326 + Has_Disconnect_Flag = 327 + Has_Active_Flag = 328 + Is_Within_Flag = 329 + Type_Marks_List = 330 + Implicit_Alias_Flag = 331 + Alias_Signature = 332 + Attribute_Signature = 333 + Overload_List = 334 + Simple_Name_Identifier = 335 + Simple_Name_Subtype = 336 + Protected_Type_Body = 337 + Protected_Type_Declaration = 338 + Use_Flag = 339 + End_Has_Reserved_Id = 340 + End_Has_Identifier = 341 + End_Has_Postponed = 342 + Has_Label = 343 + Has_Begin = 344 + Has_End = 345 + Has_Is = 346 + Has_Pure = 347 + Has_Body = 348 + Has_Parameter = 349 + Has_Component = 350 + Has_Identifier_List = 351 + Has_Mode = 352 + Has_Class = 353 + Has_Delay_Mechanism = 354 + Suspend_Flag = 355 + Is_Ref = 356 + Is_Forward_Ref = 357 + Psl_Property = 358 + Psl_Sequence = 359 + Psl_Declaration = 360 + Psl_Expression = 361 + Psl_Boolean = 362 + PSL_Clock = 363 + PSL_NFA = 364 + PSL_Nbr_States = 365 + PSL_Clock_Sensitivity = 366 + PSL_EOS_Flag = 367 + PSL_Abort_Flag = 368 + Count_Expression = 369 + Clock_Expression = 370 + Default_Clock = 371 + Foreign_Node = 372 def Get_Boolean(node, field): @@ -1488,6 +1489,12 @@ def Has_Label(kind: IirKind) -> bool: @export +@BindToLibGHDL("vhdl__nodes_meta__has_return_identifier") +def Has_Return_Identifier(kind: IirKind) -> bool: + """""" + + +@export @BindToLibGHDL("vhdl__nodes_meta__has_visible_flag") def Has_Visible_Flag(kind: IirKind) -> bool: """""" diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 94c01f275..947cd771d 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -3711,6 +3711,22 @@ package body Vhdl.Nodes is Set_Field3 (Target, Name_Id_To_Iir (Label)); end Set_Label; + function Get_Return_Identifier (Target : Iir) return Iir is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Return_Identifier (Get_Kind (Target)), + "no field Return_Identifier"); + return Get_Field11 (Target); + end Get_Return_Identifier; + + procedure Set_Return_Identifier (Target : Iir; Decl : Iir) is + begin + pragma Assert (Target /= Null_Iir); + pragma Assert (Has_Return_Identifier (Get_Kind (Target)), + "no field Return_Identifier"); + Set_Field11 (Target, Decl); + end Set_Return_Identifier; + function Get_Visible_Flag (Target : Iir) return Boolean is begin pragma Assert (Target /= Null_Iir); diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index a36566a5c..aac961bb6 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -1606,6 +1606,8 @@ package Vhdl.Nodes is -- -- Get/Set_Subprogram_Depth (Field10) -- + -- Get/Set_Return_Identifier (Field11) + -- -- Get/Set_Overload_Number (Field12) -- -- Get/Set_Seen_Flag (Flag1) @@ -8183,6 +8185,11 @@ package Vhdl.Nodes is function Get_Label (Target : Iir) return Name_Id; procedure Set_Label (Target : Iir; Label : Name_Id); + -- Return a subtype declaration for the return subtype (vhdl-19) + -- Field: Field11 + function Get_Return_Identifier (Target : Iir) return Iir; + procedure Set_Return_Identifier (Target : Iir; Decl : Iir); + -- Get/Set the visible flag of a declaration. -- The visible flag is true to make invalid the use of the identifier -- during its declaration. It is set to false when the identifier is added diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index 53eceebd9..f08c00504 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -161,6 +161,7 @@ package body Vhdl.Nodes_Meta is Field_Primary_Unit => Type_Iir, Field_Identifier => Type_Name_Id, Field_Label => Type_Name_Id, + Field_Return_Identifier => Type_Iir, Field_Visible_Flag => Type_Boolean, Field_Range_Constraint => Type_Iir, Field_Direction => Type_Direction_Type, @@ -687,6 +688,8 @@ package body Vhdl.Nodes_Meta is return "identifier"; when Field_Label => return "label"; + when Field_Return_Identifier => + return "return_identifier"; when Field_Visible_Flag => return "visible_flag"; when Field_Range_Constraint => @@ -2083,6 +2086,8 @@ package body Vhdl.Nodes_Meta is return Attr_None; when Field_Label => return Attr_None; + when Field_Return_Identifier => + return Attr_None; when Field_Visible_Flag => return Attr_None; when Field_Range_Constraint => @@ -3485,6 +3490,7 @@ package body Vhdl.Nodes_Meta is Field_Generic_Chain, Field_Return_Type_Mark, Field_Subprogram_Body, + Field_Return_Identifier, -- Iir_Kind_Procedure_Declaration Field_Subprogram_Depth, Field_Overload_Number, @@ -3510,6 +3516,7 @@ package body Vhdl.Nodes_Meta is Field_Generic_Chain, Field_Return_Type_Mark, Field_Subprogram_Body, + Field_Return_Identifier, -- Iir_Kind_Function_Body Field_Impure_Depth, Field_End_Has_Reserved_Id, @@ -5364,214 +5371,214 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Psl_Declaration => 776, Iir_Kind_Psl_Endpoint_Declaration => 790, Iir_Kind_Enumeration_Literal => 802, - Iir_Kind_Function_Declaration => 827, - Iir_Kind_Procedure_Declaration => 851, - Iir_Kind_Function_Body => 861, - Iir_Kind_Procedure_Body => 872, - Iir_Kind_Function_Instantiation_Declaration => 883, - Iir_Kind_Procedure_Instantiation_Declaration => 893, - Iir_Kind_Terminal_Declaration => 902, - Iir_Kind_Object_Alias_Declaration => 914, - Iir_Kind_Free_Quantity_Declaration => 926, - Iir_Kind_Spectrum_Quantity_Declaration => 939, - Iir_Kind_Noise_Quantity_Declaration => 951, - Iir_Kind_Across_Quantity_Declaration => 967, - Iir_Kind_Through_Quantity_Declaration => 983, - Iir_Kind_File_Declaration => 998, - Iir_Kind_Guard_Signal_Declaration => 1012, - Iir_Kind_Signal_Declaration => 1029, - Iir_Kind_Variable_Declaration => 1042, - Iir_Kind_Constant_Declaration => 1056, - Iir_Kind_Iterator_Declaration => 1068, - Iir_Kind_Interface_Constant_Declaration => 1085, - Iir_Kind_Interface_Variable_Declaration => 1101, - Iir_Kind_Interface_Signal_Declaration => 1122, - Iir_Kind_Interface_File_Declaration => 1138, - Iir_Kind_Interface_Quantity_Declaration => 1154, - Iir_Kind_Interface_Terminal_Declaration => 1166, - Iir_Kind_Interface_Type_Declaration => 1177, - Iir_Kind_Interface_Package_Declaration => 1190, - Iir_Kind_Interface_Function_Declaration => 1208, - Iir_Kind_Interface_Procedure_Declaration => 1222, - Iir_Kind_Signal_Attribute_Declaration => 1225, - Iir_Kind_Identity_Operator => 1229, - Iir_Kind_Negation_Operator => 1233, - Iir_Kind_Absolute_Operator => 1237, - Iir_Kind_Not_Operator => 1241, - Iir_Kind_Implicit_Condition_Operator => 1245, - Iir_Kind_Condition_Operator => 1249, - Iir_Kind_Reduction_And_Operator => 1253, - Iir_Kind_Reduction_Or_Operator => 1257, - Iir_Kind_Reduction_Nand_Operator => 1261, - Iir_Kind_Reduction_Nor_Operator => 1265, - Iir_Kind_Reduction_Xor_Operator => 1269, - Iir_Kind_Reduction_Xnor_Operator => 1273, - Iir_Kind_And_Operator => 1278, - Iir_Kind_Or_Operator => 1283, - Iir_Kind_Nand_Operator => 1288, - Iir_Kind_Nor_Operator => 1293, - Iir_Kind_Xor_Operator => 1298, - Iir_Kind_Xnor_Operator => 1303, - Iir_Kind_Equality_Operator => 1308, - Iir_Kind_Inequality_Operator => 1313, - Iir_Kind_Less_Than_Operator => 1318, - Iir_Kind_Less_Than_Or_Equal_Operator => 1323, - Iir_Kind_Greater_Than_Operator => 1328, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1333, - Iir_Kind_Match_Equality_Operator => 1338, - Iir_Kind_Match_Inequality_Operator => 1343, - Iir_Kind_Match_Less_Than_Operator => 1348, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1353, - Iir_Kind_Match_Greater_Than_Operator => 1358, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1363, - Iir_Kind_Sll_Operator => 1368, - Iir_Kind_Sla_Operator => 1373, - Iir_Kind_Srl_Operator => 1378, - Iir_Kind_Sra_Operator => 1383, - Iir_Kind_Rol_Operator => 1388, - Iir_Kind_Ror_Operator => 1393, - Iir_Kind_Addition_Operator => 1398, - Iir_Kind_Substraction_Operator => 1403, - Iir_Kind_Concatenation_Operator => 1408, - Iir_Kind_Multiplication_Operator => 1413, - Iir_Kind_Division_Operator => 1418, - Iir_Kind_Modulus_Operator => 1423, - Iir_Kind_Remainder_Operator => 1428, - Iir_Kind_Exponentiation_Operator => 1433, - Iir_Kind_Function_Call => 1441, - Iir_Kind_Aggregate => 1448, - Iir_Kind_Parenthesis_Expression => 1451, - Iir_Kind_Qualified_Expression => 1455, - Iir_Kind_Type_Conversion => 1460, - Iir_Kind_Allocator_By_Expression => 1465, - Iir_Kind_Allocator_By_Subtype => 1471, - Iir_Kind_Selected_Element => 1479, - Iir_Kind_Dereference => 1484, - Iir_Kind_Implicit_Dereference => 1489, - Iir_Kind_Slice_Name => 1496, - Iir_Kind_Indexed_Name => 1502, - Iir_Kind_Psl_Prev => 1508, - Iir_Kind_Psl_Stable => 1513, - Iir_Kind_Psl_Rose => 1518, - Iir_Kind_Psl_Fell => 1523, - Iir_Kind_Psl_Onehot => 1526, - Iir_Kind_Psl_Onehot0 => 1529, - Iir_Kind_Psl_Expression => 1531, - Iir_Kind_Sensitized_Process_Statement => 1552, - Iir_Kind_Process_Statement => 1572, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1585, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1598, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1612, - Iir_Kind_Concurrent_Assertion_Statement => 1620, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1627, - Iir_Kind_Concurrent_Break_Statement => 1635, - Iir_Kind_Psl_Assert_Directive => 1649, - Iir_Kind_Psl_Assume_Directive => 1661, - Iir_Kind_Psl_Cover_Directive => 1673, - Iir_Kind_Psl_Restrict_Directive => 1684, - Iir_Kind_Block_Statement => 1698, - Iir_Kind_If_Generate_Statement => 1709, - Iir_Kind_Case_Generate_Statement => 1718, - Iir_Kind_For_Generate_Statement => 1727, - Iir_Kind_Component_Instantiation_Statement => 1738, - Iir_Kind_Psl_Default_Clock => 1741, - Iir_Kind_Generate_Statement_Body => 1752, - Iir_Kind_If_Generate_Else_Clause => 1758, - Iir_Kind_Simple_Simultaneous_Statement => 1765, - Iir_Kind_Simultaneous_Null_Statement => 1769, - Iir_Kind_Simultaneous_Procedural_Statement => 1780, - Iir_Kind_Simultaneous_Case_Statement => 1789, - Iir_Kind_Simultaneous_If_Statement => 1798, - Iir_Kind_Simultaneous_Elsif => 1804, - Iir_Kind_Simple_Signal_Assignment_Statement => 1815, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1826, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1838, - Iir_Kind_Signal_Force_Assignment_Statement => 1848, - Iir_Kind_Signal_Release_Assignment_Statement => 1857, - Iir_Kind_Null_Statement => 1861, - Iir_Kind_Assertion_Statement => 1868, - Iir_Kind_Report_Statement => 1874, - Iir_Kind_Wait_Statement => 1882, - Iir_Kind_Variable_Assignment_Statement => 1889, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1896, - Iir_Kind_Return_Statement => 1902, - Iir_Kind_For_Loop_Statement => 1913, - Iir_Kind_While_Loop_Statement => 1924, - Iir_Kind_Next_Statement => 1931, - Iir_Kind_Exit_Statement => 1938, - Iir_Kind_Case_Statement => 1947, - Iir_Kind_Procedure_Call_Statement => 1953, - Iir_Kind_Break_Statement => 1960, - Iir_Kind_If_Statement => 1970, - Iir_Kind_Elsif => 1976, - Iir_Kind_Character_Literal => 1983, - Iir_Kind_Simple_Name => 1990, - Iir_Kind_Selected_Name => 1998, - Iir_Kind_Operator_Symbol => 2003, - Iir_Kind_Reference_Name => 2008, - Iir_Kind_External_Constant_Name => 2017, - Iir_Kind_External_Signal_Name => 2026, - Iir_Kind_External_Variable_Name => 2036, - Iir_Kind_Selected_By_All_Name => 2042, - Iir_Kind_Parenthesis_Name => 2047, - Iir_Kind_Package_Pathname => 2051, - Iir_Kind_Absolute_Pathname => 2052, - Iir_Kind_Relative_Pathname => 2053, - Iir_Kind_Pathname_Element => 2058, - Iir_Kind_Base_Attribute => 2060, - Iir_Kind_Subtype_Attribute => 2065, - Iir_Kind_Element_Attribute => 2070, - Iir_Kind_Across_Attribute => 2075, - Iir_Kind_Through_Attribute => 2080, - Iir_Kind_Nature_Reference_Attribute => 2084, - Iir_Kind_Left_Type_Attribute => 2089, - Iir_Kind_Right_Type_Attribute => 2094, - Iir_Kind_High_Type_Attribute => 2099, - Iir_Kind_Low_Type_Attribute => 2104, - Iir_Kind_Ascending_Type_Attribute => 2109, - Iir_Kind_Image_Attribute => 2115, - Iir_Kind_Value_Attribute => 2121, - Iir_Kind_Pos_Attribute => 2127, - Iir_Kind_Val_Attribute => 2133, - Iir_Kind_Succ_Attribute => 2139, - Iir_Kind_Pred_Attribute => 2145, - Iir_Kind_Leftof_Attribute => 2151, - Iir_Kind_Rightof_Attribute => 2157, - Iir_Kind_Signal_Slew_Attribute => 2165, - Iir_Kind_Quantity_Slew_Attribute => 2173, - Iir_Kind_Ramp_Attribute => 2181, - Iir_Kind_Zoh_Attribute => 2189, - Iir_Kind_Ltf_Attribute => 2197, - Iir_Kind_Ztf_Attribute => 2207, - Iir_Kind_Dot_Attribute => 2214, - Iir_Kind_Integ_Attribute => 2221, - Iir_Kind_Above_Attribute => 2229, - Iir_Kind_Quantity_Delayed_Attribute => 2237, - Iir_Kind_Delayed_Attribute => 2246, - Iir_Kind_Stable_Attribute => 2255, - Iir_Kind_Quiet_Attribute => 2264, - Iir_Kind_Transaction_Attribute => 2273, - Iir_Kind_Event_Attribute => 2277, - Iir_Kind_Active_Attribute => 2281, - Iir_Kind_Last_Event_Attribute => 2285, - Iir_Kind_Last_Active_Attribute => 2289, - Iir_Kind_Last_Value_Attribute => 2293, - Iir_Kind_Driving_Attribute => 2297, - Iir_Kind_Driving_Value_Attribute => 2301, - Iir_Kind_Behavior_Attribute => 2301, - Iir_Kind_Structure_Attribute => 2301, - Iir_Kind_Simple_Name_Attribute => 2308, - Iir_Kind_Instance_Name_Attribute => 2313, - Iir_Kind_Path_Name_Attribute => 2318, - Iir_Kind_Left_Array_Attribute => 2325, - Iir_Kind_Right_Array_Attribute => 2332, - Iir_Kind_High_Array_Attribute => 2339, - Iir_Kind_Low_Array_Attribute => 2346, - Iir_Kind_Length_Array_Attribute => 2353, - Iir_Kind_Ascending_Array_Attribute => 2360, - Iir_Kind_Range_Array_Attribute => 2367, - Iir_Kind_Reverse_Range_Array_Attribute => 2374, - Iir_Kind_Attribute_Name => 2383 + Iir_Kind_Function_Declaration => 828, + Iir_Kind_Procedure_Declaration => 853, + Iir_Kind_Function_Body => 863, + Iir_Kind_Procedure_Body => 874, + Iir_Kind_Function_Instantiation_Declaration => 885, + Iir_Kind_Procedure_Instantiation_Declaration => 895, + Iir_Kind_Terminal_Declaration => 904, + Iir_Kind_Object_Alias_Declaration => 916, + Iir_Kind_Free_Quantity_Declaration => 928, + Iir_Kind_Spectrum_Quantity_Declaration => 941, + Iir_Kind_Noise_Quantity_Declaration => 953, + Iir_Kind_Across_Quantity_Declaration => 969, + Iir_Kind_Through_Quantity_Declaration => 985, + Iir_Kind_File_Declaration => 1000, + Iir_Kind_Guard_Signal_Declaration => 1014, + Iir_Kind_Signal_Declaration => 1031, + Iir_Kind_Variable_Declaration => 1044, + Iir_Kind_Constant_Declaration => 1058, + Iir_Kind_Iterator_Declaration => 1070, + Iir_Kind_Interface_Constant_Declaration => 1087, + Iir_Kind_Interface_Variable_Declaration => 1103, + Iir_Kind_Interface_Signal_Declaration => 1124, + Iir_Kind_Interface_File_Declaration => 1140, + Iir_Kind_Interface_Quantity_Declaration => 1156, + Iir_Kind_Interface_Terminal_Declaration => 1168, + Iir_Kind_Interface_Type_Declaration => 1179, + Iir_Kind_Interface_Package_Declaration => 1192, + Iir_Kind_Interface_Function_Declaration => 1210, + Iir_Kind_Interface_Procedure_Declaration => 1224, + Iir_Kind_Signal_Attribute_Declaration => 1227, + Iir_Kind_Identity_Operator => 1231, + Iir_Kind_Negation_Operator => 1235, + Iir_Kind_Absolute_Operator => 1239, + Iir_Kind_Not_Operator => 1243, + Iir_Kind_Implicit_Condition_Operator => 1247, + Iir_Kind_Condition_Operator => 1251, + Iir_Kind_Reduction_And_Operator => 1255, + Iir_Kind_Reduction_Or_Operator => 1259, + Iir_Kind_Reduction_Nand_Operator => 1263, + Iir_Kind_Reduction_Nor_Operator => 1267, + Iir_Kind_Reduction_Xor_Operator => 1271, + Iir_Kind_Reduction_Xnor_Operator => 1275, + Iir_Kind_And_Operator => 1280, + Iir_Kind_Or_Operator => 1285, + Iir_Kind_Nand_Operator => 1290, + Iir_Kind_Nor_Operator => 1295, + Iir_Kind_Xor_Operator => 1300, + Iir_Kind_Xnor_Operator => 1305, + Iir_Kind_Equality_Operator => 1310, + Iir_Kind_Inequality_Operator => 1315, + Iir_Kind_Less_Than_Operator => 1320, + Iir_Kind_Less_Than_Or_Equal_Operator => 1325, + Iir_Kind_Greater_Than_Operator => 1330, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1335, + Iir_Kind_Match_Equality_Operator => 1340, + Iir_Kind_Match_Inequality_Operator => 1345, + Iir_Kind_Match_Less_Than_Operator => 1350, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1355, + Iir_Kind_Match_Greater_Than_Operator => 1360, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1365, + Iir_Kind_Sll_Operator => 1370, + Iir_Kind_Sla_Operator => 1375, + Iir_Kind_Srl_Operator => 1380, + Iir_Kind_Sra_Operator => 1385, + Iir_Kind_Rol_Operator => 1390, + Iir_Kind_Ror_Operator => 1395, + Iir_Kind_Addition_Operator => 1400, + Iir_Kind_Substraction_Operator => 1405, + Iir_Kind_Concatenation_Operator => 1410, + Iir_Kind_Multiplication_Operator => 1415, + Iir_Kind_Division_Operator => 1420, + Iir_Kind_Modulus_Operator => 1425, + Iir_Kind_Remainder_Operator => 1430, + Iir_Kind_Exponentiation_Operator => 1435, + Iir_Kind_Function_Call => 1443, + Iir_Kind_Aggregate => 1450, + Iir_Kind_Parenthesis_Expression => 1453, + Iir_Kind_Qualified_Expression => 1457, + Iir_Kind_Type_Conversion => 1462, + Iir_Kind_Allocator_By_Expression => 1467, + Iir_Kind_Allocator_By_Subtype => 1473, + Iir_Kind_Selected_Element => 1481, + Iir_Kind_Dereference => 1486, + Iir_Kind_Implicit_Dereference => 1491, + Iir_Kind_Slice_Name => 1498, + Iir_Kind_Indexed_Name => 1504, + Iir_Kind_Psl_Prev => 1510, + Iir_Kind_Psl_Stable => 1515, + Iir_Kind_Psl_Rose => 1520, + Iir_Kind_Psl_Fell => 1525, + Iir_Kind_Psl_Onehot => 1528, + Iir_Kind_Psl_Onehot0 => 1531, + Iir_Kind_Psl_Expression => 1533, + Iir_Kind_Sensitized_Process_Statement => 1554, + Iir_Kind_Process_Statement => 1574, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1587, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1600, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1614, + Iir_Kind_Concurrent_Assertion_Statement => 1622, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1629, + Iir_Kind_Concurrent_Break_Statement => 1637, + Iir_Kind_Psl_Assert_Directive => 1651, + Iir_Kind_Psl_Assume_Directive => 1663, + Iir_Kind_Psl_Cover_Directive => 1675, + Iir_Kind_Psl_Restrict_Directive => 1686, + Iir_Kind_Block_Statement => 1700, + Iir_Kind_If_Generate_Statement => 1711, + Iir_Kind_Case_Generate_Statement => 1720, + Iir_Kind_For_Generate_Statement => 1729, + Iir_Kind_Component_Instantiation_Statement => 1740, + Iir_Kind_Psl_Default_Clock => 1743, + Iir_Kind_Generate_Statement_Body => 1754, + Iir_Kind_If_Generate_Else_Clause => 1760, + Iir_Kind_Simple_Simultaneous_Statement => 1767, + Iir_Kind_Simultaneous_Null_Statement => 1771, + Iir_Kind_Simultaneous_Procedural_Statement => 1782, + Iir_Kind_Simultaneous_Case_Statement => 1791, + Iir_Kind_Simultaneous_If_Statement => 1800, + Iir_Kind_Simultaneous_Elsif => 1806, + Iir_Kind_Simple_Signal_Assignment_Statement => 1817, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1828, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1840, + Iir_Kind_Signal_Force_Assignment_Statement => 1850, + Iir_Kind_Signal_Release_Assignment_Statement => 1859, + Iir_Kind_Null_Statement => 1863, + Iir_Kind_Assertion_Statement => 1870, + Iir_Kind_Report_Statement => 1876, + Iir_Kind_Wait_Statement => 1884, + Iir_Kind_Variable_Assignment_Statement => 1891, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1898, + Iir_Kind_Return_Statement => 1904, + Iir_Kind_For_Loop_Statement => 1915, + Iir_Kind_While_Loop_Statement => 1926, + Iir_Kind_Next_Statement => 1933, + Iir_Kind_Exit_Statement => 1940, + Iir_Kind_Case_Statement => 1949, + Iir_Kind_Procedure_Call_Statement => 1955, + Iir_Kind_Break_Statement => 1962, + Iir_Kind_If_Statement => 1972, + Iir_Kind_Elsif => 1978, + Iir_Kind_Character_Literal => 1985, + Iir_Kind_Simple_Name => 1992, + Iir_Kind_Selected_Name => 2000, + Iir_Kind_Operator_Symbol => 2005, + Iir_Kind_Reference_Name => 2010, + Iir_Kind_External_Constant_Name => 2019, + Iir_Kind_External_Signal_Name => 2028, + Iir_Kind_External_Variable_Name => 2038, + Iir_Kind_Selected_By_All_Name => 2044, + Iir_Kind_Parenthesis_Name => 2049, + Iir_Kind_Package_Pathname => 2053, + Iir_Kind_Absolute_Pathname => 2054, + Iir_Kind_Relative_Pathname => 2055, + Iir_Kind_Pathname_Element => 2060, + Iir_Kind_Base_Attribute => 2062, + Iir_Kind_Subtype_Attribute => 2067, + Iir_Kind_Element_Attribute => 2072, + Iir_Kind_Across_Attribute => 2077, + Iir_Kind_Through_Attribute => 2082, + Iir_Kind_Nature_Reference_Attribute => 2086, + Iir_Kind_Left_Type_Attribute => 2091, + Iir_Kind_Right_Type_Attribute => 2096, + Iir_Kind_High_Type_Attribute => 2101, + Iir_Kind_Low_Type_Attribute => 2106, + Iir_Kind_Ascending_Type_Attribute => 2111, + Iir_Kind_Image_Attribute => 2117, + Iir_Kind_Value_Attribute => 2123, + Iir_Kind_Pos_Attribute => 2129, + Iir_Kind_Val_Attribute => 2135, + Iir_Kind_Succ_Attribute => 2141, + Iir_Kind_Pred_Attribute => 2147, + Iir_Kind_Leftof_Attribute => 2153, + Iir_Kind_Rightof_Attribute => 2159, + Iir_Kind_Signal_Slew_Attribute => 2167, + Iir_Kind_Quantity_Slew_Attribute => 2175, + Iir_Kind_Ramp_Attribute => 2183, + Iir_Kind_Zoh_Attribute => 2191, + Iir_Kind_Ltf_Attribute => 2199, + Iir_Kind_Ztf_Attribute => 2209, + Iir_Kind_Dot_Attribute => 2216, + Iir_Kind_Integ_Attribute => 2223, + Iir_Kind_Above_Attribute => 2231, + Iir_Kind_Quantity_Delayed_Attribute => 2239, + Iir_Kind_Delayed_Attribute => 2248, + Iir_Kind_Stable_Attribute => 2257, + Iir_Kind_Quiet_Attribute => 2266, + Iir_Kind_Transaction_Attribute => 2275, + Iir_Kind_Event_Attribute => 2279, + Iir_Kind_Active_Attribute => 2283, + Iir_Kind_Last_Event_Attribute => 2287, + Iir_Kind_Last_Active_Attribute => 2291, + Iir_Kind_Last_Value_Attribute => 2295, + Iir_Kind_Driving_Attribute => 2299, + Iir_Kind_Driving_Value_Attribute => 2303, + Iir_Kind_Behavior_Attribute => 2303, + Iir_Kind_Structure_Attribute => 2303, + Iir_Kind_Simple_Name_Attribute => 2310, + Iir_Kind_Instance_Name_Attribute => 2315, + Iir_Kind_Path_Name_Attribute => 2320, + Iir_Kind_Left_Array_Attribute => 2327, + Iir_Kind_Right_Array_Attribute => 2334, + Iir_Kind_High_Array_Attribute => 2341, + Iir_Kind_Low_Array_Attribute => 2348, + Iir_Kind_Length_Array_Attribute => 2355, + Iir_Kind_Ascending_Array_Attribute => 2362, + Iir_Kind_Range_Array_Attribute => 2369, + Iir_Kind_Reverse_Range_Array_Attribute => 2376, + Iir_Kind_Attribute_Name => 2385 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -6210,6 +6217,8 @@ package body Vhdl.Nodes_Meta is return Get_Unit_Chain (N); when Field_Primary_Unit => return Get_Primary_Unit (N); + when Field_Return_Identifier => + return Get_Return_Identifier (N); when Field_Range_Constraint => return Get_Range_Constraint (N); when Field_Left_Limit => @@ -6666,6 +6675,8 @@ package body Vhdl.Nodes_Meta is Set_Unit_Chain (N, V); when Field_Primary_Unit => Set_Primary_Unit (N, V); + when Field_Return_Identifier => + Set_Return_Identifier (N, V); when Field_Range_Constraint => Set_Range_Constraint (N, V); when Field_Left_Limit => @@ -9564,6 +9575,17 @@ package body Vhdl.Nodes_Meta is end case; end Has_Label; + function Has_Return_Identifier (K : Iir_Kind) return Boolean is + begin + case K is + when Iir_Kind_Function_Declaration + | Iir_Kind_Procedure_Declaration => + return True; + when others => + return False; + end case; + end Has_Return_Identifier; + function Has_Visible_Flag (K : Iir_Kind) return Boolean is begin case K is diff --git a/src/vhdl/vhdl-nodes_meta.ads b/src/vhdl/vhdl-nodes_meta.ads index 44ae8b048..15e9c1b3d 100644 --- a/src/vhdl/vhdl-nodes_meta.ads +++ b/src/vhdl/vhdl-nodes_meta.ads @@ -205,6 +205,7 @@ package Vhdl.Nodes_Meta is Field_Primary_Unit, Field_Identifier, Field_Label, + Field_Return_Identifier, Field_Visible_Flag, Field_Range_Constraint, Field_Direction, @@ -791,6 +792,7 @@ package Vhdl.Nodes_Meta is function Has_Primary_Unit (K : Iir_Kind) return Boolean; function Has_Identifier (K : Iir_Kind) return Boolean; function Has_Label (K : Iir_Kind) return Boolean; + function Has_Return_Identifier (K : Iir_Kind) return Boolean; function Has_Visible_Flag (K : Iir_Kind) return Boolean; function Has_Range_Constraint (K : Iir_Kind) return Boolean; function Has_Direction (K : Iir_Kind) return Boolean; diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index e84f7d726..6e574b0a5 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -2100,6 +2100,8 @@ package body Vhdl.Parse is is Old : Iir; pragma Unreferenced (Old); + Tm : Iir; + Ret : Iir; Inters : Iir; begin if Current_Token = Tok_Parameter then @@ -2141,8 +2143,27 @@ package body Vhdl.Parse is -- Skip 'return' Scan; - Set_Return_Type_Mark - (Subprg, Parse_Type_Mark (Check_Paren => True)); + Tm := Parse_Type_Mark (Check_Paren => True); + + if Current_Token = Tok_Of then + if Vhdl_Std < Vhdl_19 then + Error_Msg_Parse + ("return identifier not allowed before vhdl 2019"); + end if; + pragma Assert (Get_Kind (Tm) = Iir_Kind_Simple_Name); + Ret := Create_Iir (Iir_Kind_Subtype_Declaration); + Location_Copy (Ret, Tm); + Set_Identifier (Ret, Get_Identifier (Tm)); + Set_Return_Identifier (Subprg, Ret); + Free_Iir (Tm); + + -- Skip 'of' + Scan; + + Tm := Parse_Type_Mark (Check_Paren => True); + end if; + + Set_Return_Type_Mark (Subprg, Tm); end if; else if Is_Func and Required then @@ -8298,6 +8319,12 @@ package body Vhdl.Parse is -- | [ PURE | IMPURE ] FUNCTION designator [ ( formal_parameter_list ) ] -- RETURN type_mark -- + -- [ LRM19 4.2 Subprogram declarations ] + -- function_specification ::= + -- [ PURE | IMPURE ] FUNCTION designator + -- subprogram_header [ [ PARAMETER ] ( formal_parameter_list) ] + -- RETURN [ return_identifier OF ] type_mark + -- -- [ LRM93 2.2 ] -- subprogram_body ::= -- subprogram_specification IS |