1 Imports System
.Collections
.Generic
3 Imports MalVal
= Mal
.types
.MalVal
4 Imports MalSymbol
= Mal
.types
.MalSymbol
5 Imports MalList
= Mal
.types
.MalList
10 Dim outer
As Env
= Nothing
11 Dim data
As Dictionary(Of
String, MalVal
) = New Dictionary(Of
String, MalVal
)
13 Public Sub New(new_outer
As Env
)
16 Public Sub New(new_outer
As Env
, binds
As MalList
, exprs
As MalList
)
18 For i
As Integer = 0 To binds
.size()-1
19 Dim sym
As String = DirectCast(binds
.nth(i
),MalSymbol
).getName()
21 data(DirectCast(binds
.nth(i
+1),MalSymbol
).getName()) = exprs
.slice(i
)
24 data(sym
) = exprs
.nth(i
)
29 Public Function find(key
As MalSymbol
) As Env
30 If data
.ContainsKey(key
.getName()) Then
32 Else If outer IsNot
Nothing Then
33 return outer
.find(key
)
39 Public Function do_get(key
As MalSymbol
) As MalVal
40 Dim e
As Env
= find(key
)
42 throw
New Mal
.types
.MalException(
43 "'" & key
.getName() & "' not found")
45 return e
.data(key
.getName())
49 Public Function do_set(key
As MalSymbol
, value
As MalVal
) As Env
50 data(key
.getName()) = value