summaryrefslogtreecommitdiff
path: root/gcc/ada/a-cihama.adb
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-11 08:28:21 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-11 08:28:21 +0000
commit84d429b9a24117fcd1ad6b88ae2658cc8fa5f8ac (patch)
treefb62b90dc09045605d9426eb9febca89032fd1b2 /gcc/ada/a-cihama.adb
parentf22b491886dbe1718cc7076fcce41f157ac735d9 (diff)
downloadgcc-84d429b9a24117fcd1ad6b88ae2658cc8fa5f8ac.tar.gz
2012-01-11 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 183090 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@183091 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-cihama.adb')
-rw-r--r--gcc/ada/a-cihama.adb99
1 files changed, 83 insertions, 16 deletions
diff --git a/gcc/ada/a-cihama.adb b/gcc/ada/a-cihama.adb
index 51e8c0c2424..35419020c10 100644
--- a/gcc/ada/a-cihama.adb
+++ b/gcc/ada/a-cihama.adb
@@ -189,6 +189,55 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
HT_Ops.Clear (Container.HT);
end Clear;
+ ------------------------
+ -- Constant_Reference --
+ ------------------------
+
+ function Constant_Reference
+ (Container : aliased Map;
+ Position : Cursor) return Constant_Reference_Type
+ is
+ begin
+ if Position.Container = null then
+ raise Constraint_Error with
+ "Position cursor has no element";
+ end if;
+
+ if Position.Container /= Container'Unrestricted_Access then
+ raise Program_Error with
+ "Position cursor designates wrong map";
+ end if;
+
+ if Position.Node.Element = null then
+ raise Program_Error with
+ "Position cursor has no element";
+ end if;
+
+ pragma Assert
+ (Vet (Position),
+ "Position cursor in Constant_Reference is bad");
+
+ return (Element => Position.Node.Element.all'Access);
+ end Constant_Reference;
+
+ function Constant_Reference
+ (Container : aliased Map;
+ Key : Key_Type) return Constant_Reference_Type
+ is
+ Node : constant Node_Access := Key_Ops.Find (Container.HT, Key);
+
+ begin
+ if Node = null then
+ raise Constraint_Error with "key not in map";
+ end if;
+
+ if Node.Element = null then
+ raise Program_Error with "key has no element";
+ end if;
+
+ return (Element => Node.Element.all'Access);
+ end Constant_Reference;
+
--------------
-- Contains --
--------------
@@ -955,31 +1004,49 @@ package body Ada.Containers.Indefinite_Hashed_Maps is
-- Reference --
---------------
- function Constant_Reference
- (Container : Map;
- Key : Key_Type) return Constant_Reference_Type
- is
- begin
- return (Element =>
- Container.Find (Key).Node.Element.all'Unrestricted_Access);
- end Constant_Reference;
-
function Reference
- (Container : Map;
- Key : Key_Type) return Reference_Type
+ (Container : aliased in out Map;
+ Position : Cursor) return Reference_Type
is
begin
- return (Element =>
- Container.Find (Key).Node.Element.all'Unrestricted_Access);
+ if Position.Container = null then
+ raise Constraint_Error with
+ "Position cursor has no element";
+ end if;
+
+ if Position.Container /= Container'Unrestricted_Access then
+ raise Program_Error with
+ "Position cursor designates wrong map";
+ end if;
+
+ if Position.Node.Element = null then
+ raise Program_Error with
+ "Position cursor has no element";
+ end if;
+
+ pragma Assert
+ (Vet (Position),
+ "Position cursor in function Reference is bad");
+
+ return (Element => Position.Node.Element.all'Access);
end Reference;
function Reference
(Container : aliased in out Map;
- Position : Cursor) return Reference_Type
+ Key : Key_Type) return Reference_Type
is
- pragma Unreferenced (Container);
+ Node : constant Node_Access := Key_Ops.Find (Container.HT, Key);
+
begin
- return (Element => Element (Position)'Unrestricted_Access);
+ if Node = null then
+ raise Constraint_Error with "key not in map";
+ end if;
+
+ if Node.Element = null then
+ raise Program_Error with "key has no element";
+ end if;
+
+ return (Element => Node.Element.all'Access);
end Reference;
-------------