]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'trace_tool' of git://factorcode.org/git/factor into trace_tool
authorSlava Pestov <slava@shill.internal.stack-effects.com>
Thu, 16 Apr 2009 00:17:43 +0000 (19:17 -0500)
committerSlava Pestov <slava@shill.internal.stack-effects.com>
Thu, 16 Apr 2009 00:17:43 +0000 (19:17 -0500)
147 files changed:
basis/alien/libraries/libraries-docs.factor
basis/bootstrap/stage2.factor
basis/bootstrap/tools/tools.factor
basis/compiler/codegen/codegen.factor
basis/compiler/compiler.factor
basis/compiler/errors/authors.txt [new file with mode: 0755]
basis/compiler/errors/errors-docs.factor [new file with mode: 0644]
basis/compiler/errors/errors.factor [new file with mode: 0644]
basis/compiler/errors/summary.txt [new file with mode: 0755]
basis/compiler/tree/builder/builder.factor
basis/concurrency/promises/promises-docs.factor
basis/debugger/debugger.factor
basis/editors/editors-docs.factor
basis/editors/editors.factor
basis/eval/eval-docs.factor
basis/eval/eval.factor
basis/help/cookbook/cookbook.factor
basis/help/handbook/handbook.factor
basis/help/home/home-docs.factor
basis/help/html/html.factor
basis/help/lint/checks/authors.txt [new file with mode: 0644]
basis/help/lint/checks/checks.factor [new file with mode: 0644]
basis/help/lint/lint-docs.factor
basis/help/lint/lint.factor
basis/help/tutorial/tutorial.factor
basis/io/launcher/launcher-docs.factor
basis/io/styles/styles-docs.factor
basis/io/styles/styles.factor
basis/listener/listener-docs.factor
basis/listener/listener.factor
basis/memoize/memoize.factor
basis/mime/multipart/multipart.factor
basis/models/arrow/smart/authors.txt [new file with mode: 0644]
basis/models/arrow/smart/smart-docs.factor
basis/models/arrow/smart/smart-tests.factor [new file with mode: 0644]
basis/models/arrow/smart/smart.factor [new file with mode: 0644]
basis/models/search/search.factor
basis/models/sort/sort.factor
basis/persistent/deques/deques.factor
basis/stack-checker/errors/errors.factor
basis/stack-checker/errors/prettyprint/prettyprint.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/transforms/transforms-tests.factor
basis/stack-checker/transforms/transforms.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/test/11/11.factor
basis/tools/deploy/test/7/7.factor
basis/tools/errors/authors.txt [new file with mode: 0644]
basis/tools/errors/errors-docs.factor [new file with mode: 0644]
basis/tools/errors/errors.factor [new file with mode: 0644]
basis/tools/profiler/profiler.factor
basis/tools/test/test-docs.factor
basis/tools/test/test.factor
basis/tools/vocabs/vocabs.factor
basis/tools/walker/walker.factor
basis/ui/backend/cocoa/tools/tools.factor
basis/ui/baseline-alignment/baseline-alignment.factor
basis/ui/gadgets/icons/icons.factor
basis/ui/gadgets/packs/packs-tests.factor
basis/ui/gadgets/packs/packs.factor
basis/ui/gadgets/panes/panes-tests.factor
basis/ui/gadgets/presentations/presentations.factor
basis/ui/gadgets/search-tables/search-tables.factor
basis/ui/gadgets/slots/slots.factor
basis/ui/gadgets/tables/tables.factor
basis/ui/operations/operations-docs.factor
basis/ui/tools/browser/browser.factor
basis/ui/tools/browser/popups/popups.factor
basis/ui/tools/debugger/debugger.factor
basis/ui/tools/error-list/authors.txt [new file with mode: 0644]
basis/ui/tools/error-list/error-list-docs.factor [new file with mode: 0644]
basis/ui/tools/error-list/error-list.factor [new file with mode: 0644]
basis/ui/tools/error-list/icons/compiler-error.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/compiler-warning.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/help-lint-error.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/linkage-error.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/note.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/source-file.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/syntax-error.tiff [new file with mode: 0644]
basis/ui/tools/error-list/icons/unit-test-error.tiff [new file with mode: 0644]
basis/ui/tools/inspector/inspector-docs.factor
basis/ui/tools/listener/listener-docs.factor
basis/ui/tools/listener/listener.factor
basis/ui/tools/operations/operations.factor
basis/ui/tools/profiler/profiler-tests.factor [new file with mode: 0644]
basis/ui/tools/profiler/profiler.factor
basis/ui/tools/tools-docs.factor
basis/ui/tools/tools.factor
basis/windows/gdi32/tags.txt
basis/windows/usp10/tags.txt [new file with mode: 0644]
basis/x11/xim/xim.factor
basis/x11/xlib/xlib.factor
core/alien/alien-docs.factor
core/bootstrap/syntax-docs.factor [new file with mode: 0644]
core/combinators/combinators.factor
core/compiler/errors/authors.txt [deleted file]
core/compiler/errors/errors-docs.factor [deleted file]
core/compiler/errors/errors.factor [deleted file]
core/compiler/errors/summary.txt [deleted file]
core/compiler/units/units-tests.factor
core/compiler/units/units.factor
core/continuations/continuations-docs.factor
core/continuations/continuations.factor
core/generic/generic.factor
core/generic/standard/engines/tuple/tuple.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/quotations/quotations-docs.factor
core/sequences/sequences.factor
core/source-files/errors/authors.txt [new file with mode: 0644]
core/source-files/errors/errors-tests.factor [new file with mode: 0644]
core/source-files/errors/errors.factor [new file with mode: 0644]
core/source-files/source-files.factor
core/vocabs/loader/loader.factor
core/words/constant/constant-docs.factor [new file with mode: 0644]
core/words/words-docs.factor
extra/4DNav/4DNav.factor
extra/4DNav/file-chooser/file-chooser.factor
extra/fuel/pprint/pprint.factor
extra/images/viewer/viewer.factor
extra/infix/infix.factor
extra/irc/client/internals/internals.factor
extra/irc/logbot/authors.txt [new file with mode: 0644]
extra/irc/logbot/log-line/authors.txt [new file with mode: 0644]
extra/irc/logbot/log-line/log-line.factor [new file with mode: 0644]
extra/irc/logbot/log-line/summary.txt [new file with mode: 0644]
extra/irc/logbot/logbot.factor [new file with mode: 0644]
extra/irc/logbot/summary.txt [new file with mode: 0644]
extra/irc/messages/messages-tests.factor
extra/irc/messages/messages.factor
extra/key-caps/key-caps.factor
extra/koszul/koszul.factor
extra/mason/common/common.factor
extra/mason/test/test.factor
extra/math/binpack/binpack.factor
extra/parser-combinators/parser-combinators.factor
extra/partial-continuations/partial-continuations.factor
extra/peg-lexer/peg-lexer.factor
extra/project-euler/011/011.factor
extra/shell/shell.factor
extra/ui/gadgets/lists/lists.factor
extra/update/util/util.factor
extra/webapps/site-watcher/site-watcher.factor
extra/webapps/site-watcher/spidering/spidering.factor
extra/wordtimer/wordtimer.factor
misc/fuel/fuel-font-lock.el
misc/fuel/fuel-syntax.el

index 3b9c56c8fb1a74162f1bafbcd0c86da3082cc529..c555061e586cb82f130bfb66409243a179a2808f 100644 (file)
@@ -58,3 +58,10 @@ $nl
     "} cond >>"
 }
 "Note the parse time evaluation with " { $link POSTPONE: << } "." } ;
+
+ARTICLE: "loading-libs" "Loading native libraries"
+"Before calling a C library, you must associate its path name on disk with a logical name which Factor uses to identify the library:"
+{ $subsection add-library }
+"Once a library has been defined, you can try loading it to see if the path name is correct:"
+{ $subsection load-library }
+"If the compiler cannot load a library, or cannot resolve a symbol in a library, a linkage error is reported using the compiler error mechanism (see " { $link "compiler-errors" } "). Once you install the right library, reload the source file containing the " { $link add-library } " form to force the compiler to try loading the library again." ;
index 12741f2170fba9dbb826481b26664cabdfc58b11..d6c1876d6a6e9149aa76137b1945cbd1b83d985e 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors init namespaces words words.symbol io
 kernel.private math memory continuations kernel io.files
 io.pathnames io.backend system parser vocabs sequences
 vocabs.loader combinators splitting source-files strings
-definitions assocs compiler.errors compiler.units math.parser
+definitions assocs compiler.units math.parser
 generic sets command-line ;
 IN: bootstrap.stage2
 
@@ -81,14 +81,11 @@ SYMBOL: bootstrap-time
         "none" require
     ] if
 
-    [
-        load-components
+    load-components
 
-        millis over - core-bootstrap-time set-global
+    millis over - core-bootstrap-time set-global
 
-        run-bootstrap-init
-    ] with-compiler-errors
-    :errors
+    run-bootstrap-init
 
     f error set-global
     f error-continuation set-global
index b0afe4a1d9bd0bf01545988b0bdc777a352d61ff..cb0792ee1e2ddaf0a21cf98b433e1365a4038af9 100644 (file)
@@ -6,6 +6,7 @@ IN: bootstrap.tools
     "bootstrap.image"
     "tools.annotations"
     "tools.crossref"
+    "tools.errors"
     "tools.deploy"
     "tools.disassembler"
     "tools.memory"
index 65e70bd04228565aa3ae2c39e3c74e5f4d0c56d1..a220de476a8ada60287d61d43d5a3082e172604e 100755 (executable)
@@ -5,6 +5,7 @@ kernel kernel.private layouts assocs words summary arrays
 combinators classes.algebra alien alien.c-types alien.structs
 alien.strings alien.arrays alien.complex sets libc alien.libraries
 continuations.private fry cpu.architecture
+source-files.errors
 compiler.errors
 compiler.alien
 compiler.cfg
@@ -379,8 +380,7 @@ TUPLE: no-such-library name ;
 M: no-such-library summary
     drop "Library not found" ;
 
-M: no-such-library compiler-error-type
-    drop +linkage+ ;
+M: no-such-library error-type drop +linkage-error+ ;
 
 : no-such-library ( name -- )
     \ no-such-library boa
@@ -391,8 +391,7 @@ TUPLE: no-such-symbol name ;
 M: no-such-symbol summary
     drop "Symbol not found" ;
 
-M: no-such-symbol compiler-error-type
-    drop +linkage+ ;
+M: no-such-symbol error-type drop +linkage-error+ ;
 
 : no-such-symbol ( name -- )
     \ no-such-symbol boa
index 04c1a9c55fb9a69033e871f7b818a79ac4337641..0afe7f1141fac2f0bc1724e4d760e9addbfa4074 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel namespaces arrays sequences io words fry
 continuations vocabs assocs dlists definitions math graphs generic
-combinators deques search-deques macros io stack-checker
+combinators deques search-deques macros io source-files.errors stack-checker
 stack-checker.state stack-checker.inlining combinators.short-circuit
 compiler.errors compiler.units compiler.tree.builder
 compiler.tree.optimizer compiler.cfg.builder compiler.cfg.optimizer
@@ -53,11 +53,18 @@ SYMBOLS: +optimized+ +unoptimized+ ;
     f swap compiler-error ;
 
 : ignore-error? ( word error -- ? )
-    [ [ inline? ] [ macro? ] bi or ]
-    [ compiler-error-type +warning+ eq? ] bi* and ;
+    [
+        {
+            [ inline? ]
+            [ macro? ]
+            [ "transform-quot" word-prop ]
+            [ "no-compile" word-prop ]
+            [ "special" word-prop ]
+        } 1||
+    ] [ error-type +compiler-warning+ eq? ] bi* and ;
 
 : fail ( word error -- * )
-    [ 2dup ignore-error? [ 2drop ] [ swap compiler-error ] if ]
+    [ 2dup ignore-error? [ drop f ] when swap compiler-error ]
     [
         drop
         [ compiled-unxref ]
@@ -122,6 +129,8 @@ t compile-dependencies? set-global
 : compile-call ( quot -- )
     [ dup infer define-temp ] with-compilation-unit execute ;
 
+\ compile-call t "no-compile" set-word-prop
+
 SINGLETON: optimizing-compiler
 
 M: optimizing-compiler recompile ( words -- alist )
diff --git a/basis/compiler/errors/authors.txt b/basis/compiler/errors/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/compiler/errors/errors-docs.factor b/basis/compiler/errors/errors-docs.factor
new file mode 100644 (file)
index 0000000..c10e33b
--- /dev/null
@@ -0,0 +1,34 @@
+IN: compiler.errors
+USING: help.markup help.syntax vocabs.loader words io
+quotations words.symbol ;
+
+ARTICLE: "compiler-errors" "Compiler warnings and errors"
+"After loading a vocabulary, you might see messages like:"
+{ $code
+    ":errors - print 2 compiler errors"
+    ":warnings - print 50 compiler warnings"
+}
+"These messages arise from the compiler's stack effect checker. Production code should not have any warnings and errors in it. Warning and error conditions are documented in " { $link "inference-errors" } "."
+$nl
+"Words to view warnings and errors:"
+{ $subsection :warnings }
+{ $subsection :errors }
+{ $subsection :linkage }
+"Compiler warnings and errors are reported using the " { $link "tools.errors" } " mechanism and are shown in the " { $link "ui.tools.error-list" } "." ;
+
+HELP: compiler-error
+{ $values { "error" "an error" } { "word" word } }
+{ $description "Saves the error for future persual via " { $link :errors } ", " { $link :warnings } " and " { $link :linkage } "." } ;
+
+HELP: :errors
+{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ;
+
+HELP: :warnings
+{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ;
+
+HELP: :linkage
+{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ;
+
+{ :errors :warnings } related-words
+
+ABOUT: "compiler-errors"
diff --git a/basis/compiler/errors/errors.factor b/basis/compiler/errors/errors.factor
new file mode 100644 (file)
index 0000000..e317447
--- /dev/null
@@ -0,0 +1,63 @@
+! Copyright (C) 2007, 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors source-files.errors kernel namespaces assocs
+tools.errors ;
+IN: compiler.errors
+
+TUPLE: compiler-error < source-file-error ;
+
+M: compiler-error error-type error>> error-type ;
+
+SYMBOL: compiler-errors
+
+compiler-errors [ H{ } clone ] initialize
+
+SYMBOLS: +compiler-error+ +compiler-warning+ +linkage-error+ ;
+
+: errors-of-type ( type -- assoc )
+    compiler-errors get-global
+    swap [ [ nip error-type ] dip eq? ] curry
+    assoc-filter ;
+
+T{ error-type
+   { type +compiler-error+ }
+   { word ":errors" }
+   { plural "compiler errors" }
+   { icon "vocab:ui/tools/error-list/icons/compiler-error.tiff" }
+   { quot [ +compiler-error+ errors-of-type values ] }
+   { forget-quot [ compiler-errors get delete-at ] }
+} define-error-type
+
+T{ error-type
+   { type +compiler-warning+ }
+   { word ":warnings" }
+   { plural "compiler warnings" }
+   { icon "vocab:ui/tools/error-list/icons/compiler-warning.tiff" }
+   { quot [ +compiler-warning+ errors-of-type values ] }
+   { forget-quot [ compiler-errors get delete-at ] }
+} define-error-type
+
+T{ error-type
+   { type +linkage-error+ }
+   { word ":linkage" }
+   { plural "linkage errors" }
+   { icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" }
+   { quot [ +linkage-error+ errors-of-type values ] }
+   { forget-quot [ compiler-errors get delete-at ] }
+} define-error-type
+
+: <compiler-error> ( error word -- compiler-error )
+    \ compiler-error <definition-error> ;
+
+: compiler-error ( error word -- )
+    compiler-errors get-global pick
+    [ [ [ <compiler-error> ] keep ] dip set-at ] [ delete-at drop ] if ;
+
+: compiler-errors. ( type -- )
+    errors-of-type values errors. ;
+
+: :errors ( -- ) +compiler-error+ compiler-errors. ;
+
+: :warnings ( -- ) +compiler-warning+ compiler-errors. ;
+
+: :linkage ( -- ) +linkage-error+ compiler-errors. ;
diff --git a/basis/compiler/errors/summary.txt b/basis/compiler/errors/summary.txt
new file mode 100755 (executable)
index 0000000..01d106b
--- /dev/null
@@ -0,0 +1 @@
+Compiler warning and error reporting
index 4cb7650b1de1721d6472408a80ac84c0e9e100a6..dc87d596aa70ab8eeb2cb07f02192c91f88f6d08 100644 (file)
@@ -42,8 +42,10 @@ IN: compiler.tree.builder
 : check-cannot-infer ( word -- )
     dup "cannot-infer" word-prop [ cannot-infer-effect ] [ drop ] if ;
 
+TUPLE: do-not-compile word ;
+
 : check-no-compile ( word -- )
-    dup "no-compile" word-prop [ cannot-infer-effect ] [ drop ] if ;
+    dup "no-compile" word-prop [ do-not-compile inference-warning ] [ drop ] if ;
 
 : build-tree-from-word ( word -- nodes )
     [
index 8e160842a93d5f7abb0c907a70723f6bc8d32ff3..69f12d87397aac4d192bc3311e7dc888e991e3e8 100644 (file)
@@ -7,6 +7,10 @@ IN: concurrency.promises
 HELP: promise\r
 { $class-description "The class of write-once promises." } ;\r
 \r
+HELP: <promise>\r
+{ $values { "promise" promise } }\r
+{ $description "Creates a new promise which may be fulfilled by calling " { $link fulfill } "." } ;\r
+\r
 HELP: promise-fulfilled?\r
 { $values { "promise" promise } { "?" "a boolean" } }\r
 { $description "Tests if " { $link fulfill } " has previously been called on the promise, in which case " { $link ?promise } " will return immediately without blocking." } ;\r
index efd35ab2803055b47556bbf552bc73c1e7d991c9..49ec534e8fa59c9bc0f27219235a8e9934394628 100644 (file)
@@ -8,8 +8,9 @@ classes.mixin classes.tuple continuations continuations.private
 combinators generic.math classes.builtin classes compiler.units
 generic.standard vocabs init kernel.private io.encodings
 accessors math.order destructors source-files parser
-classes.tuple.parser effects.parser lexer compiler.errors
-generic.parser strings.parser vocabs.loader vocabs.parser ;
+classes.tuple.parser effects.parser lexer
+generic.parser strings.parser vocabs.loader vocabs.parser see
+source-files.errors ;
 IN: debugger
 
 GENERIC: error. ( error -- )
@@ -213,14 +214,13 @@ M: condition error-help error>> error-help ;
 
 M: assert summary drop "Assertion failed" ;
 
-M: assert error.
-    "Assertion failed" print
+M: assert-sequence summary drop "Assertion failed" ;
+
+M: assert-sequence error.
     standard-table-style [
-        15 length-limit set
-        5 line-limit set
-        [ expect>> [ [ "Expect:" write ] with-cell pprint-cell ] with-row ]
-        [ got>> [ [ "Got:" write ] with-cell pprint-cell ] with-row ] bi
-    ] tabular-output nl ;
+        [ "=== Expected:" print expected>> stack. ]
+        [ "=== Got:" print got>> stack. ] bi
+    ] tabular-output ;
 
 M: immutable summary drop "Sequence is immutable" ;
 
@@ -268,20 +268,6 @@ M: duplicate-slot-names summary
 M: invalid-slot-name summary
     drop "Invalid slot name" ;
 
-: file. ( file -- ) path>> <pathname> . ;
-
-M: source-file-error error.
-    [ file>> file. ] [ error>> error. ] bi ;
-
-M: source-file-error summary
-    error>> summary ;
-
-M: source-file-error compute-restarts
-    error>> compute-restarts ;
-
-M: source-file-error error-help
-    error>> error-help ;
-
 M: not-in-a-method-error summary
     drop "call-next-method can only be called in a method definition" ;
 
@@ -309,12 +295,6 @@ M: lexer-error compute-restarts
 M: lexer-error error-help
     error>> error-help ;
 
-M: object compiler-error. ( error word -- )
-    nl
-    "While compiling " write pprint ": " print
-    nl
-    print-error ;
-
 M: bad-effect summary
     drop "Bad stack effect declaration" ;
 
index e3961aef80dbab80e76181fe54fdf46f3b73e02e..30611ca699297f0b3b7e736653fb3cd10506adad 100644 (file)
@@ -1,4 +1,5 @@
-USING: help.markup help.syntax parser source-files vocabs.loader ;
+USING: help.markup help.syntax parser source-files
+source-files.errors vocabs.loader ;
 IN: editors
 
 ARTICLE: "editor" "Editor integration"
@@ -13,6 +14,9 @@ ARTICLE: "editor" "Editor integration"
 
 ABOUT: "editor"
 
+HELP: edit-hook
+{ $var-description "A quotation with stack effect " { $snippet "( file line -- )" } ". If not set, the " { $link edit } " word throws a condition with restarts for loading one of the sub-vocabularies of the " { $vocab-link "editors" } " vocabulary." } ;
+
 HELP: edit
 { $values { "defspec" "a definition specifier" } }
 { $description "Opens the source file containing the definition using the current " { $link edit-hook } ". See " { $link "editor" } "." }
index 0003b508fb2c6903aad9e5532e3a2777d1d98bab..6088400bd8e41d422675d403fa3c61477b103d16 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: parser lexer kernel namespaces sequences definitions
-io.files io.backend io.pathnames io summary continuations
-tools.crossref tools.vocabs prettyprint source-files assocs
+USING: parser lexer kernel namespaces sequences definitions io.files
+io.backend io.pathnames io summary continuations tools.crossref
+tools.vocabs prettyprint source-files source-files.errors assocs
 vocabs vocabs.loader splitting accessors debugger prettyprint
 help.topics ;
 IN: editors
@@ -57,7 +57,7 @@ M: lexer-error error-line
     [ error>> error-line ] [ line>> ] bi or ;
 
 M: source-file-error error-file
-    [ error>> error-file ] [ file>> path>> ] bi or ;
+    [ error>> error-file ] [ file>> ] bi or ;
 
 M: source-file-error error-line
     error>> error-line ;
@@ -81,6 +81,9 @@ M: object error-line
 : :edit ( -- )
     error get (:edit) ;
 
+: edit-error ( error -- )
+    [ file>> ] [ line#>> ] bi 2dup and [ edit-location ] [ 2drop ] if ;
+
 : edit-each ( seq -- )
     [
         [ "Editing " write . ]
index b53c3bae6bb040eda37fe7e186129594d642d1ee..b30c6d9cb93d83840535892dcff3fcbd06d9b134 100644 (file)
@@ -1,18 +1,23 @@
 IN: eval
-USING: help.markup help.syntax strings io ;
+USING: help.markup help.syntax strings io effects ;
 
 HELP: eval
-{ $values { "str" string } }
-{ $description "Parses Factor source code from a string, and calls the resulting quotation." }
+{ $values { "str" string } { "effect" effect } }
+{ $description "Parses Factor source code from a string, and calls the resulting quotation, which must have the given stack effect." }
+{ $errors "Throws an error if the input is malformed, or if the evaluation itself throws an error." } ;
+
+HELP: eval(
+{ $syntax "eval( inputs -- outputs )" }
+{ $description "Parses Factor source code from the string at the top of the stack, and calls the resulting quotation, which must have the given stack effect." }
 { $errors "Throws an error if the input is malformed, or if the evaluation itself throws an error." } ;
 
 HELP: eval>string
 { $values { "str" string } { "output" string } }
-{ $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string." } ;
+{ $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string. The code in the string must not take or leave any values on the stack." } ;
 
 ARTICLE: "eval" "Evaluating strings at runtime"
 "The " { $vocab-link "eval" } " vocabulary implements support for evaluating strings at runtime."
-{ $subsection eval }
+{ $subsection POSTPONE: eval( }
 { $subsection eval>string } ;
 
 ABOUT: "eval"
index 3672337a584d0f17f8860a816246f6ef87d93348..4c5b9e8cf9a72c0fb56860cd7cb01b22ef92a8a1 100644 (file)
@@ -1,23 +1,25 @@
 ! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: splitting parser compiler.units kernel namespaces
-debugger io.streams.string fry ;
+debugger io.streams.string fry combinators effects.parser ;
 IN: eval
 
 : parse-string ( str -- quot )
     [ string-lines parse-lines ] with-compilation-unit ;
 
-: (eval) ( str -- )
-    parse-string call ;
+: (eval) ( str effect -- )
+    [ parse-string ] dip call-effect ; inline
 
-: eval ( str -- )
-    [ (eval) ] with-file-vocabs ;
+: eval ( str effect -- )
+    [ (eval) ] with-file-vocabs ; inline
+
+SYNTAX: eval( \ eval parse-call( ;
 
 : (eval>string) ( str -- output )
     [
         "quiet" on
         parser-notes off
-        '[ _ (eval) ] try
+        '[ _ (( -- )) (eval) ] try
     ] with-string-writer ;
 
 : eval>string ( str -- output )
index 867f3732098b8d855683b0f934624b3160e5651f..9bb76f8d5a4767d73d973451d4c1b420ab7323c8 100644 (file)
@@ -74,7 +74,7 @@ $nl
     "shuffle-words"
     "words"
     "generic"
-    "tools"
+    "handbook-tools-reference"
 } ;
 
 ARTICLE: "cookbook-combinators" "Control flow cookbook"
index 0845264d61312c9068d80f3fd2a0f4f49bb03b6a..ebce042e06054a0d063e304a3e8fb7cdb23f5c1a 100644 (file)
@@ -5,7 +5,7 @@ math system strings sbufs vectors byte-arrays quotations
 io.streams.byte-array classes.builtin parser lexer
 classes.predicate classes.union classes.intersection
 classes.singleton classes.tuple help.vocabs math.parser
-accessors definitions ;
+accessors definitions sets ;
 IN: help.handbook
 
 ARTICLE: "conventions" "Conventions"
@@ -197,29 +197,6 @@ ARTICLE: "io" "Input and output"
 { $subsection "io.ports" }
 { $see-also "destructors" } ;
 
-ARTICLE: "tools" "Developer tools"
-{ $subsection "tools.vocabs" }
-"Exploratory tools:"
-{ $subsection "see" }
-{ $subsection "editor" }
-{ $subsection "listener" }
-{ $subsection "tools.crossref" }
-{ $subsection "inspector" }
-{ $subsection "tools.completion" }
-{ $subsection "summary" }
-"Debugging tools:"
-{ $subsection "tools.annotations" }
-{ $subsection "tools.test" }
-{ $subsection "tools.threads" }
-"Performance tools:"
-{ $subsection "tools.memory" }
-{ $subsection "profiling" }
-{ $subsection "timing" }
-{ $subsection "tools.disassembler" }
-"Deployment tools:"
-{ $subsection "tools.deploy" }
-{ $see-also "ui-tools" } ;
-
 ARTICLE: "article-index" "Article index"
 { $index [ articles get keys ] } ;
 
@@ -248,59 +225,79 @@ ARTICLE: "class-index" "Class index"
 
 USING: help.cookbook help.tutorial ;
 
-ARTICLE: "handbook-language-reference" "Language reference"
-"Fundamentals:"
+ARTICLE: "handbook-language-reference" "The language"
+{ $heading "Fundamentals" }
 { $subsection "conventions" }
 { $subsection "syntax" }
 { $subsection "effects" }
-"Data types:"
+{ $subsection "evaluator" }
+{ $heading "Data types" }
 { $subsection "booleans" }
 { $subsection "numbers" }
 { $subsection "collections" }
-"Evaluation semantics:"
-{ $subsection "evaluator" }
+{ $heading "Evaluation" }
 { $subsection "words" }
 { $subsection "shuffle-words" }
 { $subsection "combinators" }
 { $subsection "errors" }
 { $subsection "continuations" }
-"Named values:"
+{ $heading "Named values" }
 { $subsection "locals" }
 { $subsection "namespaces" }
 { $subsection "namespaces-global" }
 { $subsection "values" }
-"Abstractions:"
+{ $heading "Abstractions" }
 { $subsection "objects" }
 { $subsection "destructors" }
 { $subsection "macros" }
 { $subsection "fry" }
-"Program organization:"
+{ $heading "Program organization" }
 { $subsection "vocabs.loader" }
 "Vocabularies tagged " { $link T{ vocab-tag { name "extensions" } } } " implement various additional language abstractions." ;
 
-ARTICLE: "handbook-environment-reference" "Environment reference"
-"Parse time and compile time:"
+ARTICLE: "handbook-system-reference" "The implementation"
+{ $heading "Parse time and compile time" }
 { $subsection "parser" }
 { $subsection "definitions" }
 { $subsection "vocabularies" }
 { $subsection "source-files" }
 { $subsection "compiler" }
-"Tools:"
-{ $subsection "prettyprint" }
-{ $subsection "tools" }
-{ $subsection "help" }
-{ $subsection "inference" }
+{ $heading "Virtual machine" }
 { $subsection "images" }
-"VM:"
 { $subsection "cli" }
 { $subsection "rc-files" }
 { $subsection "init" }
 { $subsection "system" }
 { $subsection "layouts" } ;
 
-ARTICLE: "handbook-library-reference" "Library reference"
-"This index only includes articles from loaded vocabularies. To explore more vocabularies, see " { $link "vocab-index" } "."
-{ $index [ "handbook" orphan-articles remove ] } ;
+ARTICLE: "handbook-tools-reference" "Developer tools"
+"The below tools are text-based. " { $link "ui-tools" } " are documented separately."
+{ $heading "Workflow" }
+{ $subsection "listener" }
+{ $subsection "editor" }
+{ $subsection "tools.vocabs" }
+{ $subsection "tools.test" }
+{ $subsection "help" }
+{ $heading "Debugging" }
+{ $subsection "prettyprint" }
+{ $subsection "inspector" }
+{ $subsection "tools.annotations" }
+{ $subsection "inference" }
+{ $heading "Browsing" }
+{ $subsection "see" }
+{ $subsection "tools.crossref" }
+{ $heading "Performance" }
+{ $subsection "timing" }
+{ $subsection "profiling" }
+{ $subsection "tools.memory" }
+{ $subsection "tools.threads" }
+{ $subsection "tools.disassembler" }
+{ $heading "Deployment" }
+{ $subsection "tools.deploy" } ;
+
+ARTICLE: "handbook-library-reference" "Libraries"
+"This index lists articles from loaded vocabularies which are not subsections of any other article. To explore more vocabularies, see " { $link "vocab-index" } "."
+{ $index [ orphan-articles { "help.home" "handbook" } diff ] } ;
 
 ARTICLE: "handbook" "Factor handbook"
 "Learn the language:"
@@ -308,11 +305,11 @@ ARTICLE: "handbook" "Factor handbook"
 { $subsection "first-program" }
 "Reference material:"
 { $subsection "handbook-language-reference" }
-{ $subsection "handbook-environment-reference" }
 { $subsection "io" }
 { $subsection "ui" }
+{ $subsection "handbook-system-reference" }
+{ $subsection "handbook-tools-reference" }
 { $subsection "ui-tools" }
-{ $subsection "unicode" }
 { $subsection "alien" }
 { $subsection "handbook-library-reference" }
 "Explore loaded libraries:"
index e6db2d3b9c3c7e400cb7c1b651ae8bf5006f0701..b40d1626702c24a9d4db273c89e057f4ca7f2557 100644 (file)
@@ -8,6 +8,7 @@ ARTICLE: "help.home" "Factor documentation"
   { $link "handbook" }
   { $link "vocab-index" }
   { $link "ui-tools" }
+  { $link "ui-listener" }
 }
 { $heading "Recently visited" }
 { $table
index d880af5b555bab654f3768ca94340740cf30f22f..f4a874248617f9645421e41e783e1a6b2e502ec0 100644 (file)
@@ -4,24 +4,26 @@ USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
 io.files io.files.temp io.directories html.streams help kernel
 assocs sequences make words accessors arrays help.topics vocabs
 tools.vocabs help.vocabs namespaces prettyprint io
-vocabs.loader serialize fry memoize unicode.case math.order
-sorting debugger html xml.syntax xml.writer ;
+vocabs.loader serialize fry memoize ascii unicode.case math.order
+sorting debugger html xml.syntax xml.writer math.parser ;
 IN: help.html
 
 : escape-char ( ch -- )
-    dup H{
-        { CHAR: " "__quo__" }
-        { CHAR: * "__star__" }
-        { CHAR: : "__colon__" }
-        { CHAR: < "__lt__" }
-        { CHAR: > "__gt__" }
-        { CHAR: ? "__que__" }
-        { CHAR: \\ "__back__" }
-        { CHAR: | "__pipe__" }
-        { CHAR: / "__slash__" }
-        { CHAR: , "__comma__" }
-        { CHAR: @ "__at__" }
-    } at [ % ] [ , ] ?if ;
+    dup ascii? [
+        dup H{
+            { CHAR: " "__quo__" }
+            { CHAR: * "__star__" }
+            { CHAR: : "__colon__" }
+            { CHAR: < "__lt__" }
+            { CHAR: > "__gt__" }
+            { CHAR: ? "__que__" }
+            { CHAR: \\ "__back__" }
+            { CHAR: | "__pipe__" }
+            { CHAR: / "__slash__" }
+            { CHAR: , "__comma__" }
+            { CHAR: @ "__at__" }
+        } at [ % ] [ , ] ?if
+    ] [ number>string "__" "__" surround % ] if ;
 
 : escape-filename ( string -- filename )
     [ [ escape-char ] each ] "" make ;
diff --git a/basis/help/lint/checks/authors.txt b/basis/help/lint/checks/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/help/lint/checks/checks.factor b/basis/help/lint/checks/checks.factor
new file mode 100644 (file)
index 0000000..4a15f86
--- /dev/null
@@ -0,0 +1,176 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays assocs classes combinators
+combinators.short-circuit definitions effects eval fry grouping
+help help.markup help.topics io.streams.string kernel macros
+namespaces sequences sequences.deep sets sorting splitting
+strings unicode.categories values vocabs vocabs.loader words
+words.symbol summary debugger io ;
+IN: help.lint.checks
+
+ERROR: simple-lint-error message ;
+
+M: simple-lint-error summary message>> ;
+
+M: simple-lint-error error. summary print ;
+
+SYMBOL: vocabs-quot
+SYMBOL: all-vocabs
+SYMBOL: vocab-articles
+
+: check-example ( element -- )
+    '[
+        _ rest [
+            but-last "\n" join
+            [ (eval>string) ] call( code -- output )
+            "\n" ?tail drop
+        ] keep
+        peek assert=
+    ] vocabs-quot get call( quot -- ) ;
+
+: check-examples ( element -- )
+    \ $example swap elements [ check-example ] each ;
+
+: extract-values ( element -- seq )
+    \ $values swap elements dup empty? [
+        first rest [ first ] map prune natural-sort
+    ] unless ;
+
+: effect-values ( word -- seq )
+    stack-effect
+    [ in>> ] [ out>> ] bi append
+    [ dup pair? [ first ] when effect>string ] map
+    prune natural-sort ;
+
+: contains-funky-elements? ( element -- ? )
+    {
+        $shuffle
+        $values-x/y
+        $predicate
+        $class-description
+        $error-description
+    } swap '[ _ elements empty? not ] any? ;
+
+: don't-check-word? ( word -- ? )
+    {
+        [ macro? ]
+        [ symbol? ]
+        [ value-word? ]
+        [ parsing-word? ]
+        [ "declared-effect" word-prop not ]
+    } 1|| ;
+
+: check-values ( word element -- )
+    {
+        [
+            [ don't-check-word? ]
+            [ contains-funky-elements? ]
+            bi* or
+        ] [
+            [ effect-values ]
+            [ extract-values ]
+            bi* sequence=
+        ]
+    } 2|| [ "$values don't match stack effect" simple-lint-error ] unless ;
+
+: check-nulls ( element -- )
+    \ $values swap elements
+    null swap deep-member?
+    [ "$values should not contain null" simple-lint-error ] when ;
+
+: check-see-also ( element -- )
+    \ $see-also swap elements [
+        rest dup prune [ length ] bi@ assert=
+    ] each ;
+
+: vocab-exists? ( name -- ? )
+    [ vocab ] [ all-vocabs get member? ] bi or ;
+
+: check-modules ( element -- )
+    \ $vocab-link swap elements [
+        second
+        vocab-exists? [
+            "$vocab-link to non-existent vocabulary"
+            simple-lint-error
+        ] unless
+    ] each ;
+
+: check-rendering ( element -- )
+    [ print-content ] with-string-writer drop ;
+
+: check-strings ( str -- )
+    [
+        "\n\t" intersects? [
+            "Paragraph text should not contain \\n or \\t"
+            simple-lint-error
+        ] when
+    ] [
+        "  " swap subseq? [
+            "Paragraph text should not contain double spaces"
+            simple-lint-error
+        ] when
+    ] bi ;
+
+: check-whitespace ( str1 str2 -- )
+    [ " " tail? ] [ " " head? ] bi* or
+    [ "Missing whitespace between strings" simple-lint-error ] unless ;
+
+: check-bogus-nl ( element -- )
+    { { $nl } { { $nl } } } [ head? ] with any? [
+        "Simple element should not begin with a paragraph break"
+        simple-lint-error
+    ] when ;
+
+: check-class-description ( word element -- )
+    [ class? not ]
+    [ { $class-description } swap elements empty? not ] bi* and
+    [ "A word that is not a class has a $class-description" simple-lint-error ] when ;
+
+: check-article-title ( article -- )
+    article-title first LETTER?
+    [ "Article title must begin with a capital letter" simple-lint-error ] unless ;
+
+: check-elements ( element -- )
+    {
+        [ check-bogus-nl ]
+        [ [ string? ] filter [ check-strings ] each ]
+        [ [ simple-element? ] filter [ check-elements ] each ]
+        [ 2 <clumps> [ [ string? ] all? ] filter [ first2 check-whitespace ] each ]
+    } cleave ;
+
+: check-descriptions ( element -- )
+    { $description $class-description $var-description }
+    swap '[
+        _ elements [
+            rest { { } { "" } } member?
+            [ "Empty description" throw ] when
+        ] each
+    ] each ;
+
+: check-markup ( element -- )
+    {
+        [ check-elements ]
+        [ check-rendering ]
+        [ check-examples ]
+        [ check-modules ]
+        [ check-descriptions ]
+    } cleave ;
+
+: files>vocabs ( -- assoc )
+    vocabs
+    [ [ [ vocab-docs-path ] keep ] H{ } map>assoc ]
+    [ [ [ vocab-source-path ] keep ] H{ } map>assoc ]
+    bi assoc-union ;
+
+: group-articles ( -- assoc )
+    articles get keys
+    files>vocabs
+    H{ } clone [
+        '[
+            dup >link where dup
+            [ first _ at _ push-at ] [ 2drop ] if
+        ] each
+    ] keep ;
+
+: all-word-help ( words -- seq )
+    [ word-help ] filter ;
index 0c0fcf92d2790b407a3f17b1910a91769e16a448..ed74748356cfb9182838d7ea8729c41066102e85 100644 (file)
@@ -14,6 +14,10 @@ $nl
 "To run help lint, use one of the following two words:"
 { $subsection help-lint }
 { $subsection help-lint-all }
+"Once a help lint run completes, failures can be listed:"
+{ $subsection :lint-failures }
+"Help lint failures are also shown in the " { $link "ui.tools.error-list" } "."
+$nl
 "Help lint performs the following checks:"
 { $list
     "ensures examples run and produce stated output"
index 7ec8c59ba6be75f0442004aed6d285527f3db086..42f29bc8b7a7a9d9113f8006cbaaa07de5fae337 100755 (executable)
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: fry accessors sequences parser kernel help help.markup
-help.topics words strings classes tools.vocabs namespaces make
-io io.streams.string prettyprint definitions arrays vectors
-combinators combinators.short-circuit splitting debugger
-hashtables sorting effects vocabs vocabs.loader assocs editors
-continuations classes.predicate macros math sets eval
-vocabs.parser words.symbol values grouping unicode.categories
-sequences.deep ;
+USING: assocs continuations fry help help.lint.checks
+help.topics io kernel namespaces parser sequences
+source-files.errors tools.vocabs vocabs words classes
+locals tools.errors ;
+FROM: help.lint.checks => all-vocabs ;
 IN: help.lint
 
-SYMBOL: vocabs-quot
-
-: check-example ( element -- )
-    '[
-        _ rest [
-            but-last "\n" join
-            [ (eval>string) ] call( code -- output )
-            "\n" ?tail drop
-        ] keep
-        peek assert=
-    ] vocabs-quot get call( quot -- ) ;
-
-: check-examples ( element -- )
-    \ $example swap elements [ check-example ] each ;
-
-: extract-values ( element -- seq )
-    \ $values swap elements dup empty? [
-        first rest [ first ] map prune natural-sort
-    ] unless ;
-
-: effect-values ( word -- seq )
-    stack-effect
-    [ in>> ] [ out>> ] bi append
-    [ dup pair? [ first ] when effect>string ] map
-    prune natural-sort ;
-
-: contains-funky-elements? ( element -- ? )
-    {
-        $shuffle
-        $values-x/y
-        $predicate
-        $class-description
-        $error-description
-    } swap '[ _ elements empty? not ] any? ;
-
-: don't-check-word? ( word -- ? )
-    {
-        [ macro? ]
-        [ symbol? ]
-        [ value-word? ]
-        [ parsing-word? ]
-        [ "declared-effect" word-prop not ]
-    } 1|| ;
-
-: check-values ( word element -- )
-    {
-        [
-            [ don't-check-word? ]
-            [ contains-funky-elements? ]
-            bi* or
-        ] [
-            [ effect-values ]
-            [ extract-values ]
-            bi* sequence=
-        ]
-    } 2|| [ "$values don't match stack effect" throw ] unless ;
-
-: check-nulls ( element -- )
-    \ $values swap elements
-    null swap deep-member?
-    [ "$values should not contain null" throw ] when ;
-
-: check-see-also ( element -- )
-    \ $see-also swap elements [
-        rest dup prune [ length ] bi@ assert=
-    ] each ;
-
-: vocab-exists? ( name -- ? )
-    [ vocab ] [ "all-vocabs" get member? ] bi or ;
-
-: check-modules ( element -- )
-    \ $vocab-link swap elements [
-        second
-        vocab-exists? [ "$vocab-link to non-existent vocabulary" throw ] unless
-    ] each ;
-
-: check-rendering ( element -- )
-    [ print-content ] with-string-writer drop ;
-
-: check-strings ( str -- )
-    [
-        "\n\t" intersects?
-        [ "Paragraph text should not contain \\n or \\t" throw ] when
-    ] [
-        "  " swap subseq?
-        [ "Paragraph text should not contain double spaces" throw ] when
-    ] bi ;
-
-: check-whitespace ( str1 str2 -- )
-    [ " " tail? ] [ " " head? ] bi* or
-    [ "Missing whitespace between strings" throw ] unless ;
-
-: check-bogus-nl ( element -- )
-    { { $nl } { { $nl } } } [ head? ] with any?
-    [ "Simple element should not begin with a paragraph break" throw ] when ;
-
-: check-elements ( element -- )
-    {
-        [ check-bogus-nl ]
-        [ [ string? ] filter [ check-strings ] each ]
-        [ [ simple-element? ] filter [ check-elements ] each ]
-        [ 2 <clumps> [ [ string? ] all? ] filter [ first2 check-whitespace ] each ]
-    } cleave ;
-
-: check-descriptions ( element -- )
-    { $description $class-description $var-description }
-    swap '[
-        _ elements [
-            rest { { } { "" } } member?
-            [ "Empty description" throw ] when
-        ] each
-    ] each ;
-
-: check-markup ( element -- )
-    {
-        [ check-elements ]
-        [ check-rendering ]
-        [ check-examples ]
-        [ check-modules ]
-        [ check-descriptions ]
-    } cleave ;
-
-: check-class-description ( word element -- )
-    [ class? not ]
-    [ { $class-description } swap elements empty? not ] bi* and
-    [ "A word that is not a class has a $class-description" throw ] when ;
-
-: all-word-help ( words -- seq )
-    [ word-help ] filter ;
-
-TUPLE: help-error error topic ;
-
-C: <help-error> help-error
-
-M: help-error error.
-    [ "In " write topic>> pprint nl ]
-    [ error>> error. ]
-    bi ;
-
-: check-something ( obj quot -- )
-    flush '[ _ call( -- ) ] swap '[ _ <help-error> , ] recover ; inline
+SYMBOL: lint-failures
+
+lint-failures [ H{ } clone ] initialize
+
+TUPLE: help-lint-error < source-file-error ;
+
+SYMBOL: +help-lint-failure+
+
+T{ error-type
+   { type +help-lint-failure+ }
+   { word ":lint-failures" }
+   { plural "help lint failures" }
+   { icon "vocab:ui/tools/error-list/icons/help-lint-error.tiff" }
+   { quot [ lint-failures get values ] }
+   { forget-quot [ lint-failures get delete-at ] }
+} define-error-type
+
+M: help-lint-error error-type drop +help-lint-failure+ ;
+
+<PRIVATE
+
+: <help-lint-error> ( error topic -- help-lint-error )
+    \ help-lint-error <definition-error> ;
+
+PRIVATE>
+
+: help-lint-error ( error topic -- )
+    lint-failures get pick
+    [ [ [ <help-lint-error> ] keep ] dip set-at ] [ delete-at drop ] if
+    notify-error-observers ;
+
+<PRIVATE
+
+:: check-something ( topic quot -- )
+    [ quot call( -- ) f ] [ ] recover
+    topic help-lint-error ; inline
 
 : check-word ( word -- )
     [ with-file-vocabs ] vocabs-quot set
     dup word-help [
-        dup '[
+        [ >link ] keep '[
             _ dup word-help
             [ check-values ]
             [ check-class-description ]
@@ -165,69 +57,38 @@ M: help-error error.
 
 : check-words ( words -- ) [ check-word ] each ;
 
-: check-article-title ( article -- )
-    article-title first LETTER?
-    [ "Article title must begin with a capital letter" throw ] unless ;
-
 : check-article ( article -- )
     [ with-interactive-vocabs ] vocabs-quot set
-    dup '[
+    >link dup '[
         _
         [ check-article-title ]
         [ article-content check-markup ] bi
     ] check-something ;
 
-: files>vocabs ( -- assoc )
-    vocabs
-    [ [ [ vocab-docs-path ] keep ] H{ } map>assoc ]
-    [ [ [ vocab-source-path ] keep ] H{ } map>assoc ]
-    bi assoc-union ;
-
-: group-articles ( -- assoc )
-    articles get keys
-    files>vocabs
-    H{ } clone [
-        '[
-            dup >link where dup
-            [ first _ at _ push-at ] [ 2drop ] if
-        ] each
-    ] keep ;
-
 : check-about ( vocab -- )
     dup '[ _ vocab-help [ article drop ] when* ] check-something ;
 
-: check-vocab ( vocab -- seq )
+: check-vocab ( vocab -- )
     "Checking " write dup write "..." print
-    [
-        [ check-about ]
-        [ words [ check-word ] each ]
-        [ "vocab-articles" get at [ check-article ] each ]
-        tri
-    ] { } make ;
+    [ vocab check-about ]
+    [ words [ check-word ] each ]
+    [ vocab-articles get at [ check-article ] each ]
+    tri ;
 
-: run-help-lint ( prefix -- alist )
+PRIVATE>
+
+: help-lint ( prefix -- )
     [
-        all-vocabs-seq [ vocab-name ] map "all-vocabs" set
-        group-articles "vocab-articles" set
+        all-vocabs-seq [ vocab-name ] map all-vocabs set
+        group-articles vocab-articles set
         child-vocabs
-        [ dup check-vocab ] { } map>assoc
-        [ nip empty? not ] assoc-filter
+        [ check-vocab ] each
     ] with-scope ;
 
-: typos. ( assoc -- )
-    [
-        "==== ALL CHECKS PASSED" print
-    ] [
-        [
-            swap vocab-heading.
-            [ print-error nl ] each
-        ] assoc-each
-    ] if-empty ;
-
-: help-lint ( prefix -- ) run-help-lint typos. ;
-
 : help-lint-all ( -- ) "" help-lint ;
 
+: :lint-failures ( -- ) lint-failures get errors. ;
+
 : unlinked-words ( words -- seq )
     all-word-help [ article-parent not ] filter ;
 
@@ -235,6 +96,6 @@ M: help-error error.
     all-words
     [ word-help not ] filter
     [ article-parent ] filter
-    [ "predicating" word-prop not ] filter ;
+    [ predicate? not ] filter ;
 
 MAIN: help-lint
index 26812947c0c3880f2511038ab7443ae0274b2099..2ed18b7cd579623720b246c25bc41ea51b4097d8 100644 (file)
@@ -76,9 +76,11 @@ $nl
 { $code "." }
 "What we just did is called " { $emphasis "interactive testing" } ". A more advanced technique which comes into play with larger programs is " { $link "tools.test" } "."
 $nl
-"Open the file named " { $snippet "palindrome-tests.factor" } "; it is located in the same directory as " { $snippet "palindrome.factor" } ", and it was created by the scaffold tool."
+"Create a test harness file using the scaffold tool:"
+{ $code "\"palindrome\" scaffold-tests" }
+"Now, open the file named " { $snippet "palindrome-tests.factor" } "; it is located in the same directory as " { $snippet "palindrome.factor" } ", and it was created by the scaffold tool."
 $nl
-"We will add some unit tests, which are similar to the interactive tests we did above. Unit tests are defined with the " { $link unit-test } " word, which takes a sequence of expected outputs, and a piece of code. It runs the code, and asserts that it outputs the expected values."
+"We will add some unit tests, which are similar to the interactive tests we did above. Unit tests are defined with the " { $link POSTPONE: unit-test } " word, which takes a sequence of expected outputs, and a piece of code. It runs the code, and asserts that it outputs the expected values."
 $nl
 "Add the following three lines to " { $snippet "palindrome-tests.factor" } ":"
 { $code
index 358521473540ce253234015f96c15a63ed1f62a9..f20e65dc275a23b94e1ebc8f06dd6a0058c755d9 100644 (file)
@@ -140,7 +140,46 @@ HELP: <process-stream>
   { "desc" "a launch descriptor" }
   { "encoding" "an encoding descriptor" }
   { "stream" "a bidirectional stream" } }
-{ $description "Launches a process and redirects its input and output via a pair of pipes which may be read and written as a stream of the given encoding." } ;
+{ $description "Launches a process and redirects its input and output via a pair of pipes which may be read and written as a stream with the given encoding." } ;
+
+HELP: <process-reader>
+{ $values
+  { "desc" "a launch descriptor" }
+  { "encoding" "an encoding descriptor" }
+  { "stream" "an input stream" } }
+{ $description "Launches a process and redirects its output via a pipe which may be read as a stream with the given encoding." } ;
+
+HELP: <process-writer>
+{ $values
+  { "desc" "a launch descriptor" }
+  { "encoding" "an encoding descriptor" }
+  { "stream" "an output stream" }
+}
+{ $description "Launches a process and redirects its input via a pipe which may be written to as a stream with the given encoding." } ;
+
+HELP: with-process-stream
+{ $values
+  { "desc" "a launch descriptor" }
+  { "encoding" "an encoding descriptor" }
+  { "quot" quotation }
+}
+{ $description "Launches a process and redirects its input and output via a pair of pipes. The quotation is called with " { $link input-stream } " and " { $link output-stream } " rebound to these pipes." } ;
+
+HELP: with-process-reader
+{ $values
+  { "desc" "a launch descriptor" }
+  { "encoding" "an encoding descriptor" }
+  { "quot" quotation }
+}
+{ $description "Launches a process and redirects its output via a pipe. The quotation is called with " { $link input-stream } " and " { $link output-stream } " rebound to this pipe." } ;
+
+HELP: with-process-writer
+{ $values
+  { "desc" "a launch descriptor" }
+  { "encoding" "an encoding descriptor" }
+  { "quot" quotation }
+}
+{ $description "Launches a process and redirects its input via a pipe. The quotation is called with " { $link input-stream } " and " { $link output-stream } " rebound to this pipe." } ;
 
 HELP: wait-for-process
 { $values { "process" process } { "status" object } }
@@ -175,7 +214,11 @@ ARTICLE: "io.launcher.launch" "Launching processes"
 "Redirecting standard input and output to a pipe:"
 { $subsection <process-reader> }
 { $subsection <process-writer> }
-{ $subsection <process-stream> } ;
+{ $subsection <process-stream> }
+"Combinators built on top of the above:"
+{ $subsection with-process-reader }
+{ $subsection with-process-writer }
+{ $subsection with-process-stream } ;
 
 ARTICLE: "io.launcher.examples" "Launcher examples"
 "Starting a command and waiting for it to finish:"
index ed45d5ccb90adc1c950e2fce9d8f465ebc3549eb..6148394c5767a66dc294f01f63282a5a4130d119 100644 (file)
@@ -274,7 +274,7 @@ HELP: <input>
 { $description "Creates a new " { $link input } "." } ;
 
 HELP: standard-table-style
-{ $values { "style" hashtable } }
+{ $values { "value" hashtable } }
 { $description "Outputs a table style where cells are separated by 5-pixel gaps and framed by a light gray border. This style can be passed to " { $link tabular-output } "." } ;
 
 ARTICLE: "io.streams.plain" "Plain writer streams"
index 89fe90b5685b938437d3b7995021632618415356..66b5f0458fbcfb59584d6c61012fb095c571a1ef 100644 (file)
@@ -135,11 +135,11 @@ SYMBOL: wrap-margin
 SYMBOL: table-gap
 SYMBOL: table-border
 
-: standard-table-style ( -- style )
+CONSTANT: standard-table-style
     H{
         { table-gap { 5 5 } }
         { table-border T{ rgba f 0.8 0.8 0.8 1.0 } }
-    } ;
+    }
 
 ! Input history
 TUPLE: input string ;
index 014e096b1db41107fb68258536bb127521b6ecc1..0f13b6dd8624064c264d500e0f8b2edd4df0e00d 100644 (file)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax kernel io system prettyprint ;
+USING: help.markup help.syntax kernel io system prettyprint continuations ;
 IN: listener
 
 ARTICLE: "listener-watch" "Watching variables in the listener"
@@ -41,32 +41,18 @@ $nl
 { $example "{ 1 2 3 } [\n    .\n] each" "1\n2\n3" }
 "The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them."
 { $subsection "listener-watch" }
-"You can start a nested listener or exit a listener using the following words:"
+"To start a nested listener:"
 { $subsection listener }
-{ $subsection bye }
-"Finally, the multi-line expression reading word can be used independently of the rest of the listener:"
+"To exit the listener, invoke the " { $link return } " word."
+$nl
+"Multi-line quotations can be read independently of the rest of the listener:"
 { $subsection read-quot } ;
 
 ABOUT: "listener"
 
-<PRIVATE
-
-HELP: quit-flag
-{ $var-description "Variable set to true by " { $link bye } " word; it forces the next iteration of the " { $link listener } " loop to end." } ;
-
-PRIVATE>
-
 HELP: read-quot
 { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } }
 { $description "Reads a Factor expression which possibly spans more than one line from " { $link input-stream } ". Additional lines of input are read while the parser stack height is greater than one. Since structural parsing words push partial quotations on the stack, this will keep on reading input until all delimited parsing words are terminated." } ;
 
-HELP: listen
-{ $description "Prompts for an expression on " { $link input-stream } " and evaluates it. On end of file, " { $link quit-flag } " is set to terminate the listener loop." }
-{ $errors "If the expression input by the user throws an error, the error is printed to " { $link output-stream } " and the word returns normally." } ;
-
 HELP: listener
 { $description "Prompts for expressions on " { $link input-stream } " and evaluates them until end of file is reached." } ;
-
-HELP: bye
-{ $description "Exits the current listener." }
-{ $notes "This word is for interactive use only. To exit the Factor runtime, use " { $link exit } "." } ;
index 4f7ccf227e54e12567e6e4d7f47916fa123278d5..4234a0023b4d9c09a38ed307b33e8f89fc263c7a 100644 (file)
@@ -4,7 +4,7 @@ USING: arrays hashtables io kernel math math.parser memory
 namespaces parser lexer sequences strings io.styles
 vectors words generic system combinators continuations debugger
 definitions compiler.units accessors colors prettyprint fry
-sets vocabs.parser ;
+sets vocabs.parser source-files.errors locals ;
 IN: listener
 
 GENERIC: stream-read-quot ( stream -- quot/f )
@@ -32,17 +32,9 @@ M: object stream-read-quot
 
 : read-quot ( -- quot/f ) input-stream get stream-read-quot ;
 
-<PRIVATE
-
-SYMBOL: quit-flag
-
-PRIVATE>
-
-: bye ( -- ) quit-flag on ;
-
 SYMBOL: visible-vars
 
-: show-var ( var -- ) visible-vars  [ swap suffix ] change ;
+: show-var ( var -- ) visible-vars [ swap suffix ] change ;
 
 : show-vars ( seq -- ) visible-vars [ swap union ] change ;
 
@@ -68,6 +60,8 @@ SYMBOL: max-stack-items
 
 10 max-stack-items set-global
 
+SYMBOL: error-summary-hook
+
 <PRIVATE
 
 : title. ( string -- )
@@ -96,26 +90,44 @@ SYMBOL: max-stack-items
         ] dip
     ] when stack. ;
 
-: stacks. ( -- )
+: datastack. ( datastack -- )
     display-stacks? get [
-        datastack [ nl "--- Data stack:" title. trimmed-stack. ] unless-empty
-    ] when ;
+        [ nl "--- Data stack:" title. trimmed-stack. ] unless-empty
+    ] [ drop ] if ;
 
 : prompt. ( -- )
-    "( " in get auto-use? get [ " - auto" append ] when " )" 3append
+    in get auto-use? get [ " - auto" append ] when "( " " )" surround
     H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ;
 
-: listen ( -- )
-    visible-vars. stacks. prompt.
-    [ read-quot [ [ call-error-hook ] recover ] [ bye ] if* ]
-    [ dup lexer-error? [ call-error-hook ] [ rethrow ] if ] recover ;
+[ error-summary ] error-summary-hook set-global
+
+: call-error-summary-hook ( -- )
+    error-summary-hook get call( -- ) ;
+
+:: (listener) ( datastack -- )
+    call-error-summary-hook
+    visible-vars.
+    datastack datastack.
+    prompt.
+
+    [
+        read-quot [
+            '[ datastack _ with-datastack ]
+            [ call-error-hook datastack ]
+            recover
+        ] [ return ] if*
+    ] [
+        dup lexer-error?
+        [ call-error-hook datastack ]
+        [ rethrow ]
+        if
+    ] recover
 
-: until-quit ( -- )
-    quit-flag get [ quit-flag off ] [ listen until-quit ] if ;
+    (listener) ;
 
 PRIVATE>
 
 : listener ( -- )
-    [ until-quit ] with-interactive-vocabs ;
+    [ [ { } (listener) ] with-interactive-vocabs ] with-return ;
 
 MAIN: listener
index 4e10fc3de4548e3afc165ad5b8b5a64c055cfb9f..74ca07cda305d0b4322f92d9b8cb36a119d93a63 100644 (file)
@@ -61,3 +61,5 @@ M: memoized reset-word
 
 : invalidate-memoized ( inputs... word -- )
     [ stack-effect in>> packer call ] [ "memoize" word-prop delete-at ] bi ;
+
+\ invalidate-memoized t "no-compile" set-word-prop
\ No newline at end of file
index 0edfb05a3081da96ed583c0454792630a6be6cc7..0cf7556bcd01513f23472bd3f5082cca7bb969c8 100755 (executable)
@@ -137,9 +137,6 @@ ERROR: no-content-disposition multipart ;
         [ no-content-disposition ]
     } case ;
 
-: assert-sequence= ( a b -- )
-    2dup sequence= [ 2drop ] [ assert ] if ;
-
 : read-assert-sequence= ( sequence -- )
     [ length read ] keep assert-sequence= ;
 
diff --git a/basis/models/arrow/smart/authors.txt b/basis/models/arrow/smart/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
index 45faf52b97948380e5235815975a2914f239d0d9..3cc22d8d40ab2314db7cfb1a9bb9cb305855dd70 100644 (file)
@@ -7,15 +7,15 @@ HELP: <smart-arrow>
 { $examples
   "A model which adds the values of two existing models:"
   { $example
-    "USING: models models.arrows.smart accessors math prettyprint ;"
+    "USING: models models.arrow.smart accessors kernel math prettyprint ;"
     "1 <model> 2 <model> [ + ] <smart-arrow>"
     "[ activate-model ] [ value>> ] bi ."
     "3"
   }
 } ;
 
-ARTICLE: "models.arrows.smart" "Smart arrow models"
-"The " { $vocab-link "models.arrows.smart" } " vocabulary generalizes arrows to arbitrary input arity. They're called “smart” because they resemble " { $link "combinators.smart" } "."
+ARTICLE: "models.arrow.smart" "Smart arrow models"
+"The " { $vocab-link "models.arrow.smart" } " vocabulary generalizes arrows to arbitrary input arity. They're called “smart” because they resemble " { $link "combinators.smart" } "."
 { $subsection <smart-arrow> } ;
 
-ABOUT: "models.arrows.smart"
\ No newline at end of file
+ABOUT: "models.arrow.smart"
\ No newline at end of file
diff --git a/basis/models/arrow/smart/smart-tests.factor b/basis/models/arrow/smart/smart-tests.factor
new file mode 100644 (file)
index 0000000..3e8375e
--- /dev/null
@@ -0,0 +1,4 @@
+IN: models.arrows.smart.tests
+USING: models.arrow.smart tools.test accessors models math kernel ;
+
+[ 7 ] [ 3 <model> 4 <model> [ + ] <smart-arrow> [ activate-model ] [ value>> ] bi ] unit-test
\ No newline at end of file
diff --git a/basis/models/arrow/smart/smart.factor b/basis/models/arrow/smart/smart.factor
new file mode 100644 (file)
index 0000000..257a2bb
--- /dev/null
@@ -0,0 +1,9 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: models.arrow models.product stack-checker accessors fry
+generalizations macros kernel ;
+IN: models.arrow.smart
+
+MACRO: <smart-arrow> ( quot -- quot' )
+    [ infer in>> dup ] keep
+    '[ _ narray <product> [ _ firstn @ ] <arrow> ] ;
\ No newline at end of file
index 4bf74b3b92e06807bfbdb4da37a1de0b92007500..5ecb0fa34ada9a88cf9a3ac944fe6cb7bd7687e7 100644 (file)
@@ -1,12 +1,10 @@
 ! Copyright (C) 2008, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays fry kernel models.product models.arrow
-sequences unicode.case ;
+USING: fry kernel models.arrow.smart sequences unicode.case ;
 IN: models.search
 
 : <search> ( values search quot -- model )
-    [ 2array <product> ] dip
-    '[ first2 _ curry filter ] <arrow> ;
+    '[ _ curry filter ] <smart-arrow> ; inline
 
 : <string-search> ( values search quot -- model )
-    '[ swap @ [ >case-fold ] bi@ subseq? ] <search> ;
+    '[ swap @ [ >case-fold ] bi@ subseq? ] <search> ; inline
index 23c150796fac63b956280264821018fcf3a3e0c6..efd2e4927b53aa8fe5c4569e5757565f8a1b2880 100644 (file)
@@ -1,8 +1,7 @@
-! Copyright (C) 2008 Slava Pestov
+! Copyright (C) 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays fry kernel models.product models.arrow
-sequences sorting ;
+USING: sorting models.arrow.smart fry ;
 IN: models.sort
 
 : <sort> ( values sort -- model )
-    2array <product> [ first2 sort ] <arrow> ;
\ No newline at end of file
+    [ '[ _ call( obj1 obj2 -- <=> ) ] sort ] <smart-arrow> ; inline
\ No newline at end of file
index 91f1dcf1f80b2a995a608e08904ac3199ee82cc2..ca9a86b6d92788a1d2e047a4f31eb66a08008232 100644 (file)
@@ -21,7 +21,7 @@ TUPLE: deque { front read-only } { back read-only } ;
     [ back>> ] [ front>> ] bi deque boa ;
 
 : flipped ( deque quot -- newdeque )
-    [ flip ] dip call flip ;
+    [ flip ] dip call flip ; inline
 PRIVATE>
 
 : deque-empty? ( deque -- ? )
index 07c26ad100f4490a19290245ab6eaadfba248570..156900f7270758bc17ad5efb19307e71a4392d79 100644 (file)
@@ -2,7 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel generic sequences io words arrays summary effects
 continuations assocs accessors namespaces compiler.errors
-stack-checker.values stack-checker.recursive-state ;
+stack-checker.values stack-checker.recursive-state
+source-files.errors compiler.errors ;
 IN: stack-checker.errors
 
 : pretty-word ( word -- word' )
@@ -10,7 +11,7 @@ IN: stack-checker.errors
 
 TUPLE: inference-error error type word ;
 
-M: inference-error compiler-error-type type>> ;
+M: inference-error error-type type>> ;
 
 : (inference-error) ( ... class type -- * )
     [ boa ] dip
@@ -18,10 +19,10 @@ M: inference-error compiler-error-type type>> ;
     \ inference-error boa rethrow ; inline
 
 : inference-error ( ... class -- * )
-    +error+ (inference-error) ; inline
+    +compiler-error+ (inference-error) ; inline
 
 : inference-warning ( ... class -- * )
-    +warning+ (inference-error) ; inline
+    +compiler-warning+ (inference-error) ; inline
 
 TUPLE: literal-expected what ;
 
@@ -81,3 +82,8 @@ TUPLE: unknown-primitive-error ;
 
 : unknown-primitive-error ( -- * )
     \ unknown-primitive-error inference-warning ;
+
+TUPLE: transform-expansion-error word error ;
+
+: transform-expansion-error ( word error -- * )
+    \ transform-expansion-error inference-error ;
\ No newline at end of file
index 9dc82339b51d3074928f2045e4c6e11a559f7dff..d6cee8e08f4b0875f1990dcf078abdfccf5ecf7e 100644 (file)
@@ -1,19 +1,26 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel prettyprint io debugger
-sequences assocs stack-checker.errors summary effects ;
+sequences assocs stack-checker.errors summary effects make ;
 IN: stack-checker.errors.prettyprint
 
+M: inference-error summary error>> summary ;
+
 M: inference-error error-help error>> error-help ;
 
 M: inference-error error.
     [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ;
 
-M: literal-expected error.
-    "Got a computed value where a " write what>> write " was expected" print ;
+M: literal-expected summary
+    [ "Got a computed value where a " % what>> % " was expected" % ] "" make ;
+
+M: literal-expected error. summary print ;
+
+M: unbalanced-branches-error summary
+    drop "Unbalanced branches" ;
 
 M: unbalanced-branches-error error.
-    "Unbalanced branches:" print
+    dup summary print
     [ quots>> ] [ branches>> [ length <effect> ] { } assoc>map ] bi zip
     [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ;
 
@@ -25,16 +32,18 @@ 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: missing-effect summary
+    [
+        "The word " %
+        word>> name>> %
+        " must declare a stack effect" %
+    ] "" make ;
 
-M: effect-error error.
-    "Stack effects of the word " write
-    [ word>> pprint " do not match." print ]
-    [ "Inferred: " write inferred>> . ]
-    [ "Declared: " write declared>> . ] tri ;
+M: effect-error summary
+    [
+        "Stack effect declaration of the word " %
+        word>> name>> % " is wrong" %
+    ] "" make ;
 
 M: recursive-quotation-error error.
     "The quotation " write
@@ -42,26 +51,40 @@ M: recursive-quotation-error error.
     " 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: undeclared-recursion-error summary
+    drop
+    "Inline recursive words must be declared recursive" ;
 
-M: diverging-recursion-error error.
-    "The recursive word " write
-    word>> pprint
-    " digs arbitrarily deep into the stack" print ;
+M: diverging-recursion-error summary
+    [
+        "The recursive word " %
+        word>> name>> %
+        " digs arbitrarily deep into the stack" %
+    ] "" make ;
 
-M: unbalanced-recursion-error error.
-    "The recursive word " write
-    word>> pprint
-    " leaves with the stack having the wrong height" print ;
+M: unbalanced-recursion-error summary
+    [
+        "The recursive word " %
+        word>> name>> %
+        " leaves with the stack having the wrong height" %
+    ] "" make ;
 
-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: inconsistent-recursive-call-error summary
+    [
+        "The recursive word " %
+        word>> name>> %
+        " calls itself with a different set of quotation parameters than were input" %
+    ] "" make ;
 
-M: unknown-primitive-error error.
+M: unknown-primitive-error summary
     drop
-    "Cannot determine stack effect statically" print ;
+    "Cannot determine stack effect statically" ;
+
+M: transform-expansion-error summary
+    drop
+    "Compiler transform threw an error" ;
+
+M: transform-expansion-error error.
+    [ summary print ]
+    [ "Word: " write word>> . nl ]
+    [ error>> error. ] tri ;
\ No newline at end of file
index c55e69a8a275fcda4af42d749345d63880cfad3d..ff7288202ab1abbf725ec8e891d61bba8970c103 100644 (file)
@@ -218,8 +218,7 @@ M: object infer-call*
     alien-callback
 } [ t "special" set-word-prop ] each
 
-{ call execute dispatch load-locals get-local drop-locals }
-[ t "no-compile" set-word-prop ] each
+\ clear t "no-compile" set-word-prop
 
 : non-inline-word ( word -- )
     dup called-dependency depends-on
index 0aa38769079edfbade031f4ba86f425561bf4d5f..abb1f2abdb575ce6f492dcf808ec6d25af1519f9 100644 (file)
@@ -1,6 +1,6 @@
 IN: stack-checker.transforms.tests
 USING: sequences stack-checker.transforms tools.test math kernel
-quotations stack-checker accessors combinators words arrays
+quotations stack-checker stack-checker.errors accessors combinators words arrays
 classes classes.tuple ;
 
 : compose-n-quot ( word n -- quot' ) <repetition> >quotation ;
@@ -70,4 +70,11 @@ DEFER: curry-folding-test ( quot -- )
 : member?-test ( a -- ? ) { 1 2 3 10 7 58 } member? ;
 
 [ f ] [ 1.0 member?-test ] unit-test
-[ t ] [ \ member?-test def>> first [ member?-test ] all? ] unit-test
\ No newline at end of file
+[ t ] [ \ member?-test def>> first [ member?-test ] all? ] unit-test
+
+! Macro expansion should throw its own type of error
+: bad-macro ( -- ) ;
+
+\ bad-macro [ "OOPS" throw ] 0 define-transform
+
+[ [ bad-macro ] infer ] [ inference-error? ] must-fail-with
\ No newline at end of file
index dfa46be7e2d5b19a92afb81f9a15446bb4ac49a3..fd62c4998da303168958a1a7ce3153b8e0558d2c 100755 (executable)
@@ -17,9 +17,14 @@ IN: stack-checker.transforms
         [ dup infer-word apply-word/effect ]
     } cond ;
 
+: call-transformer ( word stack quot -- newquot )
+    '[ _ _ with-datastack [ length 1 assert= ] [ first ] bi nip ]
+    [ transform-expansion-error ]
+    recover ;
+
 :: ((apply-transform)) ( word quot values stack rstate -- )
     rstate recursive-state
-    [ stack quot with-datastack first ] with-variable
+    [ word stack quot call-transformer ] with-variable
     [
         word inlined-dependency depends-on
         values [ length meta-d shorten-by ] [ #drop, ] bi
index 7c9a38796b5de053f56b9a0a3ba4c4f8c1bd64ff..3bb9ae72ac5b757af47f631a6fe38537bab7b03a 100755 (executable)
@@ -354,8 +354,6 @@ IN: tools.deploy.shaker
 
 : finish-deploy ( final-image -- )
     "Finishing up" show
-    [ { } set-datastack ] dip
-    { } set-retainstack
     V{ } set-namestack
     V{ } set-catchstack
     "Saving final image" show
index b4f862262752c82aede515fbc851dd4d3d812cd6..3310686f05c307abb2db64747fb6f27c97633cb5 100644 (file)
@@ -3,6 +3,6 @@
 USING: eval ;
 IN: tools.deploy.test.11
 
-: foo ( -- ) "USING: math prettyprint ; 2 2 + ." eval ;
+: foo ( -- ) "USING: math prettyprint ; 2 2 + ." eval( -- ) ;
 
 MAIN: foo
\ No newline at end of file
index a16e3c82c565bbc81bd31337556d3c8bcf1d708b..5d6816121d28074dc7901141d5eb1a9e7cdafd1f 100644 (file)
@@ -9,7 +9,7 @@ GENERIC: my-generic ( x -- b )
 
 M: integer my-generic sq ;
 
-M: fixnum my-generic call-next-method my-var get call ;
+M: fixnum my-generic call-next-method my-var get call( a -- b ) ;
 
 : test-7 ( -- )
     [ 1 + ] my-var set-global
diff --git a/basis/tools/errors/authors.txt b/basis/tools/errors/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/tools/errors/errors-docs.factor b/basis/tools/errors/errors-docs.factor
new file mode 100644 (file)
index 0000000..9fc324b
--- /dev/null
@@ -0,0 +1,19 @@
+IN: tools.errors
+USING: help.markup help.syntax source-files.errors ;
+
+HELP: errors.
+{ $values { "errors" "a sequence of " { $link source-file-error } " instances" } }
+{ $description "Prints a list of errors, grouped by source file." } ;
+
+ARTICLE: "tools.errors" "Batch error reporting"
+"Some tools, such as the " { $link "compiler" } ", " { $link "tools.test" } " and " { $link "help.lint" } " need to report multiple errors at a time. Each error is associated with a source file, line number, and optionally, a definition. " { $link "errors" } " cannot be used for this purpose, so the " { $vocab-link "source-files.errors" } " vocabulary provides an alternative mechanism. Note that the words in this vocabulary are used for implementation only; to actually list errors, consult the documentation for the relevant tools."
+$nl
+"Source file errors inherit from a class:"
+{ $subsection source-file-error }
+"Printing an error summary:"
+{ $subsection error-summary }
+"Printing a list of errors:"
+{ $subsection errors. }
+"Batch errors are reported in the " { $link "ui.tools.error-list" } "." ;
+
+ABOUT: "tools.errors"
\ No newline at end of file
diff --git a/basis/tools/errors/errors.factor b/basis/tools/errors/errors.factor
new file mode 100644 (file)
index 0000000..a8708fd
--- /dev/null
@@ -0,0 +1,40 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs debugger io kernel sequences source-files.errors
+summary accessors continuations make math.parser io.styles namespaces ;
+IN: tools.errors
+
+#! Tools for source-files.errors. Used by tools.tests and others
+#! for error reporting
+
+M: source-file-error summary
+    error>> summary ;
+
+M: source-file-error compute-restarts
+    error>> compute-restarts ;
+
+M: source-file-error error-help
+    error>> error-help ;
+
+M: source-file-error error.
+    [
+        [
+            [
+                [ file>> [ % ": " % ] when* ]
+                [ line#>> [ # "\n" % ] when* ] bi
+            ] "" make
+        ] [
+            [
+                presented set
+                bold font-style set
+            ] H{ } make-assoc
+        ] bi format
+    ] [ error>> error. ] bi ;
+
+: errors. ( errors -- )
+    group-by-source-file sort-errors
+    [
+        [ nl "==== " write print nl ]
+        [ [ nl ] [ error. ] interleave ]
+        bi*
+    ] assoc-each ;
index 864a637096c0c75790b63ff4d57e74cb208fc96a..f4488136b2d7b32323acb884d07c07be762d7191 100644 (file)
@@ -7,7 +7,7 @@ continuations generic compiler.units sets classes fry ;
 IN: tools.profiler
 
 : profile ( quot -- )
-    [ t profiling call ] [ f profiling ] [ ] cleanup ;
+    [ t profiling call ] [ f profiling ] [ ] cleanup ; inline
 
 : filter-counts ( alist -- alist' )
     [ second 0 > ] filter ;
index 3cabff457f270a2258cfb302289859bb867a59cc..9122edcb67b2be3bb9ec57c441c5a1ff56396639 100644 (file)
@@ -3,33 +3,26 @@ IN: tools.test
 
 ARTICLE: "tools.test.write" "Writing unit tests"
 "Assert that a quotation outputs a specific set of values:"
-{ $subsection unit-test }
+{ $subsection POSTPONE: unit-test }
 "Assert that a quotation throws an error:"
-{ $subsection must-fail }
-{ $subsection must-fail-with }
+{ $subsection POSTPONE: must-fail }
+{ $subsection POSTPONE: must-fail-with }
 "Assert that a quotation or word has a specific static stack effect (see " { $link "inference" } "):"
-{ $subsection must-infer }
-{ $subsection must-infer-as } ;
+{ $subsection POSTPONE: must-infer }
+{ $subsection POSTPONE: must-infer-as }
+"All of the above are used like ordinary words but are actually parsing words. This ensures that parse-time state, namely the line number, can be associated with the test in question, and reported in test failures." ;
 
 ARTICLE: "tools.test.run" "Running unit tests"
 "The following words run test harness files; any test failures are collected and printed at the end:"
 { $subsection test }
-{ $subsection test-all } ;
-
-ARTICLE: "tools.test.failure" "Handling test failures"
-"Most of the time the words documented in " { $link "tools.test.run" } " are used because they print all test failures in human-readable form. Some tools inspect the test failures and takes some kind of action instead, for example, " { $vocab-link "mason" } "."
-$nl
-"The following words output an association list mapping vocabulary names to sequences of failures; a failure is an array having the shape " { $snippet "{ error test continuation }" } ", and the elements are as follows:"
-{ $list
-    { { $snippet "error" } " - the error thrown by the unit test" }
-    { { $snippet "test" } " - a pair " { $snippet "{ output input }" } " containing expected output and a unit test quotation which didn't produce this output" }
-    { { $snippet "continuation" } " - the traceback at the point of the error" }
-}
-"The following words run test harness files and output failures:"
-{ $subsection run-tests }
-{ $subsection run-all-tests }
+{ $subsection test-all }
 "The following word prints failures:"
-{ $subsection test-failures. } ;
+{ $subsection :test-failures }
+"Test failures are reported using the " { $link "tools.errors" } " mechanism and are shown in the " { $link "ui.tools.error-list" } "."
+$nl
+"Unit test failures are instances of a class, and are stored in a global variable:"
+{ $subsection test-failure }
+{ $subsection test-failures } ;
 
 ARTICLE: "tools.test" "Unit testing"
 "A unit test is a piece of code which starts with known input values, then compares the output of a word with an expected output, where the expected output is defined by the word's contract."
@@ -45,12 +38,12 @@ $nl
 $nl
 "If the test harness needs to define words, they should be placed in a vocabulary named " { $snippet { $emphasis "vocab" } ".tests" } " where " { $emphasis "vocab" } " is the vocab being tested."
 { $subsection "tools.test.write" }
-{ $subsection "tools.test.run" }
-{ $subsection "tools.test.failure" } ;
+{ $subsection "tools.test.run" } ;
 
 ABOUT: "tools.test"
 
 HELP: unit-test
+{ $syntax "[ output ] [ input ] unit-test" }
 { $values { "output" "a sequence of expected stack elements" } { "input" "a quotation run with an empty stack" } }
 { $description "Runs a quotation with an empty stack, comparing the resulting stack with " { $snippet "output" } ". Elements are compared using " { $link = } ". Throws an error if the expected stack does not match the resulting stack." } ;
 
@@ -78,17 +71,8 @@ HELP: test
 { $values { "prefix" "a vocabulary name" } }
 { $description "Runs unit tests for the vocabulary named " { $snippet "prefix" } " and all of its child vocabularies." } ;
 
-HELP: run-tests
-{ $values { "prefix" "a vocabulary name" } { "failures" "an association list of unit test failures" } }
-{ $description "Runs unit tests for the vocabulary named " { $snippet "prefix" } " and all of its child vocabularies. Outputs unit test failures as documented in " { $link "tools.test.failure" } "." } ;
-
 HELP: test-all
 { $description "Runs unit tests for all loaded vocabularies." } ;
 
-HELP: run-all-tests
-{ $values { "failures" "an association list of unit test failures" } }
-{ $description "Runs unit tests for all loaded vocabularies and outputs unit test failures as documented in " { $link "tools.test.failure" } "." } ;
-
-HELP: test-failures.
-{ $values { "assoc" "an association list of unit test failures" } }
-{ $description "Prints unit test failures output by " { $link run-tests } " or " { $link run-all-tests } " to " { $link output-stream } "." } ;
+HELP: :test-failures
+{ $description "Prints all pending unit test failures." } ;
index c6dea08d181556e9051b3dd3a310daa763b6b681..0741b90984d574c9ff8292fc8ba88fea35821fb7 100644 (file)
-! Copyright (C) 2003, 2008 Slava Pestov.
+! Copyright (C) 2003, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces arrays prettyprint sequences kernel
-vectors quotations words parser assocs combinators continuations
-debugger io io.styles io.files vocabs vocabs.loader source-files
-compiler.units summary stack-checker effects tools.vocabs fry ;
+USING: accessors arrays assocs combinators compiler.units
+continuations debugger effects fry generalizations io io.files
+io.styles kernel lexer locals macros math.parser namespaces
+parser prettyprint quotations sequences source-files splitting
+stack-checker summary unicode.case vectors vocabs vocabs.loader words
+tools.vocabs tools.errors source-files.errors io.streams.string make
+compiler.errors ;
 IN: tools.test
 
-SYMBOL: failures
+TUPLE: test-failure < source-file-error continuation ;
 
-: <failure> ( error what -- triple )
-    error-continuation get 3array ;
+SYMBOL: +test-failure+
 
-: failure ( error what -- )
+M: test-failure error-type drop +test-failure+ ;
+
+SYMBOL: test-failures
+
+test-failures [ V{ } clone ] initialize
+
+T{ error-type
+   { type +test-failure+ }
+   { word ":test-failures" }
+   { plural "unit test failures" }
+   { icon "vocab:ui/tools/error-list/icons/unit-test-error.tiff" }
+   { quot [ test-failures get ] }
+} define-error-type
+
+<PRIVATE
+
+: <test-failure> ( error experiment file line# -- triple )
+    test-failure new
+        swap >>line#
+        swap >>file
+        swap >>asset
+        swap >>error
+        error-continuation get >>continuation ;
+
+: failure ( error experiment file line# -- )
     "--> test failed!" print
-    <failure> failures get push ;
+    <test-failure> test-failures get push
+    notify-error-observers ;
 
-SYMBOL: this-test
+SYMBOL: file
 
-: (unit-test) ( what quot -- )
-    swap dup . flush this-test set
-    failures get [
-        [ this-test get failure ] recover
-    ] [
-        call
-    ] if ; inline
+: file-failure ( error -- )
+    f file get f failure ;
 
-: unit-test ( output input -- )
-    [ 2array ] 2keep '[
-        _ { } _ with-datastack swap >array assert=
-    ] (unit-test) ;
+:: (unit-test) ( output input -- error ? )
+    [ { } input with-datastack output assert-sequence= f f ] [ t ] recover ; inline
 
 : short-effect ( effect -- pair )
     [ in>> length ] [ out>> length ] bi 2array ;
 
-: must-infer-as ( effect quot -- )
-    [ 1quotation ] dip '[ _ infer short-effect ] unit-test ;
+:: (must-infer-as) ( effect quot -- error ? )
+    [ quot infer short-effect effect assert= f f ] [ t ] recover ; inline
+
+:: (must-infer) ( word/quot -- error ? )
+    word/quot dup word? [ '[ _ execute ] ] when :> quot
+    [ quot infer drop f f ] [ t ] recover ; inline
+
+TUPLE: did-not-fail ;
+CONSTANT: did-not-fail T{ did-not-fail }
+
+M: did-not-fail summary drop "Did not fail" ;
+
+:: (must-fail-with) ( quot pred -- error ? )
+    [ quot call did-not-fail t ]
+    [ dup pred call [ drop f f ] [ t ] if ] recover ; inline
+
+:: (must-fail) ( quot -- error ? )
+    [ quot call did-not-fail t ] [ drop f f ] recover ; inline
+
+: experiment-title ( word -- string )
+    "(" ?head drop ")" ?tail drop { { CHAR: - CHAR: \s } } substitute >title ;
 
-: must-infer ( word/quot -- )
-    dup word? [ 1quotation ] when
-    '[ _ infer drop ] [ ] swap unit-test ;
+MACRO: <experiment> ( word -- )
+    [ stack-effect in>> length dup ]
+    [ name>> experiment-title ] bi
+    '[ _ ndup _ narray _ prefix ] ;
 
-: must-fail-with ( quot pred -- )
-    [ '[ @ f ] ] dip '[ _ _ recover ] [ t ] swap unit-test ;
+: experiment. ( seq -- )
+    [ first write ": " write ] [ rest . ] bi ;
 
-: must-fail ( quot -- )
-    [ drop t ] must-fail-with ;
+:: experiment ( word: ( -- error ? ) line# -- )
+    word <experiment> :> e
+    e experiment.
+    word execute [
+        file get [
+            e file get line# failure
+        ] [ rethrow ] if
+    ] [ drop ] if ; inline
 
-: (run-test) ( vocab -- )
+: parse-test ( accum word -- accum )
+    literalize parsed
+    lexer get line>> parsed
+    \ experiment parsed ; inline
+
+<<
+
+SYNTAX: TEST:
+    scan
+    [ create-in ]
+    [ "(" ")" surround search '[ _ parse-test ] ] bi
+    define-syntax ;
+
+>>
+
+: run-test-file ( path -- )
+    dup file [
+        test-failures get file get +test-failure+ delete-file-errors
+        '[ _ run-file ] [ file-failure ] recover
+    ] with-variable ;
+
+: run-vocab-tests ( vocab -- )
     dup vocab source-loaded?>> [
-        vocab-tests [ run-file ] each
+        vocab-tests [ run-test-file ] each
     ] [ drop ] if ;
 
-: run-test ( vocab -- failures )
-    V{ } clone [
-        failures [
-            [ (run-test) ] [ swap failure ] recover
-        ] with-variable
-    ] keep ;
-
-: failure. ( triple -- )
-    dup second .
-    dup first print-error
-    "Traceback" swap third write-object ;
-
-: test-failures. ( assoc -- )
-    [
-        nl
-        [
-            "==== ALL TESTS PASSED" print
-        ] [
-            "==== FAILING TESTS:" print
-            [
-                swap vocab-heading.
-                [ failure. nl ] each
-            ] assoc-each
-        ] if-empty
-    ] [
-        "==== NOTHING TO TEST" print
-    ] if* ;
-
-: run-tests ( prefix -- failures )
-    child-vocabs [ f ] [
-        [ dup run-test ] { } map>assoc
-        [ second empty? not ] filter
-    ] if-empty ;
+: traceback-button. ( failure -- )
+    "[" write [ "Traceback" ] dip continuation>> write-object "]" print ;
 
-: test ( prefix -- )
-    run-tests test-failures. ;
+PRIVATE>
 
-: run-all-tests ( -- failures )
-    "" run-tests ;
+TEST: unit-test
+TEST: must-infer-as
+TEST: must-infer
+TEST: must-fail-with
+TEST: must-fail
+
+M: test-failure summary
+    asset>> [ [ experiment. ] with-string-writer ] [ "Top-level form" ] if* ;
+
+M: test-failure error. ( error -- )
+    [ call-next-method ]
+    [ traceback-button. ]
+    bi ;
+
+: :test-failures ( -- ) test-failures get errors. ;
+
+: test ( prefix -- )
+    child-vocabs [ run-vocab-tests ] each ;
 
-: test-all ( -- )
-    run-all-tests test-failures. ;
+: test-all ( -- ) "" test ;
index 6167a5be233fe5a42884d8d667c9be52563e1e45..66618ee23c5e1abd39a56246f736fa4d23feab1f 100644 (file)
@@ -78,7 +78,7 @@ SYMBOL: failures
             recover\r
         ] each\r
         failures get\r
-    ] with-compiler-errors ;\r
+    ] with-scope ;\r
 \r
 : source-modified? ( path -- ? )\r
     dup source-files get at [\r
index a1f18df57af6c5de52de2dc8243b6f0420e0c92e..72d7cd81cd0d3f96794a48f23a465ff4e8d69152 100644 (file)
@@ -43,6 +43,18 @@ break-hook [
     ]
 ] initialize
 
+<< {
+    (step-into-quot)
+    (step-into-dip)
+    (step-into-2dip)
+    (step-into-3dip)
+    (step-into-if)
+    (step-into-dispatch)
+    (step-into-execute)
+    (step-into-continuation)
+    (step-into-call-next-method)
+} [ t "no-compile" set-word-prop ] each >>
+
 ! Messages sent to walker thread
 SYMBOL: step
 SYMBOL: step-out
index 46ecc1a37f4db36812a48d74ec3624697a3d9d63..eb8823b10781803c1b40db4b0632b2266780ad38 100644 (file)
@@ -70,7 +70,7 @@ CLASS: {
 ! Service support; evaluate Factor code from other apps
 :: do-service ( pboard error quot -- )
     pboard error ?pasteboard-string
-    dup [ quot call ] when
+    dup [ quot call( string -- result/f ) ] when
     [ pboard set-pasteboard-string ] when* ;
 
 CLASS: {
index e02c6188f5ccd1c0c284f8614ab564c4ba651c6c..f7f7a757f54b9224833c1990f852cd9b5dd963fb 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel locals math math.order math.vectors
+USING: arrays kernel locals math math.functions math.order math.vectors
 sequences ui.gadgets accessors combinators ;
 IN: ui.baseline-alignment
 
@@ -24,35 +24,47 @@ TUPLE: gadget-metrics height ascent descent cap-height ;
     [ dup [ 2dup - ] [ f ] if ] dip
     gadget-metrics boa ; inline
 
+: ?supremum ( seq -- n/f )
+    sift [ f ] [ supremum ] if-empty ;
+
 : max-ascent ( seq -- n )
-    0 [ ascent>> [ max ] when* ] reduce ; inline
+    [ ascent>> ] map ?supremum ;
 
 : max-cap-height ( seq -- n )
-    0 [ cap-height>> [ max ] when* ] reduce ; inline
+    [ cap-height>> ] map ?supremum ;
 
 : max-descent ( seq -- n )
-    0 [ descent>> [ max ] when* ] reduce ; inline
+    [ descent>> ] map ?supremum ;
 
 : max-text-height ( seq -- y )
-    0 [ [ height>> ] [ ascent>> ] bi [ max ] [ drop ] if ] reduce ;
+    [ ascent>> ] filter [ height>> ] map ?supremum ;
 
 : max-graphics-height ( seq -- y )
-    0 [ [ height>> ] [ ascent>> ] bi [ drop ] [ max ] if ] reduce ;
-
-: (align-baselines) ( y max leading -- y' ) [ swap - ] dip + ;
+    [ ascent>> not ] filter [ height>> ] map ?supremum 0 or ;
 
 :: combine-metrics ( graphics-height ascent descent cap-height -- ascent' descent' )
-    cap-height 2 / :> mid-line 
-    graphics-height 2 /
-    [ ascent mid-line - max mid-line + >integer ]
-    [ descent mid-line + max mid-line - >integer ] bi ;
+    ascent [
+        cap-height 2 / :> mid-line 
+        graphics-height 2 /
+        [ ascent mid-line - max mid-line + floor >integer ]
+        [ descent mid-line + max mid-line - ceiling >integer ] bi
+    ] [ f f ] if ;
+
+: (measure-metrics) ( children sizes -- graphics-height ascent descent cap-height )
+    [ <gadget-metrics> ] 2map
+    {
+        [ max-graphics-height ]
+        [ max-ascent ]
+        [ max-descent ]
+        [ max-cap-height ]
+    } cleave ;
 
 PRIVATE>
 
 :: align-baselines ( gadgets -- ys )
     gadgets [ dup pref-dim <gadget-metrics> ] map
-    dup max-ascent :> max-ascent
-    dup max-cap-height :> max-cap-height
+    dup max-ascent 0 or :> max-ascent
+    dup max-cap-height 0 or :> max-cap-height
     dup max-graphics-height :> max-graphics-height
     
     max-cap-height max-graphics-height + 2 /i :> critical-line
@@ -61,20 +73,12 @@ PRIVATE>
 
     [
         dup ascent>>
-        [ ascent>> max-ascent text-leading ]
-        [ height>> max-graphics-height graphics-leading ] if
-        (align-baselines)
+        [ ascent>> max-ascent swap - text-leading ]
+        [ height>> max-graphics-height swap - 2/ graphics-leading ] if +
     ] map ;
 
 : measure-metrics ( children sizes -- ascent descent )
-    [ <gadget-metrics> ] 2map
-    {
-        [ max-graphics-height ]
-        [ max-ascent ]
-        [ max-descent ]
-        [ max-cap-height ]
-    } cleave
-    combine-metrics ;
+    (measure-metrics) combine-metrics ;
 
 : measure-height ( children sizes -- height )
-    measure-metrics + ;
\ No newline at end of file
+    (measure-metrics) dup [ combine-metrics + ] [ 3drop ] if ;
\ No newline at end of file
index ddadb6b99edce0e53cce10ce9d32eb185160086b..123f7a540dcc7253566dafb964902563ee57feb2 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors ui.images ui.pens
-ui.pens.image ui.gadgets ;
+ui.pens.image ui.gadgets ui.gadgets.labels ;
 IN: ui.gadgets.icons
 
 TUPLE: icon < gadget ;
@@ -9,4 +9,6 @@ TUPLE: icon < gadget ;
 : <icon> ( image-name -- icon )
     icon new swap <image-pen> t >>fill? >>interior ;
 
-M: icon pref-dim* dup interior>> pen-pref-dim ;
\ No newline at end of file
+M: icon pref-dim* dup interior>> pen-pref-dim ;
+
+M: image-name >label <icon> ;
\ No newline at end of file
index cae7d12dc3feae0396edfaafcae67ecb2859de3f..b49f46c05a9e4429533f9a0c4cc8fdcd45f9f743 100644 (file)
@@ -90,4 +90,50 @@ IN: ui.gadgets.packs.tests
 
 [ ] [ "g" get prefer ] unit-test
 
-[ ] [ "g" get layout ] unit-test
\ No newline at end of file
+[ ] [ "g" get layout ] unit-test
+
+! Baseline alignment without any text gadgets should behave like align=1/2
+<shelf> +baseline+ >>align
+    <gadget> { 30 30 } >>dim add-gadget
+    <gadget> { 30 20 } >>dim add-gadget
+"g" set
+
+[ { 60 30 } ] [ "g" get pref-dim ] unit-test
+
+[ ] [ "g" get prefer ] unit-test
+
+[ ] [ "g" get layout ] unit-test
+
+[ V{ { 0 0 } { 30 5 } } ]
+[ "g" get children>> [ loc>> ] map ] unit-test
+
+<shelf> +baseline+ >>align
+<gadget> { 30 30 } >>dim add-gadget
+10 10 { 10 10 } <baseline-gadget> add-gadget
+"g" set
+
+[ ] [ "g" get prefer ] unit-test
+
+[ ] [ "g" get layout ] unit-test
+
+[ V{ { 0 0 } { 30 10 } } ]
+[ "g" get children>> [ loc>> ] map ] unit-test
+
+<shelf> +baseline+ >>align
+<shelf> <gadget> { 30 30 } >>dim add-gadget add-gadget
+10 10 { 10 10 } <baseline-gadget> add-gadget
+"g" set
+
+[ ] [ "g" get prefer ] unit-test
+
+[ ] [ "g" get layout ] unit-test
+
+[ V{ { 0 0 } { 30 10 } } ]
+[ "g" get children>> [ loc>> ] map ] unit-test
+
+<shelf> +baseline+ >>align
+<gadget> { 24 24 } >>dim add-gadget
+12 9 { 15 15 } <baseline-gadget> add-gadget
+"g" set
+
+[ { 39 24 } ] [ "g" get pref-dim ] unit-test
\ No newline at end of file
index 95f04dfe4dc13c1f29c8839a6e7848503fa52aa8..f47b374aeb30aad2559ff958d63b5bc92ef12866 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences ui.gadgets ui.baseline-alignment kernel math
-math.functions math.vectors math.order math.rectangles namespaces
-accessors fry combinators arrays ;
+USING: sequences ui.gadgets ui.baseline-alignment
+ui.baseline-alignment.private kernel math math.functions math.vectors
+math.order math.rectangles namespaces accessors fry combinators arrays ;
 IN: ui.gadgets.packs
 
 TUPLE: pack < gadget
@@ -84,8 +84,7 @@ M: pack pref-dim*
     children>> dup pref-dims measure-metrics drop ;
 
 : pack-cap-height ( pack -- n )
-    children>> [ cap-height ] map sift
-    [ f ] [ supremum ] if-empty ;
+    children>> [ cap-height ] map ?supremum ;
 
 PRIVATE>
 
index 0529437a76663c1d6edbb7c5877d4fcc3d39e615..01abe8b3d958c0175ee1f81b2a7be511fc65a917 100644 (file)
@@ -2,7 +2,7 @@ USING: alien ui.gadgets.panes ui.gadgets namespaces
 kernel sequences io io.styles io.streams.string tools.test
 prettyprint definitions help help.syntax help.markup
 help.stylesheet splitting ui.gadgets.debug models math summary
-inspector accessors help.topics see ;
+inspector accessors help.topics see fry ;
 IN: ui.gadgets.panes.tests
 
 : #children ( -- n ) "pane" get children>> length ;
@@ -18,8 +18,9 @@ IN: ui.gadgets.panes.tests
 [ t ] [ #children "num-children" get = ] unit-test
 
 : test-gadget-text ( quot -- ? )
-    dup make-pane gadget-text dup print "======" print
-    swap with-string-writer dup print = ;
+    '[ _ call( -- ) ]
+    [ make-pane gadget-text dup print "======" print ]
+    [ with-string-writer dup print ] bi = ;
 
 [ t ] [ [ "hello" write ] test-gadget-text ] unit-test
 [ t ] [ [ "hello" pprint ] test-gadget-text ] unit-test
index 621e7006c91fdac4dfe5fbc7492ce1f7cb5543b0..a0799c7b86e2d9e3e2577b060f8f3a4b088c022f 100644 (file)
@@ -10,7 +10,7 @@ IN: ui.gadgets.presentations
 TUPLE: presentation < button object hook ;
 
 : invoke-presentation ( presentation command -- )
-    [ [ dup hook>> call ] [ object>> ] bi ] dip
+    [ [ dup hook>> call( presentation -- ) ] [ object>> ] bi ] dip
     invoke-command ;
 
 : invoke-primary ( presentation -- )
index 17570a8714a805903c79f213533e0afa7a6da4be..fc564b6ffe9eabd8c644ef2e236489e591cab550 100644 (file)
@@ -74,7 +74,7 @@ CONSULT: table-protocol search-table table>> ;
         dup field>> { 2 2 } <filled-border> f track-add
         values search 500 milliseconds <delay> quot <string-search>
         renderer <table> f >>takes-focus? >>table
-        dup table>> <scroller> 1 track-add ;
+        dup table>> <scroller> 1 track-add ; inline
 
 M: search-table model-changed
     nip field>> clear-search-field ;
index 592900d0cbf6867141f511e1c41302f6341ca5cf..39e42aa723d7ffc1d79ce8ea440d84aefca641ef 100644 (file)
@@ -23,14 +23,14 @@ TUPLE: slot-editor < track ref close-hook update-hook text ;
 } define-command
 
 : close ( slot-editor -- )
-    dup close-hook>> call ;
+    dup close-hook>> call( slot-editor -- ) ;
 
 \ close H{
     { +description+ "Close the slot editor without saving changes." }
 } define-command
 
 : close-and-update ( slot-editor -- )
-    [ update-hook>> call ] [ close ] bi ;
+    [ update-hook>> call( -- ) ] [ close ] bi ;
 
 : slot-editor-value ( slot-editor -- object )
     text>> control-value parse-fresh first ;
@@ -44,11 +44,8 @@ TUPLE: slot-editor < track ref close-hook update-hook text ;
     { +description+ "Parse the object being edited, and store the result back into the edited slot." }
 } define-command
 
-: eval-1 ( string -- object )
-    1array [ eval ] with-datastack first ;
-
 : com-eval ( slot-editor -- )
-    [ [ text>> editor-string eval-1 ] [ ref>> ] bi set-ref ]
+    [ [ text>> editor-string eval( -- result ) ] [ ref>> ] bi set-ref ]
     [ close-and-update ]
     bi ;
 
index 77249149aee11e97986ee9b95d05e5791c765d40..3fe2156df0ee3e2673c781595fdf7d46a00b2bc7 100644 (file)
@@ -59,14 +59,19 @@ focused? ;
 
 GENERIC: cell-width ( font cell -- x )
 GENERIC: cell-height ( font cell -- y )
+GENERIC: cell-padding ( cell -- y )
 GENERIC: draw-cell ( font cell -- )
 
 M: string cell-width text-width ;
 M: string cell-height text-height ceiling ;
+M: string cell-padding drop 0 ;
 M: string draw-cell draw-text ;
 
+CONSTANT: image-padding 2
+
 M: image-name cell-width nip image-dim first ;
 M: image-name cell-height nip image-dim second ;
+M: image-name cell-padding drop image-padding ;
 M: image-name draw-cell nip draw-image ;
 
 : table-rows ( table -- rows )
@@ -87,7 +92,7 @@ CONSTANT: column-title-background COLOR: light-gray
     if ;
 
 : row-column-widths ( table row -- widths )
-    [ font>> ] dip [ cell-width ] with map ;
+    [ font>> ] dip [ [ cell-width ] [ cell-padding ] bi + ] with map ;
 
 : compute-total-width ( gap widths -- total )
     swap [ column-offsets drop ] keep - ;
@@ -162,9 +167,10 @@ M: table layout*
         '[ [ 0 2array ] [ _ 2array ] bi gl-line ] each
     ] bi ;
 
-: column-loc ( font column width align -- loc )
-    [ [ cell-width ] dip swap - ] dip
-    * >integer 0 2array ;
+:: column-loc ( font column width align -- loc )
+    font column cell-width width swap - align * column cell-padding 2 / 1 align - * +
+    font column cell-height \ line-height get swap - 2 /
+    [ >integer ] bi@ 2array ;
 
 : translate-column ( width gap -- )
     + 0 2array gl-translate ;
@@ -203,18 +209,21 @@ M: table draw-line ( row index table -- )
 
 M: table draw-gadget*
     dup control-value empty? [ drop ] [
-        {
-            [ draw-selected-row ]
-            [ draw-lines ]
-            [ draw-column-lines ]
-            [ draw-focused-row ]
-            [ draw-moused-row ]
-        } cleave
+        dup line-height \ line-height [
+            {
+                [ draw-selected-row ]
+                [ draw-lines ]
+                [ draw-column-lines ]
+                [ draw-focused-row ]
+                [ draw-moused-row ]
+            } cleave
+        ] with-variable
     ] if ;
 
 M: table line-height ( table -- y )
     [ font>> ] [ renderer>> prototype-row ] bi
-    [ cell-height ] with [ max ] map-reduce ;
+    [ [ cell-height ] [ cell-padding ] bi + ] with
+    [ max ] map-reduce ;
 
 M: table pref-dim*
     [ compute-column-widths drop ] keep
@@ -379,14 +388,16 @@ TUPLE: column-headers < gadget table ;
         column-title-background <solid> >>interior ;
 
 : draw-column-titles ( table -- )
-    {
-        [ renderer>> column-titles ]
-        [ column-widths>> ]
-        [ table-column-alignment ]
-        [ font>> column-title-font ]
-        [ gap>> ]
-    } cleave
-    draw-columns ;
+    dup font>> font-metrics height>> \ line-height [
+        {
+            [ renderer>> column-titles ]
+            [ column-widths>> ]
+            [ table-column-alignment ]
+            [ font>> column-title-font ]
+            [ gap>> ]
+        } cleave
+        draw-columns
+    ] with-variable ;
 
 M: column-headers draw-gadget*
     table>> draw-column-titles ;
index cfec6613b1427e97fcd9159778e3902e1beed5d7..4114a2c3b24c20a099022c85d4dff53b5a8c81cd 100644 (file)
@@ -4,7 +4,7 @@ ui.gestures ;
 IN: ui.operations
 
 : $operations ( element -- )
-    >quotation call
+    >quotation call( -- obj )
     f operations>commands
     command-map. ;
 
index 0c6e1fe05a5b34f111bd4d4bd13c2c8492f69433..a493d5d7d2d8cadd4f6c511b24e57715849116be 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: debugger help help.topics help.crossref help.home kernel models
+USING: debugger classes help help.topics help.crossref help.home kernel models
 compiler.units assocs words vocabs accessors fry arrays
 combinators.short-circuit namespaces sequences models help.apropos
 combinators ui ui.commands ui.gadgets ui.gadgets.panes
@@ -91,6 +91,10 @@ M: browser-gadget focusable-child* search-field>> ;
 : browser-window ( -- )
     "help.home" (browser-window) ;
 
+: error-help-window ( error -- )
+    [ error-help ]
+    [ dup tuple? [ class ] [ drop "errors" ] if ] bi or (browser-window) ;
+
 \ browser-window H{ { +nullary+ t } } define-command
 
 : com-browse ( link -- )
index 05d77793059c26e1d0d233d4ec7830749d609ec8..91ac96e0f9ae9adaa37a237589fdf52d57501be4 100644 (file)
@@ -46,7 +46,7 @@ SLOT: model
 
 : show-links-popup ( browser-gadget quot title -- )
     [ dup model>> ] 2dip <links-popup>
-    [ hand-loc get { 0 0 } <rect> show-glass ] [ request-focus ] bi ;
+    [ hand-loc get { 0 0 } <rect> show-glass ] [ request-focus ] bi ; inline
 
 : com-show-outgoing-links ( browser-gadget -- )
     [ uses ] "Outgoing links" show-links-popup ;
index c3ead4e3f5625f8cf55434ac295b231ac1c40c94..42666ab0643c82c22e13c9d4ab5dec18225de865 100644 (file)
@@ -8,7 +8,7 @@ ui.gadgets.buttons ui.gadgets.labels ui.gadgets.panes
 ui.gadgets.presentations ui.gadgets.viewports ui.gadgets.tables
 ui.gadgets.tracks ui.gadgets.scrollers ui.gadgets.panes
 ui.gadgets.borders ui.gadgets.status-bar ui.tools.traceback
-ui.tools.inspector ;
+ui.tools.inspector ui.tools.browser ;
 IN: ui.tools.debugger
 
 TUPLE: debugger < track error restarts restart-hook restart-list continuation ;
@@ -86,9 +86,7 @@ debugger "gestures" f {
 
 : com-traceback ( debugger -- ) continuation>> traceback-window ;
 
-: com-help ( debugger -- ) error>> (:help) ;
-
-\ com-help H{ { +listener+ t } } define-command
+: com-help ( debugger -- ) error>> error-help-window ;
 
 : com-edit ( debugger -- ) error>> (:edit) ;
 
diff --git a/basis/ui/tools/error-list/authors.txt b/basis/ui/tools/error-list/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/ui/tools/error-list/error-list-docs.factor b/basis/ui/tools/error-list/error-list-docs.factor
new file mode 100644 (file)
index 0000000..10ca80d
--- /dev/null
@@ -0,0 +1,20 @@
+IN: ui.tools.error-list
+USING: help.markup help.syntax ui.tools.common ui.commands ;
+
+ARTICLE: "ui.tools.error-list" "UI error list tool"
+"The error list tool displays messages generated by tools which process source files and definitions. To display the error list, press " { $command tool "common" show-error-list } " in any UI tool window."
+$nl
+"The " { $vocab-link "source-files.errors" } " vocabulary contains backend code used by this tool."
+{ $heading "Message icons" }
+{ $table
+    { "Icon" "Message type" "Reference" }
+    { { $image "vocab:ui/tools/error-list/icons/note.tiff" } "Parser note" { $link "parser" } }
+    { { $image "vocab:ui/tools/error-list/icons/syntax-error.tiff" } "Syntax error" { $link "syntax" } }
+    { { $image "vocab:ui/tools/error-list/icons/compiler-warning.tiff" } "Compiler warning" { $link "compiler-errors" } }
+    { { $image "vocab:ui/tools/error-list/icons/compiler-error.tiff" } "Compiler error" { $link "compiler-errors" } }
+    { { $image "vocab:ui/tools/error-list/icons/unit-test-error.tiff" } "Unit test failure" { $link "tools.test" } }
+    { { $image "vocab:ui/tools/error-list/icons/help-lint-error.tiff" } "Help lint failure" { $link "help.lint" } }
+    { { $image "vocab:ui/tools/error-list/icons/linkage-error.tiff" } "Linkage error" { $link "loading-libs" } }
+} ;
+
+ABOUT: "ui.tools.error-list"
diff --git a/basis/ui/tools/error-list/error-list.factor b/basis/ui/tools/error-list/error-list.factor
new file mode 100644 (file)
index 0000000..7efe023
--- /dev/null
@@ -0,0 +1,205 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays sequences sorting assocs colors.constants fry
+combinators combinators.smart combinators.short-circuit editors make
+memoize compiler.units fonts kernel io.pathnames prettyprint
+source-files.errors math.parser init math.order models models.arrow
+models.arrow.smart models.search models.mapping models.delay debugger namespaces
+summary locals ui ui.commands ui.gadgets ui.gadgets.panes
+ui.gadgets.tables ui.gadgets.labeled ui.gadgets.tracks ui.gestures
+ui.operations ui.tools.browser ui.tools.common ui.gadgets.scrollers
+ui.tools.inspector ui.gadgets.status-bar ui.operations
+ui.gadgets.buttons ui.gadgets.borders ui.gadgets.packs
+ui.gadgets.labels ui.baseline-alignment ui.images
+compiler.errors calendar ;
+IN: ui.tools.error-list
+
+CONSTANT: source-file-icon
+    T{ image-name f "vocab:ui/tools/error-list/icons/source-file.tiff" }
+
+MEMO: error-icon ( type -- image-name )
+    error-icon-path <image-name> ;
+
+: <checkboxes> ( alist -- gadget )
+    [ <shelf> { 15 0 } >>gap ] dip
+    [ swap <checkbox> add-gadget ] assoc-each ;
+
+: <error-toggle> ( -- model gadget )
+    #! Linkage errors are not shown by default.
+    error-types get keys [ dup +linkage-error+ eq? not <model> ] { } map>assoc
+    [ [ [ error-icon ] dip ] assoc-map <checkboxes> ]
+    [ <mapping> ] bi ;
+
+TUPLE: error-list-gadget < tool
+visible-errors source-file error
+error-toggle source-file-table error-table error-display ;
+
+SINGLETON: source-file-renderer
+
+M: source-file-renderer row-columns
+    drop first2 [
+        [ source-file-icon ]
+        [ "<Listener input>" or ]
+        [ length number>string ] tri*
+    ] output>array ;
+
+M: source-file-renderer prototype-row
+    drop source-file-icon "" "" 3array ;
+
+M: source-file-renderer row-value
+    drop dup [ first [ <pathname> ] [ f ] if* ] when ;
+
+M: source-file-renderer column-titles
+    drop { "" "File" "Errors" } ;
+
+M: source-file-renderer column-alignment drop { 0 0 1 } ;
+
+M: source-file-renderer filled-column drop 1 ;
+
+: <source-file-model> ( model -- model' )
+    [ group-by-source-file >alist sort-keys ] <arrow> ;
+
+:: <source-file-table> ( error-list -- table )
+    error-list model>> <source-file-model>
+    source-file-renderer
+    <table>
+        [ invoke-primary-operation ] >>action
+        COLOR: dark-gray >>column-line-color
+        6 >>gap
+        5 >>min-rows
+        5 >>max-rows
+        60 >>min-cols
+        60 >>max-cols
+        t >>selection-required?
+        error-list source-file>> >>selected-value ;
+
+SINGLETON: error-renderer
+
+M: error-renderer row-columns
+    drop [
+        {
+            [ error-type error-icon ]
+            [ line#>> [ number>string ] [ "" ] if* ]
+            [ asset>> unparse-short ]
+            [ error>> summary ]
+        } cleave
+    ] output>array ;
+
+M: error-renderer prototype-row
+    drop [ +compiler-error+ error-icon "" "" "" ] output>array ;
+
+M: error-renderer row-value
+    drop ;
+
+M: error-renderer column-titles
+    drop { "" "Line" "Asset" "Error" } ;
+
+M: error-renderer column-alignment drop { 0 1 0 0 } ;
+
+: sort-errors ( seq -- seq' )
+    [ [ [ asset>> unparse-short ] [ line#>> ] bi 2array ] keep ] { } map>assoc
+    sort-keys values ;
+
+: file-matches? ( error pathname/f -- ? )
+    [ file>> ] [ dup [ string>> ] when ] bi* = ;
+
+: <error-table-model> ( error-list -- model )
+    [ model>> ] [ source-file>> ] bi
+    [ file-matches? ] <search>
+    [ sort-errors ] <arrow> ;
+
+:: <error-table> ( error-list -- table )
+    error-list <error-table-model>
+    error-renderer
+    <table>
+        [ invoke-primary-operation ] >>action
+        COLOR: dark-gray >>column-line-color
+        6 >>gap
+        5 >>min-rows
+        5 >>max-rows
+        60 >>min-cols
+        60 >>max-cols
+        t >>selection-required?
+        error-list error>> >>selected-value ;
+
+TUPLE: error-display < track ;
+
+: <error-display> ( error-list -- gadget )
+    vertical error-display new-track
+        add-toolbar
+        swap error>> >>model
+        dup model>> [ [ print-error ] when* ] <pane-control> <scroller> 1 track-add ;
+
+: com-inspect ( error-display -- )
+    model>> value>> [ inspector ] when* ;
+
+: com-help ( error-display -- )
+    model>> value>> [ error>> error-help-window ] when* ;
+
+: com-edit ( error-display -- )
+    model>> value>> [ edit-error ] when* ;
+
+error-display "toolbar" f {
+    { f com-inspect }
+    { f com-help }
+    { f com-edit }
+} define-command-map
+
+: <error-list-toolbar> ( error-list -- toolbar )
+    [ <toolbar> ] [ error-toggle>> "Show errors:" label-on-left add-gadget ] bi ;
+
+: <error-model> ( visible-errors model -- model' )
+    [ swap '[ error-type _ at ] filter ] <smart-arrow> ;
+
+:: <error-list-gadget> ( model -- gadget )
+    vertical error-list-gadget new-track
+        <error-toggle> [ >>error-toggle ] [ >>visible-errors ] bi*
+        dup visible-errors>> model <error-model> >>model 
+        f <model> >>source-file
+        f <model> >>error
+        dup <source-file-table> >>source-file-table
+        dup <error-table> >>error-table
+        dup <error-display> >>error-display
+    :> error-list
+    error-list vertical <track>
+        { 5 5 } >>gap
+        error-list <error-list-toolbar> f track-add
+        error-list source-file-table>> <scroller> "Source files" <labeled-gadget> 1/4 track-add
+        error-list error-table>> <scroller> "Errors" <labeled-gadget> 1/2 track-add
+        error-list error-display>> "Details" <labeled-gadget> 1/4 track-add
+    { 5 5 } <filled-border> 1 track-add ;
+
+M: error-list-gadget focusable-child*
+    source-file-table>> ;
+
+: error-list-help ( -- ) "ui.tools.error-list" com-browse ;
+
+\ error-list-help H{ { +nullary+ t } } define-command
+
+error-list-gadget "toolbar" f {
+    { T{ key-down f f "F1" } error-list-help }
+} define-command-map
+
+SYMBOL: error-list-model
+
+error-list-model [ f <model> ] initialize
+
+SINGLETON: updater
+
+M: updater errors-changed
+    drop f error-list-model get-global set-model ;
+
+[ updater add-error-observer ] "ui.tools.error-list" add-init-hook
+
+: <error-list-model> ( -- model )
+    error-list-model get-global
+    1/2 seconds <delay> [ drop all-errors ] <arrow> ;
+
+: error-list-window ( -- )
+    <error-list-model> <error-list-gadget> "Errors" open-status-window ;
+
+: show-error-list ( -- )
+    [ error-list-gadget? ] find-window
+    [ raise-window ] [ error-list-window ] if* ;
+
+\ show-error-list H{ { +nullary+ t } } define-command
diff --git a/basis/ui/tools/error-list/icons/compiler-error.tiff b/basis/ui/tools/error-list/icons/compiler-error.tiff
new file mode 100644 (file)
index 0000000..7a53d57
Binary files /dev/null and b/basis/ui/tools/error-list/icons/compiler-error.tiff differ
diff --git a/basis/ui/tools/error-list/icons/compiler-warning.tiff b/basis/ui/tools/error-list/icons/compiler-warning.tiff
new file mode 100644 (file)
index 0000000..405cfd4
Binary files /dev/null and b/basis/ui/tools/error-list/icons/compiler-warning.tiff differ
diff --git a/basis/ui/tools/error-list/icons/help-lint-error.tiff b/basis/ui/tools/error-list/icons/help-lint-error.tiff
new file mode 100644 (file)
index 0000000..464728a
Binary files /dev/null and b/basis/ui/tools/error-list/icons/help-lint-error.tiff differ
diff --git a/basis/ui/tools/error-list/icons/linkage-error.tiff b/basis/ui/tools/error-list/icons/linkage-error.tiff
new file mode 100644 (file)
index 0000000..78644fd
Binary files /dev/null and b/basis/ui/tools/error-list/icons/linkage-error.tiff differ
diff --git a/basis/ui/tools/error-list/icons/note.tiff b/basis/ui/tools/error-list/icons/note.tiff
new file mode 100644 (file)
index 0000000..834dea6
Binary files /dev/null and b/basis/ui/tools/error-list/icons/note.tiff differ
diff --git a/basis/ui/tools/error-list/icons/source-file.tiff b/basis/ui/tools/error-list/icons/source-file.tiff
new file mode 100644 (file)
index 0000000..5fb3375
Binary files /dev/null and b/basis/ui/tools/error-list/icons/source-file.tiff differ
diff --git a/basis/ui/tools/error-list/icons/syntax-error.tiff b/basis/ui/tools/error-list/icons/syntax-error.tiff
new file mode 100644 (file)
index 0000000..5446c80
Binary files /dev/null and b/basis/ui/tools/error-list/icons/syntax-error.tiff differ
diff --git a/basis/ui/tools/error-list/icons/unit-test-error.tiff b/basis/ui/tools/error-list/icons/unit-test-error.tiff
new file mode 100644 (file)
index 0000000..b6ea439
Binary files /dev/null and b/basis/ui/tools/error-list/icons/unit-test-error.tiff differ
index c329f037e178a20a71e904d3aa84ef0b1a06e14c..72f4e1fe66f747f8aea8b5d63db6ab9f52f05d1e 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax ui.commands ui.gadgets.slots
-ui.gadgets.editors ;
+ui.gadgets.editors kernel ;
 IN: ui.tools.inspector
 
 ARTICLE: "ui-inspector-edit" "Editing slot values in the inspector"
@@ -21,4 +21,8 @@ $nl
 "The UI inspector is an instance of " { $link inspector-gadget } "."
 { $subsection "ui-inspector-edit" } ;
 
+HELP: inspector
+{ $values { "obj" object } }
+{ $description "Opens a new inspector window displaying the slots of " { $snippet "obj" } "." } ;
+
 ABOUT: "ui-inspector"
\ No newline at end of file
index afe890b9c5264cc997792c243e8a39bca9d3a206..ec4fc80a4df3a772150b8589d37e199d02db1962 100644 (file)
@@ -27,6 +27,8 @@ ARTICLE: "ui-listener" "UI listener"
 { $command-map interactor "quotation" }
 { $heading "Editing commands" }
 "The text editing commands are standard; see " { $link "gadgets-editors-commands" } "."
+$nl
+"The listener displays a summary with any outstanding error conditions before every prompt. See " { $link "ui.tools.error-list" } " for details."
 { $heading "Implementation" }
 "Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } ") and an input area (instance of " { $link interactor } "). Clickable presentations can also be printed to the listener; see " { $link "ui-presentations" } "." ;
 
index 7cb3c70cbc2de118de752be69697f5463fd4e78c..57689b002bf79e470c3466a19f4e6a3a31a395ca 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs calendar combinators locals
-colors.constants combinators.short-circuit compiler.units
-help.tips concurrency.flags concurrency.mailboxes continuations
-destructors documents documents.elements fry hashtables help
-help.markup io io.styles kernel lexer listener math models
+source-files.errors colors.constants combinators.short-circuit
+compiler.units help.tips concurrency.flags concurrency.mailboxes
+continuations destructors documents documents.elements fry hashtables
+help help.markup io io.styles kernel lexer listener math models sets
 models.delay models.arrow namespaces parser prettyprint quotations
 sequences strings threads tools.vocabs vocabs vocabs.loader
 vocabs.parser words debugger ui ui.commands ui.pens.solid ui.gadgets
@@ -13,7 +13,8 @@ ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers
 ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.borders ui.gestures
 ui.operations ui.tools.browser ui.tools.common ui.tools.debugger
 ui.tools.listener.completion ui.tools.listener.popups
-ui.tools.listener.history ;
+ui.tools.listener.history ui.tools.error-list ;
+FROM: source-files.errors => all-errors ;
 IN: ui.tools.listener
 
 ! If waiting is t, we're waiting for user input, and invoking
@@ -356,10 +357,19 @@ interactor "completion" f {
     { T{ key-down f { C+ } "r" } history-completion-popup }
 } define-command-map
 
+: ui-error-summary ( -- )
+    all-errors [
+        [ error-type ] map prune
+        [ error-icon-path 1array \ $image prefix " " 2array ] { } map-as
+        { "Press " { $command tool "common" show-error-list } " to view errors." }
+        append print-element nl
+    ] unless-empty ;
+
 : listener-thread ( listener -- )
     dup listener-streams [
         [ com-browse ] help-hook set
         '[ [ _ input>> ] 2dip debugger-popup ] error-hook set
+        [ ui-error-summary ] error-summary-hook set
         tip-of-the-day. nl
         listener
     ] with-streams* ;
index c6371ac8aaf3794e8f9eae2eb4a639f52e134bd7..3c160118978f7e10a67599a7a32490740d04fc8b 100644 (file)
@@ -1,15 +1,15 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations definitions generic help.topics threads
-stack-checker summary io.pathnames io.styles kernel namespaces
-parser prettyprint quotations tools.crossref tools.annotations
-editors tools.profiler tools.test tools.time tools.walker vocabs
-vocabs.loader words sequences tools.vocabs classes
-compiler.units accessors vocabs.parser macros.expander ui
-ui.tools.browser ui.tools.listener ui.tools.listener.completion
-ui.tools.profiler ui.tools.inspector ui.tools.traceback
-ui.commands ui.gadgets.editors ui.gestures ui.operations
-ui.tools.deploy models help.tips ;
+stack-checker summary io.pathnames io.styles kernel namespaces parser
+prettyprint quotations tools.crossref tools.annotations editors
+tools.profiler tools.test tools.time tools.walker vocabs vocabs.loader
+words sequences tools.vocabs classes compiler.errors compiler.units
+accessors vocabs.parser macros.expander ui ui.tools.browser
+ui.tools.listener ui.tools.listener.completion ui.tools.profiler
+ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors
+ui.gestures ui.operations ui.tools.deploy models help.tips
+source-files.errors ;
 IN: ui.tools.operations
 
 ! Objects
@@ -86,6 +86,21 @@ IN: ui.tools.operations
     { +listener+ t }
 } define-operation
 
+! Source file error
+[ source-file-error? ] \ edit-error H{
+    { +primary+ t }
+    { +secondary+ t }
+    { +listener+ t }
+} define-operation
+
+: com-reload ( error -- )
+    file>> run-file ;
+
+[ compiler-error? ] \ com-reload H{
+    { +listener+ t }
+} define-operation
+
+! Definitions
 : com-forget ( defspec -- )
     [ forget ] with-compilation-unit ;
 
@@ -173,4 +188,4 @@ interactor
 "These commands operate on the entire contents of the input area."
 [ ]
 [ quot-action ]
-define-operation-map
+define-operation-map
\ No newline at end of file
diff --git a/basis/ui/tools/profiler/profiler-tests.factor b/basis/ui/tools/profiler/profiler-tests.factor
new file mode 100644 (file)
index 0000000..86bebdd
--- /dev/null
@@ -0,0 +1,3 @@
+USING: ui.tools.profiler tools.test ;
+
+\ profiler-window must-infer
index 1c2318a35e94328d30cdf8f41231591ebb638cc5..5fef64ea8857e72b395f36a6f69529b49df93506 100644 (file)
@@ -11,6 +11,7 @@ ui.gadgets.tabbed ui.gadgets.status-bar ui.gadgets.borders
 ui.tools.browser ui.tools.common ui.baseline-alignment
 ui.operations ui.images ;
 FROM: models.arrow => <arrow> ;
+FROM: models.arrow.smart => <smart-arrow> ;
 FROM: models.product => <product> ;
 IN: ui.tools.profiler
 
@@ -112,8 +113,8 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ;
 : <methods-model> ( profiler -- model )
     [
         [ method-counters <model> ] dip
-        [ generic>> ] [ class>> ] bi 3array <product>
-        [ first3 '[ _ _ method-matches? ] filter ] <arrow>
+        [ generic>> ] [ class>> ] bi
+        [ '[ _ _ method-matches? ] filter ] <smart-arrow>
     ] keep <profiler-model> ;
 
 : sort-by-name ( obj1 obj2 -- <=> )
@@ -208,6 +209,6 @@ profiler-gadget "toolbar" f {
 : profiler-window ( -- )
     <profiler-gadget> "Profiling results" open-status-window ;
 
-: com-profile ( quot -- ) profile profiler-window ;
+: com-profile ( quot -- ) profile profiler-window ; inline
 
 MAIN: profiler-window
index 52cd77d7263cdb656b02bad68248c59eca720dd1..92aa1be947a45de20403e81b1c5f5a1c2b88e0c9 100644 (file)
@@ -66,6 +66,7 @@ $nl
 { $subsection "ui-listener" }
 { $subsection "ui-browser" }
 { $subsection "ui-inspector" }
+{ $subsection "ui.tools.error-list" }
 { $subsection "ui.tools.profiler" }
 { $subsection "ui-walker" }
 { $subsection "ui.tools.deploy" }
index 203953db1a7b13f2935022878f99e738b1f57e50..c825c60dbb78bab21db794dfab4048a1c5e73698 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: memory system kernel tools.vocabs ui.tools.operations
-ui.tools.listener ui.tools.browser ui.tools.common
+ui.tools.listener ui.tools.browser ui.tools.common ui.tools.error-list
 ui.tools.walker ui.commands ui.gestures ui ui.private ;
 IN: ui.tools
 
@@ -30,4 +30,5 @@ tool "common" f {
     { T{ key-down f { A+ } "w" } close-window }
     { T{ key-down f { A+ } "q" } com-exit }
     { T{ key-down f f "F2" } refresh-all }
+    { T{ key-down f f "F3" } show-error-list }
 } define-command-map
\ No newline at end of file
index 6bf68304bb221e6af6772aa750c8024b36773ef3..2320bdd64800598d4f0633f3441065dc20e4018f 100644 (file)
@@ -1 +1,2 @@
 unportable
+bindings
diff --git a/basis/windows/usp10/tags.txt b/basis/windows/usp10/tags.txt
new file mode 100644 (file)
index 0000000..2320bdd
--- /dev/null
@@ -0,0 +1,2 @@
+unportable
+bindings
index e06872fa83456402e0f74de3f33638911106f268..e4aaef9bbd2903df52d923af94bcdec1e515b487 100644 (file)
@@ -22,7 +22,7 @@ SYMBOL: xim
     xim get-global XCloseIM drop f xim set-global ;
 
 : with-xim ( quot -- )
-    [ "Factor" init-xim ] dip [ close-xim ] [ ] cleanup ;
+    [ "Factor" init-xim ] dip [ close-xim ] [ ] cleanup ; inline
 
 : create-xic ( window classname -- xic )
     [
index 3394de87b271cd9bdd9f4b24f9503281477f0c73..1a2cf091297054a6d200bf5622d0f4bf20ec8a73 100644 (file)
@@ -1440,4 +1440,4 @@ SYMBOL: root
 : close-x ( -- ) dpy get XCloseDisplay drop ;
 
 : with-x ( display-string quot -- )
-    [ initialize-x ] dip [ close-x ] [ ] cleanup ;
+    [ initialize-x ] dip [ close-x ] [ ] cleanup ; inline
index 6bd1d2f53a429f23a034eccfa356d19a2f27e55f..66e67ab32263ad8231588b72f644729c6db9f972 100644 (file)
@@ -145,12 +145,6 @@ ARTICLE: "reading-writing-memory" "Reading and writing memory directly"
 { $subsection set-alien-float }
 { $subsection set-alien-double } ;
 
-ARTICLE: "loading-libs" "Loading native libraries"
-"Before calling a C library, you must associate its path name on disk with a logical name which Factor uses to identify the library:"
-{ $subsection add-library }
-"Once a library has been defined, you can try loading it to see if the path name is correct:"
-{ $subsection load-library } ;
-
 ARTICLE: "alien-invoke" "Calling C from Factor"
 "The easiest way to call into a C library is to define bindings using a pair of parsing words:"
 { $subsection POSTPONE: LIBRARY: }
diff --git a/core/bootstrap/syntax-docs.factor b/core/bootstrap/syntax-docs.factor
new file mode 100644 (file)
index 0000000..e69de29
index 4c600e06ca76bee4ed4c2e683e589c0176431489..1438edf3fa2dbfa88dda86389bb6edfbadec0ff4 100755 (executable)
@@ -86,6 +86,8 @@ ERROR: no-case object ;
         ] [ callable? ] if
     ] find nip ;
 
+\ case-find t "no-compile" set-word-prop
+
 : case ( obj assoc -- )
     case-find {
         { [ dup array? ] [ nip second call ] }
diff --git a/core/compiler/errors/authors.txt b/core/compiler/errors/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/core/compiler/errors/errors-docs.factor b/core/compiler/errors/errors-docs.factor
deleted file mode 100644 (file)
index 8368afe..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-IN: compiler.errors
-USING: help.markup help.syntax vocabs.loader words io
-quotations words.symbol ;
-
-ARTICLE: "compiler-errors" "Compiler warnings and errors"
-"After loading a vocabulary, you might see messages like:"
-{ $code
-    ":errors - print 2 compiler errors."
-    ":warnings - print 50 compiler warnings."
-}
-"These warnings arise from the compiler's stack effect checker. Warnings are non-fatal conditions -- not all code has a static stack effect, so you try to minimize warnings but understand that in many cases they cannot be eliminated. Errors indicate programming mistakes, such as erroneous stack effect declarations."
-$nl
-"The precise warning and error conditions are documented in " { $link "inference-errors" } "."
-$nl
-"Words to view warnings and errors:"
-{ $subsection :errors }
-{ $subsection :warnings }
-{ $subsection :linkage }
-"Words such as " { $link require } " use a combinator which counts errors and prints a report at the end:"
-{ $subsection with-compiler-errors } ;
-
-HELP: compiler-errors
-{ $var-description "Global variable holding an assoc mapping words to compiler errors. This variable is set by " { $link with-compiler-errors } "." } ;
-
-ABOUT: "compiler-errors"
-
-HELP: compiler-error
-{ $values { "error" "an error" } { "word" word } }
-{ $description "If inside a " { $link with-compiler-errors } ", saves the error for future persual via " { $link :errors } ", " { $link :warnings } " and " { $link :linkage } ". If not inside a " { $link with-compiler-errors } ", ignores the error." } ;
-
-HELP: compiler-error.
-{ $values { "error" "an error" } { "word" word } }
-{ $description "Prints a compiler error to " { $link output-stream } "." } ;
-
-HELP: compiler-errors.
-{ $values { "type" symbol } }
-{ $description "Prints compiler errors to " { $link output-stream } ". The type parameter is one of " { $link +error+ } ", " { $link +warning+ } ", or " { $link +linkage+ } "." } ;
-HELP: :errors
-{ $description "Prints all serious compiler errors from the most recent compile to " { $link output-stream } "." } ;
-
-HELP: :warnings
-{ $description "Prints all ignorable compiler warnings from the most recent compile to " { $link output-stream } "." } ;
-
-HELP: :linkage
-{ $description "Prints all C library interface linkage errors from the most recent compile to " { $link output-stream } "." } ;
-
-{ :errors :warnings } related-words
-
-HELP: with-compiler-errors
-{ $values { "quot" quotation } }
-{ $description "Calls the quotation and collects any compiler warnings and errors. Compiler warnings and errors are summarized at the end and can be viewed with " { $link :errors } ", " { $link :warnings } ", and " { $link :linkage } "." }
-{ $notes "Nested calls to " { $link with-compiler-errors } " are ignored, and only the outermost call collects warnings and errors." } ;
diff --git a/core/compiler/errors/errors.factor b/core/compiler/errors/errors.factor
deleted file mode 100644 (file)
index 1ea497c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-! Copyright (C) 2007, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces make assocs io sequences
-sorting continuations math math.parser ;
-IN: compiler.errors
-
-SYMBOL: +error+
-SYMBOL: +warning+
-SYMBOL: +linkage+
-
-GENERIC: compiler-error-type ( error -- ? )
-
-M: object compiler-error-type drop +error+ ;
-
-GENERIC# compiler-error. 1 ( error word -- )
-
-SYMBOL: compiler-errors
-
-SYMBOL: with-compiler-errors?
-
-: errors-of-type ( type -- assoc )
-    compiler-errors get-global
-    swap [ [ nip compiler-error-type ] dip eq? ] curry
-    assoc-filter ;
-
-: compiler-errors. ( type -- )
-    errors-of-type >alist sort-keys
-    [ swap compiler-error. ] assoc-each ;
-
-: (compiler-report) ( what type word -- )
-    over errors-of-type assoc-empty? [ 3drop ] [
-        [
-            ":" %
-            %
-            " - print " %
-            errors-of-type assoc-size #
-            " " %
-            %
-            "." %
-        ] "" make print
-    ] if ;
-
-: compiler-report ( -- )
-    "semantic errors" +error+ "errors" (compiler-report)
-    "semantic warnings" +warning+ "warnings" (compiler-report)
-    "linkage errors" +linkage+ "linkage" (compiler-report) ;
-
-: :errors ( -- ) +error+ compiler-errors. ;
-
-: :warnings ( -- ) +warning+ compiler-errors. ;
-
-: :linkage ( -- ) +linkage+ compiler-errors. ;
-
-: compiler-error ( error word -- )
-    with-compiler-errors? get [
-        compiler-errors get pick
-        [ set-at ] [ delete-at drop ] if
-    ] [ 2drop ] if ;
-
-: with-compiler-errors ( quot -- )
-    with-compiler-errors? get "quiet" get or [ call ] [
-        [
-            with-compiler-errors? on
-            V{ } clone compiler-errors set-global
-            [ compiler-report ] [ ] cleanup
-        ] with-scope
-    ] if ; inline
diff --git a/core/compiler/errors/summary.txt b/core/compiler/errors/summary.txt
deleted file mode 100755 (executable)
index 01d106b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Compiler warning and error reporting
index d84b377f361d92256d69b0bcc455f08dfeaf5f20..464e17025d7b194373f236e1b9d9eb992d520de7 100644 (file)
@@ -1,6 +1,6 @@
-IN: compiler.units.tests
 USING: definitions compiler.units tools.test arrays sequences words kernel
-accessors namespaces fry ;
+accessors namespaces fry eval ;
+IN: compiler.units.tests
 
 [ [ [ ] define-temp ] with-compilation-unit ] must-infer
 [ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer
@@ -30,4 +30,32 @@ accessors namespaces fry ;
         "a" get [ "B" ] define
     ] with-compilation-unit
     "b" get execute
-] unit-test
\ No newline at end of file
+] unit-test
+
+! Notify observers even if compilation unit did nothing
+SINGLETON: observer
+
+observer add-definition-observer
+
+SYMBOL: counter
+
+0 counter set-global
+
+M: observer definitions-changed 2drop global [ counter inc ] bind ;
+
+[ ] with-compilation-unit
+
+[ 1 ] [ counter get-global ] unit-test
+
+observer remove-definition-observer
+
+! Notify observers with nested compilation units
+observer add-definition-observer
+
+0 counter set-global
+
+DEFER: nesting-test
+
+[ ] [ "IN: compiler.units.tests << : nesting-test ( -- ) ; >>" eval ] unit-test
+
+observer remove-definition-observer
\ No newline at end of file
index afa05f94426e20657ff84a932902518a27e08e22..a278bf0d5ecf4a90f38624a3bab0bfe3ff2f704a 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays kernel continuations assocs namespaces
 sequences words vocabs definitions hashtables init sets
 math math.order classes classes.algebra classes.tuple
-classes.tuple.private generic ;
+classes.tuple.private generic source-files.errors ;
 IN: compiler.units
 
 SYMBOL: old-definitions
@@ -62,7 +62,7 @@ GENERIC: definitions-changed ( assoc obj -- )
     definition-observers get push ;
 
 : remove-definition-observer ( obj -- )
-    definition-observers get delete ;
+    definition-observers get delq ;
 
 : notify-definition-observers ( assoc -- )
     definition-observers get
@@ -132,17 +132,20 @@ GENERIC: definitions-changed ( assoc obj -- )
     changed-generics get compiled-generic-usages
     append assoc-combine keys ;
 
-: unxref-forgotten-definitions ( -- )
-    forgotten-definitions get
-    keys [ word? ] filter
-    [ delete-compiled-xref ] each ;
+: process-forgotten-definitions ( -- )
+    forgotten-definitions get keys
+    [ [ word? ] filter [ delete-compiled-xref ] each ]
+    [ [ delete-definition-errors ] each ]
+    bi ;
 
 : finish-compilation-unit ( -- )
     remake-generics
     to-recompile recompile
     update-tuples
-    unxref-forgotten-definitions
-    modify-code-heap ;
+    process-forgotten-definitions
+    modify-code-heap
+    updated-definitions notify-definition-observers
+    notify-error-observers ;
 
 : with-nested-compilation-unit ( quot -- )
     [
@@ -166,9 +169,5 @@ GENERIC: definitions-changed ( assoc obj -- )
         H{ } clone new-classes set
         <definitions> new-definitions set
         <definitions> old-definitions set
-        [
-            finish-compilation-unit
-            updated-definitions
-            notify-definition-observers
-        ] [ ] cleanup
+        [ finish-compilation-unit ] [ ] cleanup
     ] with-scope ; inline
index 0627ed5265dc78ebc614d872170f35e7adb74827..651169554eacabea03ece6839a3b596e4e761c0e 100644 (file)
@@ -30,7 +30,7 @@ $nl
 { $heading "Anti-pattern #4: Logging and rethrowing" }
 "If you are going to rethrow an error, do not log a message. If you do so, the user will see two log messages for the same error, which will clutter logs without adding any useful information." ;
 
-ARTICLE: "errors" "Error handling"
+ARTICLE: "errors" "Exception handling"
 "Support for handling exceptional situations such as bad user input, implementation bugs, and input/output errors is provided by a set of words built using continuations."
 $nl
 "Two words raise an error in the innermost error handler for the current dynamic extent:"
index 051d28d8c23eeca8a60a31c5343c60e641927987..e350b2485692602e95e3639d02df08afa4c7e565 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays vectors kernel kernel.private sequences
 namespaces make math splitting sorting quotations assocs
-combinators combinators.private accessors ;
+combinators combinators.private accessors words ;
 IN: continuations
 
 SYMBOL: error
@@ -81,6 +81,8 @@ C: <continuation> continuation
     [ set-datastack ] dip
     set-callstack ;
 
+\ (continue) t "no-compile" set-word-prop
+
 PRIVATE>
 
 : continue-with ( obj continuation -- * )
index 65a802dc2dd3c968a85e96fe66292abee698848a..7fdb339069eca9036636f1c73754a79778d932ce 100644 (file)
@@ -33,6 +33,8 @@ M: generic definition drop f ;
 
 GENERIC: effective-method ( generic -- method )
 
+\ effective-method t "no-compile" set-word-prop
+
 : next-method-class ( class generic -- class/f )
     order [ class<= ] with filter reverse dup length 1 =
     [ drop f ] [ second ] if ;
index c88bd9d97ed1b9cf3fe4bda5ec45ce15eaa3e4be..7e91adfaa191e5155daeb47dca0a803b4edf6b7b 100644 (file)
@@ -82,6 +82,8 @@ M: engine-word stack-effect
         effect boa
     ] [ 2drop f ] if ;
 
+M: engine-word where "tuple-dispatch-generic" word-prop where ;
+
 M: engine-word crossref? "forgotten" word-prop not ;
 
 M: engine-word irrelevant? drop t ;
index 3ba414fe6beb9304cbd6ff56def0e823ddd92697..9e1fcb95bdcc1c49a940a07386b46657d3dc3514 100644 (file)
@@ -3,7 +3,7 @@ io.streams.string namespaces classes effects source-files assocs
 sequences strings io.files io.pathnames definitions
 continuations sorting classes.tuple compiler.units debugger
 vocabs vocabs.loader accessors eval combinators lexer
-vocabs.parser words.symbol multiline ;
+vocabs.parser words.symbol multiline source-files.errors ;
 IN: parser.tests
 
 \ run-file must-infer
index 6d613a8b2459e30340bc3a46ec36a3845ba2f3da..38cb4869ab3c75f41d7a671190b7f3e91969b59b 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays definitions generic assocs kernel math namespaces
-sequences strings vectors words words.symbol quotations io combinators
-sorting splitting math.parser effects continuations io.files vocabs
-io.encodings.utf8 source-files classes hashtables compiler.errors
-compiler.units accessors sets lexer vocabs.parser effects.parser slots ;
+sequences strings vectors words words.symbol quotations io
+combinators sorting splitting math.parser effects continuations
+io.files vocabs io.encodings.utf8 source-files classes
+hashtables compiler.units accessors sets lexer vocabs.parser
+effects.parser slots ;
 IN: parser
 
 : location ( -- loc )
@@ -280,11 +281,9 @@ print-use-hook [ [ ] ] initialize
 
 : parse-file ( file -- quot )
     [
-        [
-            [ parsing-file ] keep
-            [ utf8 <file-reader> ] keep
-            parse-stream
-        ] with-compiler-errors
+        [ parsing-file ] keep
+        [ utf8 <file-reader> ] keep
+        parse-stream
     ] [
         over parse-file-restarts rethrow-restarts
         drop parse-file
index a72f4adf8805b30e8390baf7aefc543220e0fd4d..603d6f2847d3b49940af4c70ec2c45268ee4f3cf 100644 (file)
@@ -24,6 +24,7 @@ ARTICLE: "wrappers" "Wrappers"
 "Wrappers are used to push words on the data stack; they evaluate to the object being wrapped:"
 { $subsection wrapper }
 { $subsection literalize }
+"Wrapper literal syntax is documented in " { $link "syntax-words" } "."
 { $see-also "combinators" } ;
 
 ABOUT: "quotations"
index 564309a6fb5c4e9aed549a92ac5c3df17f297eaa..79195d19384e1f00a32597fe1503051b02f1901e 100755 (executable)
@@ -568,6 +568,11 @@ M: sequence <=>
     2dup [ length ] bi@ =
     [ mismatch not ] [ 2drop f ] if ; inline
 
+ERROR: assert-sequence got expected ;
+
+: assert-sequence= ( a b -- )
+    2dup sequence= [ 2drop ] [ assert-sequence ] if ;
+
 : sequence-hashcode-step ( oldhash newpart -- newhash )
     >fixnum swap [
         [ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi
diff --git a/core/source-files/errors/authors.txt b/core/source-files/errors/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/core/source-files/errors/errors-tests.factor b/core/source-files/errors/errors-tests.factor
new file mode 100644 (file)
index 0000000..f13790f
--- /dev/null
@@ -0,0 +1,10 @@
+USING: assocs compiler.errors compiler.units definitions
+namespaces source-files.errors tools.test words ;
+IN: source-files.errors.tests
+
+DEFER: forget-test
+
+[ ] [ [ \ forget-test [ 1 ] (( -- )) define-declared ] with-compilation-unit ] unit-test
+[ t ] [ \ forget-test compiler-errors get key? ] unit-test
+[ ] [ [ \ forget-test forget ] with-compilation-unit ] unit-test
+[ f ] [ \ forget-test compiler-errors get key? ] unit-test
\ No newline at end of file
diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor
new file mode 100644 (file)
index 0000000..e179c99
--- /dev/null
@@ -0,0 +1,77 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs kernel math.order sorting sequences definitions
+namespaces arrays splitting io math.parser math init ;
+IN: source-files.errors
+
+TUPLE: source-file-error error asset file line# ;
+
+: sort-errors ( errors -- alist )
+    [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ;
+
+: group-by-source-file ( errors -- assoc )
+    H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ;
+
+TUPLE: error-type type word plural icon quot forget-quot ;
+
+GENERIC: error-type ( error -- type )
+
+: <definition-error> ( error definition class -- source-file-error )
+    new
+        swap
+        [ >>asset ]
+        [ where [ first2 [ >>file ] [ >>line# ] bi* ] when* ] bi
+        swap >>error ; inline
+
+SYMBOL: error-types
+
+error-types [ V{ } clone ] initialize
+
+: define-error-type ( error-type -- )
+    dup type>> error-types get set-at ;
+
+: error-icon-path ( type -- icon )
+    error-types get at icon>> ;
+
+: error-counts ( -- alist )
+    error-types get [ nip dup quot>> call( -- seq ) length ] assoc-map ;
+
+: error-summary ( -- )
+    error-counts
+    [ nip 0 > ] assoc-filter
+    [
+        over
+        [ word>> write ]
+        [ " - show " write number>string write bl ]
+        [ plural>> print ] tri*
+    ] assoc-each ;
+
+: all-errors ( -- errors )
+    error-types get values
+    [ quot>> call( -- seq ) ] map
+    concat ;
+
+GENERIC: errors-changed ( observer -- )
+
+SYMBOL: error-observers
+
+[ V{ } clone error-observers set-global ] "source-files.errors" add-init-hook
+
+: add-error-observer ( observer -- ) error-observers get push ;
+
+: remove-error-observer ( observer -- ) error-observers get delq ;
+
+: notify-error-observers ( -- ) error-observers get [ errors-changed ] each ;
+
+: delete-file-errors ( seq file type -- )
+    [
+        [ swap file>> = ] [ swap error-type = ]
+        bi-curry* bi and not
+    ] 2curry filter-here
+    notify-error-observers ;
+
+: delete-definition-errors ( definition -- )
+    error-types get [
+        second forget-quot>> dup
+        [ call( definition -- ) ] [ 2drop ] if
+    ] with each ;
\ No newline at end of file
index c8441ba3b0a2bf65605720ee4f50f0a66aa1d976..6884a10d039231cb822fd5471367ddb2bac929df 100644 (file)
@@ -4,7 +4,7 @@ USING: arrays definitions generic assocs kernel math namespaces
 sequences strings vectors words quotations io io.files
 io.pathnames combinators sorting splitting math.parser effects
 continuations checksums checksums.crc32 vocabs hashtables graphs
-compiler.units io.encodings.utf8 accessors ;
+compiler.units io.encodings.utf8 accessors source-files.errors ;
 IN: source-files
 
 SYMBOL: source-files
@@ -61,8 +61,7 @@ M: pathname where string>> 1 2array ;
     [
         source-file
         [ unxref-source ]
-        [ definitions>> [ keys forget-all ] each ]
-        bi
+        [ definitions>> [ keys forget-all ] each ] bi
     ]
     [ source-files get delete-at ]
     bi ;
@@ -77,21 +76,20 @@ M: pathname forget*
 
 SYMBOL: file
 
-TUPLE: source-file-error error file ;
-
-: <source-file-error> ( msg -- error )
+: wrap-source-file-error ( error -- * )
+    file get rollback-source-file
     \ source-file-error new
-        file get >>file
-        swap >>error ;
+        f >>line#
+        file get path>> >>file
+        swap >>error rethrow ;
 
 : with-source-file ( name quot -- )
     #! Should be called from inside with-compilation-unit.
     [
-        swap source-file
-        dup file set
-        definitions>> old-definitions set
         [
-            file get rollback-source-file
-            <source-file-error> rethrow
-        ] recover
+            source-file
+            [ file set ]
+            [ definitions>> old-definitions set ] bi
+        ] dip
+        [ wrap-source-file-error ] recover
     ] with-scope ; inline
index 4f9005e11061fed8915062e79b77c3d838be274f..6561c55b6714f1236f664c242c4da8b5099a7a56 100644 (file)
@@ -3,7 +3,7 @@
 USING: namespaces make sequences io io.files io.pathnames kernel
 assocs words vocabs definitions parser continuations hashtables
 sorting source-files arrays combinators strings system
-math.parser compiler.errors splitting init accessors sets ;
+math.parser splitting init accessors sets ;
 IN: vocabs.loader
 
 SYMBOL: vocab-roots
@@ -80,11 +80,11 @@ SYMBOL: load-help?
 PRIVATE>
 
 : require ( vocab -- )
-    [ load-vocab drop ] with-compiler-errors ;
+    load-vocab drop ;
 
 : reload ( name -- )
     dup vocab
-    [ [ [ load-source ] [ load-docs ] bi ] with-compiler-errors ]
+    [ [ load-source ] [ load-docs ] bi ]
     [ require ]
     ?if ;
 
@@ -125,9 +125,7 @@ PRIVATE>
 [
     dup vocab-name blacklist get at* [ rethrow ] [
         drop dup find-vocab-root
-        [ [ (load-vocab) ] with-compiler-errors ]
-        [ dup vocab [ ] [ no-vocab ] ?if ]
-        if
+        [ (load-vocab) ] [ dup vocab [ ] [ no-vocab ] ?if ] if
     ] if
 ] load-vocab-hook set-global
 
diff --git a/core/words/constant/constant-docs.factor b/core/words/constant/constant-docs.factor
new file mode 100644 (file)
index 0000000..3175b5d
--- /dev/null
@@ -0,0 +1,12 @@
+USING: help.markup help.syntax words.constant ;
+IN: words.constant
+
+ARTICLE: "words.constant" "Constants"
+"There is a syntax for defining words which push literals on the stack."
+$nl
+"Define a new word that pushes a literal on the stack:"
+{ $subsection POSTPONE: CONSTANT: }
+"Define an constant at run-time:"
+{ $subsection define-constant } ;
+
+ABOUT: "words.constant"
index 1ad6928acbab2e0c8319df57d765bd15328a0ee6..c20ee66de8e8c236c93f410ba8d3354bdc9f4e14 100644 (file)
@@ -31,7 +31,7 @@ $nl
 { $subsection define }
 { $subsection define-declared }
 { $subsection define-inline }
-"Word definitions should declare their stack effect, unless the definition is completely trivial. See " { $link "effect-declaration" } "."
+"Word definitions must declare their stack effect. See " { $link "effect-declaration" } "."
 $nl
 "All other types of word definitions, such as " { $link "words.symbol" } " and " { $link "generic" } ", are just special cases of the above." ;
 
@@ -75,6 +75,7 @@ ARTICLE: "word-definition" "Defining words"
 { $subsection "colon-definition" }
 { $subsection "words.symbol" }
 { $subsection "words.alias" }
+{ $subsection "words.constant" }
 { $subsection "primitives" }
 { $subsection "deferred" }
 { $subsection "declarations" }
index aae0b40d381b521ec920dd6df43dcf852a1dd145..b9679ec26beddbd600ad4b86b9e35f8538bd4235 100755 (executable)
@@ -75,8 +75,6 @@ VAR: present-space
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r
 \r
 ! namespace utilities\r
-    \r
-: make* ( seq -- seq ) [ dup quotation? [ call ] [ ] if ] map ;\r
 \r
 : closed-quot ( quot -- quot )\r
   namestack swap '[ namestack [ _ set-namestack @ ] dip set-namestack ] ;\r
@@ -156,9 +154,9 @@ VAR: present-space
     3 model-projection <model> view4> (>>model) ;\r
 \r
 : camera-action ( quot -- quot ) \r
-    [ drop [ ] observer3d>  \r
+    '[ drop _ observer3d>  \r
     with-self update-observer-projections ] \r
-    make* closed-quot ;\r
+    closed-quot ;\r
 \r
 : win3D ( text gadget -- ) \r
     "navigateur 4D : " rot append open-window ;\r
@@ -400,7 +398,7 @@ M: handler handle-gesture ( gesture gadget -- ? )
 \r
 : add-keyboard-delegate ( obj -- obj )\r
  <handler>\r
-{\r
+H{\r
         { T{ key-down f f "LEFT" }  \r
             [ [ rotation-step turn-left ] camera-action ] }\r
         { T{ key-down f f "RIGHT" } \r
@@ -435,7 +433,7 @@ M: handler handle-gesture ( gesture gadget -- ? )
         { T{ key-down f f "3" } [ mvt-3D-3  camera-action ] }\r
         { T{ key-down f f "4" } [ mvt-3D-4  camera-action ] }\r
 \r
-    } [ make* ] map >hashtable >>table\r
+    } >>table\r
     ;    \r
 \r
 ! --------------------------------------------\r
index 9bd0e9c011ae4570796ab6cfbcceb9d1f28570a5..ad799f75c96ea67b211177e904f5cdd320267177 100755 (executable)
@@ -72,17 +72,17 @@ file-chooser H{
 : init-filelist-model ( file-chooser -- file-chooser )\r
     dup list-of-files <model> >>model ; \r
 \r
-: (fc-go) ( file-chooser quot -- )\r
+: (fc-go) ( file-chooser button quot -- )\r
     [ [ file-chooser? ] find-parent dup path>> ] dip\r
     call\r
     normalize-path swap set-model\r
     update-filelist-model\r
-    drop ;\r
+    drop ; inline\r
 \r
-: fc-go-parent ( file-chooser -- )\r
+: fc-go-parent ( file-chooser button -- )\r
     [ dup value>> parent-directory ] (fc-go) ;\r
 \r
-: fc-go-home ( file-chooser -- )\r
+: fc-go-home ( file-chooser button -- )\r
     [ home ] (fc-go) ;\r
 \r
 : fc-change-directory ( file-chooser file -- )\r
index 9dcbd763686fc6b7a3955cbcf7e8f6b5da9d603f..41f1102768345c23b87c0bf41755b61bf2a2650a 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: accessors arrays classes.tuple combinators continuations io
 kernel lexer math prettyprint quotations sequences source-files
-strings words ;
+source-files.errors strings words ;
 
 IN: fuel.pprint
 
index 4eaa98495328e5f9f94067cb87a2784d0e870855..cf9e9c836aceb06ca93cafc7cc0c78d2ba30ca61 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2007 Doug Coleman.
+! Copyright (C) 2007, 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors images images.loader io.pathnames kernel namespaces
 opengl opengl.gl opengl.textures sequences strings ui ui.gadgets
@@ -27,11 +27,8 @@ M: image-gadget draw-gadget* ( gadget -- )
 
 GENERIC: image. ( object -- )
 
-: default-image. ( path -- )
-    <image-gadget> gadget. ;
+M: string image. ( image -- ) load-image image. ;
 
-M: string image. ( image -- ) load-image default-image. ;
+M: pathname image. ( image -- ) load-image image. ;
 
-M: pathname image. ( image -- ) load-image default-image. ;
-
-M: image image. ( image -- ) default-image. ;
+M: image image. ( image -- ) <image-gadget> gadget. ;
index ed268e558daaee26b47325b1ef03b13c6672861b..5597422898768672224e33f76c05fe8a97b87a0c 100644 (file)
@@ -40,7 +40,7 @@ M: ast-array infix-codegen
 M: ast-op infix-codegen
     [ left>> infix-codegen ] [ right>> infix-codegen ]
     [ op>> select-op ] tri
-    2over [ number? ] both? [ call ] [
+    2over [ number? ] both? [ call( a b -- c ) ] [
         [ [ prepare-operand ] bi@ ] dip '[ @ @ @ ]
     ] if ;
 
index 2081ae4510545650e9dc302d961ef3835301d6f2..5bae054e1836cc13adfd0e28d04787b13ab8d575 100644 (file)
@@ -45,11 +45,11 @@ M: sequence chat-put [ chat-put ] with each ;
 
 ! Server message handling
 
-GENERIC: forward-message ( irc-message -- )
-M: irc-message   forward-message +server-chat+ chat-put ;
-M: to-one-chat   forward-message dup chat> chat-put ;
-M: to-all-chats  forward-message chats> chat-put ;
-M: to-many-chats forward-message dup sender>> participant-chats chat-put ;
+GENERIC: message-forwards ( irc-message -- seq )
+M: irc-message   message-forwards drop +server-chat+ ;
+M: to-one-chat   message-forwards chat> ;
+M: to-all-chats  message-forwards drop chats> ;
+M: to-many-chats message-forwards sender>> participant-chats ;
 
 GENERIC: process-message ( irc-message -- )
 M: object process-message drop ; 
@@ -91,7 +91,7 @@ M: irc-message handle-outgoing-irc irc-message>string irc-print t ;
 : handle-reader-message ( irc-message -- ) irc> in-messages>> mailbox-put ;
 
 : (handle-disconnect) ( -- )
-    irc> in-messages>> irc-disconnected swap mailbox-put
+    irc-disconnected irc> in-messages>> mailbox-put
     irc> reconnect-time>> sleep
     (connect-irc)
     (do-login) ;
@@ -113,8 +113,12 @@ M: f      handle-input handle-disconnect ;
 ! Processing loops
 
 : in-multiplexer-loop ( -- ? )
-    irc> in-messages>> mailbox-get
-    [ process-message ] [ forward-message ] [ irc-end? not ] tri ;
+    irc> in-messages>> mailbox-get {
+        [ message-forwards ]
+        [ process-message ]
+        [ swap chat-put ]
+        [ irc-end? not ]
+    } cleave ;
 
 : strings>privmsg ( name string -- privmsg )
     " :" prepend append "PRIVMSG " prepend string>irc-message ;
diff --git a/extra/irc/logbot/authors.txt b/extra/irc/logbot/authors.txt
new file mode 100644 (file)
index 0000000..f4a8cb1
--- /dev/null
@@ -0,0 +1 @@
+Bruno Deferrari
diff --git a/extra/irc/logbot/log-line/authors.txt b/extra/irc/logbot/log-line/authors.txt
new file mode 100644 (file)
index 0000000..f4a8cb1
--- /dev/null
@@ -0,0 +1 @@
+Bruno Deferrari
diff --git a/extra/irc/logbot/log-line/log-line.factor b/extra/irc/logbot/log-line/log-line.factor
new file mode 100644 (file)
index 0000000..b3af41a
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2009 Bruno Deferrari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors irc.messages irc.messages.base kernel make ;
+EXCLUDE: sequences => join ;
+IN: irc.logbot.log-line
+
+: dot-or-parens ( string -- string )
+    [ "." ] [ " (" prepend ")." append ] if-empty ;
+
+GENERIC: >log-line ( object -- line )
+
+M: irc-message >log-line line>> ;
+
+M: privmsg >log-line
+    [ "<" % dup sender>> % "> " % text>> % ] "" make ;
+
+M: join >log-line
+    [ "* " % sender>> % " has joined the channel." % ] "" make ;
+
+M: part >log-line
+    [ "* " % dup sender>> % " has left the channel" %
+      comment>> dot-or-parens % ] "" make ;
+
+M: quit >log-line
+    [ "* " % dup sender>> % " has quit" %
+      comment>> dot-or-parens % ] "" make ;
+
+M: kick >log-line
+    [ "* " % dup sender>> % " has kicked " % dup user>> %
+      " from the channel" % comment>> dot-or-parens % ] "" make ;
+
+M: participant-mode >log-line
+    [ "* " % dup sender>> % " has set mode " % dup mode>> %
+      " to " % parameter>> % ] "" make ;
+
+M: nick >log-line
+    [ "* " % dup sender>> % " is now known as " % nickname>> % ] "" make ;
diff --git a/extra/irc/logbot/log-line/summary.txt b/extra/irc/logbot/log-line/summary.txt
new file mode 100644 (file)
index 0000000..96ab2bf
--- /dev/null
@@ -0,0 +1 @@
+IRC message formatting for logs
diff --git a/extra/irc/logbot/logbot.factor b/extra/irc/logbot/logbot.factor
new file mode 100644 (file)
index 0000000..a389304
--- /dev/null
@@ -0,0 +1,56 @@
+! Copyright (C) 2009 Bruno Deferrari.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors calendar calendar.format destructors fry io io.encodings.8-bit
+io.files io.pathnames irc.client irc.client.chats irc.messages
+irc.messages.base kernel make namespaces sequences threads
+irc.logbot.log-line ;
+IN: irc.logbot
+
+CONSTANT: bot-channel "#concatenative"
+CONSTANT: log-directory "/tmp/logs"
+
+SYMBOL: current-day
+SYMBOL: current-stream
+
+: bot-profile ( -- obj )
+    "irc.freenode.org" 6667 "flogger" f <irc-profile> ;
+
+: add-timestamp ( string timestamp -- string )
+    timestamp>hms "[" prepend "] " append prepend ;
+
+: timestamp-path ( timestamp -- path )
+    timestamp>ymd ".log" append log-directory prepend-path ;
+
+: timestamp>stream ( timestamp  -- stream )
+    dup day-of-year current-day get = [
+        drop
+    ] [
+        current-stream get [ dispose ] when*
+        [ day-of-year current-day set ]
+        [ timestamp-path latin1 <file-writer> ] bi
+        current-stream set
+    ] if current-stream get ;
+
+: log-message ( string timestamp -- )
+    [ add-timestamp ] [ timestamp>stream ] bi
+    [ stream-print ] [ stream-flush ] bi ;
+
+GENERIC: handle-message ( msg -- )
+
+M: object      handle-message drop ;
+M: irc-message handle-message [ >log-line ] [ timestamp>> ] bi log-message ;
+
+: bot-loop ( chat -- ) dup hear handle-message bot-loop ;
+
+: start-bot ( -- )
+    bot-profile <irc-client>
+    [ connect-irc ]
+    [
+        [ bot-channel <irc-channel-chat> ] dip
+        '[ _ [ _ attach-chat ] [ bot-loop ] bi ]
+        "LogBot" spawn drop
+    ] bi ;
+
+: logbot ( -- ) start-bot ;
+
+MAIN: logbot
diff --git a/extra/irc/logbot/summary.txt b/extra/irc/logbot/summary.txt
new file mode 100644 (file)
index 0000000..1e49fcb
--- /dev/null
@@ -0,0 +1 @@
+An IRC logging bot
index 218ed92018908c7d6bf2d4d45ba2027f60bb257a..539fba54ebd171e8f8a30f5fd47dd60cdca4d068 100644 (file)
@@ -58,7 +58,8 @@ IN: irc.messages.tests
      { command "NICK" }
      { parameters  { } }
      { trailing "someuser2" }
-     { sender "someuser" } } }
+     { sender "someuser" }
+     { nickname "someuser2" } } }
 [ ":someuser!n=user@some.where NICK :someuser2"
   string>irc-message f >>timestamp ] unit-test
 
index 2ea476e1b44e47e341929620866e656b3fe477a3..a6bf02f8a700e60af3153760a77123ad81b99954 100755 (executable)
@@ -7,7 +7,7 @@ IN: irc.messages
 
 ! connection
 IRC: pass        "PASS"    password ;
-IRC: nick        "NICK"    nickname ;
+IRC: nick        "NICK"    nickname ;
 IRC: user        "USER"    user mode _ : realname ;
 IRC: oper        "OPER"    name password ;
 IRC: mode        "MODE"    name mode parameter ;
index 02f5ce8b21ebbaa8c08c4da6950a46ef1a20b0e1..9f86336f96229e7695a9aa83c75f108a0f1ad2f8 100755 (executable)
@@ -141,7 +141,7 @@ TUPLE: key-caps-gadget < gadget keys alarm ;
         swap [ 
             " " [ drop ] <border-button>
             swap [ first >>loc ] [ second >>dim ] bi
-        ] [ execute ] bi*
+        ] [ execute( -- value ) ] bi*
     ] dip set-nth ;
 
 : add-keys-gadgets ( gadget -- gadget )
index 7ac69d298057301e834cba23108c15083180005a..4ba8e2f66b34fca014983b88a587f55a7da30be6 100755 (executable)
@@ -165,7 +165,7 @@ DEFER: (d)
     swap call [ at 0 or ] curry map ; inline
 
 : op-matrix ( domain range quot -- matrix )
-    rot [ [ 2dup ] dip (op-matrix) ] map 2nip ; inline
+    rot [ (op-matrix) ] with with map ; inline
 
 : d-matrix ( domain range -- matrix )
     [ (d) ] op-matrix ;
index 047bdaa84435a7a203f640af9f87201f4162e5ca..1aade3bcae1787e553a25452d3a84988de3d17e8 100755 (executable)
@@ -87,9 +87,11 @@ CONSTANT: test-all-errors-file "test-all-errors"
 CONSTANT: help-lint-vocabs-file "help-lint-vocabs"
 CONSTANT: help-lint-errors-file "help-lint-errors"
 
+CONSTANT: compiler-errors-file "compiler-errors"
+CONSTANT: compiler-error-messages-file "compiler-error-messages"
+
 CONSTANT: boot-time-file "boot-time"
 CONSTANT: load-time-file "load-time"
-CONSTANT: compiler-errors-file "compiler-errors"
 CONSTANT: test-time-file "test-time"
 CONSTANT: help-lint-time-file "help-lint-time"
 CONSTANT: benchmark-time-file "benchmark-time"
index bc00f659fa5ae87625628c001a4e1726ec56635c..dab9b75528a364f99be39ff2a9b1849f9702ac3f 100644 (file)
@@ -4,7 +4,7 @@ USING: accessors assocs benchmark bootstrap.stage2
 compiler.errors generic help.html help.lint io.directories
 io.encodings.utf8 io.files kernel mason.common math namespaces
 prettyprint sequences sets sorting tools.test tools.time
-tools.vocabs words system io ;
+tools.vocabs words system io tools.errors locals ;
 IN: mason.test
 
 : do-load ( -- )
@@ -19,24 +19,27 @@ M: word word-vocabulary vocabulary>> ;
 
 M: method-body word-vocabulary "method-generic" word-prop word-vocabulary ;
 
+:: do-step ( errors summary-file details-file -- )
+    errors [ file>> ] map prune natural-sort summary-file to-file
+    errors details-file utf8 [ errors. ] with-file-writer ;
+
 : do-compile-errors ( -- )
-    compiler-errors-file utf8 [
-        +error+ errors-of-type keys
-        [ word-vocabulary ] map
-        prune natural-sort .
-    ] with-file-writer ;
+    compiler-errors get values
+    compiler-error-messages-file
+    compiler-errors-file
+    do-step ;
 
 : do-tests ( -- )
-    run-all-tests
-    [ keys test-all-vocabs-file to-file ]
-    [ test-all-errors-file utf8 [ test-failures. ] with-file-writer ]
-    bi ;
+    test-all test-failures get
+    test-all-vocabs-file
+    test-all-errors-file
+    do-step ;
 
 : do-help-lint ( -- )
-    "" run-help-lint
-    [ keys help-lint-vocabs-file to-file ]
-    [ help-lint-errors-file utf8 [ typos. ] with-file-writer ]
-    bi ;
+    help-lint-all lint-failures get values
+    help-lint-vocabs-file
+    help-lint-errors-file
+    do-step ;
 
 : do-benchmarks ( -- )
     run-benchmarks benchmarks-file to-file ;
index e3a009feb5c6dfebefb96d972d156051c68542f2..4bd1bc1b81fcc3c0022386327db20f3ead24dee7 100644 (file)
@@ -18,5 +18,5 @@ IN: math.binpack
     [ dup zip ] dip binpack [ keys ] map ;
 
 : binpack! ( items quot n -- bins ) 
-    [ dupd map zip ] dip binpack [ keys ] map ;
+    [ dupd map zip ] dip binpack [ keys ] map ; inline
 
index 99e8099f38e38bc92b47d2e9d4ec72e0f438fdb1..030d0a2a7350846091072034c68868d0bee76f4d 100755 (executable)
@@ -76,7 +76,7 @@ M: satisfy-parser parse ( input parser -- list )
     over empty? [
         2drop nil
     ] [
-        quot>> [ unclip-slice dup ] dip call
+        quot>> [ unclip-slice dup ] dip call( char -- ? )
         [ swap <parse-results> ] [ 2drop nil ] if
     ] if ;
 
index 7ec294ca2e9137d5364b774c41481725374c878f..829679570eecefeb8c95258db03ddc21955bdfbf 100755 (executable)
@@ -4,7 +4,7 @@ IN: partial-continuations
 USING: kernel continuations arrays sequences quotations ;
 
 : breset ( quot -- )
-    [ 1array swap keep first continue-with ] callcc1 nip ;
+    [ 1array swap keep first continue-with ] callcc1 nip ; inline
 
 : (bshift) ( v r k -- obj )
     [ dup first -rot ] dip
index 90d2e0e34c80d6782552400b2a36d6ba548a26cc..e7acf1f5bbe1b87feddbc4f839434ac92f7f5f6b 100644 (file)
@@ -43,7 +43,7 @@ M: lex-hash at*
 
 : parse* ( parser -- ast )
     compile
-    [ execute [ error-stack get first throw ] unless* ] with-global-lexer
+    [ execute( -- result ) [ error-stack get first throw ] unless* ] with-global-lexer
     ast>> ;
 
 : create-bnf ( name parser -- )
index 9d98ac67668817bbf2cdc514fdcabaaa2dfd602f..beed787fba1504fb86708b992623b3e386fa72bb 100644 (file)
@@ -95,7 +95,7 @@ PRIVATE>
 : euler011 ( -- answer )
     [
         { [ horizontal ] [ vertical ] [ diagonal/ ] [ diagonal\ ] }
-        [ call 4 max-product , ] each
+        [ call( -- matrix ) 4 max-product , ] each
     ] { } make supremum ;
 
 ! [ euler011 ] 100 ave-time
index d6c98ea203ab4b23e451bd6a43f6dc295b8f2c65..5f1c75ba8a0ee9607a960bd7ebd3937222950bf2 100644 (file)
@@ -41,7 +41,7 @@ METHOD: expand { glob-expr }
     [ ]
   if ;
 
-METHOD: expand { factor-expr } expr>> eval unparse ;
+METHOD: expand { factor-expr } expr>> eval>string ;
 
 DEFER: expansion
 
@@ -64,7 +64,7 @@ METHOD: expand { object } ;
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 : run-sword ( basic-expr -- )
-  command>> expansion unclip "shell" lookup execute ;
+  command>> expansion unclip "shell" lookup execute( arguments -- ) ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index aa98793c70ef6a2642e2288df9c6ae5b2877a409..5ff5bb38791e46072eb91a8969bc9aa3428899c3 100644 (file)
@@ -90,7 +90,7 @@ M: list focusable-child* drop t ;
 
 : invoke-value-action ( list -- )
     dup list-empty? [
-        dup hook>> call
+        dup hook>> call( list -- )
     ] [
         [ index>> ] keep nth-gadget invoke-secondary
     ] if ;
index beeddc7abb7ac8a0604eaf727b60721c8a80a679..77cd916139f9778fb13025559b01efdc128ac6a3 100644 (file)
@@ -20,8 +20,8 @@ DEFER: to-strings
   dup class
     {
       { \ string    [ ] }
-      { \ quotation [ call ] }
-      { \ word      [ execute ] }
+      { \ quotation [ call( -- string ) ] }
+      { \ word      [ execute( -- string ) ] }
       { \ fixnum    [ number>string ] }
       { \ array     [ to-strings concat ] }
     }
index b60f1b1b6a59abf7cff73eecd95f3cf7a96c7cc7..f82eb6dcd88594f3a1dcac50baa6e5494f58753d 100644 (file)
@@ -79,8 +79,7 @@ site-watcher-db <alloy>
 main-responder set-global
 
 M: site-watcher-app init-user-profile
-    drop B
-    "username" value "email" value <account> insert-tuple ;
+    drop "username" value "email" value <account> insert-tuple ;
 
 : init-db ( -- )
     site-watcher-db [
index d0116a7f2dc3060e5c60b9e8e5d117d6cb950b5d..a838c6763aecd4588f209da7ac13348a576d1095 100644 (file)
@@ -12,7 +12,7 @@ CONSTANT: site-list-url URL" $site-watcher-app/spider-list"
         { site-watcher-app "spider-list" } >>template
         [
             ! Silly query
-            username spidering-sites [ site>> ] map
+            username spidering-sites [ site>> ] map
             "sites" set-value
         ] >>init
     <protected>
index 34cd19c34fc99344f8b86536dfd7a51f4cf2d703..11a1e325c3f857961c350fadae02c20c6e98c0b3 100644 (file)
@@ -58,7 +58,7 @@ SYMBOL: *calling*
   swap [ * - ] keep 2array ;
   
 : change-global ( variable quot -- )
-  global swap change-at ;
+  global swap change-at ; inline
 
 : (correct-for-timing-overhead) ( timingshash -- timingshash )
   time-dummy-word [ subtract-overhead ] curry assoc-map ;  
@@ -75,7 +75,7 @@ SYMBOL: *calling*
       correct-for-timing-overhead
       "total time:" write
   ] dip pprint nl
-  print-word-timings nl ;
+  print-word-timings nl ; inline
 
 : profile-vocab ( vocab quot -- )
   "annotating vocab..." print flush
@@ -88,4 +88,4 @@ SYMBOL: *calling*
       correct-for-timing-overhead
       "total time:" write
   ] dip pprint
-  print-word-timings ;
+  print-word-timings ; inline
index bc1bb900ce450804cc71e273940eceacff2c7cec..aa7d25ebbd138c504184f42df11de3892bd0573b 100644 (file)
@@ -60,6 +60,7 @@
   (declaration keyword "declaration words")
   (ebnf-form constant "EBNF: ... ;EBNF form")
   (parsing-word keyword  "parsing words")
+  (postpone-body comment "postponed form")
   (setter-word function-name "setter words (>>foo)")
   (getter-word function-name "getter words (foo>>)")
   (stack-effect comment "stack effect specifications")
 (defun fuel-font-lock--syntactic-face (state)
   (if (nth 3 state) 'factor-font-lock-string
     (let ((c (char-after (nth 8 state))))
-      (cond ((or (char-equal c ?\ )
-                 (char-equal c ?\n)
-                 (char-equal c ?E))
+      (cond ((memq c '(?\  ?\n ?E ?P))
              (save-excursion
                (goto-char (nth 8 state))
                (beginning-of-line)
-               (cond ((looking-at-p "USING: ")
+               (cond ((looking-at "E") 'factor-font-lock-ebnf-form)
+                     ((looking-at "P") 'factor-font-lock-postpone-body)
+                     ((looking-at-p "USING: ")
                       'factor-font-lock-vocabulary-name)
-                     ((looking-at-p "\\(TUPLE\\|SYMBOLS\\|VARS\\|SINGLETONS\\):")
+                     ((looking-at-p
+                       "\\(TUPLE\\|SYMBOLS\\|VARS\\|SINGLETONS\\):")
                       'factor-font-lock-symbol)
                      ((looking-at-p "C-ENUM:\\( \\|\n\\)")
                       'factor-font-lock-constant)
-                     ((looking-at-p "E")
-                      'factor-font-lock-ebnf-form)
                      (t 'default))))
             ((or (char-equal c ?U) (char-equal c ?C))
              'factor-font-lock-parsing-word)
     (,fuel-syntax--alien-function-regex (1 'factor-font-lock-type-name)
                                         (2 'factor-font-lock-word))
     (,fuel-syntax--vocab-ref-regexp  2 'factor-font-lock-vocabulary-name)
-    (,fuel-syntax--constructor-decl-regex (1 'factor-font-lock-word)
-                                          (2 'factor-font-lock-type-name)
-                                          (3 'factor-font-lock-invalid-syntax nil t))
+    (,fuel-syntax--constructor-decl-regex
+     (1 'factor-font-lock-word)
+     (2 'factor-font-lock-type-name)
+     (3 'factor-font-lock-invalid-syntax nil t))
     (,fuel-syntax--typedef-regex (1 'factor-font-lock-type-name)
                                  (2 'factor-font-lock-type-name)
                                  (3 'factor-font-lock-invalid-syntax nil t))
index 1c889893664dbcca7b6a5e5f79def96432ae4afc..6b646511ca0794887d2170321cbc8abc80d9f0b6 100644 (file)
     ;; Strings and chars
     ("CHAR: \\(\"\\) [^\\\"]*?\\(\"\\)\\([^\\\"]\\|\\\\.\\)*?\\(\"\\)"
      (1 "w") (2 "\"") (4 "\""))
-    ("\\(CHAR:\\|POSTPONE:\\|\\\\\\) \\(.\\)\\( \\|$\\)" (2 "w"))
+    ("\\(CHAR:\\|\\\\\\) \\(.\\)\\( \\|$\\)" (2 "w"))
     ("\\( \\|^\\)\\(DLL\\|P\\|SBUF\\)\\(\"\\)\\([^\n\r\f\\\"]\\|\\\\.\\)*?\\(\"\\)"
      (3 "\"") (5 "\""))
     ("\\_<\\(\"\\)\\([^\n\r\f\\\"]\\|\\\\.\\)*?\\(\"\\)" (1 "\"") (3 "\""))
     ("\\_<<\\(\"\\)\\_>" (1 "<b"))
     ("\\_<\\(\"\\)>\\_>" (1 ">b"))
+    ;; postpone
+    ("\\_<POSTPONE:\\( \\).*\\(\n\\)" (1 "<b") (2 ">b"))
     ;; Multiline constructs
     ("\\_<\\(E\\)BNF:\\( \\|\n\\)" (1 "<b"))
     ("\\_<;EBN\\(F\\)\\_>" (1 ">b"))