Merge pull request #386 from asarhaddon/test-let-recursive-def
[jackhill/mal.git] / ada.2 / types-maps.ads
CommitLineData
5a07bb53 1private with Ada.Containers.Hashed_Maps;
daffc668 2
5a07bb53 3with Garbage_Collected;
daffc668
NB
4
5package Types.Maps is
6
8185fe14
NB
7 -- All function receiving a key check that its kind is keyword or
8 -- string.
9
10 type Instance (<>) is abstract new Garbage_Collected.Instance with private;
daffc668
NB
11
12 -- Built-in functions.
8185fe14
NB
13 function Assoc (Args : in T_Array) return T;
14 function Contains (Args : in T_Array) return T;
15 function Dissoc (Args : in T_Array) return T;
16 function Get (Args : in T_Array) return T;
17 function Hash_Map (Args : in T_Array) return T;
18 function Keys (Args : in T_Array) return T;
19 function Vals (Args : in T_Array) return T;
daffc668 20
5a07bb53
NB
21 function "=" (Left, Right : in Instance) return Boolean with Inline;
22
8185fe14
NB
23 -- Used to print each element of a map.
24 type Cursor (<>) is limited private;
25 function Has_Element (Position : in Cursor) return Boolean with Inline;
26 function Key (Position : in Cursor) return T with Inline;
27 function Element (Position : in Cursor) return T with Inline;
28 function First (Container : in Instance) return Cursor with Inline;
29 procedure Next (Position : in out Cursor) with Inline;
daffc668
NB
30
31 -- Used to evaluate each element of a map.
8185fe14
NB
32 function New_Map (Source : in Instance) return T with Inline;
33 procedure Replace_Element (Container : in out Instance;
34 Position : in Cursor;
35 New_Item : in T) with Inline;
5a07bb53 36
8185fe14
NB
37 function Meta (Container : in Instance) return T with Inline;
38 function With_Meta (Container : in Instance;
39 Metadata : in T) return T with Inline;
daffc668
NB
40
41private
42
8185fe14 43 function Hash (Item : in T) return Ada.Containers.Hash_Type with Inline;
5a07bb53
NB
44 -- This function also checks the kind of the key, and raise an
45 -- error in case of problem.
46
8185fe14
NB
47 package HM is new Ada.Containers.Hashed_Maps (Key_Type => T,
48 Element_Type => T,
5a07bb53 49 Hash => Hash,
8185fe14
NB
50 Equivalent_Keys => "=",
51 "=" => "=");
5a07bb53
NB
52
53 type Instance is new Garbage_Collected.Instance with record
54 Data : HM.Map;
8185fe14 55 F_Meta : T;
5a07bb53 56 end record;
8185fe14 57
5a07bb53 58 overriding procedure Keep_References (Object : in out Instance) with Inline;
daffc668 59
8185fe14
NB
60 type Cursor is new HM.Cursor;
61
daffc668 62end Types.Maps;