aboutsummaryrefslogtreecommitdiff
path: root/forth/types.fs
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-02-14 16:08:17 -0500
committerChouser <chouser@n01se.net>2015-02-21 13:22:44 -0500
commit79feb89f9c75d30e79b9ef13fa40d2f8e22f4b9b (patch)
treee133202bdc8f99e0ea61b31d7241940f5a3e9f6c /forth/types.fs
parente6106d4543fd4917a18ca501ee62a995a152d263 (diff)
downloadmal-79feb89f9c75d30e79b9ef13fa40d2f8e22f4b9b.tar.gz
mal-79feb89f9c75d30e79b9ef13fa40d2f8e22f4b9b.zip
forth: Add defspecial for Mal special ops
Diffstat (limited to 'forth/types.fs')
-rw-r--r--forth/types.fs19
1 files changed, 12 insertions, 7 deletions
diff --git a/forth/types.fs b/forth/types.fs
index 305ff31..a8dd2da 100644
--- a/forth/types.fs
+++ b/forth/types.fs
@@ -84,11 +84,15 @@ end-struct MalTypeType%
dup MalTypeType-name-len 0 swap ! ( MalTypeType )
;
+\ parse-name uses temporary space, so copy into dictionary stack:
+: parse-allot-name { -- new-str-addr str-len }
+ parse-name { str-addr str-len }
+ here { new-str-addr } str-len allot
+ str-addr new-str-addr str-len cmove
+ new-str-addr str-len ;
+
: deftype ( struct-align struct-len R:type-name -- )
- parse-name { orig-name-addr name-len }
- \ parse-name uses temporary space, so copy into dictionary stack:
- here { name-addr } name-len allot
- orig-name-addr name-addr name-len cmove
+ parse-allot-name { name-addr name-len }
\ allot and initialize type structure
deftype* { mt }
@@ -183,14 +187,15 @@ MalNil new constant mal-nil
does> ( ??? obj xt-ref -- ??? )
@ execute-method ;
-: extend ( type -- type pxt <noname...>)
+: extend ( type -- type pxt install-xt <noname...>)
parse-name find-name name>int ( type pxt )
+ ['] extend-method*
:noname
;
: ;; ( type pxt <noname...> -- type )
- [compile] ; ( type pxt ixt )
- extend-method*
+ [compile] ; ( type pxt install-xt ixt )
+ swap execute
; immediate
(