From 4f0a9f311e13a2007acae2f82949ec0ca500853d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 8 Dec 2008 14:58:00 -0600 Subject: [PATCH] Untangling some dependencies --- basis/alien/prettyprint/prettyprint.factor | 14 ++++ basis/alien/syntax/syntax.factor | 12 +--- basis/bit-arrays/bit-arrays.factor | 2 +- basis/bit-vectors/bit-vectors.factor | 2 +- basis/bootstrap/bootstrap-error.factor | 8 +++ basis/bootstrap/compiler/compiler.factor | 11 ++- basis/bootstrap/finish-bootstrap.factor | 16 +++++ basis/bootstrap/finish-staging.factor | 10 +++ basis/bootstrap/math/math.factor | 4 +- basis/bootstrap/stage2.factor | 29 +++----- basis/byte-vectors/byte-vectors.factor | 2 +- basis/checksums/md5/md5.factor | 4 +- basis/checksums/openssl/openssl.factor | 5 +- basis/checksums/sha1/sha1.factor | 5 +- basis/checksums/stream/stream.factor | 12 ++++ basis/command-line/command-line.factor | 21 +----- .../alias-analysis-tests.factor | 4 +- .../cfg/dead-code/dead-code-tests.factor | 3 +- basis/compiler/cfg/debugger/debugger.factor | 20 +++++- basis/compiler/cfg/registers/registers.factor | 17 +---- .../value-numbering-tests.factor | 5 +- .../write-barrier/write-barrier-tests.factor | 3 +- basis/compiler/codegen/fixup/fixup.factor | 10 +-- basis/compiler/compiler.factor | 21 +++--- basis/compiler/tree/debugger/debugger.factor | 5 +- basis/debugger/debugger.factor | 6 +- basis/help/definitions/definitions.factor | 3 +- basis/help/lint/lint.factor | 2 +- basis/io/styles/styles.factor | 10 ++- basis/locals/locals.factor | 6 +- basis/math/complex/complex.factor | 8 +-- .../complex/prettyprint/prettyprint.factor | 8 +++ basis/nibble-arrays/nibble-arrays.factor | 2 +- basis/persistent/hashtables/hashtables.factor | 2 +- basis/persistent/vectors/vectors.factor | 2 +- basis/prettyprint/backend/backend-docs.factor | 8 +-- basis/prettyprint/backend/backend.factor | 21 ++---- basis/prettyprint/custom/custom-docs.factor | 9 +++ basis/prettyprint/custom/custom.factor | 9 +++ basis/prettyprint/prettyprint-docs.factor | 2 +- basis/prettyprint/prettyprint.factor | 15 +++-- basis/qualified/qualified.factor | 2 +- basis/regexp/regexp.factor | 10 +-- .../specialized-arrays/functor/functor.factor | 2 +- .../functor/functor.factor | 2 +- basis/stack-checker/backend/backend.factor | 12 ++-- basis/stack-checker/errors/errors.factor | 67 +------------------ .../errors/prettyprint/prettyprint.factor | 67 +++++++++++++++++++ .../known-words/known-words.factor | 2 +- basis/summary/summary.factor | 13 +--- basis/tools/deploy/backend/backend.factor | 11 ++- basis/tools/deploy/config/config-docs.factor | 29 +------- basis/tools/deploy/config/config.factor | 20 +----- .../deploy/config/editor/editor-docs.factor | 27 ++++++++ .../tools/deploy/config/editor/editor.factor | 20 ++++++ basis/tools/deploy/deploy-docs.factor | 5 ++ basis/tools/deploy/shaker/shaker.factor | 34 +++------- .../disassembler/disassembler-tests.factor | 4 +- basis/urls/urls.factor | 6 +- basis/vlists/vlists.factor | 2 +- core/bootstrap/primitives.factor | 1 - core/bootstrap/stage1.factor | 2 +- core/bootstrap/syntax.factor | 1 - core/checksums/checksums.factor | 7 +- core/classes/algebra/algebra-docs.factor | 1 + core/growable/growable-docs.factor | 2 +- core/syntax/syntax.factor | 18 +++-- 67 files changed, 386 insertions(+), 339 deletions(-) create mode 100644 basis/alien/prettyprint/prettyprint.factor create mode 100644 basis/bootstrap/bootstrap-error.factor create mode 100644 basis/bootstrap/finish-bootstrap.factor create mode 100644 basis/bootstrap/finish-staging.factor create mode 100644 basis/checksums/stream/stream.factor create mode 100644 basis/math/complex/prettyprint/prettyprint.factor create mode 100644 basis/prettyprint/custom/custom-docs.factor create mode 100644 basis/prettyprint/custom/custom.factor create mode 100644 basis/stack-checker/errors/prettyprint/prettyprint.factor create mode 100644 basis/tools/deploy/config/editor/editor-docs.factor create mode 100644 basis/tools/deploy/config/editor/editor.factor diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor new file mode 100644 index 0000000000..0794ab7789 --- /dev/null +++ b/basis/alien/prettyprint/prettyprint.factor @@ -0,0 +1,14 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel combinators alien alien.strings alien.syntax +prettyprint.backend prettyprint.custom prettyprint.sections ; +IN: alien.prettyprint + +M: alien pprint* + { + { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] } + { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] } + [ \ ALIEN: [ alien-address pprint* ] pprint-prefix ] + } cond ; + +M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ; diff --git a/basis/alien/syntax/syntax.factor b/basis/alien/syntax/syntax.factor index d10c97cd3d..b0ba10a316 100644 --- a/basis/alien/syntax/syntax.factor +++ b/basis/alien/syntax/syntax.factor @@ -3,8 +3,7 @@ USING: accessors arrays alien alien.c-types alien.structs alien.arrays alien.strings kernel math namespaces parser sequences words quotations math.parser splitting grouping -effects prettyprint prettyprint.sections prettyprint.backend -assocs combinators lexer strings.parser alien.parser ; +effects assocs combinators lexer strings.parser alien.parser ; IN: alien.syntax : DLL" lexer get skip-blank parse-string dlopen parsed ; parsing @@ -34,12 +33,3 @@ IN: alien.syntax dup length [ [ create-in ] dip 1quotation define ] 2each ; parsing - -M: alien pprint* - { - { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] } - { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] } - [ \ ALIEN: [ alien-address pprint* ] pprint-prefix ] - } cond ; - -M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ; diff --git a/basis/bit-arrays/bit-arrays.factor b/basis/bit-arrays/bit-arrays.factor index 4cb2032f4f..d5e94f0238 100644 --- a/basis/bit-arrays/bit-arrays.factor +++ b/basis/bit-arrays/bit-arrays.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: alien.c-types accessors math alien.accessors kernel kernel.private locals sequences sequences.private byte-arrays -parser prettyprint.backend fry ; +parser prettyprint.custom fry ; IN: bit-arrays TUPLE: bit-array diff --git a/basis/bit-vectors/bit-vectors.factor b/basis/bit-vectors/bit-vectors.factor index 404b26829b..85bea80b2d 100644 --- a/basis/bit-vectors/bit-vectors.factor +++ b/basis/bit-vectors/bit-vectors.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel kernel.private math sequences -sequences.private growable bit-arrays prettyprint.backend +sequences.private growable bit-arrays prettyprint.custom parser accessors ; IN: bit-vectors diff --git a/basis/bootstrap/bootstrap-error.factor b/basis/bootstrap/bootstrap-error.factor new file mode 100644 index 0000000000..01eb002e44 --- /dev/null +++ b/basis/bootstrap/bootstrap-error.factor @@ -0,0 +1,8 @@ +USING: continuations kernel io debugger vocabs words system namespaces ; + +:c +:error +"listener" vocab +[ restarts. vocab-main execute ] +[ die ] if* +1 exit diff --git a/basis/bootstrap/compiler/compiler.factor b/basis/bootstrap/compiler/compiler.factor index 9968af4330..f0d9e8e131 100644 --- a/basis/bootstrap/compiler/compiler.factor +++ b/basis/bootstrap/compiler/compiler.factor @@ -5,17 +5,22 @@ sequences namespaces parser kernel kernel.private classes classes.private arrays hashtables vectors classes.tuple sbufs hashtables.private sequences.private math classes.tuple.private growable namespaces.private assocs words command-line vocabs io -io.encodings.string prettyprint libc splitting math.parser +io.encodings.string libc splitting math.parser compiler.units math.order compiler.tree.builder compiler.tree.optimizer compiler.cfg.optimizer ; IN: bootstrap.compiler ! Don't bring this in when deploying, since it will store a ! reference to 'eval' in a global variable -"deploy-vocab" get [ +"deploy-vocab" get "staging" get or [ "alien.remote-control" require ] unless +"prettyprint" vocab [ + "stack-checker.errors.prettyprint" require + "alien.prettyprint" require +] when + "cpu." cpu name>> append require enable-compiler @@ -86,7 +91,7 @@ nl "." write flush { - . malloc calloc free memcpy + malloc calloc free memcpy } compile-uncompiled "." write flush diff --git a/basis/bootstrap/finish-bootstrap.factor b/basis/bootstrap/finish-bootstrap.factor new file mode 100644 index 0000000000..133b64acaa --- /dev/null +++ b/basis/bootstrap/finish-bootstrap.factor @@ -0,0 +1,16 @@ +USING: init command-line debugger system continuations +namespaces eval kernel vocabs.loader io ; + +[ + boot + do-init-hooks + [ + (command-line) parse-command-line + load-vocab-roots + run-user-init + "e" get [ eval ] when* + ignore-cli-args? not script get and + [ run-script ] [ "run" get run ] if* + output-stream get [ stream-flush ] when* + ] [ print-error 1 exit ] recover +] set-boot-quot diff --git a/basis/bootstrap/finish-staging.factor b/basis/bootstrap/finish-staging.factor new file mode 100644 index 0000000000..a60ce04e15 --- /dev/null +++ b/basis/bootstrap/finish-staging.factor @@ -0,0 +1,10 @@ +USING: init command-line system namespaces kernel vocabs.loader +io ; + +[ + boot + do-init-hooks + (command-line) parse-command-line + "run" get run + output-stream get [ stream-flush ] when* +] set-boot-quot diff --git a/basis/bootstrap/math/math.factor b/basis/bootstrap/math/math.factor index a293efd33e..347969af0d 100644 --- a/basis/bootstrap/math/math.factor +++ b/basis/bootstrap/math/math.factor @@ -1,5 +1,7 @@ -USE: vocabs.loader +USING: vocabs vocabs.loader kernel ; "math.ratios" require "math.floats" require "math.complex" require + +"prettyprint" vocab [ "math.complex.prettyprint" require ] when diff --git a/basis/bootstrap/stage2.factor b/basis/bootstrap/stage2.factor index 4ab36ec94e..78355a4670 100644 --- a/basis/bootstrap/stage2.factor +++ b/basis/bootstrap/stage2.factor @@ -2,10 +2,10 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors init namespaces words io kernel.private math memory continuations kernel io.files -io.backend system parser vocabs sequences prettyprint +io.backend system parser vocabs sequences vocabs.loader combinators splitting source-files strings definitions assocs compiler.errors compiler.units -math.parser generic sets debugger command-line ; +math.parser generic sets command-line ; IN: bootstrap.stage2 SYMBOL: core-bootstrap-time @@ -86,25 +86,18 @@ SYMBOL: bootstrap-time f error set-global f error-continuation set-global + millis swap - bootstrap-time set-global + print-report + "deploy-vocab" get [ "tools.deploy.shaker" run ] [ - [ - boot - do-init-hooks - handle-command-line - ] set-boot-quot - - millis swap - bootstrap-time set-global - print-report + "staging" get [ + "resource:basis/bootstrap/finish-staging.factor" run-file + ] [ + "resource:basis/bootstrap/finish-bootstrap.factor" run-file + ] if "output-image" get save-image-and-exit ] if -] [ - :c - dup print-error flush - "listener" vocab - [ restarts. vocab-main execute ] - [ die ] if* - 1 exit -] recover +] [ drop "resource:basis/bootstrap/bootstrap-error.factor" run-file ] recover diff --git a/basis/byte-vectors/byte-vectors.factor b/basis/byte-vectors/byte-vectors.factor index b2c0d55c0f..e24c808bbc 100644 --- a/basis/byte-vectors/byte-vectors.factor +++ b/basis/byte-vectors/byte-vectors.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel kernel.private math sequences sequences.private growable byte-arrays accessors parser -prettyprint.backend ; +prettyprint.custom ; IN: byte-vectors TUPLE: byte-vector diff --git a/basis/checksums/md5/md5.factor b/basis/checksums/md5/md5.factor index 257fd930c4..d919b0e313 100644 --- a/basis/checksums/md5/md5.factor +++ b/basis/checksums/md5/md5.factor @@ -4,7 +4,7 @@ USING: kernel io io.binary io.files io.streams.byte-array math math.functions math.parser namespaces splitting grouping strings sequences byte-arrays locals sequences.private io.encodings.binary symbols math.bitwise checksums -checksums.common ; +checksums.common checksums.stream ; IN: checksums.md5 ! See http://www.faqs.org/rfcs/rfc1321.html @@ -180,7 +180,7 @@ PRIVATE> SINGLETON: md5 -INSTANCE: md5 checksum +INSTANCE: md5 stream-checksum M: md5 checksum-stream ( stream -- byte-array ) drop [ initialize-md5 stream>md5 get-md5 ] with-input-stream ; diff --git a/basis/checksums/openssl/openssl.factor b/basis/checksums/openssl/openssl.factor index 821cbe2f3a..4bc7a7964a 100644 --- a/basis/checksums/openssl/openssl.factor +++ b/basis/checksums/openssl/openssl.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008 Slava Pestov ! See http://factorcode.org/license.txt for BSD license. USING: accessors byte-arrays alien.c-types kernel continuations -destructors sequences io openssl openssl.libcrypto checksums ; +destructors sequences io openssl openssl.libcrypto checksums +checksums.stream ; IN: checksums.openssl ERROR: unknown-digest name ; @@ -12,7 +13,7 @@ TUPLE: openssl-checksum name ; : openssl-sha1 T{ openssl-checksum f "sha1" } ; -INSTANCE: openssl-checksum checksum +INSTANCE: openssl-checksum stream-checksum C: openssl-checksum diff --git a/basis/checksums/sha1/sha1.factor b/basis/checksums/sha1/sha1.factor index 3767af7c55..6cdc9270aa 100644 --- a/basis/checksums/sha1/sha1.factor +++ b/basis/checksums/sha1/sha1.factor @@ -3,7 +3,8 @@ USING: arrays combinators kernel io io.encodings.binary io.files io.streams.byte-array math.vectors strings sequences namespaces make math parser sequences assocs grouping vectors io.binary -hashtables symbols math.bitwise checksums checksums.common ; +hashtables symbols math.bitwise checksums checksums.common +checksums.stream ; IN: checksums.sha1 ! Implemented according to RFC 3174. @@ -113,7 +114,7 @@ SYMBOLS: h0 h1 h2 h3 h4 A B C D E w K ; SINGLETON: sha1 -INSTANCE: sha1 checksum +INSTANCE: sha1 stream-checksum M: sha1 checksum-stream ( stream -- sha1 ) drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ; diff --git a/basis/checksums/stream/stream.factor b/basis/checksums/stream/stream.factor new file mode 100644 index 0000000000..e753467323 --- /dev/null +++ b/basis/checksums/stream/stream.factor @@ -0,0 +1,12 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io.encodings.binary io.streams.byte-array kernel +checksums ; +IN: checksums.stream + +MIXIN: stream-checksum + +M: stream-checksum checksum-bytes + [ binary ] dip checksum-stream ; + +INSTANCE: stream-checksum checksum diff --git a/basis/command-line/command-line.factor b/basis/command-line/command-line.factor index 1b58053b64..7d5a041951 100644 --- a/basis/command-line/command-line.factor +++ b/basis/command-line/command-line.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: init continuations debugger hashtables io -io.encodings.utf8 io.files kernel kernel.private namespaces -parser sequences strings system splitting eval vocabs.loader ; +USING: init continuations hashtables io io.encodings.utf8 +io.files kernel kernel.private namespaces parser sequences +strings system splitting vocabs.loader ; IN: command-line SYMBOL: script @@ -31,8 +31,6 @@ SYMBOL: command-line ] [ drop ] if ] when ; - - : parse-command-line ( args -- ) [ command-line off script off ] [ unclip "-" ?head @@ -76,15 +72,4 @@ SYMBOL: main-vocab-hook : script-mode ( -- ) ; -: handle-command-line ( -- ) - [ - (command-line) parse-command-line - load-vocab-roots - run-user-init - "e" get [ eval ] when* - ignore-cli-args? not script get and - [ run-script ] [ "run" get run ] if* - output-stream get [ stream-flush ] when* - ] [ print-error 1 exit ] recover ; - [ default-cli-args ] "command-line" add-init-hook diff --git a/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor b/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor index c7094c8c36..d8bad5ec41 100644 --- a/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor +++ b/basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor @@ -1,6 +1,6 @@ USING: compiler.cfg.instructions compiler.cfg.registers -compiler.cfg.alias-analysis cpu.architecture tools.test -kernel ; +compiler.cfg.alias-analysis compiler.cfg.debugger +cpu.architecture tools.test kernel ; IN: compiler.cfg.alias-analysis.tests [ ] [ diff --git a/basis/compiler/cfg/dead-code/dead-code-tests.factor b/basis/compiler/cfg/dead-code/dead-code-tests.factor index b9c3af5215..ee7d8d2a43 100644 --- a/basis/compiler/cfg/dead-code/dead-code-tests.factor +++ b/basis/compiler/cfg/dead-code/dead-code-tests.factor @@ -1,5 +1,6 @@ USING: compiler.cfg.dead-code compiler.cfg.instructions -compiler.cfg.registers cpu.architecture tools.test ; +compiler.cfg.registers compiler.cfg.debugger +cpu.architecture tools.test ; IN: compiler.cfg.dead-code.tests [ { } ] [ diff --git a/basis/compiler/cfg/debugger/debugger.factor b/basis/compiler/cfg/debugger/debugger.factor index 7b1b9100c4..ba58e60a4a 100644 --- a/basis/compiler/cfg/debugger/debugger.factor +++ b/basis/compiler/cfg/debugger/debugger.factor @@ -2,10 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel words sequences quotations namespaces io classes.tuple accessors prettyprint prettyprint.config -compiler.tree.builder compiler.tree.optimizer +prettyprint.backend prettyprint.custom prettyprint.sections +parser compiler.tree.builder compiler.tree.optimizer compiler.cfg.builder compiler.cfg.linearization -compiler.cfg.stack-frame compiler.cfg.linear-scan -compiler.cfg.two-operand compiler.cfg.optimizer ; +compiler.cfg.registers compiler.cfg.stack-frame +compiler.cfg.linear-scan compiler.cfg.two-operand +compiler.cfg.optimizer ; IN: compiler.cfg.debugger GENERIC: test-cfg ( quot -- cfgs ) @@ -40,3 +42,15 @@ SYMBOL: allocate-registers? instructions>> [ insn. ] each nl ] each ; + +! Prettyprinting +M: vreg pprint* + > pprint* ] [ n>> pprint* ] bi + block> ; + +: pprint-loc ( loc word -- ) > pprint* block> ; + +M: ds-loc pprint* \ D pprint-loc ; + +M: rs-loc pprint* \ R pprint-loc ; diff --git a/basis/compiler/cfg/registers/registers.factor b/basis/compiler/cfg/registers/registers.factor index 21572ec615..2b9d3df6f6 100644 --- a/basis/compiler/cfg/registers/registers.factor +++ b/basis/compiler/cfg/registers/registers.factor @@ -1,7 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors namespaces kernel arrays -parser prettyprint.backend prettyprint.sections ; +USING: accessors namespaces kernel arrays parser ; IN: compiler.cfg.registers ! Virtual registers, used by CFG and machine IRs @@ -18,20 +17,6 @@ C: ds-loc TUPLE: rs-loc < loc ; C: rs-loc -! Prettyprinting : V scan-word scan-word vreg boa parsed ; parsing - -M: vreg pprint* - > pprint* ] [ n>> pprint* ] bi - block> ; - -: pprint-loc ( loc word -- ) > pprint* block> ; - : D scan-word parsed ; parsing - -M: ds-loc pprint* \ D pprint-loc ; - : R scan-word parsed ; parsing - -M: rs-loc pprint* \ R pprint-loc ; diff --git a/basis/compiler/cfg/value-numbering/value-numbering-tests.factor b/basis/compiler/cfg/value-numbering/value-numbering-tests.factor index 8adeaa21f4..641ccceb5d 100644 --- a/basis/compiler/cfg/value-numbering/value-numbering-tests.factor +++ b/basis/compiler/cfg/value-numbering/value-numbering-tests.factor @@ -1,7 +1,8 @@ IN: compiler.cfg.value-numbering.tests USING: compiler.cfg.value-numbering compiler.cfg.instructions -compiler.cfg.registers cpu.architecture tools.test kernel math -combinators.short-circuit accessors sequences ; +compiler.cfg.registers compiler.cfg.debugger cpu.architecture +tools.test kernel math combinators.short-circuit accessors +sequences ; : trim-temps ( insns -- insns ) [ diff --git a/basis/compiler/cfg/write-barrier/write-barrier-tests.factor b/basis/compiler/cfg/write-barrier/write-barrier-tests.factor index 7a4b1c488f..73748dbc37 100644 --- a/basis/compiler/cfg/write-barrier/write-barrier-tests.factor +++ b/basis/compiler/cfg/write-barrier/write-barrier-tests.factor @@ -1,5 +1,6 @@ USING: compiler.cfg.write-barrier compiler.cfg.instructions -compiler.cfg.registers cpu.architecture arrays tools.test ; +compiler.cfg.registers compiler.cfg.debugger cpu.architecture +arrays tools.test ; IN: compiler.cfg.write-barrier.tests [ diff --git a/basis/compiler/codegen/fixup/fixup.factor b/basis/compiler/codegen/fixup/fixup.factor index a56ae04a7b..e0f391deb5 100755 --- a/basis/compiler/codegen/fixup/fixup.factor +++ b/basis/compiler/codegen/fixup/fixup.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays byte-arrays generic assocs hashtables io.binary -kernel kernel.private math namespaces make sequences words -quotations strings alien.accessors alien.strings layouts system -combinators math.bitwise words.private math.order accessors -growable cpu.architecture compiler.constants ; +USING: arrays byte-arrays byte-vectors generic assocs hashtables +io.binary kernel kernel.private math namespaces make sequences +words quotations strings alien.accessors alien.strings layouts +system combinators math.bitwise words.private math.order +accessors growable cpu.architecture compiler.constants ; IN: compiler.codegen.fixup GENERIC: fixup* ( obj -- ) diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index e5cbd888d9..0d24daef71 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -1,15 +1,14 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel namespaces arrays sequences io debugger -words fry continuations vocabs assocs dlists definitions -math threads graphs generic combinators deques search-deques -prettyprint io stack-checker stack-checker.state -stack-checker.inlining compiler.errors compiler.units -compiler.tree.builder compiler.tree.optimizer -compiler.cfg.builder compiler.cfg.optimizer -compiler.cfg.linearization compiler.cfg.two-operand -compiler.cfg.linear-scan compiler.cfg.stack-frame -compiler.codegen ; +USING: accessors kernel namespaces arrays sequences io +words fry continuations vocabs assocs dlists definitions math +threads graphs generic combinators deques search-deques io +stack-checker stack-checker.state stack-checker.inlining +compiler.errors compiler.units compiler.tree.builder +compiler.tree.optimizer compiler.cfg.builder +compiler.cfg.optimizer compiler.cfg.linearization +compiler.cfg.two-operand compiler.cfg.linear-scan +compiler.cfg.stack-frame compiler.codegen ; IN: compiler SYMBOL: compile-queue @@ -45,7 +44,7 @@ SYMBOL: +failed+ 2bi ; : start ( word -- ) - "trace-compilation" get [ dup . flush ] when + "trace-compilation" get [ dup name>> print flush ] when H{ } clone dependencies set H{ } clone generic-dependencies set f swap compiler-error ; diff --git a/basis/compiler/tree/debugger/debugger.factor b/basis/compiler/tree/debugger/debugger.factor index 8d764a2833..8a2823010d 100644 --- a/basis/compiler/tree/debugger/debugger.factor +++ b/basis/compiler/tree/debugger/debugger.factor @@ -2,8 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel assocs match fry accessors namespaces make effects sequences sequences.private quotations generic macros arrays -prettyprint prettyprint.backend prettyprint.sections math words -combinators combinators.short-circuit io sorting hints qualified +prettyprint prettyprint.backend prettyprint.custom +prettyprint.sections math words combinators +combinators.short-circuit io sorting hints qualified compiler.tree compiler.tree.recursive compiler.tree.normalization diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 35b09713d3..4e0c4e8840 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -22,9 +22,6 @@ M: tuple error-help class ; M: string error. print ; -: :error ( -- ) - error get error. ; - : :s ( -- ) error-continuation get data>> stack. ; @@ -63,6 +60,9 @@ M: string error. print ; [ global [ "Error in print-error!" print drop ] bind ] recover ; +: :error ( -- ) + error get print-error ; + : print-error-and-restarts ( error -- ) print-error restarts. diff --git a/basis/help/definitions/definitions.factor b/basis/help/definitions/definitions.factor index e5202e1306..3e4066d8b7 100644 --- a/basis/help/definitions/definitions.factor +++ b/basis/help/definitions/definitions.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors definitions help help.topics help.syntax -prettyprint.backend prettyprint words kernel effects ; +prettyprint.backend prettyprint.custom prettyprint words kernel +effects ; IN: help.definitions ! Definition protocol implementation diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 0a392733ac..fbebc7f0f6 100644 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -150,7 +150,7 @@ M: help-error error. ] [ [ swap vocab-heading. - [ error. nl ] each + [ print-error nl ] each ] assoc-each ] if-empty ; diff --git a/basis/io/styles/styles.factor b/basis/io/styles/styles.factor index c9ba8f66df..e07753c640 100644 --- a/basis/io/styles/styles.factor +++ b/basis/io/styles/styles.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2005, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: hashtables io colors ; +USING: hashtables io colors summary make accessors splitting +kernel ; IN: io.styles SYMBOL: plain @@ -43,4 +44,11 @@ TUPLE: input string ; C: input +M: input summary + [ + "Input: " % + string>> "\n" split1 swap % + "..." "" ? % + ] "" make ; + : write-object ( str obj -- ) presented associate format ; diff --git a/basis/locals/locals.factor b/basis/locals/locals.factor index b78b95bc24..80bafb0b55 100644 --- a/basis/locals/locals.factor +++ b/basis/locals/locals.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces make sequences sequences.private assocs math vectors strings classes.tuple generalizations parser words -quotations debugger macros arrays macros splitting combinators -prettyprint.backend definitions prettyprint hashtables -prettyprint.sections sets sequences.private effects +quotations macros arrays macros splitting combinators +prettyprint.backend prettyprint.custom definitions prettyprint +hashtables prettyprint.sections sets sequences.private effects effects.parser generic generic.parser compiler.units accessors locals.backend memoize macros.expander lexer classes summary fry fry.private ; diff --git a/basis/math/complex/complex.factor b/basis/math/complex/complex.factor index c228684e32..90713cd40f 100644 --- a/basis/math/complex/complex.factor +++ b/basis/math/complex/complex.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel kernel.private math math.private -math.libm math.functions prettyprint.backend arrays -math.functions.private sequences parser ; +math.libm math.functions arrays math.functions.private sequences +parser ; IN: math.complex.private M: real real-part ; @@ -47,7 +47,3 @@ M: complex sqrt >polar [ fsqrt ] [ 2.0 / ] bi* polar> ; IN: syntax : C{ \ } [ first2 rect> ] parse-literal ; parsing - -M: complex pprint-delims drop \ C{ \ } ; -M: complex >pprint-sequence >rect 2array ; -M: complex pprint* pprint-object ; diff --git a/basis/math/complex/prettyprint/prettyprint.factor b/basis/math/complex/prettyprint/prettyprint.factor new file mode 100644 index 0000000000..09eeb8045c --- /dev/null +++ b/basis/math/complex/prettyprint/prettyprint.factor @@ -0,0 +1,8 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: math math.functions arrays prettyprint.custom kernel ; +IN: math.complex.prettyprint + +M: complex pprint* pprint-object ; +M: complex pprint-delims drop \ C{ \ } ; +M: complex >pprint-sequence >rect 2array ; diff --git a/basis/nibble-arrays/nibble-arrays.factor b/basis/nibble-arrays/nibble-arrays.factor index c753d0fb78..82643bef15 100644 --- a/basis/nibble-arrays/nibble-arrays.factor +++ b/basis/nibble-arrays/nibble-arrays.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: math kernel sequences sequences.private byte-arrays -alien.c-types prettyprint.backend parser accessors ; +alien.c-types prettyprint.custom parser accessors ; IN: nibble-arrays TUPLE: nibble-array diff --git a/basis/persistent/hashtables/hashtables.factor b/basis/persistent/hashtables/hashtables.factor index e50fd52c10..8c80782a2e 100644 --- a/basis/persistent/hashtables/hashtables.factor +++ b/basis/persistent/hashtables/hashtables.factor @@ -1,7 +1,7 @@ ! Based on Clojure's PersistentHashMap by Rich Hickey. USING: kernel math accessors assocs fry combinators parser -prettyprint.backend make +prettyprint.custom make persistent.assocs persistent.hashtables.nodes persistent.hashtables.nodes.empty diff --git a/basis/persistent/vectors/vectors.factor b/basis/persistent/vectors/vectors.factor index 92b3f82a54..cd8e7c49e0 100644 --- a/basis/persistent/vectors/vectors.factor +++ b/basis/persistent/vectors/vectors.factor @@ -1,7 +1,7 @@ ! Based on Clojure's PersistentVector by Rich Hickey. USING: math accessors kernel sequences.private sequences arrays -combinators combinators.short-circuit parser prettyprint.backend +combinators combinators.short-circuit parser prettyprint.custom persistent.sequences ; IN: persistent.vectors diff --git a/basis/prettyprint/backend/backend-docs.factor b/basis/prettyprint/backend/backend-docs.factor index 64e1fd45ff..165621887f 100644 --- a/basis/prettyprint/backend/backend-docs.factor +++ b/basis/prettyprint/backend/backend-docs.factor @@ -1,14 +1,10 @@ USING: help.markup help.syntax io kernel -prettyprint.config prettyprint.sections words strings ; +prettyprint.config prettyprint.sections prettyprint.custom +words strings ; IN: prettyprint.backend ABOUT: "prettyprint-extension" -HELP: pprint* -{ $values { "obj" "an object" } } -{ $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." } -$prettyprinting-note ; - HELP: pprint-word { $values { "word" "a word" } } { $description "Adds a text section for the word. Unlike the " { $link word } " method of " { $link pprint* } ", this does not add a " { $link POSTPONE: POSTPONE: } " prefix to parsing words." } diff --git a/basis/prettyprint/backend/backend.factor b/basis/prettyprint/backend/backend.factor index 76c3918f63..92d039a15d 100644 --- a/basis/prettyprint/backend/backend.factor +++ b/basis/prettyprint/backend/backend.factor @@ -1,15 +1,13 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays byte-arrays byte-vectors generic -hashtables io assocs kernel math namespaces make sequences -strings sbufs io.styles vectors words prettyprint.config +USING: accessors arrays byte-arrays generic hashtables io assocs +kernel math namespaces make sequences strings sbufs io.styles +vectors words prettyprint.config prettyprint.custom prettyprint.sections quotations io io.files math.parser effects classes.tuple math.order classes.tuple.private classes combinators colors ; IN: prettyprint.backend -GENERIC: pprint* ( obj -- ) - M: effect pprint* effect>string "(" ")" surround text ; : ?effect-height ( word -- n ) @@ -161,26 +159,19 @@ M: tuple pprint* [ [ pprint* ] each ] dip [ "~" swap number>string " more~" 3append text ] when* ; -GENERIC: pprint-delims ( obj -- start end ) - M: quotation pprint-delims drop \ [ \ ] ; M: curry pprint-delims drop \ [ \ ] ; M: compose pprint-delims drop \ [ \ ] ; M: array pprint-delims drop \ { \ } ; M: byte-array pprint-delims drop \ B{ \ } ; -M: byte-vector pprint-delims drop \ BV{ \ } ; M: vector pprint-delims drop \ V{ \ } ; M: hashtable pprint-delims drop \ H{ \ } ; M: tuple pprint-delims drop \ T{ \ } ; M: wrapper pprint-delims drop \ W{ \ } ; M: callstack pprint-delims drop \ CS{ \ } ; -GENERIC: >pprint-sequence ( obj -- seq ) - M: object >pprint-sequence ; - M: vector >pprint-sequence ; -M: byte-vector >pprint-sequence ; M: curry >pprint-sequence ; M: compose >pprint-sequence ; M: hashtable >pprint-sequence >alist ; @@ -191,16 +182,13 @@ M: tuple >pprint-sequence [ class ] [ tuple-slots ] bi [ 1array ] [ [ f 2array ] dip append ] if-empty ; -GENERIC: pprint-narrow? ( obj -- ? ) - M: object pprint-narrow? drop f ; - M: array pprint-narrow? drop t ; M: vector pprint-narrow? drop t ; M: hashtable pprint-narrow? drop t ; M: tuple pprint-narrow? drop t ; -: pprint-object ( obj -- ) +M: object pprint-object ( obj -- ) [ pprint-sequence ( obj -- seq ) +GENERIC: pprint-narrow? ( obj -- ? ) diff --git a/basis/prettyprint/prettyprint-docs.factor b/basis/prettyprint/prettyprint-docs.factor index 3c004e5b30..46d4e6e5ff 100644 --- a/basis/prettyprint/prettyprint-docs.factor +++ b/basis/prettyprint/prettyprint-docs.factor @@ -1,4 +1,4 @@ -USING: prettyprint.backend prettyprint.config +USING: prettyprint.backend prettyprint.config prettyprint.custom prettyprint.sections prettyprint.private help.markup help.syntax io kernel words definitions quotations strings generic classes ; IN: prettyprint diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 7c4de1e973..9d5af9e6a5 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -2,12 +2,13 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays generic generic.standard assocs io kernel math namespaces make sequences strings io.styles io.streams.string -vectors words prettyprint.backend prettyprint.sections -prettyprint.config sorting splitting grouping math.parser vocabs -definitions effects classes.builtin classes.tuple io.files -classes continuations hashtables classes.mixin classes.union -classes.intersection classes.predicate classes.singleton -combinators quotations sets accessors colors parser ; +vectors words prettyprint.backend prettyprint.custom +prettyprint.sections prettyprint.config sorting splitting +grouping math.parser vocabs definitions effects classes.builtin +classes.tuple io.files classes continuations hashtables +classes.mixin classes.union classes.intersection +classes.predicate classes.singleton combinators quotations sets +accessors colors parser summary ; IN: prettyprint : make-pprint ( obj quot -- block in use ) @@ -231,6 +232,8 @@ M: pathname synopsis* pprint* ; [ synopsis* ] with-in ] with-string-writer ; +M: word summary synopsis ; + : synopsis-alist ( definitions -- alist ) [ dup synopsis swap ] { } map>assoc ; diff --git a/basis/qualified/qualified.factor b/basis/qualified/qualified.factor index 25d04ed929..2cd64e90bf 100644 --- a/basis/qualified/qualified.factor +++ b/basis/qualified/qualified.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2007, 2008 Daniel Ehrenberg. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences assocs hashtables parser lexer -vocabs words namespaces vocabs.loader debugger sets fry ; +vocabs words namespaces vocabs.loader sets fry ; IN: qualified : define-qualified ( vocab-name prefix-name -- ) diff --git a/basis/regexp/regexp.factor b/basis/regexp/regexp.factor index b41e4d271e..c615719cc4 100644 --- a/basis/regexp/regexp.factor +++ b/basis/regexp/regexp.factor @@ -1,10 +1,10 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors combinators kernel math sequences strings -sets assocs prettyprint.backend make lexer namespaces parser -arrays fry regexp.backend regexp.utils regexp.parser regexp.nfa -regexp.dfa regexp.traversal regexp.transition-tables splitting -sorting ; +USING: accessors combinators kernel math sequences strings sets +assocs prettyprint.backend prettyprint.custom make lexer +namespaces parser arrays fry regexp.backend regexp.utils +regexp.parser regexp.nfa regexp.dfa regexp.traversal +regexp.transition-tables splitting sorting ; IN: regexp : default-regexp ( string -- regexp ) diff --git a/basis/specialized-arrays/functor/functor.factor b/basis/specialized-arrays/functor/functor.factor index 52977dc22a..2894649428 100644 --- a/basis/specialized-arrays/functor/functor.factor +++ b/basis/specialized-arrays/functor/functor.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: functors sequences sequences.private prettyprint.backend +USING: functors sequences sequences.private prettyprint.custom kernel words classes math parser alien.c-types byte-arrays accessors summary ; IN: specialized-arrays.functor diff --git a/basis/specialized-vectors/functor/functor.factor b/basis/specialized-vectors/functor/functor.factor index 0628f8b484..8ba5354dc4 100644 --- a/basis/specialized-vectors/functor/functor.factor +++ b/basis/specialized-vectors/functor/functor.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: functors sequences sequences.private growable -prettyprint.backend kernel words classes math parser ; +prettyprint.custom kernel words classes math parser ; IN: specialized-vectors.functor FUNCTOR: define-vector ( T -- ) diff --git a/basis/stack-checker/backend/backend.factor b/basis/stack-checker/backend/backend.factor index 7f8c920b19..147749864d 100644 --- a/basis/stack-checker/backend/backend.factor +++ b/basis/stack-checker/backend/backend.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: fry arrays generic io io.streams.string kernel math -namespaces parser prettyprint sequences strings vectors words -quotations effects classes continuations debugger assocs -combinators compiler.errors accessors math.order definitions -sets generic.standard.engines.tuple hints stack-checker.state -stack-checker.visitor stack-checker.errors -stack-checker.values stack-checker.recursive-state ; +namespaces parser sequences strings vectors words quotations +effects classes continuations assocs combinators +compiler.errors accessors math.order definitions sets +generic.standard.engines.tuple hints stack-checker.state +stack-checker.visitor stack-checker.errors stack-checker.values +stack-checker.recursive-state ; IN: stack-checker.backend : push-d ( obj -- ) meta-d push ; diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 5b6b3c0893..58944e7bc4 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2006, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: kernel generic sequences prettyprint io words arrays -summary effects debugger assocs accessors namespaces -compiler.errors stack-checker.values +USING: kernel generic sequences io words arrays summary effects +assocs accessors namespaces compiler.errors stack-checker.values stack-checker.recursive-state ; IN: stack-checker.errors @@ -10,8 +9,6 @@ TUPLE: inference-error error type word ; M: inference-error compiler-error-type type>> ; -M: inference-error error-help error>> error-help ; - : (inference-error) ( ... class type -- * ) [ boa ] dip recursive-state get word>> @@ -23,14 +20,8 @@ M: inference-error error-help error>> error-help ; : inference-warning ( ... class -- * ) +warning+ (inference-error) ; inline -M: inference-error error. - [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ; - TUPLE: literal-expected ; -M: literal-expected summary - drop "Literal value expected" ; - M: object (literal) \ literal-expected inference-warning ; TUPLE: unbalanced-branches-error branches quots ; @@ -38,79 +29,25 @@ TUPLE: unbalanced-branches-error branches quots ; : unbalanced-branches-error ( branches quots -- * ) \ unbalanced-branches-error inference-error ; -M: unbalanced-branches-error error. - "Unbalanced branches:" print - [ quots>> ] [ branches>> [ length ] { } assoc>map ] bi zip - [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; - TUPLE: too-many->r ; -M: too-many->r summary - drop - "Quotation pushes elements on retain stack without popping them" ; - TUPLE: too-many-r> ; -M: too-many-r> summary - drop - "Quotation pops retain stack elements which it did not push" ; - TUPLE: missing-effect word ; -M: missing-effect error. - "The word " write - word>> pprint - " must declare a stack effect" print ; - TUPLE: effect-error word inferred declared ; : effect-error ( word inferred declared -- * ) \ effect-error inference-error ; -M: effect-error error. - "Stack effects of the word " write - [ word>> pprint " do not match." print ] - [ "Inferred: " write inferred>> . ] - [ "Declared: " write declared>> . ] tri ; - TUPLE: recursive-quotation-error quot ; -M: recursive-quotation-error error. - "The quotation " write - quot>> pprint - " calls itself." print - "Stack effect inference is undecidable when quotation-level recursion is permitted." print ; - TUPLE: undeclared-recursion-error word ; -M: undeclared-recursion-error error. - "The inline recursive word " write - word>> pprint - " must be declared recursive" print ; - TUPLE: diverging-recursion-error word ; -M: diverging-recursion-error error. - "The recursive word " write - word>> pprint - " digs arbitrarily deep into the stack" print ; - TUPLE: unbalanced-recursion-error word height ; -M: unbalanced-recursion-error error. - "The recursive word " write - word>> pprint - " leaves with the stack having the wrong height" print ; - TUPLE: inconsistent-recursive-call-error word ; -M: inconsistent-recursive-call-error error. - "The recursive word " write - word>> pprint - " calls itself with a different set of quotation parameters than were input" print ; - TUPLE: unknown-primitive-error ; - -M: unknown-primitive-error error. - drop - "Cannot determine stack effect statically" print ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor new file mode 100644 index 0000000000..21c6d64402 --- /dev/null +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -0,0 +1,67 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors kernel prettyprint io debugger +sequences assocs stack-checker.errors summary effects ; +IN: stack-checker.errors.prettyprint + +M: inference-error error-help error>> error-help ; + +M: inference-error error. + [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ; + +M: literal-expected summary + drop "Literal value expected" ; + +M: unbalanced-branches-error error. + "Unbalanced branches:" print + [ quots>> ] [ branches>> [ length ] { } assoc>map ] bi zip + [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; + +M: too-many->r summary + drop + "Quotation pushes elements on retain stack without popping them" ; + +M: too-many-r> summary + drop + "Quotation pops retain stack elements which it did not push" ; + +M: missing-effect error. + "The word " write + word>> pprint + " must declare a stack effect" print ; + +M: effect-error error. + "Stack effects of the word " write + [ word>> pprint " do not match." print ] + [ "Inferred: " write inferred>> . ] + [ "Declared: " write declared>> . ] tri ; + +M: recursive-quotation-error error. + "The quotation " write + quot>> pprint + " calls itself." print + "Stack effect inference is undecidable when quotation-level recursion is permitted." print ; + +M: undeclared-recursion-error error. + "The inline recursive word " write + word>> pprint + " must be declared recursive" print ; + +M: diverging-recursion-error error. + "The recursive word " write + word>> pprint + " digs arbitrarily deep into the stack" print ; + +M: unbalanced-recursion-error error. + "The recursive word " write + word>> pprint + " leaves with the stack having the wrong height" print ; + +M: inconsistent-recursive-call-error error. + "The recursive word " write + word>> pprint + " calls itself with a different set of quotation parameters than were input" print ; + +M: unknown-primitive-error error. + drop + "Cannot determine stack effect statically" print ; diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 28634f2d44..0442d4c227 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -5,7 +5,7 @@ classes sequences.private continuations.private effects generic hashtables hashtables.private io io.backend io.files io.files.private io.streams.c kernel kernel.private math math.private memory namespaces namespaces.private parser -prettyprint quotations quotations.private sbufs sbufs.private +quotations quotations.private sbufs sbufs.private sequences sequences.private slots.private strings strings.private system threads.private classes.tuple classes.tuple.private vectors vectors.private words definitions diff --git a/basis/summary/summary.factor b/basis/summary/summary.factor index ea2c19fd6d..44e5374dc5 100644 --- a/basis/summary/summary.factor +++ b/basis/summary/summary.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors classes sequences splitting kernel namespaces -make words math math.parser io.styles prettyprint assocs ; +USING: accessors classes sequences kernel namespaces +make words math math.parser assocs ; IN: summary GENERIC: summary ( object -- string ) @@ -11,15 +11,6 @@ GENERIC: summary ( object -- string ) M: object summary object-summary ; -M: input summary - [ - "Input: " % - string>> "\n" split1 swap % - "..." "" ? % - ] "" make ; - -M: word summary synopsis ; - M: sequence summary [ dup class name>> % diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor index 18713c7b0c..f33e4840eb 100644 --- a/basis/tools/deploy/backend/backend.factor +++ b/basis/tools/deploy/backend/backend.factor @@ -5,8 +5,8 @@ assocs kernel vocabs words sequences memory io system arrays continuations math definitions mirrors splitting parser classes summary layouts vocabs.loader prettyprint.config prettyprint debugger io.streams.c io.files io.backend quotations io.launcher -words.private tools.deploy.config bootstrap.image -io.encodings.utf8 destructors accessors ; +words.private tools.deploy.config tools.deploy.config.editor +bootstrap.image io.encodings.utf8 destructors accessors ; IN: tools.deploy.backend : copy-vm ( executable bundle-name extension -- vm ) @@ -88,6 +88,10 @@ DEFER: ?make-staging-image dup staging-image-name exists? [ drop ] [ make-staging-image ] if ; +: make-deploy-config ( vocab -- file ) + [ deploy-config unparse-use ] [ "deploy-config-" prepend ] bi + [ utf8 set-file-contents ] keep ; + : deploy-command-line ( image vocab config -- flags ) [ bootstrap-profile ?make-staging-image @@ -99,7 +103,8 @@ DEFER: ?make-staging-image "-run=tools.deploy.shaker" , - "-deploy-vocab=" prepend , + [ "-deploy-vocab=" prepend , ] + [ make-deploy-config "-deploy-config=" prepend , ] bi "-output-image=" prepend , diff --git a/basis/tools/deploy/config/config-docs.factor b/basis/tools/deploy/config/config-docs.factor index e8dcd2b90e..c8249e4e41 100644 --- a/basis/tools/deploy/config/config-docs.factor +++ b/basis/tools/deploy/config/config-docs.factor @@ -2,16 +2,6 @@ USING: help.markup help.syntax words alien.c-types assocs kernel math ; IN: tools.deploy.config -ARTICLE: "deploy-config" "Deployment configuration" -"The deployment configuration is a key/value mapping stored in the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If this file does not exist, the default deployment configuration is used:" -{ $subsection default-config } -"The deployment configuration can be read and written with a pair of words:" -{ $subsection deploy-config } -{ $subsection set-deploy-config } -"A utility word is provided to load the configuration, change a flag, and store it back to disk:" -{ $subsection set-deploy-flag } -"The " { $link "ui.tools.deploy" } " provides a graphical way of editing the configuration." ; - ARTICLE: "deploy-flags" "Deployment flags" "There are two sets of deployment flags. The first set controls the major subsystems which are to be included in the deployment image:" { $subsection deploy-math? } @@ -25,12 +15,7 @@ ARTICLE: "deploy-flags" "Deployment flags" { $subsection deploy-word-props? } { $subsection deploy-c-types? } ; -ARTICLE: "prepare-deploy" "Preparing to deploy an application" -"In order to deploy an application as a stand-alone image, the application's vocabulary must first be given a " { $link POSTPONE: MAIN: } " hook. Then, a " { $emphasis "deployment configuration" } " must be created." -{ $subsection "deploy-config" } -{ $subsection "deploy-flags" } ; - -ABOUT: "prepare-deploy" +ABOUT: "deploy-flags" HELP: deploy-name { $description "Deploy setting. The name of the executable." @@ -114,15 +99,3 @@ HELP: deploy-reflection HELP: default-config { $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } } { $description "Outputs the default deployment configuration for a vocabulary." } ; - -HELP: deploy-config -{ $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } } -{ $description "Loads a vocabulary's deployment configuration from the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If the file does not exist, the " { $link default-config } " is output." } ; - -HELP: set-deploy-config -{ $values { "assoc" assoc } { "vocab" "a vocabulary specifier" } } -{ $description "Stores a vocabulary's deployment configuration to the " { $snippet "deploy.factor" } " file in the vocabulary's directory." } ; - -HELP: set-deploy-flag -{ $values { "value" object } { "key" object } { "vocab" "a vocabulary specifier" } } -{ $description "Modifies an entry in a vocabulary's deployment configuration on disk." } ; diff --git a/basis/tools/deploy/config/config.factor b/basis/tools/deploy/config/config.factor index 84bfab682b..1d9761e885 100644 --- a/basis/tools/deploy/config/config.factor +++ b/basis/tools/deploy/config/config.factor @@ -1,8 +1,7 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: vocabs.loader io.files io kernel sequences assocs -splitting parser prettyprint namespaces math vocabs -hashtables tools.vocabs ; +USING: io.files io kernel sequences assocs splitting parser +namespaces math vocabs hashtables ; IN: tools.deploy.config SYMBOL: deploy-name @@ -66,18 +65,3 @@ SYMBOL: deploy-image ! default value for deploy.macosx { "stop-after-last-window?" t } } assoc-union ; - -: deploy-config-path ( vocab -- string ) - vocab-dir "deploy.factor" append-path ; - -: deploy-config ( vocab -- assoc ) - dup default-config swap - dup deploy-config-path vocab-file-contents - parse-fresh [ first assoc-union ] unless-empty ; - -: set-deploy-config ( assoc vocab -- ) - [ unparse-use string-lines ] dip - dup deploy-config-path set-vocab-file-contents ; - -: set-deploy-flag ( value key vocab -- ) - [ deploy-config [ set-at ] keep ] keep set-deploy-config ; diff --git a/basis/tools/deploy/config/editor/editor-docs.factor b/basis/tools/deploy/config/editor/editor-docs.factor new file mode 100644 index 0000000000..b677d37f95 --- /dev/null +++ b/basis/tools/deploy/config/editor/editor-docs.factor @@ -0,0 +1,27 @@ +USING: assocs help.markup help.syntax kernel +tools.deploy.config ; +IN: tools.deploy.config.editor + +ARTICLE: "deploy-config" "Deployment configuration" +"The deployment configuration is a key/value mapping stored in the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If this file does not exist, the default deployment configuration is used:" +{ $subsection default-config } +"The deployment configuration can be read and written with a pair of words:" +{ $subsection deploy-config } +{ $subsection set-deploy-config } +"A utility word is provided to load the configuration, change a flag, and store it back to disk:" +{ $subsection set-deploy-flag } +"The " { $link "ui.tools.deploy" } " provides a graphical way of editing the configuration." ; + +HELP: deploy-config +{ $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } } +{ $description "Loads a vocabulary's deployment configuration from the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If the file does not exist, the " { $link default-config } " is output." } ; + +HELP: set-deploy-config +{ $values { "assoc" assoc } { "vocab" "a vocabulary specifier" } } +{ $description "Stores a vocabulary's deployment configuration to the " { $snippet "deploy.factor" } " file in the vocabulary's directory." } ; + +HELP: set-deploy-flag +{ $values { "value" object } { "key" object } { "vocab" "a vocabulary specifier" } } +{ $description "Modifies an entry in a vocabulary's deployment configuration on disk." } ; + +ABOUT: "deploy-config" diff --git a/basis/tools/deploy/config/editor/editor.factor b/basis/tools/deploy/config/editor/editor.factor new file mode 100644 index 0000000000..2b5788adfc --- /dev/null +++ b/basis/tools/deploy/config/editor/editor.factor @@ -0,0 +1,20 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs io.files kernel parser prettyprint sequences +splitting tools.deploy.config tools.vocabs vocabs.loader ; +IN: tools.deploy.config.editor + +: deploy-config-path ( vocab -- string ) + vocab-dir "deploy.factor" append-path ; + +: deploy-config ( vocab -- assoc ) + dup default-config swap + dup deploy-config-path vocab-file-contents + parse-fresh [ first assoc-union ] unless-empty ; + +: set-deploy-config ( assoc vocab -- ) + [ unparse-use string-lines ] dip + dup deploy-config-path set-vocab-file-contents ; + +: set-deploy-flag ( value key vocab -- ) + [ deploy-config [ set-at ] keep ] keep set-deploy-config ; diff --git a/basis/tools/deploy/deploy-docs.factor b/basis/tools/deploy/deploy-docs.factor index eccb3982c7..00e747cf00 100644 --- a/basis/tools/deploy/deploy-docs.factor +++ b/basis/tools/deploy/deploy-docs.factor @@ -2,6 +2,11 @@ USING: help.markup help.syntax words alien.c-types assocs kernel ; IN: tools.deploy +ARTICLE: "prepare-deploy" "Preparing to deploy an application" +"In order to deploy an application as a stand-alone image, the application's vocabulary must first be given a " { $link POSTPONE: MAIN: } " hook. Then, a " { $emphasis "deployment configuration" } " must be created." +{ $subsection "deploy-config" } +{ $subsection "deploy-flags" } ; + ARTICLE: "tools.deploy" "Application deployment" "The stand-alone application deployment tool compiles a vocabulary down to a native executable which runs the vocabulary's " { $link POSTPONE: MAIN: } " hook. Deployed executables do not depend on Factor being installed, and do not expose any source code, and thus are suitable for delivering commercial end-user applications." $nl diff --git a/basis/tools/deploy/shaker/shaker.factor b/basis/tools/deploy/shaker/shaker.factor index 15fd2a37d7..01cc80e90d 100755 --- a/basis/tools/deploy/shaker/shaker.factor +++ b/basis/tools/deploy/shaker/shaker.factor @@ -1,11 +1,11 @@ ! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: accessors qualified io.backend io.streams.c init fry -namespaces make assocs kernel parser lexer strings.parser -tools.deploy.config vocabs sequences words words.private memory -kernel.private continuations io prettyprint vocabs.loader -debugger system strings sets vectors quotations byte-arrays -sorting compiler.units definitions generic generic.standard ; +namespaces make assocs kernel parser lexer strings.parser vocabs +sequences words words.private memory kernel.private +continuations io vocabs.loader system strings sets +vectors quotations byte-arrays sorting compiler.units +definitions generic generic.standard tools.deploy.config ; QUALIFIED: bootstrap.stage2 QUALIFIED: classes QUALIFIED: command-line @@ -14,7 +14,6 @@ QUALIFIED: continuations QUALIFIED: definitions QUALIFIED: init QUALIFIED: layouts -QUALIFIED: prettyprint.config QUALIFIED: source-files QUALIFIED: vocabs IN: tools.deploy.shaker @@ -41,7 +40,7 @@ IN: tools.deploy.shaker ] when ; : strip-debugger ( -- ) - strip-debugger? [ + strip-debugger? "debugger" vocab and [ "Stripping debugger" show "resource:basis/tools/deploy/shaker/strip-debugger.factor" run-file @@ -81,14 +80,11 @@ IN: tools.deploy.shaker >alist f like ] change-props drop ] each - ] [ - "Remaining word properties:\n" show - [ props>> keys ] gather unparse show ] [ H{ } clone '[ [ [ _ [ ] cache ] map ] change-props drop ] each - ] tri ; + ] bi ; : stripped-word-props ( -- seq ) [ @@ -275,12 +271,7 @@ IN: tools.deploy.shaker ] when strip-prettyprint? [ - { - prettyprint.config:margin - prettyprint.config:string-limit? - prettyprint.config:boa-tuples? - prettyprint.config:tab-size - } % + { } { "prettyprint.config" } strip-vocab-globals % ] when strip-debugger? [ @@ -308,7 +299,6 @@ IN: tools.deploy.shaker '[ drop _ member? not ] assoc-filter [ drop string? not ] assoc-filter ! strip CLI args sift-assoc - dup keys unparse show 21 setenv ] [ drop ] if ; @@ -362,7 +352,7 @@ SYMBOL: deploy-vocab init-hooks get values concat % , strip-io? [ \ flush , ] unless - ] [ ] make "Boot quotation: " show dup unparse show + ] [ ] make set-boot-quot ; : init-stripper ( -- ) @@ -405,16 +395,14 @@ SYMBOL: deploy-vocab deploy-vocab get require strip finish-deploy - ] [ - print-error flush 1 exit - ] recover + ] [ die 1 exit ] recover ] bind ; : do-deploy ( -- ) "output-image" get "deploy-vocab" get "Deploying " write dup write "..." print - dup deploy-config dup . + "deploy-config" get parse-file first (deploy) ; MAIN: do-deploy diff --git a/basis/tools/disassembler/disassembler-tests.factor b/basis/tools/disassembler/disassembler-tests.factor index 782f244c68..96f5a04378 100644 --- a/basis/tools/disassembler/disassembler-tests.factor +++ b/basis/tools/disassembler/disassembler-tests.factor @@ -1,6 +1,6 @@ IN: tools.disassembler.tests -USING: math classes.tuple prettyprint.backend tools.disassembler -tools.test strings ; +USING: math classes.tuple prettyprint.custom +tools.disassembler tools.test strings ; [ ] [ \ + disassemble ] unit-test [ ] [ { string pprint* } disassemble ] unit-test diff --git a/basis/urls/urls.factor b/basis/urls/urls.factor index c0fb1695c3..5f6d04a54f 100644 --- a/basis/urls/urls.factor +++ b/basis/urls/urls.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel ascii combinators combinators.short-circuit sequences splitting fry namespaces make assocs arrays strings -io.sockets io.encodings.string -io.encodings.utf8 math math.parser accessors parser -strings.parser lexer prettyprint.backend hashtables present +io.sockets io.encodings.string io.encodings.utf8 math +math.parser accessors parser strings.parser lexer +prettyprint.backend prettyprint.custom hashtables present peg.ebnf urls.encoding ; IN: urls diff --git a/basis/vlists/vlists.factor b/basis/vlists/vlists.factor index e0f7e55554..ea40594964 100644 --- a/basis/vlists/vlists.factor +++ b/basis/vlists/vlists.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays accessors sequences sequences.private persistent.sequences assocs persistent.assocs kernel math -vectors parser prettyprint.backend ; +vectors parser prettyprint.custom ; IN: vlists TUPLE: vlist diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index f90ba23999..42e1de19ee 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -68,7 +68,6 @@ bootstrapping? on "alien.accessors" "arrays" "byte-arrays" - "byte-vectors" "classes.private" "classes.tuple" "classes.tuple.private" diff --git a/core/bootstrap/stage1.factor b/core/bootstrap/stage1.factor index 26a27ecefb..874a9dd0d2 100644 --- a/core/bootstrap/stage1.factor +++ b/core/bootstrap/stage1.factor @@ -31,7 +31,7 @@ load-help? off "math.integers" require "math.floats" require "memory" require - + "io.streams.c" require "vocabs.loader" require diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index e7dd333ed8..badc1f5218 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -16,7 +16,6 @@ IN: bootstrap.syntax " ] dip checksum-stream ; - M: checksum checksum-stream [ contents ] dip checksum-bytes ; diff --git a/core/classes/algebra/algebra-docs.factor b/core/classes/algebra/algebra-docs.factor index 810bdbe10f..2730e4683b 100644 --- a/core/classes/algebra/algebra-docs.factor +++ b/core/classes/algebra/algebra-docs.factor @@ -4,6 +4,7 @@ IN: classes.algebra ARTICLE: "class-operations" "Class operations" "Set-theoretic operations on classes:" +{ $subsection class= } { $subsection class< } { $subsection class<= } { $subsection class-and } diff --git a/core/growable/growable-docs.factor b/core/growable/growable-docs.factor index 9f950aa36c..e1ab50cdcd 100644 --- a/core/growable/growable-docs.factor +++ b/core/growable/growable-docs.factor @@ -14,7 +14,7 @@ $nl } "The underlying sequence must implement a generic word:" { $subsection resize } -{ $link "vectors" } ", " { $link "byte-vectors" } " and " { $link "sbufs" } " are implemented using the resizable sequence facility." ; +{ $link "vectors" } " and " { $link "sbufs" } " are implemented using the resizable sequence facility." ; ABOUT: "growable" diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index c951750b34..0b7d9d008f 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -1,14 +1,13 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors alien arrays byte-arrays byte-vectors -definitions generic hashtables kernel math namespaces parser -lexer sequences strings strings.parser sbufs vectors -words quotations io assocs splitting classes.tuple -generic.standard generic.math generic.parser classes io.files -vocabs classes.parser classes.union -classes.intersection classes.mixin classes.predicate -classes.singleton classes.tuple.parser compiler.units -combinators effects.parser slots ; +USING: accessors alien arrays byte-arrays definitions generic +hashtables kernel math namespaces parser lexer sequences strings +strings.parser sbufs vectors words quotations io assocs +splitting classes.tuple generic.standard generic.math +generic.parser classes io.files vocabs classes.parser +classes.union classes.intersection classes.mixin +classes.predicate classes.singleton classes.tuple.parser +compiler.units combinators effects.parser slots ; IN: bootstrap.syntax ! These words are defined as a top-level form, instead of with @@ -81,7 +80,6 @@ IN: bootstrap.syntax "{" [ \ } [ >array ] parse-literal ] define-syntax "V{" [ \ } [ >vector ] parse-literal ] define-syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-syntax - "BV{" [ \ } [ >byte-vector ] parse-literal ] define-syntax "H{" [ \ } [ >hashtable ] parse-literal ] define-syntax "T{" [ parse-tuple-literal parsed ] define-syntax "W{" [ \ } [ first ] parse-literal ] define-syntax