aboutsummaryrefslogtreecommitdiff
path: root/go/src/step2_eval
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
committerJoel Martin <github@martintribe.org>2014-10-09 21:37:00 -0500
commitf2544a9467ea032aff505b3ced3b4b3510a828fe (patch)
treeaa1984aef01c20b7b093527c28c37bd7d4d803d5 /go/src/step2_eval
parentf2c9811fd8cbb205fad68952ebc1ba5d310f148d (diff)
downloadmal-f2544a9467ea032aff505b3ced3b4b3510a828fe.tar.gz
mal-f2544a9467ea032aff505b3ced3b4b3510a828fe.zip
go: add metadata and atoms. HashMap dedicated type.
HashMap needs a dedicated type now to be able to store the metadata.
Diffstat (limited to 'go/src/step2_eval')
-rw-r--r--go/src/step2_eval/step2_eval.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/go/src/step2_eval/step2_eval.go b/go/src/step2_eval/step2_eval.go
index d28de20..7a9a33f 100644
--- a/go/src/step2_eval/step2_eval.go
+++ b/go/src/step2_eval/step2_eval.go
@@ -33,7 +33,7 @@ func eval_ast(ast MalType, env map[string]MalType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return List{lst}, nil
+ return List{lst,nil}, nil
} else if Vector_Q(ast) {
lst := []MalType{}
for _, a := range ast.(Vector).Val {
@@ -41,11 +41,11 @@ func eval_ast(ast MalType, env map[string]MalType) (MalType, error) {
if e != nil { return nil, e }
lst = append(lst, exp)
}
- return Vector{lst}, nil
+ return Vector{lst,nil}, nil
} else if HashMap_Q(ast) {
- m := ast.(map[string]MalType)
- new_hm := map[string]MalType{}
- for k, v := range m {
+ m := ast.(HashMap)
+ new_hm := HashMap{map[string]MalType{},nil}
+ for k, v := range m.Val {
ke, e1 := EVAL(k, env)
if e1 != nil { return nil, e1 }
if _, ok := ke.(string); !ok {
@@ -53,7 +53,7 @@ func eval_ast(ast MalType, env map[string]MalType) (MalType, error) {
}
kv, e2 := EVAL(v, env)
if e2 != nil { return nil, e2 }
- new_hm[ke.(string)] = kv
+ new_hm.Val[ke.(string)] = kv
}
return new_hm, nil
} else {
@@ -62,7 +62,7 @@ func eval_ast(ast MalType, env map[string]MalType) (MalType, error) {
}
func EVAL(ast MalType, env map[string]MalType) (MalType, error) {
- //fmt.Printf("EVAL: %#v\n", ast)
+ //fmt.Printf("EVAL: %v\n", printer.Pr_str(ast, true))
switch ast.(type) {
case List: // continue
default: return eval_ast(ast, env)