aboutsummaryrefslogtreecommitdiff
path: root/forth/types.fs
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-02-15 16:46:34 -0500
committerChouser <chouser@n01se.net>2015-02-21 13:22:44 -0500
commitc4403c179e732a50e2b21a01469f0a38ea2d0187 (patch)
tree71cb962c6f9dafafae6e31a17072e14b1e52b381 /forth/types.fs
parent136ce7c9afb5e103133fe6e423e6dad3d23db38d (diff)
downloadmal-c4403c179e732a50e2b21a01469f0a38ea2d0187.tar.gz
mal-c4403c179e732a50e2b21a01469f0a38ea2d0187.zip
forth: Add support for & var-args
Diffstat (limited to 'forth/types.fs')
-rw-r--r--forth/types.fs10
1 files changed, 7 insertions, 3 deletions
diff --git a/forth/types.fs b/forth/types.fs
index 7675a5e..51f04ed 100644
--- a/forth/types.fs
+++ b/forth/types.fs
@@ -125,6 +125,8 @@ MalType% deftype MalFalse MalFalse new constant mal-false
\ === protocol methods === /
+0 constant trace
+
\ Used by protocol methods to find the appropriate implementation of
\ themselves for the given object, and then execute that implementation.
: execute-method { obj pxt -- }
@@ -153,10 +155,10 @@ MalType% deftype MalFalse MalFalse new constant mal-false
." '"
1 throw
endif
+ trace if ." Calling '" pxt >name name>string type ." ' on " obj mal-type @ type-name type cr endif
cells swap MalTypeType-method-vals @ + @ ( xt )
- obj swap execute
- ;
+ obj swap execute ;
\ Extend a type with a protocol method. This mutates the MalTypeType
\ object that represents the MalType being extended.
@@ -313,13 +315,15 @@ deftype MalVector
MalVector
extend to-list
- MalVector/list @ to-list ;;
+ MalVector/list @ ;;
extend empty?
MalVector/list @
MalList/count @ 0= mal-bool ;;
extend mal-count
MalVector/list @
MalList/count @ MalInt. ;;
+ extend mal=
+ MalVector/list @ swap m= ;;
drop
MalType%