aboutsummaryrefslogtreecommitdiff
path: root/forth/env.fs
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-02-21 18:50:50 -0500
committerChouser <chouser@n01se.net>2015-02-23 22:22:04 -0500
commit3a17cb968281f7e833088fdb22cf793861810912 (patch)
tree8758fc89cdc319a3615d12be26facea80d06cd86 /forth/env.fs
parent975126be58a92228e945730f9ff2337bfea41b9a (diff)
downloadmal-3a17cb968281f7e833088fdb22cf793861810912.tar.gz
mal-3a17cb968281f7e833088fdb22cf793861810912.zip
forth: Clean up symbol eval for better perf
Diffstat (limited to 'forth/env.fs')
-rw-r--r--forth/env.fs17
1 files changed, 5 insertions, 12 deletions
diff --git a/forth/env.fs b/forth/env.fs
index 1b5a362..9469bf2 100644
--- a/forth/env.fs
+++ b/forth/env.fs
@@ -15,25 +15,18 @@ deftype MalEnv
key val env MalEnv/data @ assoc
env MalEnv/data ! ;
-: env/find { key env -- env-or-0 }
+: env/get-addr { key env -- val-addr }
env
begin ( env )
- dup 0 key rot MalEnv/data @ get ( env val-or-0 )
- 0= if ( env )
+ key over MalEnv/data @ MalMap/get-addr ( env addr-or-0 )
+ ?dup 0= if ( env )
MalEnv/outer @ dup 0= ( env-or-0 done-looping? )
- else
- -1 \ found it! ( env -1 )
+ else ( env addr )
+ nip -1 \ found it! ( addr -1 )
endif
until ;
MalEnv
- extend get { not-found key env -- }
- key env env/find ( env-or-0 )
- ?dup 0= if
- not-found
- else ( env )
- not-found key rot MalEnv/data @ get
- endif ;;
extend pr-buf { env }
env MalEnv/data @ pr-buf
a-space s" outer: " str-append