HCoop
/
jackhill
/
mal.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Added first, rest and nth
[jackhill/mal.git]
/
livescript
/
env.ls
1
export class Env
2
(
outer
=
null
,
data
= {}) ->
3
@outer
=
outer
4
@data
=
data
5
6
set
: (
symbol
,
ast
) ->
7
@data
[
symbol
] =
ast
8
9
find
: (
symbol
) ->
10
if symbol of @data then @
11
else if @outer? then @outer.find symbol
12
13
get
: (
symbol
) ->
14
result
=
@try
-
get symbol
15
if not result
16
then throw new
Error
"symbol not found
:
#
{
symbol
}
"
17
else result
18
19
try
-
get
: (
symbol
) ->
20
env
=
@find symbol
21
if env then env.data
[
symbol
]