summaryrefslogtreecommitdiff
path: root/gcc/ada/a-coorse.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-29 13:38:55 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-29 13:38:55 +0000
commitb818431600fef3f751f6713c943b47d88d2effd2 (patch)
treec5c5a59fe92af48a72ef4d23e699ecfeee3903ef /gcc/ada/a-coorse.adb
parent15f3d9888ce2a021c4b42032a3a051c07b5bdcad (diff)
downloadgcc-b818431600fef3f751f6713c943b47d88d2effd2.tar.gz
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb: Remove Build_Explicit_Dereference. * sem_util.adb, sem_util.ads (Build_Explicit_Dereference): Moved here from sem_res.adb, used in analysis of additional constructs. (Is_Iterator, Is_Reversible_Iterator): New predicates for Ada2012 expansion of iterators. (Is_Object_Reference): Recognize variables rewritten as explicit dereferences in Ada2012. * snames.ads-tmpl: Add Has_Element, Forward_Iterator, Reversible_Iterator names, for expansion of Ada2012 iterators. * aspects.ads, aspects.adb (Find_Aspect): Utility. * a-cdlili.ads, a-cdlili.adb: Add new iterator machinery to doubly linked list container. * a-coinve.ads, a-coinve.adb: Ditto for indefinite vector containers. * a-coorse.ads, a-coorse.adb: Ditto for ordered sets. 2011-08-29 Ed Schonberg <schonberg@adacore.com> * a-cohama.adb, a-cohama.ads: Add iterator primitives to hashed map containers. 2011-08-29 Vincent Celier <celier@adacore.com> * make.adb (Gnatmake): Get the maximum number of simultaneous compilation processes after the Builder switches has been scanned, as there may include -jnn. 2011-08-29 Matthew Heaney <heaney@adacore.com> * a-chtgbo.adb (Generic_Equal): Use correct overloading of Next. 2011-08-29 Tristan Gingold <gingold@adacore.com> * gnatcmd.adb (GNATCmd): On OpenVMS, truncate the length of GNAT_DRIVER_COMMAND_LINE to 255. 2011-08-29 Pascal Obry <obry@adacore.com> * freeze.adb, sem_ch8.adb, a-convec.adb, a-convec.ads: Minor reformatting and style fix (class attribute casing). 2011-08-29 Yannick Moy <moy@adacore.com> * exp_ch11.adb: Yet another case where expansion should be common between CodePeer and Alfa. 2011-08-29 Yannick Moy <moy@adacore.com> * exp_ch9.adb: Partial revert of previous change for Alfa mode. 2011-08-29 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (Matches_Limited_With_View): The limited views of an incomplete type and its completion match. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178228 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-coorse.adb')
-rw-r--r--gcc/ada/a-coorse.adb121
1 files changed, 121 insertions, 0 deletions
diff --git a/gcc/ada/a-coorse.adb b/gcc/ada/a-coorse.adb
index d4e73029b2a..2224fdf317e 100644
--- a/gcc/ada/a-coorse.adb
+++ b/gcc/ada/a-coorse.adb
@@ -40,6 +40,19 @@ pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
package body Ada.Containers.Ordered_Sets is
+ type Iterator is new
+ Ordered_Set_Iterator_Interfaces.Reversible_Iterator with record
+ Container : access constant Set;
+ Node : Node_Access;
+ end record;
+
+ overriding function First (Object : Iterator) return Cursor;
+ overriding function Last (Object : Iterator) return Cursor;
+ overriding function Next (Object : Iterator; Position : Cursor)
+ return Cursor;
+ overriding function Previous (Object : Iterator; Position : Cursor)
+ return Cursor;
+
------------------------------
-- Access to Fields of Node --
------------------------------
@@ -512,6 +525,12 @@ package body Ada.Containers.Ordered_Sets is
return Cursor'(Container'Unrestricted_Access, Container.Tree.First);
end First;
+ function First (Object : Iterator) return Cursor is
+ begin
+ return Cursor'(
+ Object.Container.all'Unrestricted_Access, Object.Container.Tree.First);
+ end First;
+
-------------------
-- First_Element --
-------------------
@@ -1115,6 +1134,23 @@ package body Ada.Containers.Ordered_Sets is
B := B - 1;
end Iterate;
+ function Iterate (Container : Set)
+ return Ordered_Set_Iterator_Interfaces.Reversible_Iterator'class
+ is
+ It : constant Iterator :=
+ (Container'Unchecked_Access, Container.Tree.First);
+ begin
+ return It;
+ end Iterate;
+
+ function Iterate (Container : Set; Start : Cursor)
+ return Ordered_Set_Iterator_Interfaces.Reversible_Iterator'class
+ is
+ It : constant Iterator := (Container'Unchecked_Access, Start.Node);
+ begin
+ return It;
+ end Iterate;
+
----------
-- Last --
----------
@@ -1128,6 +1164,16 @@ package body Ada.Containers.Ordered_Sets is
return Cursor'(Container'Unrestricted_Access, Container.Tree.Last);
end Last;
+ function Last (Object : Iterator) return Cursor is
+ begin
+ if Object.Container.Tree.Last = null then
+ return No_Element;
+ end if;
+
+ return Cursor'(
+ Object.Container.all'Unrestricted_Access, Object.Container.Tree.Last);
+ end Last;
+
------------------
-- Last_Element --
------------------
@@ -1202,6 +1248,14 @@ package body Ada.Containers.Ordered_Sets is
Position := Next (Position);
end Next;
+ function Next (Object : Iterator; Position : Cursor)
+ return Cursor
+ is
+ pragma Unreferenced (Object);
+ begin
+ return Next (Position);
+ end Next;
+
-------------
-- Overlap --
-------------
@@ -1251,6 +1305,13 @@ package body Ada.Containers.Ordered_Sets is
Position := Previous (Position);
end Previous;
+ overriding function Previous (Object : Iterator; Position : Cursor)
+ return Cursor
+ is
+ pragma Unreferenced (Object);
+ begin
+ return Previous (Position);
+ end Previous;
-------------------
-- Query_Element --
-------------------
@@ -1339,6 +1400,50 @@ package body Ada.Containers.Ordered_Sets is
raise Program_Error with "attempt to stream set cursor";
end Read;
+ procedure Read
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : out Reference_Type)
+ is
+ begin
+ raise Program_Error with "attempt to stream reference";
+ end Read;
+
+ procedure Read
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : out Constant_Reference_Type)
+ is
+ begin
+ raise Program_Error with "attempt to stream reference";
+ end Read;
+
+ ---------------
+ -- Reference --
+ ---------------
+
+ function Constant_Reference (Container : Set; Position : Cursor)
+ return Constant_Reference_Type
+ is
+ pragma Unreferenced (Container);
+ begin
+ if Position.Container = null then
+ raise Constraint_Error with "Position cursor has no element";
+ end if;
+
+ return (Element => Position.Node.Element'Access);
+ end Constant_Reference;
+
+ function Reference (Container : Set; Position : Cursor)
+ return Reference_Type
+ is
+ pragma Unreferenced (Container);
+ begin
+ if Position.Container = null then
+ raise Constraint_Error with "Position cursor has no element";
+ end if;
+
+ return (Element => Position.Node.Element'Access);
+ end Reference;
+
-------------
-- Replace --
-------------
@@ -1654,4 +1759,20 @@ package body Ada.Containers.Ordered_Sets is
raise Program_Error with "attempt to stream set cursor";
end Write;
+ procedure Write
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : Reference_Type)
+ is
+ begin
+ raise Program_Error with "attempt to stream reference";
+ end Write;
+
+ procedure Write
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : Constant_Reference_Type)
+ is
+ begin
+ raise Program_Error with "attempt to stream reference";
+ end Write;
+
end Ada.Containers.Ordered_Sets;