1 with Ada
.Containers
.Hashed_Maps
;
2 --with Ada.Strings.Unbounded;
3 with Ada
.Strings
.Unbounded
.Hash
;
9 type Env_Handle
is private;
11 function New_Env
(Outer
: Env_Handle
) return Env_Handle
;
13 -- Set adds an element to the environment E.
17 Elem
: Smart_Pointers
.Smart_Pointer
);
19 -- Get finds a key in the E env. If it can't be found it looks
20 -- in an outer env. If it runs out of envs, Not Found is raised.
21 function Get
(E
: Env_Handle
; Key
: String)
22 return Smart_Pointers
.Smart_Pointer
;
25 (E
: Env_Handle
; Outer_Env
: Env_Handle
);
27 function To_String
(E
: Env_Handle
) return String;
29 Not_Found
: exception;
31 -- Sym and Exprs are lists. Bind Sets Keys in Syms to the corresponding
32 -- expression in Exprs. Returns true if all the parameters were bound.
33 function Bind
(E
: Env_Handle
; Syms
, Exprs
: Types
.List_Mal_Type
)
36 -- Create a New_Env. The previous one is pushed to the stack and the
37 -- new one becomes the current one.
40 -- Destroys the top-most env and replaces it with the previous one
44 function Get_Current
return Env_Handle
;
46 Debug
: Boolean := False;
50 type Env_Handle
is new Smart_Pointers
.Smart_Pointer
;
52 function Is_Null
(E
: Env_Handle
) return Boolean;
54 package String_Mal_Hash
is new Ada
.Containers
.Hashed_Maps
55 (Key_Type
=> Ada
.Strings
.Unbounded
.Unbounded_String
,
56 Element_Type
=> Smart_Pointers
.Smart_Pointer
,
57 Hash
=> Ada
.Strings
.Unbounded
.Hash
,
58 Equivalent_Keys
=> Ada
.Strings
.Unbounded
."=",
59 "=" => Smart_Pointers
."=");
61 type Env
is new Smart_Pointers
.Base_Class
with record
62 The_Map
: String_Mal_Hash
.Map
;
63 Outer_Env
: Env_Handle
;
69 type Env_Ptr
is access all Env
;
71 function Deref
(SP
: Env_Handle
) return Env_Ptr
;