diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 14:07:24 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-29 14:07:24 +0000 |
commit | a17a5f8322a746a3b2028251e83ee178bf58eca5 (patch) | |
tree | ad2c626c4e1e4b8d2efe3dd7f4aedb0ad37a2408 /gcc/ada/a-cidlli.ads | |
parent | a053db0dacfa6b670bc8f8e3f9dff1f24159db77 (diff) | |
download | gcc-a17a5f8322a746a3b2028251e83ee178bf58eca5.tar.gz |
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* exp_ch5.adb (Expand_Iterator_Loop): Handle properly a loop over a
container of a derived type.
2011-08-29 Hristian Kirtchev <kirtchev@adacore.com>
* impunit.adb, s-stposu.adb, s-stposu.ads, exp_ch4.adb, s-finmas.adb,
s-finmas.ads: Revert previous change.
2011-08-29 Ed Schonberg <schonberg@adacore.com>
* a-cidlli.adb, a-cidlli.ads, a-cihama.adb, a-cihama.ads,
a-ciorse.adb, a-ciorse.ads: Add iterator machinery to containers.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178237 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cidlli.ads')
-rw-r--r-- | gcc/ada/a-cidlli.ads | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/gcc/ada/a-cidlli.ads b/gcc/ada/a-cidlli.ads index 7d572a8cc93..a6fd7106321 100644 --- a/gcc/ada/a-cidlli.ads +++ b/gcc/ada/a-cidlli.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -31,8 +31,9 @@ -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ +with Ada.Iterator_Interfaces; +with Ada.Streams; use Ada.Streams; private with Ada.Finalization; -private with Ada.Streams; generic type Element_Type (<>) is private; @@ -44,7 +45,13 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is pragma Preelaborate; pragma Remote_Types; - type List is tagged private; + type List is tagged private + with + Constant_Indexing => Constant_Reference, + Variable_Indexing => Reference, + Default_Iterator => Iterate, + Iterator_Element => Element_Type; + pragma Preelaborable_Initialization (List); type Cursor is private; @@ -53,6 +60,10 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is Empty_List : constant List; No_Element : constant Cursor; + function Has_Element (Position : Cursor) return Boolean; + + package List_Iterator_Interfaces is new + Ada.Iterator_Interfaces (Cursor, Has_Element); function "=" (Left, Right : List) return Boolean; @@ -170,8 +181,6 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is (Container : List; Item : Element_Type) return Boolean; - function Has_Element (Position : Cursor) return Boolean; - procedure Iterate (Container : List; Process : not null access procedure (Position : Cursor)); @@ -180,6 +189,54 @@ package Ada.Containers.Indefinite_Doubly_Linked_Lists is (Container : List; Process : not null access procedure (Position : Cursor)); + function Iterate (Container : List) + return List_Iterator_Interfaces.Reversible_Iterator'class; + + function Iterate (Container : List; Start : Cursor) + return List_Iterator_Interfaces.Reversible_Iterator'class; + + type Constant_Reference_Type + (Element : not null access constant Element_Type) is private + with + Implicit_Dereference => Element; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Constant_Reference_Type); + + for Constant_Reference_Type'Write use Write; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Constant_Reference_Type); + + for Constant_Reference_Type'Read use Read; + + type Reference_Type (Element : not null access Element_Type) is + private + with + Implicit_Dereference => Element; + + procedure Write + (Stream : not null access Root_Stream_Type'Class; + Item : Reference_Type); + + for Reference_Type'Write use Write; + + procedure Read + (Stream : not null access Root_Stream_Type'Class; + Item : out Reference_Type); + + for Reference_Type'Read use Read; + + function Constant_Reference + (Container : List; Position : Cursor) -- SHOULD BE ALIASED + return Constant_Reference_Type; + + function Reference + (Container : List; Position : Cursor) -- SHOULD BE ALIASED + return Reference_Type; + generic with function "<" (Left, Right : Element_Type) return Boolean is <>; package Generic_Sorting is @@ -220,12 +277,16 @@ private Lock : Natural := 0; end record; + type Constant_Reference_Type + (Element : not null access constant Element_Type) is null record; + + type Reference_Type + (Element : not null access Element_Type) is null record; + overriding procedure Adjust (Container : in out List); overriding procedure Finalize (Container : in out List) renames Clear; - use Ada.Streams; - procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out List); |