From a26c93ff4565451dc07e640cd0b0de8d749f494d Mon Sep 17 00:00:00 2001 From: slava Date: Mon, 3 Apr 2006 05:33:52 +0000 Subject: [PATCH] Cleanup compiler and some minor library code --- doc/handbook/collections.facts | 1 - library/alien/alien-invoke.factor | 3 +- library/bootstrap/boot-stage1.factor | 2 +- library/bootstrap/boot-stage2.factor | 4 +- library/collections/hashtables.factor | 3 - library/collections/hashtables.facts | 5 -- library/collections/slicing.factor | 3 +- library/compiler/intrinsics.factor | 4 +- library/compiler/linearizer.factor | 87 +++++++++----------- library/compiler/stack.factor | 68 ---------------- library/compiler/templates.factor | 103 ++++++++++++++++++++++++ library/compiler/vops.factor | 2 +- library/help/crossref.factor | 1 - library/io/null-stream.factor | 2 +- library/test/compiler/intrinsics.factor | 3 + library/test/io/io.factor | 2 + library/test/test.factor | 8 +- library/words.factor | 5 +- 18 files changed, 164 insertions(+), 142 deletions(-) delete mode 100644 library/compiler/stack.factor create mode 100644 library/compiler/templates.factor diff --git a/doc/handbook/collections.facts b/doc/handbook/collections.facts index b16c7b504e..bb35ca060a 100644 --- a/doc/handbook/collections.facts +++ b/doc/handbook/collections.facts @@ -52,7 +52,6 @@ ARTICLE: "hashtables-lookup" "Looking up keys in hashtables" ARTICLE: "hashtables-mutation" "Storing keys in hashtables" { $subsection set-hash } -{ $subsection ?set-hash } { $subsection remove-hash } { $subsection clear-hash } ; diff --git a/library/alien/alien-invoke.factor b/library/alien/alien-invoke.factor index 64500b44fa..98bd4067a0 100644 --- a/library/alien/alien-invoke.factor +++ b/library/alien/alien-invoke.factor @@ -74,7 +74,8 @@ M: alien-invoke stack-reserve* alien-invoke-parameters stack-space ; : parse-arglist ( return seq -- types stack-effect ) - unpair rot dup "void" = [ drop { } ] [ 1array ] if 2array + 2 swap group unpair + rot dup "void" = [ drop { } ] [ 1array ] if 2array effect>string ; : (define-c-word) ( type lib func types stack-effect -- ) diff --git a/library/bootstrap/boot-stage1.factor b/library/bootstrap/boot-stage1.factor index 4446b4029d..0fd7a1e16e 100644 --- a/library/bootstrap/boot-stage1.factor +++ b/library/bootstrap/boot-stage1.factor @@ -127,9 +127,9 @@ vectors words ; "/library/compiler/assembler.factor" "/library/compiler/vops.factor" + "/library/compiler/templates.factor" "/library/compiler/linearizer.factor" "/library/compiler/xt.factor" - "/library/compiler/stack.factor" "/library/compiler/intrinsics.factor" "/library/compiler/generator.factor" "/library/compiler/basic-blocks.factor" diff --git a/library/bootstrap/boot-stage2.factor b/library/bootstrap/boot-stage2.factor index df2814acba..0bc45c89da 100644 --- a/library/bootstrap/boot-stage2.factor +++ b/library/bootstrap/boot-stage2.factor @@ -5,8 +5,8 @@ kernel-internals lists math memory namespaces optimizer parser sequences sequences-internals words ; "Cross-referencing..." print -xref-words -xref-articles +H{ } clone crossref set-global xref-words +H{ } clone help-graph set-global xref-articles "compile" get [ "native-io" get [ diff --git a/library/collections/hashtables.factor b/library/collections/hashtables.factor index 85519d0d30..bd3e027fe7 100644 --- a/library/collections/hashtables.factor +++ b/library/collections/hashtables.factor @@ -235,9 +235,6 @@ M: hashtable hashcode ( hash -- n ) : ?hash* ( key hash/f -- value/f ) dup [ hash* ] [ 2drop f f ] if ; flushable -: ?set-hash ( value key hash/f -- hash ) - [ [ set-hash ] keep ] [ associate ] if ; - : hash-stack ( key seq -- value ) [ dupd hash-member? ] find-last nip ?hash ; flushable diff --git a/library/collections/hashtables.facts b/library/collections/hashtables.facts index c27f9b1bce..d39ed9c04a 100644 --- a/library/collections/hashtables.facts +++ b/library/collections/hashtables.facts @@ -146,11 +146,6 @@ HELP: set-hash "( value key hash -- )" { $description "Stores an entry into the hashtable." } { $see-also hash remove-hash } ; -HELP: ?set-hash "( value key hash/f -- hash )" -{ $values { "value" "a value" } { "key" "a key" } { "hash/f" "a hashtable or " { $link f } } } -{ $description "If the mapping is " { $link f } ", constructs a new hashtable storing the given key/value pair. Otherwise, stores the key/value pair into the hashtable." } -{ $see-also hash remove-hash } ; - HELP: hash-keys "( hash -- keys )" { $values { "hash" "a hashtable" } { "keys" "an array of keys" } } { $description "Outputs an array of all keys in the hashtable." } diff --git a/library/collections/slicing.factor b/library/collections/slicing.factor index 7099e80d7e..3784cab3c6 100644 --- a/library/collections/slicing.factor +++ b/library/collections/slicing.factor @@ -104,8 +104,7 @@ strings vectors ; tuck swap tail-slice >r swap tail-slice r> ; : unpair ( seq -- firsts seconds ) - 2 swap group flip - dup empty? [ drop { } { } ] [ first2 ] if ; + flip dup empty? [ drop { } { } ] [ first2 ] if ; : concat ( seq -- seq ) dup empty? [ [ [ % ] each ] over first make ] unless ; diff --git a/library/compiler/intrinsics.factor b/library/compiler/intrinsics.factor index 4b33371349..50fec8c080 100644 --- a/library/compiler/intrinsics.factor +++ b/library/compiler/intrinsics.factor @@ -77,13 +77,13 @@ namespaces sequences words ; \ getenv [ { { f "env" } } { "out" } [ T{ vreg f 0 } "out" set - "out" get "env" get %getenv , + "env" get "out" get %getenv , ] with-template ] "intrinsic" set-word-prop \ setenv [ { { 0 "value" } { f "env" } } { } [ - "env" get "value" get %setenv , + "value" get "env" get %setenv , ] with-template ] "intrinsic" set-word-prop diff --git a/library/compiler/linearizer.factor b/library/compiler/linearizer.factor index c97ff52e4d..7a7c98e9ef 100644 --- a/library/compiler/linearizer.factor +++ b/library/compiler/linearizer.factor @@ -58,11 +58,7 @@ SYMBOL: renamed-labels M: node linearize* ( node -- next ) drop iterate-next ; : linearize-call ( label -- next ) - tail-call? [ - %jump , f - ] [ - %call , iterate-next - ] if ; + tail-call? [ %jump , f ] [ %call , iterate-next ] if ; : rename-label ( label -- label )