diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index a28e5bf968..1a71ec2bb3 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -15,12 +15,8 @@ - more compact relocation info - problem if major gc happens during relocation - in fact relocation should not cons at all -- better way of dealing with compiler errors - - messages tool - - sort into warnings and errors - - quick way to navigate to offending word - variable width word wrap - - + - needs layout tricks - add-gadget, model-changed, set-model should compile - graphical module manager tool - list of modules -- loaded, not loaded diff --git a/library/compiler/compiler.factor b/library/compiler/compiler.factor index 8cfdc029be..3f5442e7c3 100644 --- a/library/compiler/compiler.factor +++ b/library/compiler/compiler.factor @@ -5,6 +5,24 @@ USING: errors generic hashtables inference io kernel math namespaces optimizer parser prettyprint sequences test threads words ; +SYMBOL: batch-errors + +GENERIC: batch-begins ( batch-errors -- ) + +M: f batch-begins drop ; + +GENERIC: compile-begins ( word batch-errors -- ) + +M: f compile-begins drop "Compiling " write . flush ; + +GENERIC: compile-error ( error batch-errors -- ) + +M: f compile-error drop error. flush ; + +GENERIC: batch-ends ( batch-errors -- ) + +M: f batch-ends drop ; + : word-dataflow ( word -- dataflow ) [ dup ?no-effect @@ -15,7 +33,7 @@ words ; : (compile) ( word -- ) dup compiling? not over compound? and [ - "Compiling " write dup . flush + dup batch-errors get compile-begins dup word-dataflow optimize generate ] [ drop @@ -25,12 +43,21 @@ words ; [ (compile) ] with-compiler ; : try-compile ( word -- ) - [ compile ] [ error. flush update-xt ] recover ; + [ + compile + ] [ + batch-errors get compile-error update-xt + ] recover ; + +: compile-batch ( seq -- ) + batch-errors get batch-begins + dup + [ f "no-effect" set-word-prop ] each + [ try-compile ] each + batch-errors get batch-ends ; : compile-vocabs ( seq -- ) - [ words ] map concat - dup [ f "no-effect" set-word-prop ] each - [ try-compile ] each ; + [ words ] map concat compile-batch ; : compile-all ( -- ) vocabs compile-vocabs changed-words get clear-hash ; @@ -42,7 +69,7 @@ words ; : recompile ( -- ) changed-words get [ - dup hash-keys [ try-compile ] each clear-hash + dup hash-keys compile-batch clear-hash ] when* ; [ recompile ] parse-hook set diff --git a/library/compiler/inference/errors.factor b/library/compiler/inference/errors.factor index 1d1b94f5d6..8f6fab5e8b 100644 --- a/library/compiler/inference/errors.factor +++ b/library/compiler/inference/errors.factor @@ -2,9 +2,9 @@ IN: inference USING: kernel generic errors sequences prettyprint io words ; M: inference-error error. - dup delegate error. - "Nesting: " write - inference-error-rstate [ first ] map . ; + dup inference-error-rstate [ first ] map + dup empty? [ "Word: " write dup peek . ] unless + swap delegate error. "Nesting: " write . ; M: inference-error error-help drop f ; diff --git a/library/compiler/inference/inference.factor b/library/compiler/inference/inference.factor index 6bc5a10dd1..2877f02216 100644 --- a/library/compiler/inference/inference.factor +++ b/library/compiler/inference/inference.factor @@ -5,19 +5,23 @@ USING: arrays errors generic io kernel math namespaces parser prettyprint sequences strings vectors words ; -TUPLE: inference-error rstate ; +TUPLE: inference-error rstate major? ; -C: inference-error ( msg rstate -- error ) +C: inference-error ( msg rstate important? -- error ) + [ set-inference-error-major? ] keep [ set-inference-error-rstate ] keep [ set-delegate ] keep ; : inference-error ( msg -- * ) - recursive-state get throw ; + recursive-state get t throw ; + +: inference-warning ( msg -- * ) + recursive-state get f throw ; TUPLE: literal-expected ; M: object value-literal - inference-error ; + inference-warning ; : pop-literal ( -- rstate obj ) 1 #drop node, diff --git a/library/compiler/inference/words.factor b/library/compiler/inference/words.factor index 0ad3ac81aa..667b9e7439 100644 --- a/library/compiler/inference/words.factor +++ b/library/compiler/inference/words.factor @@ -34,7 +34,7 @@ IN: inference TUPLE: no-effect word ; : no-effect ( word -- * ) - inference-error ; + inference-warning ; : nest-node ( -- ) #entry node, ; diff --git a/library/ui/load.factor b/library/ui/load.factor index 3995fb38ef..5b5232fc99 100644 --- a/library/ui/load.factor +++ b/library/ui/load.factor @@ -37,6 +37,7 @@ PROVIDE: library/ui { "gadgets/presentations.factor" "ui.factor" "tools/tools.factor" + "tools/messages.factor" "tools/listener.factor" "tools/walker.factor" "tools/search.factor" diff --git a/library/ui/tools/listener.factor b/library/ui/tools/listener.factor index 035fc9a85a..badc216a33 100644 --- a/library/ui/tools/listener.factor +++ b/library/ui/tools/listener.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005, 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: gadgets-listener -USING: arrays gadgets gadgets-frames gadgets-labels +USING: compiler arrays gadgets gadgets-frames gadgets-labels gadgets-panes gadgets-scrolling gadgets-text gadgets-theme gadgets-tracks gadgets-workspace generic hashtables tools io kernel listener math models namespaces parser prettyprint @@ -16,24 +16,6 @@ TUPLE: listener-gadget input output stack ; dup listener-gadget-input swap listener-gadget-output ; -: listener-thread ( listener -- ) - dup listener-stream [ - [ ui-listener-hook ] curry listener-hook set tty - ] with-stream* ; - -: start-listener ( listener -- ) - [ >r clear r> init-namespaces listener-thread ] in-thread - drop ; - -: ( gadget title -- gadget ) - { - { [