diff options
| author | Chouser <chouser@n01se.net> | 2015-02-20 02:52:51 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-02-21 13:22:44 -0500 |
| commit | b254151c2a32203fe1920b4dd1db614ed2b0691b (patch) | |
| tree | e9799a7b01f6ab5280d7e745265f37b6ca994b9f | |
| parent | 45c1894b9690b1156ffdc2caeb726bbc9526597a (diff) | |
| download | mal-b254151c2a32203fe1920b4dd1db614ed2b0691b.tar.gz mal-b254151c2a32203fe1920b4dd1db614ed2b0691b.zip | |
forth: Fix bug in extend-protocol array insertion
| -rw-r--r-- | forth/misc-tests.fs | 1 | ||||
| -rw-r--r-- | forth/types.fs | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/forth/misc-tests.fs b/forth/misc-tests.fs index 2526067..35e665b 100644 --- a/forth/misc-tests.fs +++ b/forth/misc-tests.fs @@ -20,6 +20,7 @@ create za 2 , 6 , 7 , 10 , 15 , 80 , 81 , 7 za 8 array-find 0 test= 3 test= 7 za 100 array-find 0 test= 7 test= 7 za 1 array-find 0 test= 0 test= +6 za 81 array-find 0 test= 6 test= 10 new-array 1 swap 0 5 array-insert diff --git a/forth/types.fs b/forth/types.fs index 791f327..5028bf3 100644 --- a/forth/types.fs +++ b/forth/types.fs @@ -30,8 +30,11 @@ require str.fs endif endif 2dup = until - cells a-addr + @ key = - ; + dup a-length = if + drop false + else + cells a-addr + @ key = + endif ; \ Create a new array, one cell in length, initialized the provided value : new-array { value -- array } @@ -170,7 +173,9 @@ MalType% deftype MalFalse MalFalse new constant mal-false else pxt array-find { idx found? } found? if \ overwrite - ." Warning: overwriting protocol method implementation" + ." Warning: overwriting protocol method implementation '" + pxt >name name>string safe-type ." ' on " type type-name safe-type ." , " idx . found? . cr + type MalTypeType-method-vals @ idx cells + ixt ! else \ resize type MalTypeType-methods dup @ 1+ dup rot ! ( new-count ) |
