From 50e417ffe32c238189e61c9701696602d40bb7f3 Mon Sep 17 00:00:00 2001 From: Chouser Date: Fri, 6 Feb 2015 02:38:58 -0500 Subject: forth: Add string printing --- forth/types.fs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'forth/types.fs') 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 ; -- cgit v1.2.3