DISABLE FDs (REMOVE ME).
[jackhill/mal.git] / ada / types-vector.ads
CommitLineData
705f3d2c
CM
1with Ada.Containers.Vectors;
2with Ada.Strings.Unbounded;
3with Smart_Pointers;
4with Envs;
5
6package Types.Vector is
7
8 type Vector_Mal_Type is new List_Mal_Type with private;
9
10 function New_Vector_Mal_Type
11 return Mal_Handle;
12
13 overriding function Prepend (Op : Mal_Handle; To_Vector : Vector_Mal_Type)
14 return Mal_Handle;
15
16 overriding procedure Append (V : in out Vector_Mal_Type; E : Mal_Handle);
17
18 overriding function Length (L : Vector_Mal_Type) return Natural;
19
20 overriding function Is_Null (L : Vector_Mal_Type) return Boolean;
21
22 overriding function Null_List (L : List_Types) return Vector_Mal_Type;
23
24 -- Duplicate copies the list (logically). This is to allow concatenation,
25 -- The result is always a List_List.
26 overriding function Duplicate (The_List : Vector_Mal_Type) return Mal_Handle;
27
28 overriding function Nth (L : Vector_Mal_Type; N : Natural) return Mal_Handle;
29
aa8c1800
CM
30 overriding procedure Add_Defs (Defs : Vector_Mal_Type; Env : Envs.Env_Handle);
31
705f3d2c 32 -- Get the first item in the list:
aa8c1800 33 overriding function Car (L : Vector_Mal_Type) return Mal_Handle;
705f3d2c
CM
34
35 -- Get the rest of the list (second item onwards)
aa8c1800 36 overriding function Cdr (L : Vector_Mal_Type) return Mal_Handle;
705f3d2c
CM
37
38 overriding function Map
39 (Func_Ptr : Func_Access;
40 L : Vector_Mal_Type)
41 return Mal_Handle;
42
43 type Vector_Ptr is access all Vector_Mal_Type;
44
45 function Deref_Vector (SP : Mal_Handle) return Vector_Ptr;
46
47private
48
49 subtype Vec_Index is Integer range 0 .. 100;
50 package Mal_Vectors is new
51 Ada.Containers.Vectors
52 (Index_Type => Vec_Index,
53 Element_Type => Mal_Handle,
54 "=" => "=");
55
56 use Mal_Vectors;
57
58 type Vector_Mal_Type is new List_Mal_Type with record
59 Vec : Mal_Vectors.Vector;
60 end record;
61
62 overriding function To_Str
63 (T : Vector_Mal_Type; Print_Readably : Boolean := True)
64 return Mal_String;
65
66end Types.Vector;