aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/a-cohama.ads
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-cohama.ads
parent3ddd922ebf36fb7d4701e8f55e633d27fca54296 (diff)
downloadgcc-3e24afaa6a24e1955ad0f3cd1ca00b6edec67a67.zip
gcc-3e24afaa6a24e1955ad0f3cd1ca00b6edec67a67.tar.gz
gcc-3e24afaa6a24e1955ad0f3cd1ca00b6edec67a67.tar.bz2
[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-cohama.ads')
-rw-r--r--gcc/ada/a-cohama.ads93
1 files changed, 75 insertions, 18 deletions
diff --git a/gcc/ada/a-cohama.ads b/gcc/ada/a-cohama.ads
index 9c00c6e..2ade56e 100644
--- a/gcc/ada/a-cohama.ads
+++ b/gcc/ada/a-cohama.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 --
@@ -32,8 +32,9 @@
------------------------------------------------------------------------------
private with Ada.Containers.Hash_Tables;
-private with Ada.Streams;
+with Ada.Streams; use Ada.Streams;
private with Ada.Finalization;
+with Ada.Iterator_Interfaces;
generic
type Key_Type is private;
@@ -47,12 +48,30 @@ package Ada.Containers.Hashed_Maps is
pragma Preelaborate;
pragma Remote_Types;
- type Map is tagged private;
+ type Map is tagged private
+ with
+ Constant_Indexing => Constant_Reference,
+ Variable_Indexing => Reference,
+ Default_Iterator => Iterate,
+ Iterator_Element => Element_Type;
+
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
+ procedure Read
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : out Cursor);
+
+ for Cursor'Read use Read;
+
+ procedure Write
+ (Stream : not null access Root_Stream_Type'Class;
+ Item : Cursor);
+
+ for Cursor'Write use Write;
+
Empty_Map : constant Map;
-- Map objects declared without an initialization expression are
-- initialized to the value Empty_Map.
@@ -61,6 +80,12 @@ package Ada.Containers.Hashed_Maps is
-- Cursor objects declared without an initialization expression are
-- initialized to the value No_Element.
+ function Has_Element (Position : Cursor) return Boolean;
+ -- Equivalent to Position /= No_Element
+
+ package Map_Iterator_Interfaces is new
+ Ada.Iterator_Interfaces (Cursor, Has_Element);
+
function "=" (Left, Right : Map) return Boolean;
-- For each key/element pair in Left, equality attempts to find the key in
-- Right; if a search fails the equality returns False. The search works by
@@ -235,9 +260,6 @@ package Ada.Containers.Hashed_Maps is
function Element (Container : Map; Key : Key_Type) return Element_Type;
-- Equivalent to Element (Find (Container, Key))
- function Has_Element (Position : Cursor) return Boolean;
- -- Equivalent to Position /= No_Element
-
function Equivalent_Keys (Left, Right : Cursor) return Boolean;
-- Returns the result of calling Equivalent_Keys with the keys of the nodes
-- designated by cursors Left and Right.
@@ -250,11 +272,54 @@ package Ada.Containers.Hashed_Maps is
-- Returns the result of calling Equivalent_Keys with key Left and the node
-- designated by Right.
+ 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 : Map; Key : Key_Type) -- SHOULD BE ALIASED
+ return Constant_Reference_Type;
+
+ function Reference (Container : Map; Key : Key_Type)
+ return Reference_Type;
+
procedure Iterate
(Container : Map;
Process : not null access procedure (Position : Cursor));
-- Calls Process for each node in the map
+ function Iterate (Container : Map)
+ return Map_Iterator_Interfaces.Forward_Iterator'class;
+
private
pragma Inline ("=");
pragma Inline (Length);
@@ -293,8 +358,6 @@ private
overriding procedure Finalize (Container : in out Map);
- use Ada.Streams;
-
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Map);
@@ -315,17 +378,11 @@ private
Node : Node_Access;
end record;
- procedure Read
- (Stream : not null access Root_Stream_Type'Class;
- Item : out Cursor);
+ type Constant_Reference_Type
+ (Element : not null access constant Element_Type) is null record;
- for Cursor'Read use Read;
-
- procedure Write
- (Stream : not null access Root_Stream_Type'Class;
- Item : Cursor);
-
- for Cursor'Write use Write;
+ type Reference_Type
+ (Element : not null access Element_Type) is null record;
Empty_Map : constant Map := (Controlled with HT => (null, 0, 0, 0));