diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-30 12:37:06 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-30 12:37:06 +0000 |
commit | 73e4df1deaadb719c7649ac0957573ceca55f842 (patch) | |
tree | 975a7ced6842710d01af3678a4a9051684a1bce8 /gcc/ada/a-cbhama.ads | |
parent | ba60c66472a4a63105c930d419641f75f4d70264 (diff) | |
download | gcc-73e4df1deaadb719c7649ac0957573ceca55f842.tar.gz |
2011-08-30 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 178289 using svnmerge.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@178293 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cbhama.ads')
-rw-r--r-- | gcc/ada/a-cbhama.ads | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/gcc/ada/a-cbhama.ads b/gcc/ada/a-cbhama.ads index 042cc0fa1df..4d7cfa2225b 100644 --- a/gcc/ada/a-cbhama.ads +++ b/gcc/ada/a-cbhama.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,7 +32,9 @@ ------------------------------------------------------------------------------ private with Ada.Containers.Hash_Tables; -private with Ada.Streams; + +with Ada.Streams; use Ada.Streams; +with Ada.Iterator_Interfaces; generic type Key_Type is private; @@ -46,7 +48,12 @@ package Ada.Containers.Bounded_Hashed_Maps is pragma Pure; pragma Remote_Types; - type Map (Capacity : Count_Type; Modulus : Hash_Type) is tagged private; + type Map (Capacity : Count_Type; Modulus : Hash_Type) 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; @@ -60,6 +67,12 @@ package Ada.Containers.Bounded_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 @@ -253,9 +266,6 @@ package Ada.Containers.Bounded_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. @@ -273,8 +283,51 @@ package Ada.Containers.Bounded_Hashed_Maps is 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; + + 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; + private - -- pragma Inline ("="); pragma Inline (Length); pragma Inline (Is_Empty); pragma Inline (Clear); @@ -285,7 +338,6 @@ private pragma Inline (Capacity); pragma Inline (Reserve_Capacity); pragma Inline (Has_Element); - pragma Inline (Equivalent_Keys); pragma Inline (Next); type Node_Type is record @@ -301,7 +353,6 @@ private new HT_Types.Hash_Table_Type (Capacity, Modulus) with null record; use HT_Types; - use Ada.Streams; procedure Write (Stream : not null access Root_Stream_Type'Class; @@ -318,9 +369,15 @@ private type Map_Access is access all Map; for Map_Access'Storage_Size use 0; + -- Note: If a Cursor object has no explicit initialization expression, + -- it must default initialize to the same value as constant No_Element. + -- The Node component of type Cursor has scalar type Count_Type, so it + -- requires an explicit initialization expression of its own declaration, + -- in order for objects of record type Cursor to properly initialize. + type Cursor is record Container : Map_Access; - Node : Count_Type; + Node : Count_Type := 0; end record; procedure Read @@ -335,6 +392,12 @@ private for Cursor'Write use Write; + 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; + No_Element : constant Cursor := (Container => null, Node => 0); Empty_Map : constant Map := |