aboutsummaryrefslogtreecommitdiff
path: root/forth/types.fs
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-02-06 02:38:58 -0500
committerChouser <chouser@n01se.net>2015-02-21 13:22:43 -0500
commit50e417ffe32c238189e61c9701696602d40bb7f3 (patch)
tree1cb834a6cf450769f2af7ea310cf5a2de6e08407 /forth/types.fs
parent59038a10f0e3ad65675cafdb149eb61405e334d3 (diff)
downloadmal-50e417ffe32c238189e61c9701696602d40bb7f3.tar.gz
mal-50e417ffe32c238189e61c9701696602d40bb7f3.zip
forth: Add string printing
Diffstat (limited to 'forth/types.fs')
-rw-r--r--forth/types.fs15
1 files changed, 13 insertions, 2 deletions
diff --git a/forth/types.fs b/forth/types.fs
index 2b74576..75996f8 100644
--- a/forth/types.fs
+++ b/forth/types.fs
@@ -22,7 +22,7 @@
endif
else
key > if ( start end middle )
- swap drop ( start middle )
+ nip ( start middle )
else
-rot 2drop dup ( middle middle )
endif
@@ -187,7 +187,7 @@ def-protocol-method conj ( obj this -- this )
\ Examples of extending existing protocol methods to existing type
MalDefault
extend conj ( obj this -- this )
- swap drop ;;
+ nip ;;
drop
MalNil
@@ -217,3 +217,14 @@ deftype* constant MalSymbol
str-addr sym MalSymbol/sym-addr !
str-len sym MalSymbol/sym-len !
sym ;
+
+MalType%
+ cell% field MalString/str-addr
+ cell% field MalString/str-len
+deftype* constant MalString
+
+: MalString. { str-addr str-len -- mal-str }
+ MalString new { str }
+ str-addr str MalString/str-addr !
+ str-len str MalString/str-len !
+ str ;