Change quasiquote algorithm
[jackhill/mal.git] / impls / ada / types-hash_map.ads
CommitLineData
874db2ac
CM
1with Ada.Containers.Hashed_Maps;
2with Smart_Pointers;
3with Envs;
4
5package Types.Hash_Map is
6
7 type Hash_Map_Mal_Type is new List_Mal_Type with private;
8
9 function New_Hash_Map_Mal_Type
10 return Mal_Handle;
11
93031830
CM
12 function "=" (A, B : Hash_Map_Mal_Type) return Boolean;
13
874db2ac
CM
14 overriding function Prepend (Op : Mal_Handle; To_Vector : Hash_Map_Mal_Type)
15 return Mal_Handle;
16
17 overriding procedure Append (V : in out Hash_Map_Mal_Type; E : Mal_Handle);
18
19 overriding function Length (L : Hash_Map_Mal_Type) return Natural;
20
21 overriding function Is_Null (L : Hash_Map_Mal_Type) return Boolean;
22
23 overriding function Null_List (L : List_Types) return Hash_Map_Mal_Type;
24
25 -- Duplicate copies the list (logically). This is to allow concatenation,
26 -- The result is always a List_List.
27 overriding function Duplicate (The_List : Hash_Map_Mal_Type) return Mal_Handle;
28
29 overriding function Nth (L :Hash_Map_Mal_Type; N : Natural) return Mal_Handle;
30
31 overriding procedure Add_Defs (Defs : Hash_Map_Mal_Type; Env : Envs.Env_Handle);
32
33 -- Get the first item in the list:
34 overriding function Car (L : Hash_Map_Mal_Type) return Mal_Handle;
35
36 -- Get the rest of the list (second item onwards)
37 overriding function Cdr (L : Hash_Map_Mal_Type) return Mal_Handle;
38
39 overriding function Map
40 (Func_Ptr : Func_Access;
41 L : Hash_Map_Mal_Type)
42 return Mal_Handle;
43
44 function Assoc (H : Hash_Map_Mal_Type; List : Mal_Handle) return Mal_Handle;
45
46 function Dis_Assoc (H : Hash_Map_Mal_Type; List : Mal_Handle) return Mal_Handle;
47
48 function Get (H : Hash_Map_Mal_Type; Key : Mal_Handle) return Mal_Handle;
49
50 function All_Keys (H : Hash_Map_Mal_Type) return Mal_Handle;
51
52 function All_Values (H : Hash_Map_Mal_Type) return Mal_Handle;
53
54 function Contains (H : Hash_Map_Mal_Type; Key : Mal_Handle) return Boolean;
55
56 type Hash_Ptr is access all Hash_Map_Mal_Type;
57
58 function Deref_Hash (SP : Mal_Handle) return Hash_Ptr;
59
60 Not_Appropriate : exception;
61
62private
63
64 function Hash (M : Mal_Handle) return Ada.Containers.Hash_Type;
65
66 package Mal_Mal_Hash is new Ada.Containers.Hashed_Maps
67 (Key_Type => Mal_Handle,
68 Element_Type => Mal_Handle,
69 Hash => Hash,
70 Equivalent_Keys => "=",
71 "=" => "=");
72
73 type Hash_Map_Mal_Type is new List_Mal_Type with record
74 Is_Key_Expected : Boolean := True;
75 Next_Key : Mal_Handle;
76 Hash : Mal_Mal_Hash.Map;
77 end record;
78
79 overriding function To_Str
80 (T : Hash_Map_Mal_Type; Print_Readably : Boolean := True)
81 return Mal_String;
82
83end Types.Hash_Map;