1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-19 09:38:28 +03:00
mal/impls/ada/types-hash_map.ads
Joel Martin 8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00

84 lines
2.5 KiB
Ada

with Ada.Containers.Hashed_Maps;
with Smart_Pointers;
with Envs;
package Types.Hash_Map is
type Hash_Map_Mal_Type is new List_Mal_Type with private;
function New_Hash_Map_Mal_Type
return Mal_Handle;
function "=" (A, B : Hash_Map_Mal_Type) return Boolean;
overriding function Prepend (Op : Mal_Handle; To_Vector : Hash_Map_Mal_Type)
return Mal_Handle;
overriding procedure Append (V : in out Hash_Map_Mal_Type; E : Mal_Handle);
overriding function Length (L : Hash_Map_Mal_Type) return Natural;
overriding function Is_Null (L : Hash_Map_Mal_Type) return Boolean;
overriding function Null_List (L : List_Types) return Hash_Map_Mal_Type;
-- Duplicate copies the list (logically). This is to allow concatenation,
-- The result is always a List_List.
overriding function Duplicate (The_List : Hash_Map_Mal_Type) return Mal_Handle;
overriding function Nth (L :Hash_Map_Mal_Type; N : Natural) return Mal_Handle;
overriding procedure Add_Defs (Defs : Hash_Map_Mal_Type; Env : Envs.Env_Handle);
-- Get the first item in the list:
overriding function Car (L : Hash_Map_Mal_Type) return Mal_Handle;
-- Get the rest of the list (second item onwards)
overriding function Cdr (L : Hash_Map_Mal_Type) return Mal_Handle;
overriding function Map
(Func_Ptr : Func_Access;
L : Hash_Map_Mal_Type)
return Mal_Handle;
function Assoc (H : Hash_Map_Mal_Type; List : Mal_Handle) return Mal_Handle;
function Dis_Assoc (H : Hash_Map_Mal_Type; List : Mal_Handle) return Mal_Handle;
function Get (H : Hash_Map_Mal_Type; Key : Mal_Handle) return Mal_Handle;
function All_Keys (H : Hash_Map_Mal_Type) return Mal_Handle;
function All_Values (H : Hash_Map_Mal_Type) return Mal_Handle;
function Contains (H : Hash_Map_Mal_Type; Key : Mal_Handle) return Boolean;
type Hash_Ptr is access all Hash_Map_Mal_Type;
function Deref_Hash (SP : Mal_Handle) return Hash_Ptr;
Not_Appropriate : exception;
private
function Hash (M : Mal_Handle) return Ada.Containers.Hash_Type;
package Mal_Mal_Hash is new Ada.Containers.Hashed_Maps
(Key_Type => Mal_Handle,
Element_Type => Mal_Handle,
Hash => Hash,
Equivalent_Keys => "=",
"=" => "=");
type Hash_Map_Mal_Type is new List_Mal_Type with record
Is_Key_Expected : Boolean := True;
Next_Key : Mal_Handle;
Hash : Mal_Mal_Hash.Map;
end record;
overriding function To_Str
(T : Hash_Map_Mal_Type; Print_Readably : Boolean := True)
return Mal_String;
end Types.Hash_Map;