-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
(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;
- Ext4 : Node_Record := Default_Node_Extension;
+ New_Id : Node_Id;
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);
- Ext4 := Nodes.Table (Src + 4);
- end if;
- end if;
-
- if not (Present (Src)
- and then not Has_Extension (Src)
- and then With_Extension
- and then Src = Nodes.Last)
+ if Present (Src)
+ and then not Has_Extension (Src)
+ and then With_Extension
+ and then Src = Nodes.Last
then
+ New_Id := Src;
+ else
-- We are allocating a new node, or extending a node
-- other than Nodes.Last.
- Nodes.Append (Nod);
+ if Present (Src) then
+ Nodes.Append (Nodes.Table (Src));
+ else
+ Nodes.Append (Default_Node);
+ end if;
+
New_Id := Nodes.Last;
Orig_Nodes.Append (New_Id);
Node_Count := Node_Count + 1;
-- Set extension nodes if required
if With_Extension then
- Nodes.Append (Ext1);
- Nodes.Append (Ext2);
- Nodes.Append (Ext3);
- Nodes.Append (Ext4);
+ if Present (Src) and then Has_Extension (Src) then
+ for J in 1 .. 4 loop
+ Nodes.Append (Nodes.Table (Src + Node_Id (J)));
+ end loop;
+ else
+ for J in 1 .. 4 loop
+ Nodes.Append (Default_Node_Extension);
+ end loop;
+ end if;
end if;
Orig_Nodes.Set_Last (Nodes.Last);
end Copy_Node;
------------------------
+ -- Copy_Separate_List --
+ ------------------------
+
+ function Copy_Separate_List (Source : List_Id) return List_Id is
+ Result : constant List_Id := New_List;
+ Nod : Node_Id;
+
+ begin
+ Nod := First (Source);
+ while Present (Nod) loop
+ Append (Copy_Separate_Tree (Nod), Result);
+ Next (Nod);
+ end loop;
+
+ return Result;
+ end Copy_Separate_List;
+
+ ------------------------
-- Copy_Separate_Tree --
------------------------
Set_Field4 (New_Id, Possible_Copy (Field4 (New_Id)));
Set_Field5 (New_Id, Possible_Copy (Field5 (New_Id)));
- -- Set Entity field to Empty
- -- Why is this done??? and why is it always right to do it???
+ -- Set Entity field to Empty to ensure that no entity references
+ -- are shared between the two, if the source is already analyzed.
if Nkind (New_Id) in N_Has_Entity
or else Nkind (New_Id) = N_Freeze_Entity
Nodes.Table (New_Id).Link := Empty_List_Or_Node;
Nodes.Table (New_Id).In_List := False;
- -- If the original is marked as a rewrite insertion, then unmark
- -- the copy, since we inserted the original, not the copy.
+ -- If the original is marked as a rewrite insertion, then unmark the
+ -- copy, since we inserted the original, not the copy.
Nodes.Table (New_Id).Rewrite_Ins := False;
pragma Debug (New_Node_Debugging_Output (New_Id));
+ -- Clear Is_Overloaded since we cannot have semantic interpretations
+ -- of this new node.
+
+ if Nkind (Source) in N_Subexpr then
+ Set_Is_Overloaded (New_Id, False);
+ end if;
+
-- Always clear Has_Aspects, the caller must take care of copying
-- aspects if this is required for the particular situation.
Nodes.Table (N).Has_Aspects := Val;
end Set_Has_Aspects;
+ -----------------------
+ -- Set_Original_Node --
+ -----------------------
+
+ procedure Set_Original_Node (N : Node_Id; Val : Node_Id) is
+ begin
+ Orig_Nodes.Table (N) := Val;
+ end Set_Original_Node;
+
---------------------
-- Set_Paren_Count --
---------------------
end if;
end Elist4;
+ function Elist5 (N : Node_Id) return Elist_Id is
+ pragma Assert (N <= Nodes.Last);
+ Value : constant Union_Id := Nodes.Table (N).Field5;
+ begin
+ if Value = 0 then
+ return No_Elist;
+ else
+ return Elist_Id (Value);
+ end if;
+ end Elist5;
+
function Elist8 (N : Node_Id) return Elist_Id is
pragma Assert (Nkind (N) in N_Entity);
Value : constant Union_Id := Nodes.Table (N + 1).Field8;
end if;
end Elist23;
+ function Elist24 (N : Node_Id) return Elist_Id is
+ pragma Assert (Nkind (N) in N_Entity);
+ Value : constant Union_Id := Nodes.Table (N + 4).Field6;
+ begin
+ if Value = 0 then
+ return No_Elist;
+ else
+ return Elist_Id (Value);
+ end if;
+ end Elist24;
+
function Elist25 (N : Node_Id) return Elist_Id is
pragma Assert (Nkind (N) in N_Entity);
Value : constant Union_Id := Nodes.Table (N + 4).Field7;
Nodes.Table (N).Field4 := Union_Id (Val);
end Set_Elist4;
+ procedure Set_Elist5 (N : Node_Id; Val : Elist_Id) is
+ begin
+ Nodes.Table (N).Field5 := Union_Id (Val);
+ end Set_Elist5;
+
procedure Set_Elist8 (N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (Nkind (N) in N_Entity);
Nodes.Table (N + 3).Field10 := Union_Id (Val);
end Set_Elist23;
+ procedure Set_Elist24 (N : Node_Id; Val : Elist_Id) is
+ begin
+ pragma Assert (Nkind (N) in N_Entity);
+ Nodes.Table (N + 4).Field6 := Union_Id (Val);
+ end Set_Elist24;
+
procedure Set_Elist25 (N : Node_Id; Val : Elist_Id) is
begin
pragma Assert (Nkind (N) in N_Entity);