diff options
| author | Chouser <chouser@n01se.net> | 2015-02-14 13:40:07 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | 69972a8399efe4abb8567526e90262e131f90d26 (patch) | |
| tree | 5e12e86da119a9c3f4372dab9e04777a746f90d0 /forth/step2_eval.fs | |
| parent | 9da223a35a176d94fbb75cbcc1000871ff5aff0b (diff) | |
| download | mal-69972a8399efe4abb8567526e90262e131f90d26.tar.gz mal-69972a8399efe4abb8567526e90262e131f90d26.zip | |
forth: Add step 3
Diffstat (limited to 'forth/step2_eval.fs')
| -rw-r--r-- | forth/step2_eval.fs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/forth/step2_eval.fs b/forth/step2_eval.fs index 51d1f6f..33ceb4e 100644 --- a/forth/step2_eval.fs +++ b/forth/step2_eval.fs @@ -15,9 +15,23 @@ value repl-env def-protocol-method mal-eval ( env ast -- val ) def-protocol-method mal-eval-ast ( env ast -- val ) +def-protocol-method invoke ( argv argc mal-fn -- ... ) MalDefault extend mal-eval nip ;; drop +MalKeyword + extend invoke { argv argc kw -- val } + argc 1 > if argv cell+ @ else mal-nil endif \ not-found + kw \ key + argv @ \ map + get ;; +drop + +MalFn + extend invoke ( ... mal-fn -- ... ) + MalFn/xt @ execute ;; +drop + MalSymbol extend mal-eval { env sym -- val } 0 sym env get |
