aboutsummaryrefslogtreecommitdiff
path: root/forth/step2_eval.fs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-02-24 09:16:20 -0600
committerJoel Martin <github@martintribe.org>2015-02-24 09:16:20 -0600
commitff26ebdb816da07b28b29073868994fc7eabf8d1 (patch)
treeee0e08f5226525cb4885512e07ae53c30f185990 /forth/step2_eval.fs
parent2a42d8274072c44dd2d83762cc27cd810f5b8452 (diff)
parenta631063f3fa2eaed473369b376a5499df92209bd (diff)
downloadmal-ff26ebdb816da07b28b29073868994fc7eabf8d1.tar.gz
mal-ff26ebdb816da07b28b29073868994fc7eabf8d1.zip
Merge pull request #8 from Chouser/forth3
Forth: Interop and perf updates
Diffstat (limited to 'forth/step2_eval.fs')
-rw-r--r--forth/step2_eval.fs15
1 files changed, 9 insertions, 6 deletions
diff --git a/forth/step2_eval.fs b/forth/step2_eval.fs
index 2b55ce0..724de44 100644
--- a/forth/step2_eval.fs
+++ b/forth/step2_eval.fs
@@ -6,12 +6,15 @@ require printer.fs
argv i cells + @ as-native
loop ;
+: env-assoc ( map sym-str-addr sym-str-len xt )
+ -rot MalSymbol. swap MalNativeFn. rot assoc ;
+
MalMap/Empty
- s" +" MalSymbol. :noname args-as-native + MalInt. ; MalNativeFn. rot assoc
- s" -" MalSymbol. :noname args-as-native - MalInt. ; MalNativeFn. rot assoc
- s" *" MalSymbol. :noname args-as-native * MalInt. ; MalNativeFn. rot assoc
- s" /" MalSymbol. :noname args-as-native / MalInt. ; MalNativeFn. rot assoc
-value repl-env
+ s" +" :noname args-as-native + MalInt. ; env-assoc
+ s" -" :noname args-as-native - MalInt. ; env-assoc
+ s" *" :noname args-as-native * MalInt. ; env-assoc
+ s" /" :noname args-as-native / MalInt. ; env-assoc
+constant repl-env
: read read-str ;
: eval ( env obj ) mal-eval ;
@@ -58,7 +61,7 @@ MalSymbol
dup 0= if
drop
." Symbol '"
- sym as-native safe-type
+ sym pr-str safe-type
." ' not found." cr
1 throw
endif ;;