summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cdlili.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-29 15:38:55 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-29 15:38:55 +0200
commit3e24afaa6a24e1955ad0f3cd1ca00b6edec67a67 (patch)
treec5c5a59fe92af48a72ef4d23e699ecfeee3903ef /gcc/ada/a-cdlili.adb
parent3ddd922ebf36fb7d4701e8f55e633d27fca54296 (diff)
downloadgcc-3e24afaa6a24e1955ad0f3cd1ca00b6edec67a67.tar.gz
[multiple changes]
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. From-SVN: r178228
Diffstat (limited to 'gcc/ada/a-cdlili.adb')
-rw-r--r--gcc/ada/a-cdlili.adb122
1 files changed, 121 insertions, 1 deletions
diff --git a/gcc/ada/a-cdlili.adb b/gcc/ada/a-cdlili.adb
index cbac8fd4a1d..8a3b98358dd 100644
--- a/gcc/ada/a-cdlili.adb
+++ b/gcc/ada/a-cdlili.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2004-2010, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-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- --
@@ -32,6 +32,18 @@ with System; use type System.Address;
with Ada.Unchecked_Deallocation;
package body Ada.Containers.Doubly_Linked_Lists is
+ type Iterator is new
+ List_Iterator_Interfaces.Reversible_Iterator with record
+ Container : List_Access;
+ 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;
-----------------------
-- Local Subprograms --
@@ -395,6 +407,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
return Cursor'(Container'Unchecked_Access, Container.First);
end First;
+ function First (Object : Iterator) return Cursor is
+ C : constant Cursor := (Object.Container, Object.Container.First);
+ begin
+ return C;
+ end First;
+
-------------------
-- First_Element --
-------------------
@@ -794,6 +812,22 @@ package body Ada.Containers.Doubly_Linked_Lists is
B := B - 1;
end Iterate;
+ function Iterate (Container : List)
+ return List_Iterator_Interfaces.Reversible_Iterator'class
+ is
+ It : constant Iterator := (Container'Unchecked_Access, Container.First);
+ begin
+ return It;
+ end Iterate;
+
+ function Iterate (Container : List; Start : Cursor)
+ return List_Iterator_Interfaces.Reversible_Iterator'class
+ is
+ It : constant Iterator := (Container'Unchecked_Access, Start.Node);
+ begin
+ return It;
+ end Iterate;
+
----------
-- Last --
----------
@@ -807,6 +841,12 @@ package body Ada.Containers.Doubly_Linked_Lists is
return Cursor'(Container'Unchecked_Access, Container.Last);
end Last;
+ function Last (Object : Iterator) return Cursor is
+ C : constant Cursor := (Object.Container, Object.Container.Last);
+ begin
+ return C;
+ end Last;
+
------------------
-- Last_Element --
------------------
@@ -887,6 +927,16 @@ package body Ada.Containers.Doubly_Linked_Lists is
end;
end Next;
+ function Next (Object : Iterator; Position : Cursor) return Cursor is
+ begin
+ if Position.Node = Object.Container.Last then
+ return No_Element;
+
+ else
+ return (Object.Container, Position.Node.Next);
+ end if;
+ end Next;
+
-------------
-- Prepend --
-------------
@@ -928,6 +978,16 @@ package body Ada.Containers.Doubly_Linked_Lists is
end;
end Previous;
+ function Previous (Object : Iterator; Position : Cursor) return Cursor is
+ begin
+ if Position.Node = Position.Container.First then
+ return No_Element;
+
+ else
+ return (Object.Container, Position.Node.Prev);
+ end if;
+ end Previous;
+
-------------------
-- Query_Element --
-------------------
@@ -1027,6 +1087,50 @@ package body Ada.Containers.Doubly_Linked_Lists is
raise Program_Error with "attempt to stream list 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 : List; Position : Cursor)
+ return Constant_Reference_Type is
+ begin
+ pragma Unreferenced (Container);
+
+ 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 : List; Position : Cursor)
+ return Reference_Type is
+ begin
+ pragma Unreferenced (Container);
+
+ 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_Element --
---------------------
@@ -1832,4 +1936,20 @@ package body Ada.Containers.Doubly_Linked_Lists is
raise Program_Error with "attempt to stream list 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.Doubly_Linked_Lists;