From 706a4067b883765331b693caded5f08a43eb2645 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 27 Sep 2011 11:58:53 +0200 Subject: [PATCH] [multiple changes] 2011-09-27 Robert Dewar * exp_ch9.adb: Minor comment fixes. 2011-09-27 Ed Schonberg * a-comutr.adb, a-comutr.ads: Add children iterators on multiway trees. From-SVN: r179257 --- gcc/ada/ChangeLog | 9 ++++++ gcc/ada/a-comutr.adb | 77 ++++++++++++++++++++++++++++++++++++++++++-- gcc/ada/a-comutr.ads | 5 +++ gcc/ada/exp_ch9.adb | 3 +- 4 files changed, 90 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d1fc22a42af..e44f19a9aac 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2011-09-27 Robert Dewar + + * exp_ch9.adb: Minor comment fixes. + +2011-09-27 Ed Schonberg + + * a-comutr.adb, a-comutr.ads: Add children iterators on multiway + trees. + 2011-09-27 Eric Botcazou * checks.adb (Apply_Scalar_Range_Check): Use Designated_Type diff --git a/gcc/ada/a-comutr.adb b/gcc/ada/a-comutr.adb index e3e25573e53..0fcb3d6d51c 100644 --- a/gcc/ada/a-comutr.adb +++ b/gcc/ada/a-comutr.adb @@ -40,11 +40,28 @@ package body Ada.Containers.Multiway_Trees is From_Root : Boolean; end record; + type Child_Iterator is new Tree_Iterator_Interfaces.Reversible_Iterator with + record + Container : Tree_Access; + Position : Cursor; + end record; + overriding function First (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; + overriding function First (Object : Child_Iterator) return Cursor; + overriding function Next + (Object : Child_Iterator; + Position : Cursor) return Cursor; + + overriding function Previous + (Object : Child_Iterator; + Position : Cursor) return Cursor; + + overriding function Last (Object : Child_Iterator) return Cursor; + ----------------------- -- Local Subprograms -- ----------------------- @@ -912,6 +929,11 @@ package body Ada.Containers.Multiway_Trees is return Object.Position; end First; + function First (Object : Child_Iterator) return Cursor is + begin + return (Object.Container, Object.Position.Node.Children.First); + end First; + ----------------- -- First_Child -- ----------------- @@ -1412,6 +1434,16 @@ package body Ada.Containers.Multiway_Trees is end loop; end Iterate_Children; + function Iterate_Children + (Container : Tree; + Parent : Cursor) + return Tree_Iterator_Interfaces.Reversible_Iterator'Class + is + pragma Unreferenced (Container); + begin + return Child_Iterator'(Parent.Container, Parent); + end Iterate_Children; + --------------------- -- Iterate_Subtree -- --------------------- @@ -1468,13 +1500,21 @@ package body Ada.Containers.Multiway_Trees is Iterate_Children (Container, Subtree, Process); end Iterate_Subtree; + ---------- + -- Last -- + ---------- + + overriding function Last (Object : Child_Iterator) return Cursor is + begin + return (Object.Container, Object.Position.Node.Children.Last); + end Last; + ---------------- -- Last_Child -- ---------------- function Last_Child (Parent : Cursor) return Cursor is Node : Tree_Node_Access; - begin if Parent = No_Element then raise Constraint_Error with "Parent cursor has no element"; @@ -1588,13 +1628,27 @@ package body Ada.Containers.Multiway_Trees is end if; else - -- If an internal node, return its first child. return (Object.Container, N.Children.First); end if; end Next; + function Next + (Object : Child_Iterator; + Position : Cursor) return Cursor + is + C : constant Tree_Node_Access := Position.Node.Next; + + begin + if C = null then + return No_Element; + + else + return (Object.Container, C); + end if; + end Next; + ------------------ -- Next_Sibling -- ------------------ @@ -1714,6 +1768,25 @@ package body Ada.Containers.Multiway_Trees is Container.Count := Container.Count + Count; end Prepend_Child; + -------------- + -- Previous -- + -------------- + + overriding function Previous + (Object : Child_Iterator; + Position : Cursor) return Cursor + is + C : constant Tree_Node_Access := Position.Node.Prev; + + begin + if C = null then + return No_Element; + + else + return (Object.Container, C); + end if; + end Previous; + ---------------------- -- Previous_Sibling -- ---------------------- diff --git a/gcc/ada/a-comutr.ads b/gcc/ada/a-comutr.ads index 02a286d3410..94cacfc9f1b 100644 --- a/gcc/ada/a-comutr.ads +++ b/gcc/ada/a-comutr.ads @@ -180,6 +180,11 @@ package Ada.Containers.Multiway_Trees is function Iterate_Subtree (Position : Cursor) return Tree_Iterator_Interfaces.Forward_Iterator'Class; + function Iterate_Children + (Container : Tree; + Parent : Cursor) + return Tree_Iterator_Interfaces.Reversible_Iterator'Class; + function Child_Count (Parent : Cursor) return Count_Type; function Child_Depth (Parent, Child : Cursor) return Count_Type; diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index c3c97ad9e52..fc70238aedb 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -71,8 +71,7 @@ package body Exp_Ch9 is -- types with defaulted discriminant of an integer type, when the bound -- of some entry family depends on a discriminant. The limitation to -- entry families of 128K should be reasonable in all cases, and is a - -- documented implementation restriction. It will be lifted when protected - -- entry families are re-implemented as a single ordered queue. + -- documented implementation restriction. Entry_Family_Bound : constant Int := 2**16; -- 2.30.2