summaryrefslogtreecommitdiff
path: root/gcc/ada/atree.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-19 15:20:16 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-19 15:20:16 +0000
commit5329ca6475e92c4a485d941efe57819159434b5e (patch)
tree978d1dfc5330e89503dce76f1c63cf981f4b9d73 /gcc/ada/atree.adb
parent4f958b344b0f1c974df27213108354f0af9adb9f (diff)
downloadgcc-5329ca6475e92c4a485d941efe57819159434b5e.tar.gz
2004-04-19 Arnaud Charlet <charlet@act-europe.fr>
* 5isystem.ads: Removed, unused. * gnat_rm.texi: Redo 1.13 change. 2004-04-19 Robert Dewar <dewar@gnat.com> * s-stoele.ads: Clean up definition of Storage_Offset (the new definition is cleaner, avoids the kludge of explicit Standard operator references, and also is consistent with a visible System.Address with no visible operations. * s-geveop.adb: Add declarations to avoid assumption of visible operations on type System.Address (since these might not be available if Address is a non-private type for which the operations are made abstract). * sem_eval.adb: Minor reformatting * s-carsi8.ads, s-carun8.ads, s-casi16.ads, s-casi32.ads, s-casi64.ads, s-caun16.ads, s-caun32.ads, s-caun64.ads: Minor reformatting (new function spec format). * s-auxdec.adb, s-carsi8.adb, s-carun8.adb, s-casi16.adb, s-casi32.adb, s-casi64.adb, s-caun16.adb, s-caun32.adb, s-caun64.adb: Add declarations to avoid assumption of visible operations on type System.Address (since these might not be available if Address is a non-private type for which the operations are made abstract). * lib.ads, lib.adb (Synchronize_Serial_Number): New procedure. * exp_intr.adb: Minor comment update * exp_aggr.adb, exp_attr.adb, exp_ch13.adb: Minor reformatting. * 5omastop.adb: Add declarations to avoid assumption of visible operations on type System.Address (since these might not be available if Address is a non-private type for which the operations are made abstract). 2004-04-19 Vincent Celier <celier@gnat.com> * switch-m.adb: (Scan_Make_Switches): Process new switch -eL * prj-pars.ads (Parse): New Boolean parameter Process_Languages, defaulted to Ada. * prj-proc.adb (Process): New Boolean parameter Process_Languages, defaulted to Ada. Call Check with Process_Languages. (Check): New Boolean parameter Process_Languages. Call Recursive_Check with Process_Languages. (Recursive_Check): New Boolean parameter Process_Languages. Call Nmsc.Ada_Check or Nmsc.Other_Languages_Check according to Process_Languages. * prj-proc.ads (Process): New Boolean parameter Process_Languages, * prj-util.ads, prj-util.adb (Executable_Of): New Boolean parameter Ada_Main, defaulted to True. Check for Ada specific characteristics only when Ada_Main is True. * opt.ads: (Follow_Links): New Boolean flag for gnatmake * prj.adb: (Project_Empty): Add new Project_Data components. * prj.ads: New types and tables for non Ada languages. (Project_Data): New components Languages, Impl_Suffixes, First_Other_Source, Last_Other_Source, Imported_Directories_Switches, Include_Path, Include_Data_Set. * prj-env.ads, prj-env.adb: Minor reformatting * prj-nmsc.ads, prj-nmsc.adb: (Other_Languages_Check): New procedure Put subprograms in alphabetical order * prj-pars.adb (Parse): New Boolean parameter Process_Languages, defaulted to Ada; Call Prj.Proc.Process with Process_Languages and Opt.Follow_Links. * mlib-prj.adb: Back out modification in last version, as they are incorrect. (Build_Library.Check_Libs): Remove useless pragma Warnings (Off) * make.adb: (Mains): Moved to package Makeutl (Linker_Opts): Moved to package Makeutl (Is_External_Assignment): Moved to package Makeutl (Test_If_Relative_Path): Moved to package Makeutl (Gnatmake): Move sorting of linker options to function Makeutl.Linker_Options_Switches. * Makefile.in: Add makeutl.o to the object files for gnatmake * makeusg.adb: Add line for new switch -eL. * gnatls.adb (Image): New function. (Output_Unit): If in verbose mode, output the list of restrictions specified by pragmas Restrictions. * 5bml-tgt.adb, 5vml-tgt.adb (Build_Dynamic_Library): Do not use Text_IO. * a-calend.adb (Split): Shift the date by multiple of 56 years, if needed, to put it in the range 1970 (included) - 2026 (excluded). (Time_Of): Do not shift Unix_Min_Year (1970). Shift the date by multiple of 56 years, if needed, to put it in the range 1970 (included) - 2026 (excluded). * adaint.h, adaint.c (__gnat_set_executable): New function. 2004-04-19 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * trans.c (tree_transform, case N_Subprogram_Body): Temporarily push and pop GC context. (tree_transform, case N_Procedure_Call): Fix typo in setting TREE_TYPE. (tree_transform, case N_Label): Don't set LABEL_STMT_FIRST_IN_EH. (tree_transform, case N_Procedure_Call_Statement): Build a tree. (tree_transform, case N_Code_Statement): Likewise. (gnat_expand_stmt, case LABEL_STMT): Don't look at LABEL_STMT_FIRST_IN_EH. (gnat_expand_stmt, case ASM_STMT): New case. * utils2.c (build_unary_op): Properly set TREE_READONLY of UNCONSTRAINED_ARRAY_REF. * utils.c (poplevel): Temporarily push/pop GC context around inline function expansion. * decl.c (maybe_variable): Properly set TREE_READONLY of UNCONSTRAINED_ARRAY_REF. (make_packable_type): Only reference TYPE_IS_PADDING_P for RECORD_TYPE. * ada-tree.def: (ASM_STMT): New. * ada-tree.h: (LABEL_STMT_FIRST_IN_EH): Deleted. (ASM_STMT_TEMPLATE, ASM_STMT_OUTPUT, ASM_STMT_ORIG_OUT, ASM_STMT_INPUT): New. (ASM_STMT_CLOBBER): Likewise. 2004-04-19 Thomas Quinot <quinot@act-europe.fr> * a-except.adb, s-parint.ads, s-parint.adb, types.ads, types.h: Use general rcheck mechanism to raise Program_Error for E.4(18), instead of a custom raiser in System.Partition_Interface. Part of general cleanup work before PolyORB integration. * snames.ads, snames.adb: Add new runtime library entities and names for PolyORB DSA. * sem_dist.ads, sem_dist.adb (Get_Subprogram_Id): Move from sem_dist to exp_dist. (Build_Subprogram_Id): New subprogram provided by exp_dist Code reorganisation in preparation for PolyORB integration. * exp_dist.ads, exp_dist.adb (Get_Subprogram_Id): Move from sem_dist to exp_dist. (Build_Subprogram_Id): New subprogram provided by exp_dist * sem_ch4.adb (Analyze_One_Call): Fix error message for mismatch in actual parameter types for call to dereference of an access-to-subprogram type. * rtsfind.ads: Add new runtime library entities and names for PolyORB DSA. * gnatlink.adb (Value): Remove. Use Interfaces.C.Strings.Value instead, which has the same behaviour here since we never pass it a NULL pointer. * link.c (run_path_option, Solaris case): Use -Wl, as for other platforms. * Makefile.in: adjust object file lists for gnatlink and gnatmake to account for new dependency upon Interfaces.C.Strings + link.o For x86 FreeBSD, use 86numaux. * make.adb, gnatcmd.adb: Linker_Library_Path_Option has been moved up from Mlib.Tgt to Mlib. * mlib.ads, mlib.adb (Linker_Library_Path_Option): New subprogram, now target-independent. * mlib-tgt.ads, mlib-tgt.adb (Linker_Library_Path_Option): Remove target-specific versions of this subprogram, now implemented as a target-independent function in Mlib. * 5aml-tgt.adb, 5bml-tgt.adb, 5gml-tgt.adb, 5hml-tgt.adb, 5lml-tgt.adb, 5sml-tgt.adb, 5vml-tgt.adb, 5zml-tgt.adb, 5wml-tgt.adb (Linker_Library_Path_Option): Remove target-specific versions of this subprogram, now implemented as a target-independent function in Mlib. * atree.adb: (Allocate_Initialize_Node): New subprogram. Factors out node table slots allocation. (Fix_Parents): New subprogram. Encapsulate the pattern of fixing up parent pointers for syntactic children of a rewritten node. (New_Copy_Tree): Use New_Copy to copy non-entity nodes. (Rewrite): Use New_Copy when creating saved copy of original node. (Replace): Use Copy_Node to copy nodes. 2004-04-19 Javier Miranda <miranda@gnat.com> * sprint.adb (Sprint_Node_Actual): Give support to the new Access_To_Subprogram node available in Access_Definition nodes. In addition, give support to the AI-231 node fields: null-exclusion, all-present, constant-present. * sem_util.ads, sem_util.adb: (Has_Declarations): New subprogram * sinfo.ads, sinfo.adb: New field Access_To_Subprogram_Definition in Access_Definition nodes * sem_ch6.adb (Process_Formals): Move here the code that creates and decorates internal subtype declaration corresponding to the null-excluding formal. This code was previously in Set_Actual_Subtypes. In addition, carry out some code cleanup on this code. In case of access to protected subprogram call Replace_Anonymous_Access_To_Protected_Subprogram. (Set_Actual_Subtypes): Code cleanup. * sem_ch8.adb (Analyze_Object_Renaming): Remove un-necessary call to Find_Type in case of anonymous access renamings. Add warning in case of null-excluding attribute used in anonymous access renaming. * sem_ch3.ads (Replace_Anonymous_Access_To_Protected_Subprogram): New subprogram * sem_ch3.adb (Replace_Anonymous_Access_To_Protected_Subprogram): New subprogram. (Access_Definition): In case of anonymous access to subprograms call the corresponding semantic routine to decorate the node. (Access_Subprogram_Declaration): Addition of some comments indicating some code that probably should be added here. Detected by comparison with the access_definition subprogram. (Analyze_Component_Declaration): In case of access to protected subprogram call Replace_Anonymous_Access_To_Protected. (Array_Type_Declaration): In case of access to protected subprogram call Replace_Anonymous_Access_To_Protected_Subprogram. (Process_Discriminants): In case of access to protected subprogram call Replace_Anonymous_Access_To_Protected_Subprogram. * par.adb (P_Access_Definition): New formal that indicates if the null-exclusion part was present. (P_Access_Type_Definition): New formal that indicates if the caller has already parsed the null-excluding part. * par-ch3.adb (P_Subtype_Declaration): Code cleanup. (P_Identifier_Declarations): Code cleanup and give support to renamings of anonymous access to subprogram types. (P_Derived_Type_Def_Or_Private_Ext_Decl): Code cleanup. (P_Array_Type_Definition): Give support to AI-254. (P_Component_Items): Give support to AI-254. (P_Access_Definition): New formal that indicates if the header was already parsed by the caller. (P_Access_Type_Definition): New formal that indicates if the caller has already parsed the null-excluding part. * par-ch6.adb (P_Formal_Part): Add the null-excluding parameter to the call to P_Access_Definition. 2004-04-19 Geert Bosch <bosch@gnat.com> * checks.adb (Apply_Float_Conversion_Check): New procedure to implement the delicate semantics of floating-point to integer conversion. (Apply_Type_Conversion_Checks): Use Apply_Float_Conversion_Check. * eval_fat.adb (Machine_Mantissa): Moved to spec. (Machine_Radix): New function. * eval_fat.ads (Machine_Mantissa): Moved from body for use in conversion checks. (Machine_Radix): New function also for use in conversion checks. 2004-04-19 Ed Schonberg <schonberg@gnat.com> * par-prag.adb (Source_File_Name_Project): Fix typo in error message. * exp_ch9.adb (Expand_Access_Protected_Subprogram_Type): Call analyze to decorate the access-to-protected subprogram and the equivalent type. * checks.adb (Null_Exclusion_Static_Checks): Code cleanup. Give support to anonymous access to subprogram types. * exp_ch4.adb (Expand_N_In): Preserve Static flag before constant-folding, for legality checks in contexts that require an RM static expression. * exp_ch6.adb (Expand_N_Function_Call): If call may generate large temporary but stack checking is not enabled, increment serial number to so that symbol generation is consistent with and without stack checking. * exp_util.ads, exp_util.adb (May_Generate_Large_Temp): Predicate is independent on whether stack checking is enabled, caller must check the corresponding flag. * sem_ch3.adb (Constrain_Index): Index bounds given by attributes need range checks. (Build_Derived_Concurrent_Type): Inherit Is_Constrained flag from parent if it has discriminants. (Build_Derived_Private_Type): Constructed full view does not come from source. (Process_Discriminants): Default discriminants on a tagged type are legal if this is the internal completion of a private untagged derivation. * sem_ch6.adb (Set_Actual_Subtypes): The generated declaration needs no constraint checks, because it corresponds to an existing object. * sem_prag.adb (Process_Convention): Pragma applies only to subprograms in the same declarative part, i.e. the same unit, not the same scope. * sem_res.adb (Valid_Conversion): In an instance or inlined body, ignore type mismatch on a numeric conversion if expression comes from expansion. 2004-04-19 Sergey Rybin <rybin@act-europe.fr> * sem_elim.adb (Process_Eliminate_Pragma): Remove the processing for Homonym_Number parameter, add processing for Source_Location parameter corresponding. (Check_Eliminated): Remove the check for homonym numbers, add the check for source location traces. * sem_elim.ads (Process_Eliminate_Pragma): Replace Arg_Homonym_Number with Arg_Source_Location corresponding to the changes in the format of the pragma. * sem_prag.adb: (Analyze_Pragma): Changes in the processing of Eliminate pragma corresponding to the changes in the format of the pragma: Homonym_Number is replaced with Source_Location, two ways of distinguishing homonyms are mutially-exclusive. 2004-04-19 Joel Brobecker <brobecker@gnat.com> * get_targ.ads (Get_No_Dollar_In_Label): Remove. * exp_dbug.adb (Output_Homonym_Numbers_Suffix): Remove use of No_Dollar_In_Label, no longer necessary, as it is always True. (Strip_Suffixes): Likewise. 2004-04-19 Gary Dismukes <dismukes@gnat.com> * s-stalib.ads (type Exception_Code): Use Integer'Size for exponent of modulus for compatibility with size clause on targets with 16-bit Integer. * layout.adb (Discrimify): In the case of private types, set Vtyp to full type to fix type mismatches on calls to size functions for discriminant-dependent array components. 2004-04-19 Jerome Guitton <guitton@act-europe.fr> * Makefile.in (gnatlib-zcx): New target, for building a ZCX run-time lib. 2004-04-19 Pascal Obry <obry@gnat.com> * mdll-utl.adb (Locate): New version is idempotent. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80856 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/atree.adb')
-rw-r--r--gcc/ada/atree.adb288
1 files changed, 123 insertions, 165 deletions
diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb
index 49938b98ece..c03a1836194 100644
--- a/gcc/ada/atree.adb
+++ b/gcc/ada/atree.adb
@@ -380,11 +380,64 @@ package body Atree is
-- Local Subprograms --
-----------------------
- procedure Fix_Parent (Field : Union_Id; Old_Node, New_Node : Node_Id);
- -- This subprogram is used to fixup parent pointers that are rendered
- -- incorrect because of a node copy. Field is checked to see if it
- -- points to a node, list, or element list that has a parent that
- -- points to Old_Node. If so, the parent is reset to point to New_Node.
+ procedure Fix_Parents (Old_Node, New_Node : Node_Id);
+ -- Fixup parent pointers for the syntactic children of New_Node after
+ -- a copy, setting them to New_Node when they pointed to Old_Node.
+
+ function Allocate_Initialize_Node
+ (Src : Node_Id;
+ With_Extension : Boolean) return Node_Id;
+ -- Allocate a new node or node extension. If Src is not empty,
+ -- the information for the newly-allocated node is copied from it.
+
+ ------------------------------
+ -- Allocate_Initialize_Node --
+ ------------------------------
+
+ function Allocate_Initialize_Node
+ (Src : Node_Id;
+ With_Extension : Boolean) return Node_Id
+ is
+ New_Id : Node_Id := Src;
+ Nod : Node_Record := Default_Node;
+ Ext1 : Node_Record := Default_Node_Extension;
+ Ext2 : Node_Record := Default_Node_Extension;
+ Ext3 : Node_Record := Default_Node_Extension;
+ begin
+ if Present (Src) then
+ Nod := Nodes.Table (Src);
+
+ if Has_Extension (Src) then
+ Ext1 := Nodes.Table (Src + 1);
+ Ext2 := Nodes.Table (Src + 2);
+ Ext3 := Nodes.Table (Src + 3);
+ end if;
+ end if;
+
+ if not (Present (Src)
+ and then not Has_Extension (Src)
+ and then With_Extension
+ and then Src = Nodes.Last)
+ then
+ -- We are allocating a new node, or extending a node
+ -- other than Nodes.Last.
+
+ Nodes.Append (Nod);
+ New_Id := Nodes.Last;
+ Orig_Nodes.Append (New_Id);
+ Node_Count := Node_Count + 1;
+ end if;
+
+ if With_Extension then
+ Nodes.Append (Ext1);
+ Nodes.Append (Ext2);
+ Nodes.Append (Ext3);
+ end if;
+
+ Orig_Nodes.Set_Last (Nodes.Last);
+ Allocate_List_Tables (Nodes.Last);
+ return New_Id;
+ end Allocate_Initialize_Node;
--------------
-- Analyzed --
@@ -584,17 +637,7 @@ package body Atree is
return Copy_Entity (Source);
else
- Nodes.Increment_Last;
- New_Id := Nodes.Last;
- Nodes.Table (New_Id) := Nodes.Table (Source);
- Nodes.Table (New_Id).Link := Empty_List_Or_Node;
- Nodes.Table (New_Id).In_List := False;
- Nodes.Table (New_Id).Rewrite_Ins := False;
- Node_Count := Node_Count + 1;
-
- Orig_Nodes.Increment_Last;
- Allocate_List_Tables (Nodes.Last);
- Orig_Nodes.Table (New_Id) := New_Id;
+ New_Id := New_Copy (Source);
-- Recursively copy descendents
@@ -787,58 +830,53 @@ package body Atree is
pragma Inline (Debug_Extend_Node);
begin
- if Node /= Nodes.Last then
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Nodes.Table (Node);
- Result := Nodes.Last;
-
- Orig_Nodes.Increment_Last;
- Orig_Nodes.Table (Nodes.Last) := Nodes.Last;
+ pragma Assert (not (Has_Extension (Node)));
+ Result := Allocate_Initialize_Node (Node, With_Extension => True);
+ pragma Debug (Debug_Extend_Node);
+ return Result;
+ end Extend_Node;
- else
- Result := Node;
- end if;
+ -----------------
+ -- Fix_Parents --
+ -----------------
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
+ procedure Fix_Parents (Old_Node, New_Node : Node_Id) is
- Orig_Nodes.Set_Last (Nodes.Last);
- Allocate_List_Tables (Nodes.Last);
+ procedure Fix_Parent (Field : Union_Id; Old_Node, New_Node : Node_Id);
+ -- Fixup one parent pointer. Field is checked to see if it
+ -- points to a node, list, or element list that has a parent that
+ -- points to Old_Node. If so, the parent is reset to point to New_Node.
- pragma Debug (Debug_Extend_Node);
- return Result;
- end Extend_Node;
+ procedure Fix_Parent (Field : Union_Id; Old_Node, New_Node : Node_Id) is
+ begin
+ -- Fix parent of node that is referenced by Field. Note that we must
+ -- exclude the case where the node is a member of a list, because in
+ -- this case the parent is the parent of the list.
- ----------------
- -- Fix_Parent --
- ----------------
+ if Field in Node_Range
+ and then Present (Node_Id (Field))
+ and then not Nodes.Table (Node_Id (Field)).In_List
+ and then Parent (Node_Id (Field)) = Old_Node
+ then
+ Set_Parent (Node_Id (Field), New_Node);
- procedure Fix_Parent (Field : Union_Id; Old_Node, New_Node : Node_Id) is
- begin
- -- Fix parent of node that is referenced by Field. Note that we must
- -- exclude the case where the node is a member of a list, because in
- -- this case the parent is the parent of the list.
-
- if Field in Node_Range
- and then Present (Node_Id (Field))
- and then not Nodes.Table (Node_Id (Field)).In_List
- and then Parent (Node_Id (Field)) = Old_Node
- then
- Set_Parent (Node_Id (Field), New_Node);
+ -- Fix parent of list that is referenced by Field
- -- Fix parent of list that is referenced by Field
+ elsif Field in List_Range
+ and then Present (List_Id (Field))
+ and then Parent (List_Id (Field)) = Old_Node
+ then
+ Set_Parent (List_Id (Field), New_Node);
+ end if;
+ end Fix_Parent;
- elsif Field in List_Range
- and then Present (List_Id (Field))
- and then Parent (List_Id (Field)) = Old_Node
- then
- Set_Parent (List_Id (Field), New_Node);
- end if;
- end Fix_Parent;
+ begin
+ Fix_Parent (Field1 (New_Node), Old_Node, New_Node);
+ Fix_Parent (Field2 (New_Node), Old_Node, New_Node);
+ Fix_Parent (Field3 (New_Node), Old_Node, New_Node);
+ Fix_Parent (Field4 (New_Node), Old_Node, New_Node);
+ Fix_Parent (Field5 (New_Node), Old_Node, New_Node);
+ end Fix_Parents;
-----------------------------------
-- Get_Comes_From_Source_Default --
@@ -942,38 +980,23 @@ package body Atree is
--------------
function New_Copy (Source : Node_Id) return Node_Id is
- New_Id : Node_Id;
+ New_Id : Node_Id := Source;
begin
- if Source <= Empty_Or_Error then
- return Source;
+ if Source > Empty_Or_Error then
+
+ New_Id := Allocate_Initialize_Node (Source, Has_Extension (Source));
- else
- Nodes.Increment_Last;
- New_Id := Nodes.Last;
- Nodes.Table (New_Id) := Nodes.Table (Source);
Nodes.Table (New_Id).Link := Empty_List_Or_Node;
Nodes.Table (New_Id).In_List := False;
- Nodes.Table (New_Id).Rewrite_Ins := False;
- Orig_Nodes.Increment_Last;
- Orig_Nodes.Table (New_Id) := New_Id;
+ -- If the original is marked as a rewrite insertion, then unmark
+ -- the copy, since we inserted the original, not the copy.
- if Has_Extension (Source) then
- Nodes.Increment_Last;
- Nodes.Table (New_Id + 1) := Nodes.Table (Source + 1);
- Nodes.Increment_Last;
- Nodes.Table (New_Id + 2) := Nodes.Table (Source + 2);
- Nodes.Increment_Last;
- Nodes.Table (New_Id + 3) := Nodes.Table (Source + 3);
-
- Orig_Nodes.Set_Last (Nodes.Last);
- end if;
-
- Allocate_List_Tables (Nodes.Last);
- Node_Count := Node_Count + 1;
- return New_Id;
+ Nodes.Table (New_Id).Rewrite_Ins := False;
end if;
+
+ return New_Id;
end New_Copy;
-------------------
@@ -1353,17 +1376,7 @@ package body Atree is
return Assoc (Old_Node);
else
- Nodes.Increment_Last;
- New_Node := Nodes.Last;
- Nodes.Table (New_Node) := Nodes.Table (Old_Node);
- Nodes.Table (New_Node).Link := Empty_List_Or_Node;
- Nodes.Table (New_Node).In_List := False;
- Node_Count := Node_Count + 1;
-
- Orig_Nodes.Increment_Last;
- Allocate_List_Tables (Nodes.Last);
-
- Orig_Nodes.Table (Nodes.Last) := Nodes.Last;
+ New_Node := New_Copy (Old_Node);
-- If the node we are copying is the associated node of a
-- previously copied Itype, then adjust the associated node
@@ -1416,10 +1429,6 @@ package body Atree is
Set_Field5
(New_Node, Copy_Field_With_Replacement (Field5 (New_Node)));
- -- If the original is marked as a rewrite insertion, then unmark
- -- the copy, since we inserted the original, not the copy.
-
- Nodes.Table (New_Node).Rewrite_Ins := False;
-- Adjust Sloc of new node if necessary
@@ -1838,7 +1847,7 @@ package body Atree is
begin
if Debug_Flag_N then
Write_Str ("Allocate entity, Id = ");
- Write_Int (Int (Nodes.Last));
+ Write_Int (Int (Ent));
Write_Str (" ");
Write_Location (New_Sloc);
Write_Str (" ");
@@ -1852,8 +1861,7 @@ package body Atree is
begin
pragma Assert (New_Node_Kind in N_Entity);
- Nodes.Increment_Last;
- Ent := Nodes.Last;
+ Ent := Allocate_Initialize_Node (Empty, With_Extension => True);
-- If this is a node with a real location and we are generating
-- source nodes, then reset Current_Error_Node. This is useful
@@ -1863,26 +1871,10 @@ package body Atree is
Current_Error_Node := Ent;
end if;
- Nodes.Table (Nodes.Last) := Default_Node;
- Nodes.Table (Nodes.Last).Nkind := New_Node_Kind;
- Nodes.Table (Nodes.Last).Sloc := New_Sloc;
+ Nodes.Table (Ent).Nkind := New_Node_Kind;
+ Nodes.Table (Ent).Sloc := New_Sloc;
pragma Debug (New_Entity_Debugging_Output);
- Orig_Nodes.Increment_Last;
- Orig_Nodes.Table (Nodes.Last) := Nodes.Last;
-
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
-
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
-
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node_Extension;
-
- Orig_Nodes.Set_Last (Nodes.Last);
- Allocate_List_Tables (Nodes.Last);
- Node_Count := Node_Count + 1;
return Ent;
end New_Entity;
@@ -1908,7 +1900,7 @@ package body Atree is
begin
if Debug_Flag_N then
Write_Str ("Allocate node, Id = ");
- Write_Int (Int (Nodes.Last));
+ Write_Int (Int (Nod));
Write_Str (" ");
Write_Location (New_Sloc);
Write_Str (" ");
@@ -1921,12 +1913,10 @@ package body Atree is
begin
pragma Assert (New_Node_Kind not in N_Entity);
- Nodes.Increment_Last;
- Nodes.Table (Nodes.Last) := Default_Node;
- Nodes.Table (Nodes.Last).Nkind := New_Node_Kind;
- Nodes.Table (Nodes.Last).Sloc := New_Sloc;
+ Nod := Allocate_Initialize_Node (Empty, With_Extension => False);
+ Nodes.Table (Nod).Nkind := New_Node_Kind;
+ Nodes.Table (Nod).Sloc := New_Sloc;
pragma Debug (New_Node_Debugging_Output);
- Nod := Nodes.Last;
-- If this is a node with a real location and we are generating
-- source nodes, then reset Current_Error_Node. This is useful
@@ -1936,10 +1926,6 @@ package body Atree is
Current_Error_Node := Nod;
end if;
- Node_Count := Node_Count + 1;
- Orig_Nodes.Increment_Last;
- Allocate_List_Tables (Nodes.Last);
- Orig_Nodes.Table (Nodes.Last) := Nodes.Last;
return Nod;
end New_Node;
@@ -2054,11 +2040,7 @@ package body Atree is
end if;
New_Node := New_Copy (Source);
- Fix_Parent (Field1 (Source), Source, New_Node);
- Fix_Parent (Field2 (Source), Source, New_Node);
- Fix_Parent (Field3 (Source), Source, New_Node);
- Fix_Parent (Field4 (Source), Source, New_Node);
- Fix_Parent (Field5 (Source), Source, New_Node);
+ Fix_Parents (Source, New_Node);
-- We now set the parent of the new node to be the same as the
-- parent of the source. Almost always this parent will be
@@ -2085,8 +2067,6 @@ package body Atree is
-------------
procedure Replace (Old_Node, New_Node : Node_Id) is
- Old_Link : constant Union_Id := Nodes.Table (Old_Node).Link;
- Old_InL : constant Boolean := Nodes.Table (Old_Node).In_List;
Old_Post : constant Boolean := Nodes.Table (Old_Node).Error_Posted;
Old_CFS : constant Boolean := Nodes.Table (Old_Node).Comes_From_Source;
@@ -2098,19 +2078,13 @@ package body Atree is
-- Do copy, preserving link and in list status and comes from source
- Nodes.Table (Old_Node) := Nodes.Table (New_Node);
- Nodes.Table (Old_Node).Link := Old_Link;
- Nodes.Table (Old_Node).In_List := Old_InL;
+ Copy_Node (Source => New_Node, Destination => Old_Node);
Nodes.Table (Old_Node).Comes_From_Source := Old_CFS;
Nodes.Table (Old_Node).Error_Posted := Old_Post;
-- Fix parents of substituted node, since it has changed identity
- Fix_Parent (Field1 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field2 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field3 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field4 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field5 (Old_Node), New_Node, Old_Node);
+ Fix_Parents (New_Node, Old_Node);
-- Since we are doing a replace, we assume that the original node
-- is intended to become the new replaced node. The call would be
@@ -2129,10 +2103,8 @@ package body Atree is
procedure Rewrite (Old_Node, New_Node : Node_Id) is
- Old_Link : constant Union_Id := Nodes.Table (Old_Node).Link;
- Old_In_List : constant Boolean := Nodes.Table (Old_Node).In_List;
Old_Error_P : constant Boolean := Nodes.Table (Old_Node).Error_Posted;
- -- These three fields are always preserved in the new node
+ -- This fields is always preserved in the new node
Old_Paren_Count : Paren_Count_Type;
Old_Must_Not_Freeze : Boolean;
@@ -2165,24 +2137,14 @@ package body Atree is
-- that does not reference the Old_Node.
if Orig_Nodes.Table (Old_Node) = Old_Node then
- Nodes.Increment_Last;
- Sav_Node := Nodes.Last;
- Nodes.Table (Sav_Node) := Nodes.Table (Old_Node);
- Nodes.Table (Sav_Node).In_List := False;
- Nodes.Table (Sav_Node).Link := Union_Id (Parent (Old_Node));
-
- Orig_Nodes.Increment_Last;
- Allocate_List_Tables (Nodes.Last);
-
+ Sav_Node := New_Copy (Old_Node);
Orig_Nodes.Table (Sav_Node) := Sav_Node;
Orig_Nodes.Table (Old_Node) := Sav_Node;
end if;
-- Copy substitute node into place, preserving old fields as required
- Nodes.Table (Old_Node) := Nodes.Table (New_Node);
- Nodes.Table (Old_Node).Link := Old_Link;
- Nodes.Table (Old_Node).In_List := Old_In_List;
+ Copy_Node (Source => New_Node, Destination => Old_Node);
Nodes.Table (Old_Node).Error_Posted := Old_Error_P;
if Nkind (New_Node) in N_Subexpr then
@@ -2190,11 +2152,7 @@ package body Atree is
Set_Must_Not_Freeze (Old_Node, Old_Must_Not_Freeze);
end if;
- Fix_Parent (Field1 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field2 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field3 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field4 (Old_Node), New_Node, Old_Node);
- Fix_Parent (Field5 (Old_Node), New_Node, Old_Node);
+ Fix_Parents (New_Node, Old_Node);
end Rewrite;
------------------