From cc5246686f8e87f27c7620da297dd22fe2f6e9a4 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 6 Apr 2005 02:18:36 +0000 Subject: [PATCH] some unix i/o work --- TODO.FACTOR.txt | 22 +++++++++++++++++++++- library/compiler/compiler.factor | 2 +- library/io/buffer.factor | 5 +++-- library/test/errors.factor | 2 +- library/unix/io.factor | 7 +++---- library/words.factor | 10 +++++----- native/error.c | 3 ++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index e8f3d8b03f..d9134c0890 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -22,7 +22,7 @@ - fix up the min thumb size hack - frame gap -+ fii: ++ ffi: - replace alien-address, local-alien? primitives with colon defs - auto-generate box/unbox, and alien accessors @@ -38,6 +38,7 @@ + compiler/ffi: +- linux? bsd? - [ [ dup call ] dup call ] infer hangs - more accurate types for various words - declarations @@ -53,6 +54,7 @@ + kernel: +- code walker & exceptions - string sub-primitives - clean up metaclasses - unify unparse and prettyprint @@ -69,3 +71,21 @@ - vector-map, string-map, seq-each, vector-project: consing - map, subset, project, append: not tail recursive + ++ nice to have libraries: + +- regexps +- XML +- matrices, vector math +- HTTP client +- real Unicode support (strings are already 16 bits and can be extended + to 21 if the need arises, but we need full character classification + predicates, comparison, case conversion, sorting...) +- full Win32 binding +- Cairo binding + ++ httpd: + +- virtual hosts +- keep alive + diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index 6e494651f6..463c24800f 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -64,7 +64,7 @@ M: compound (compile) ( word -- ) drop ] ifte ; -M: compound (undefine) +M: compound (uncrossref) dup f "infer-effect" set-word-prop dup f "no-effect" set-word-prop decompile ; diff --git a/library/io/buffer.factor b/library/io/buffer.factor index 811720b69d..d2eb58c7bb 100644 --- a/library/io/buffer.factor +++ b/library/io/buffer.factor @@ -85,8 +85,9 @@ C: buffer ( size -- buffer ) : buffer-end ( buffer -- int ) dup buffer-ptr swap buffer-fill + ; -: buffer-peek ( buffer -- char ) - buffer@ 0 alien-unsigned-1 ; +: buffer-pop ( buffer -- char ) + [ buffer@ 0 alien-unsigned-1 1 ] keep + buffer-consume ; : buffer-set ( string buffer -- ) 2dup buffer-ptr string>memory diff --git a/library/test/errors.factor b/library/test/errors.factor index 83bab7d214..2d36de7646 100644 --- a/library/test/errors.factor +++ b/library/test/errors.factor @@ -28,4 +28,4 @@ USE: stdio ! [ [ "\"\" { } vector-nth" ] parse ] [ type-check-error ] catch ! This should not raise an error -[ ] [ f throw ] unit-test +[ 1 2 3 ] [ 1 2 3 f throw ] unit-test diff --git a/library/unix/io.factor b/library/unix/io.factor index dcdee808b9..deb91b0347 100644 --- a/library/unix/io.factor +++ b/library/unix/io.factor @@ -17,11 +17,10 @@ C: reader ( buffer -- reader ) dup buffer-length 0 = [ 2drop f ] [ - dup buffer-peek dup CHAR: \n = [ + dup buffer-pop dup CHAR: \n = [ 3drop t ] [ - 1 pick buffer-consume pick sbuf-append - read-line-loop + pick sbuf-append read-line-loop ] ifte ] ifte ; @@ -85,7 +84,7 @@ GENERIC: refill* ( reader -- ) ] ifte ; : pop-line ( reader -- str ) - dup reader-line sbuf>string >r + dup reader-line dup [ sbuf>string ] when >r f over set-reader-line f swap set-reader-ready? r> ; diff --git a/library/words.factor b/library/words.factor index cf778d5924..777d8f54a0 100644 --- a/library/words.factor +++ b/library/words.factor @@ -86,17 +86,17 @@ global [ crossref set ] bind #! the crossref hash. crossref get closure ; -GENERIC: (undefine) ( word -- ) -M: word (undefine) drop ; +GENERIC: (uncrossref) ( word -- ) +M: word (uncrossref) drop ; -: undefine ( word -- ) - dup (undefine) usages [ (undefine) ] each ; +: uncrossref ( word -- ) + dup (uncrossref) usages [ (uncrossref) ] each ; ! The word primitive combined with the word def specify what the ! word does when invoked. : define ( word primitive parameter -- ) - pick undefine + pick uncrossref pick set-word-def over set-word-primitive f "parsing" set-word-prop ; diff --git a/native/error.c b/native/error.c index bc528c0227..5fcd8e21ba 100644 --- a/native/error.c +++ b/native/error.c @@ -54,7 +54,8 @@ void throw_error(CELL error, bool keep_stacks) void primitive_throw(void) { CELL error = dpop(); - throw_error(error,true); + if(error != F) + throw_error(error,true); } void primitive_die(void)