From b5c5991747049f74845c7bbfdb83943353e45903 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 28 Mar 2009 04:19:02 -0500 Subject: [PATCH 01/19] Working on UI compile error viewer tool --- basis/debugger/debugger.factor | 21 +++-- basis/ui/tools/compiler-errors/authors.txt | 1 + .../compiler-errors/compiler-errors.factor | 77 +++++++++++++++++++ basis/ui/tools/operations/operations.factor | 20 ++++- core/compiler/errors/errors.factor | 37 ++++++--- core/compiler/units/units-tests.factor | 19 ++++- core/compiler/units/units.factor | 4 +- 7 files changed, 158 insertions(+), 21 deletions(-) create mode 100644 basis/ui/tools/compiler-errors/authors.txt create mode 100644 basis/ui/tools/compiler-errors/compiler-errors.factor diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index efd35ab280..fd7696576b 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -9,7 +9,7 @@ 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 ; +generic.parser strings.parser vocabs.loader vocabs.parser see ; IN: debugger GENERIC: error. ( error -- ) @@ -309,11 +309,20 @@ 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: object compiler-error. ( error -- ) + [ + [ + [ + [ line#>> # ": " % ] + [ word>> synopsis % ] bi + ] "" make + ] [ + [ + presented set + bold font-style set + ] H{ } make-assoc + ] bi format nl + ] [ error>> error. ] bi ; M: bad-effect summary drop "Bad stack effect declaration" ; diff --git a/basis/ui/tools/compiler-errors/authors.txt b/basis/ui/tools/compiler-errors/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/ui/tools/compiler-errors/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/compiler-errors/compiler-errors.factor new file mode 100644 index 0000000000..e574aa077a --- /dev/null +++ b/basis/ui/tools/compiler-errors/compiler-errors.factor @@ -0,0 +1,77 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors arrays sorting assocs colors.constants combinators +combinators.smart compiler.errors compiler.units fonts kernel +math.parser math.order models models.arrow namespaces summary ui +ui.commands ui.gadgets ui.gadgets.tables ui.gadgets.tracks +ui.gestures ui.operations ui.tools.browser ui.tools.common +ui.gadgets.scrollers ; +IN: ui.tools.compiler-errors + +TUPLE: error-list-gadget < tool table ; + +SINGLETON: error-renderer + +M: error-renderer row-columns + drop [ + { + [ file>> ] + [ line#>> number>string ] + [ word>> name>> ] + [ error>> summary ] + } cleave + ] output>array ; + +M: error-renderer row-value + drop ; + +M: error-renderer column-titles + drop { "File" "Line" "Word" "Error" } ; + +: ( model -- table ) + [ [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ] + error-renderer + [ invoke-primary-operation ] >>action + monospace-font >>font + COLOR: dark-gray >>column-line-color + 6 >>gap + 30 >>min-rows + 30 >>max-rows + 80 >>min-cols + 80 >>max-cols ; + +: ( model -- gadget ) + [ values ] vertical error-list-gadget new-track + { 3 3 } >>gap + swap >>table + dup table>> 1 track-add ; + +M: error-list-gadget focusable-child* + table>> ; + +: error-list-help ( -- ) "ui-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: compiler-error-model + +compiler-error-model [ f ] initialize + +SINGLETON: updater + +M: updater definitions-changed + 2drop + compiler-errors get-global + compiler-error-model get-global + set-model ; + +updater remove-definition-observer +updater add-definition-observer + +: error-list-window ( obj -- ) + compiler-error-model get-global + "Compiler errors" open-window ; \ No newline at end of file diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index c6371ac8aa..881808ea03 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -5,7 +5,7 @@ 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 +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 @@ -86,6 +86,24 @@ IN: ui.tools.operations { +listener+ t } } define-operation +! Compiler errors +: edit-error ( error -- ) + [ file>> ] [ line#>> ] bi edit-location ; + +[ compiler-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 ; diff --git a/core/compiler/errors/errors.factor b/core/compiler/errors/errors.factor index 1ea497c3fc..f5e6fda646 100644 --- a/core/compiler/errors/errors.factor +++ b/core/compiler/errors/errors.factor @@ -1,21 +1,28 @@ -! Copyright (C) 2007, 2008 Slava Pestov. +! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces make assocs io sequences -sorting continuations math math.parser ; +sorting continuations math math.order math.parser accessors +definitions ; IN: compiler.errors SYMBOL: +error+ SYMBOL: +warning+ SYMBOL: +linkage+ +TUPLE: compiler-error error word file line# ; + GENERIC: compiler-error-type ( error -- ? ) M: object compiler-error-type drop +error+ ; -GENERIC# compiler-error. 1 ( error word -- ) +M: compiler-error compiler-error-type error>> compiler-error-type ; + +GENERIC: compiler-error. ( error -- ) SYMBOL: compiler-errors +compiler-errors [ H{ } clone ] initialize + SYMBOL: with-compiler-errors? : errors-of-type ( type -- assoc ) @@ -23,9 +30,19 @@ SYMBOL: with-compiler-errors? swap [ [ nip compiler-error-type ] dip eq? ] curry assoc-filter ; +: sort-compile-errors ( assoc -- alist ) + [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ; + +: group-by-source-file ( errors -- assoc ) + H{ } clone [ [ push-at ] curry [ nip dup file>> ] prepose assoc-each ] keep ; + : compiler-errors. ( type -- ) - errors-of-type >alist sort-keys - [ swap compiler-error. ] assoc-each ; + errors-of-type group-by-source-file sort-compile-errors + [ + [ nl "==== " write print nl ] + [ [ nl ] [ compiler-error. ] interleave ] + bi* + ] assoc-each ; : (compiler-report) ( what type word -- ) over errors-of-type assoc-empty? [ 3drop ] [ @@ -51,17 +68,17 @@ SYMBOL: with-compiler-errors? : :linkage ( -- ) +linkage+ compiler-errors. ; +: ( error word -- compiler-error ) + dup where [ first2 ] [ "" 0 ] if* \ compiler-error boa ; + : compiler-error ( error word -- ) - with-compiler-errors? get [ - compiler-errors get pick - [ set-at ] [ delete-at drop ] if - ] [ 2drop ] if ; + compiler-errors get-global pick + [ [ [ ] keep ] dip set-at ] [ delete-at drop ] 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/units/units-tests.factor b/core/compiler/units/units-tests.factor index d84b377f36..6545a45604 100644 --- a/core/compiler/units/units-tests.factor +++ b/core/compiler/units/units-tests.factor @@ -1,6 +1,6 @@ -IN: compiler.units.tests USING: definitions compiler.units tools.test arrays sequences words kernel accessors namespaces fry ; +IN: compiler.units.tests [ [ [ ] define-temp ] with-compilation-unit ] must-infer [ [ [ ] define-temp ] with-nested-compilation-unit ] must-infer @@ -30,4 +30,19 @@ 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 \ No newline at end of file diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index afa05f9442..e8b5b4647d 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -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 compiler.errors ; IN: compiler.units SYMBOL: old-definitions @@ -41,7 +41,7 @@ SYMBOL: compiler-impl HOOK: recompile compiler-impl ( words -- alist ) ! Non-optimizing compiler -M: f recompile [ f ] { } map>assoc ; +M: f recompile [ [ f swap compiler-error ] each ] [ [ f ] { } map>assoc ] bi ; ! Trivial compiler. We don't want to touch the code heap ! during stage1 bootstrap, it would just waste time. From 9be60e36afa38cf33daa9f658ff7ec75e0331a95 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 28 Mar 2009 04:19:33 -0500 Subject: [PATCH 02/19] Add models.arrow.smart: abstracts out common / pattern --- basis/models/arrow/smart/authors.txt | 1 + basis/models/arrow/smart/smart-tests.factor | 4 ++++ basis/models/arrow/smart/smart.factor | 9 +++++++++ basis/models/search/search.factor | 8 +++----- basis/models/sort/sort.factor | 7 +++---- basis/tools/profiler/profiler.factor | 2 +- basis/ui/gadgets/panes/panes-tests.factor | 7 ++++--- basis/ui/gadgets/search-tables/search-tables.factor | 2 +- basis/ui/tools/profiler/profiler-tests.factor | 3 +++ basis/ui/tools/profiler/profiler.factor | 7 ++++--- 10 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 basis/models/arrow/smart/authors.txt create mode 100644 basis/models/arrow/smart/smart-tests.factor create mode 100644 basis/models/arrow/smart/smart.factor create mode 100644 basis/ui/tools/profiler/profiler-tests.factor diff --git a/basis/models/arrow/smart/authors.txt b/basis/models/arrow/smart/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/models/arrow/smart/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ 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 index 0000000000..3e8375e512 --- /dev/null +++ b/basis/models/arrow/smart/smart-tests.factor @@ -0,0 +1,4 @@ +IN: models.arrows.smart.tests +USING: models.arrow.smart tools.test accessors models math kernel ; + +[ 7 ] [ 3 4 [ + ] [ 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 index 0000000000..257a2bb1ea --- /dev/null +++ b/basis/models/arrow/smart/smart.factor @@ -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: ( quot -- quot' ) + [ infer in>> dup ] keep + '[ _ narray [ _ firstn @ ] ] ; \ No newline at end of file diff --git a/basis/models/search/search.factor b/basis/models/search/search.factor index 4bf74b3b92..5ecb0fa34a 100644 --- a/basis/models/search/search.factor +++ b/basis/models/search/search.factor @@ -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 : ( values search quot -- model ) - [ 2array ] dip - '[ first2 _ curry filter ] ; + '[ _ curry filter ] ; inline : ( values search quot -- model ) - '[ swap @ [ >case-fold ] bi@ subseq? ] ; + '[ swap @ [ >case-fold ] bi@ subseq? ] ; inline diff --git a/basis/models/sort/sort.factor b/basis/models/sort/sort.factor index 23c150796f..efd2e4927b 100644 --- a/basis/models/sort/sort.factor +++ b/basis/models/sort/sort.factor @@ -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 : ( values sort -- model ) - 2array [ first2 sort ] ; \ No newline at end of file + [ '[ _ call( obj1 obj2 -- <=> ) ] sort ] ; inline \ No newline at end of file diff --git a/basis/tools/profiler/profiler.factor b/basis/tools/profiler/profiler.factor index 864a637096..f4488136b2 100644 --- a/basis/tools/profiler/profiler.factor +++ b/basis/tools/profiler/profiler.factor @@ -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 ; diff --git a/basis/ui/gadgets/panes/panes-tests.factor b/basis/ui/gadgets/panes/panes-tests.factor index 0529437a76..01abe8b3d9 100644 --- a/basis/ui/gadgets/panes/panes-tests.factor +++ b/basis/ui/gadgets/panes/panes-tests.factor @@ -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 diff --git a/basis/ui/gadgets/search-tables/search-tables.factor b/basis/ui/gadgets/search-tables/search-tables.factor index 4a2983bfe0..9947facedb 100644 --- a/basis/ui/gadgets/search-tables/search-tables.factor +++ b/basis/ui/gadgets/search-tables/search-tables.factor @@ -73,7 +73,7 @@ CONSULT: table-protocol search-table table>> ; dup field>> { 2 2 } f track-add values search 500 milliseconds quot renderer
f >>takes-focus? >>table - dup table>> 1 track-add ; + dup table>> 1 track-add ; inline M: search-table model-changed nip field>> clear-search-field ; diff --git a/basis/ui/tools/profiler/profiler-tests.factor b/basis/ui/tools/profiler/profiler-tests.factor new file mode 100644 index 0000000000..86bebddbc9 --- /dev/null +++ b/basis/ui/tools/profiler/profiler-tests.factor @@ -0,0 +1,3 @@ +USING: ui.tools.profiler tools.test ; + +\ profiler-window must-infer diff --git a/basis/ui/tools/profiler/profiler.factor b/basis/ui/tools/profiler/profiler.factor index 1c2318a35e..5fef64ea88 100644 --- a/basis/ui/tools/profiler/profiler.factor +++ b/basis/ui/tools/profiler/profiler.factor @@ -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 => ; +FROM: models.arrow.smart => ; FROM: models.product => ; IN: ui.tools.profiler @@ -112,8 +113,8 @@ M: method-renderer column-titles drop { "" "Method" "Count" } ; : ( profiler -- model ) [ [ method-counters ] dip - [ generic>> ] [ class>> ] bi 3array - [ first3 '[ _ _ method-matches? ] filter ] + [ generic>> ] [ class>> ] bi + [ '[ _ _ method-matches? ] filter ] ] keep ; : sort-by-name ( obj1 obj2 -- <=> ) @@ -208,6 +209,6 @@ profiler-gadget "toolbar" f { : profiler-window ( -- ) "Profiling results" open-status-window ; -: com-profile ( quot -- ) profile profiler-window ; +: com-profile ( quot -- ) profile profiler-window ; inline MAIN: profiler-window From 07f585a81d266d7fc470417441c6f38fbed3d676 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 6 Apr 2009 15:24:21 -0500 Subject: [PATCH 03/19] Error list tool work in progress --- .../errors/prettyprint/prettyprint.factor | 2 ++ basis/ui/tools/browser/popups/popups.factor | 2 +- .../compiler-errors/compiler-errors.factor | 36 +++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index 9dc82339b5..a71af74871 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -4,6 +4,8 @@ USING: accessors kernel prettyprint io debugger sequences assocs stack-checker.errors summary effects ; IN: stack-checker.errors.prettyprint +M: inference-error summary error>> summary ; + M: inference-error error-help error>> error-help ; M: inference-error error. diff --git a/basis/ui/tools/browser/popups/popups.factor b/basis/ui/tools/browser/popups/popups.factor index 05d7779305..91ac96e0f9 100644 --- a/basis/ui/tools/browser/popups/popups.factor +++ b/basis/ui/tools/browser/popups/popups.factor @@ -46,7 +46,7 @@ SLOT: model : show-links-popup ( browser-gadget quot title -- ) [ dup model>> ] 2dip - [ hand-loc get { 0 0 } show-glass ] [ request-focus ] bi ; + [ hand-loc get { 0 0 } show-glass ] [ request-focus ] bi ; inline : com-show-outgoing-links ( browser-gadget -- ) [ uses ] "Outgoing links" show-links-popup ; diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/compiler-errors/compiler-errors.factor index e574aa077a..6efb5586ba 100644 --- a/basis/ui/tools/compiler-errors/compiler-errors.factor +++ b/basis/ui/tools/compiler-errors/compiler-errors.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays sorting assocs colors.constants combinators -combinators.smart compiler.errors compiler.units fonts kernel +USING: accessors arrays sequences sorting assocs colors.constants combinators +combinators.smart compiler.errors compiler.units fonts kernel io.pathnames math.parser math.order models models.arrow namespaces summary ui ui.commands ui.gadgets ui.gadgets.tables ui.gadgets.tracks ui.gestures ui.operations ui.tools.browser ui.tools.common @@ -10,6 +10,29 @@ IN: ui.tools.compiler-errors TUPLE: error-list-gadget < tool table ; +SINGLETON: source-file-renderer + +M: source-file-renderer row-columns + drop [ first2 length number>string 2array ] [ { "All" "" } ] if* ; + +M: source-file-renderer row-value + drop first ; + +M: source-file-renderer column-titles + drop { "File" "Errors" } ; + +: ( model -- table ) + [ group-by-source-file >alist sort-keys f prefix ] + source-file-renderer
+ [ invoke-primary-operation ] >>action + COLOR: dark-gray >>column-line-color + { 1 f } >>column-widths + 6 >>gap + 30 >>min-rows + 30 >>max-rows + 80 >>min-cols + 80 >>max-cols ; + SINGLETON: error-renderer M: error-renderer row-columns @@ -32,7 +55,6 @@ M: error-renderer column-titles [ [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ] error-renderer
[ invoke-primary-operation ] >>action - monospace-font >>font COLOR: dark-gray >>column-line-color 6 >>gap 30 >>min-rows @@ -41,10 +63,10 @@ M: error-renderer column-titles 80 >>max-cols ; : ( model -- gadget ) - [ values ] vertical error-list-gadget new-track + vertical error-list-gadget new-track { 3 3 } >>gap - swap >>table - dup table>> 1 track-add ; + swap >>table + dup table>> 1/2 track-add ; M: error-list-gadget focusable-child* table>> ; @@ -72,6 +94,6 @@ M: updater definitions-changed updater remove-definition-observer updater add-definition-observer -: error-list-window ( obj -- ) +: error-list-window ( -- ) compiler-error-model get-global "Compiler errors" open-window ; \ No newline at end of file From 2b384a7742b55ccaf59bde905798fb7cba15c5b8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 8 Apr 2009 23:05:45 -0500 Subject: [PATCH 04/19] Re-organize some error-related code, three-pane look for compiler errors tool, add Joe's icons --- basis/debugger/debugger.factor | 4 +- basis/editors/editors.factor | 3 + .../errors/prettyprint/prettyprint.factor | 84 ++++++----- basis/ui/tools/browser/browser.factor | 6 +- .../compiler-errors/compiler-errors.factor | 131 ++++++++++++++---- basis/ui/tools/debugger/debugger.factor | 4 +- .../error-list/icons/compiler-error.tiff | Bin 0 -> 1298 bytes .../error-list/icons/compiler-warning.tiff | Bin 0 -> 1194 bytes .../error-list/icons/help-lint-error.tiff | Bin 0 -> 1060 bytes basis/ui/tools/error-list/icons/note.tiff | Bin 0 -> 784 bytes .../tools/error-list/icons/syntax-error.tiff | Bin 0 -> 1260 bytes .../error-list/icons/unit-test-error.tiff | Bin 0 -> 1258 bytes basis/ui/tools/operations/operations.factor | 5 +- 13 files changed, 165 insertions(+), 72 deletions(-) create mode 100644 basis/ui/tools/error-list/icons/compiler-error.tiff create mode 100644 basis/ui/tools/error-list/icons/compiler-warning.tiff create mode 100644 basis/ui/tools/error-list/icons/help-lint-error.tiff create mode 100644 basis/ui/tools/error-list/icons/note.tiff create mode 100644 basis/ui/tools/error-list/icons/syntax-error.tiff create mode 100644 basis/ui/tools/error-list/icons/unit-test-error.tiff diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index fd7696576b..04f43043b5 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -309,7 +309,7 @@ M: lexer-error compute-restarts M: lexer-error error-help error>> error-help ; -M: object compiler-error. ( error -- ) +M: compiler-error compiler-error. ( error -- ) [ [ [ @@ -324,6 +324,8 @@ M: object compiler-error. ( error -- ) ] bi format nl ] [ error>> error. ] bi ; +M: compiler-error error. compiler-error. ; + M: bad-effect summary drop "Bad stack effect declaration" ; diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor index 0003b508fb..327cdea3c1 100644 --- a/basis/editors/editors.factor +++ b/basis/editors/editors.factor @@ -81,6 +81,9 @@ M: object error-line : :edit ( -- ) error get (:edit) ; +: edit-error ( error -- ) + [ file>> ] [ line#>> ] bi edit-location ; + : edit-each ( seq -- ) [ [ "Editing " write . ] diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index a71af74871..c111f3bb9f 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -1,7 +1,7 @@ -! 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 ; @@ -11,11 +11,16 @@ 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 ] { } assoc>map ] bi zip [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ; @@ -27,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 @@ -44,26 +51,31 @@ 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: diverging-recursion-error error. - "The recursive word " write - word>> pprint - " digs arbitrarily deep into the stack" print ; - -M: unbalanced-recursion-error error. - "The recursive word " write - word>> pprint - " leaves with the stack having the wrong height" print ; - -M: inconsistent-recursive-call-error error. - "The recursive word " write - word>> pprint - " calls itself with a different set of quotation parameters than were input" print ; - -M: unknown-primitive-error error. +M: undeclared-recursion-error summary drop - "Cannot determine stack effect statically" print ; + "Inline recursive words must be declared recursive" ; + +M: diverging-recursion-error summary + [ + "The recursive word " % + word>> name>> % + " digs arbitrarily deep into the stack" % + ] "" make ; + +M: unbalanced-recursion-error summary + [ + "The recursive word " % + word>> name>> % + " leaves with the stack having the wrong height" % + ] "" make ; + +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 summary + drop + "Cannot determine stack effect statically" ; diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 0c6e1fe05a..a493d5d7d2 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -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 -- ) diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/compiler-errors/compiler-errors.factor index 6efb5586ba..45eb3dee5b 100644 --- a/basis/ui/tools/compiler-errors/compiler-errors.factor +++ b/basis/ui/tools/compiler-errors/compiler-errors.factor @@ -1,14 +1,18 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors arrays sequences sorting assocs colors.constants combinators -combinators.smart compiler.errors compiler.units fonts kernel io.pathnames -math.parser math.order models models.arrow namespaces summary ui -ui.commands ui.gadgets ui.gadgets.tables ui.gadgets.tracks -ui.gestures ui.operations ui.tools.browser ui.tools.common -ui.gadgets.scrollers ; +USING: accessors arrays sequences sorting assocs colors.constants +combinators combinators.smart combinators.short-circuit editors +compiler.errors compiler.units fonts kernel io.pathnames +stack-checker.errors math.parser math.order models models.arrow +models.search 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.images ; IN: ui.tools.compiler-errors -TUPLE: error-list-gadget < tool table ; +TUPLE: error-list-gadget < tool source-file error source-file-table error-table error-display ; SINGLETON: source-file-renderer @@ -16,60 +20,133 @@ M: source-file-renderer row-columns drop [ first2 length number>string 2array ] [ { "All" "" } ] if* ; M: source-file-renderer row-value - drop first ; + drop dup [ first ] when ; M: source-file-renderer column-titles drop { "File" "Errors" } ; -: ( model -- table ) - [ group-by-source-file >alist sort-keys f prefix ] - source-file-renderer
+M: source-file-renderer column-alignment drop { 0 1 } ; + +M: source-file-renderer filled-column drop 0 ; + +: ( model -- model' ) + [ group-by-source-file >alist sort-keys f prefix ] ; + +:: ( error-list -- table ) + error-list model>> + source-file-renderer +
[ invoke-primary-operation ] >>action COLOR: dark-gray >>column-line-color - { 1 f } >>column-widths 6 >>gap 30 >>min-rows 30 >>max-rows - 80 >>min-cols - 80 >>max-cols ; + 60 >>min-cols + 60 >>max-cols + t >>selection-required? + error-list source-file>> >>selected-value ; SINGLETON: error-renderer +GENERIC: error-icon ( error -- icon ) + +: ( name -- image-name ) + "vocab:ui/tools/error-list/icons/" ".tiff" surround ; + +M: inference-error error-icon + type>> { + { +error+ [ "compiler-error" ] } + { +warning+ [ "compiler-warning" ] } + } case ; + +M: object error-icon drop "HAI" ; + +M: compiler-error error-icon error>> error-icon ; + M: error-renderer row-columns drop [ { - [ file>> ] + [ error-icon ] [ line#>> number>string ] [ word>> name>> ] [ error>> summary ] } cleave ] output>array ; +M: error-renderer prototype-row + drop [ "compiler-error" "" "" "" ] output>array ; + M: error-renderer row-value drop ; M: error-renderer column-titles - drop { "File" "Line" "Word" "Error" } ; + drop { "" "Line" "Word" "Error" } ; -: ( model -- table ) - [ [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ] - error-renderer
+M: error-renderer column-alignment drop { 0 1 0 0 } ; + +: sort-errors ( seq -- seq' ) + [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ; + +: ( error-list -- model ) + [ model>> [ values ] ] [ source-file>> ] bi + [ swap { [ drop not ] [ [ string>> ] [ file>> ] bi* = ] } 2|| ] + [ sort-errors ] ; + +:: ( error-list -- table ) + error-list + error-renderer +
[ invoke-primary-operation ] >>action COLOR: dark-gray >>column-line-color 6 >>gap 30 >>min-rows 30 >>max-rows - 80 >>min-cols - 80 >>max-cols ; + 60 >>min-cols + 60 >>max-cols + t >>selection-required? + error-list error>> >>selected-value ; -: ( model -- gadget ) +TUPLE: error-display < track ; + +: ( error-list -- gadget ) + vertical error-display new-track + add-toolbar + swap error>> >>model + dup model>> [ print-error ] 1 track-add ; + +: com-inspect ( error-display -- ) + model>> value>> inspector ; + +: com-help ( error-display -- ) + model>> value>> error>> error-help-window ; + +: com-edit ( error-display -- ) + model>> value>> edit-error ; + +error-display "toolbar" f { + { f com-inspect } + { f com-help } + { f com-edit } +} define-command-map + +:: ( model -- gadget ) vertical error-list-gadget new-track - { 3 3 } >>gap - swap >>table - dup table>> 1/2 track-add ; + model >>model + f >>source-file + f >>error + dup >>source-file-table + dup >>error-table + dup >>error-display + :> error-list + error-list vertical + { 5 5 } >>gap + error-list source-file-table>> "Source files" 1/4 track-add + error-list error-table>> "Errors" 1/2 track-add + error-list error-display>> "Details" 1/4 track-add + { 5 5 } 1 track-add ; M: error-list-gadget focusable-child* - table>> ; + source-file-table>> ; : error-list-help ( -- ) "ui-error-list" com-browse ; @@ -96,4 +173,4 @@ updater add-definition-observer : error-list-window ( -- ) compiler-error-model get-global - "Compiler errors" open-window ; \ No newline at end of file + "Compiler errors" open-status-window ; \ No newline at end of file diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor index c3ead4e3f5..e1e176a8c4 100644 --- a/basis/ui/tools/debugger/debugger.factor +++ b/basis/ui/tools/debugger/debugger.factor @@ -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/icons/compiler-error.tiff b/basis/ui/tools/error-list/icons/compiler-error.tiff new file mode 100644 index 0000000000000000000000000000000000000000..1d6b1575ee480a2672e42742026ad473cd40343d GIT binary patch literal 1298 zcmebD)MD7i%)roK|GzyZaF7QQ^q3ddY$&wcT#%3hGa{qaw3)dlWPLZnpW{57YZj&yV6Ffi0< z-leX4x~r!y`4>2d*v{Z|W2XZIG%vmCzjF=X}K#rj+)Zf^)(Jx$rz z@$9`d-|zfgwS3a{mqu4&ZJL97%53K^U|YQM^V%lo1uc#OIt;=r4X>>JiUo5z-a7Q{ z=dI?Kzy34GPk*<8Nw?<>gZ*xifaxj>Gu7A}SRDhbV{>j~eA?vKGb=FpT-L{nSAIJ_ zVBm4>JTs|r#RP^lo`V7m!b}N9VzYJIIUm$6c(6lkOZ!vK12^{N7_qflYz$3eMq&Yy$0~JOFYc;Rc=BSdIH#jl%8#9AwVe4k>hJn=%=naI zQqEDQk8wo}>=QrLD?eOe!qUL%v5Jp@kwbxL!NWsq7=%3=7?>FnxcCH{0t&boea~{M z9XxS>$yH$ED$Px0^Bouxe54mJReW5bxMUlHBv%5X*@DT2`xr!-mK+f9$<%qvXZf+h zioIdUoEg`&7cC4aVqnc&S84QAVi9ix(}NiH29c?n-V7o~PVBer+Ig&EesY!)qYP`t z8b0Pn25vJA9~_j(WnlMwwaxIcMH)u~;{_{L29}M}%EP|wHQISR@WJxnIcBom$v4fS z-pt$05XqCnz_(T4P?w^E6ob_A=sNxo29{d!1kqauiyFi&PZTUz%xWKSCI8kgY2lKY z(~9NZ?Br5pI>7KnuBne%F>c<}zs0zvv$g!D^cKe=CbPjJ|dYkrrgUGYH{Bf`Og8np4aT7EzopXx!x`hLK;&p}1 zDR*o3US1@4WSf_|RR71HLbmsuSACgq=!cyU=cC}&+v^rpT7J8^+Cr}C;ENS<>2BwL z-E;T5>c3BZ`O!)b`(3AhOG-a@_GiA9@aG-8UU4&)Wv+KU`uCE(_n(Cw1xzj+6Gar3 zMDz$QviQ&Okx_(!fsvVkk%56h0f-rq*i1k+3s7tgkYI+2vjX{SP&N~g%>`wH^z$+@ zF#t_t*aB29$jAaVlLN>XLQ*3NWrNHWgR&ifY;maib-?mNijftp_XJRpG?aY-$d*Ae zM+3?RDrYbR+G_=*ZvfTULd8LD^MaZQWHJOHiG%nYP?(&bTacNPTBMs=RFq$&SCW~Q z#?Wx+YXwk=1B~{}O-xVqO-#>B&Q>tfGto0pFfi9QG}1S)PzW?MQ^+VODX`MlFE20G Q%LJ(eVxUUB{GxOQ0AD@BApigX literal 0 HcmV?d00001 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 index 0000000000000000000000000000000000000000..b50afa45f963269d4343eac280be291b90c33f2d GIT binary patch literal 1194 zcmebD)MD^qW?*Qrf8fBOBF4+!;*=P$BY;gNfsL7ggTwgZOW{WQD*`8;l-Y9h9DfpI zVW1$uXxrL!fca3N1w*H!Pn!et#VfBEl;ru_e~Ee8_j_cBSlG-8)S6~AGnnB(lE8}+ zN4CS6Ywi_W&%3DYz$KdJ?l$Grd68AAR<;2vL)9*KUinlTH!(af~J5eTMp`Q zb9`B_AzN&%m}(b?KKBX5CzZ+%S7bGbs(NtelA*xGw4h(v zUQ}TvPs~}3w3C~f*ch8Q=B{>JkkKT`=ET9+kfGAnB+BZS*V4afD4>bJHzwLDPesrXCF}x6RLKDWBwPV9ruvkP%^E;O{tOY<5;w-P_E#=Y>Lv ztU}91T{GVUEDv@b;ZRtn*}%@L?sdWBsL2lb_D3A7jTy@G&UPtvab(R}pGUz!`P}`;>a{URuulEsE)LPw48;>g%8yQL zY7#kWCR(^-`kAo$#W$M7YUdZ~_%VpLKHB0c=%Mh+YJDY3&|}3uC(+5aCT5oXdb}4H z0;Xsv?9$s)x%sq~^3O|_;fEd{)9iX-PSCs)>+`teo*aC;d$((QjP;$TOY_d=9^SK|Mo4_$hugDu9w=oURtP8z|^7Sv52c%nM26@ied)`Fr*oo z85kKD7!-h*5sA$NWU~OpoPY!~RGbyaXM?htfNU-(8>F9?k%>VJNP7X*3o^2R&Ex>` zg^<*ULfIg5#h`2lAX^-&-UXPer5IVkdJ}+(q@nB#AX^5>91SQNsGPwNXs;EJE&!^r zg^GjR<^?qq$YcmY5(n`)pfEW0n$lHkbJslhw1sEyz0kf9cWYfb{Hb9ETH+A7$!Ld-pwX-}4QUT5S7Xs&9B^@?n#s635P%6cigzAkB3dbt=oO+6^8ryzOtlr_BBHkIm|_ z&ABMIueSX~HZQlYeZZj8t)Zm!+n#}W$9oH&>R*pk_?5UBHfCMnV6a_ZBh=*B;UdRi z_x_B=maX~R8jXj0XKm*{qVb_mc|prZnY{8V*uy3tBprnwT7>ggrRA{u74* z^MV%)p4^!&4&l%78z~J{KirdzI@~4Lm0U?TqnobE#S@C&uNv;e- z5ChAv`$yZCTsB=|*t2F)@Rd^M!2JcQTdoPL(GBIdEo9jo?q4dZ(zm})I%=J>hil#> zHpfXE=`+9lsg!46DU@l8FkQ@}ILT?`BlES6sj$}wo& zaU!%oUAt^e%#Pb!zbEYW+P*lrY>!Y;eZ`XSxqq7DZU}WYssAt)Z@K&Go5Z5T(`|~0 z8*a?jt-W0!)Y!czc%8|?M{Axjaz7R+b36NJCmX-`{GYW?`&2uN5}MV@%YtX7mKDh` zEaI4Yp-Jh)A(q}}9#Kpp3=E9S42%p63<^NZh{R?BvRQy)dzcv*n4#jVKt3Ck4NUqB zTu?ShKQAK_gD8+b0#q-^$O1N#1IQObQX>jwgUl6!vK@eIaj5!zKtrV%S;2a50nL$y zvL6B2GDzlVK-oZH21B5|RzUg{kYfuK2f57)Y9^4$5QHQS;&VV@MruxhZcb)iiEe69 zQGStLNoHCaFh?KyS^-q#0HZx~6Vp?D6Vo%3vlYzrO!N#C49xWnjr0vH6ao#+6f#Om Y3as??%gf94GC?YV7^qS&zbKsn087SP5&!@I literal 0 HcmV?d00001 diff --git a/basis/ui/tools/error-list/icons/note.tiff b/basis/ui/tools/error-list/icons/note.tiff new file mode 100644 index 0000000000000000000000000000000000000000..01c328f09ed1292af787a28dc3639182ad2c8c0a GIT binary patch literal 784 zcmebD)M7Zs$iUEGe?Y)OMU0od#VIjhhYyz|e}_xrhZj@AbOpLx9|!JGN#kG?X%^}a zV*bM_)4>pbU>oy=8~?KpKE7a(_2rnOU4!GKj^+yt&GpNtzgLnuCBRg->wu%>lh9iX zT>IxAuriTh`d{6^C~{-+0|rh8`vayCrg592yZ0U7{J?6kTwr~KPMC-8tgTW33_J=9 z7L3mrm=5ciNy|v3G3<^~I=O&x4ud^|fu86e)l2pfyN}&!V02*MoV+tJVMmQ`k#h6S zhYO`5R&QYFXE0&lmigAKy=rxuVZc`lhC2+`9qutO)ZGqVeD&SJ{yQ0ruNZO~Bp)!E zJMEtG_;{sRMY9WoJ_Dx%?*YaY3{zjfD7s*q;&_dL+fnoYQ~&b(6L-EVX&W$F3p`+8 znEd9=f?VY(9sLfBeDAkuY!0|+?SI;+gFS(yIHXVO!BrfNf zp*3Nt=AIFD!plz$3pFOba+s*nX>wrG(#)*58K;b64jew`_2i}1 z^2vKX^eHGXh%hiPGBW_9kwF278IjmbKsFOli~|Unq2jDSJ{yz`(!+(s=4E7J-~x*6 z0csLtWC5GW0ptrIsS$;;LFS4<*$qIpI8^;!prKNXtYE#zfQqD{>~lc243aq-P&PAA zuOZN0DB w&Q>tfGto0pFfi9QG}1S)PzW?MQ^+VODX`MlFE20G%LJ(eVxUUB{GxOQ0ECd++W-In literal 0 HcmV?d00001 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 index 0000000000000000000000000000000000000000..869cfe7ffa30e5eee03e272d717734cf26c33970 GIT binary patch literal 1260 zcmebD)MA*#%)roK|GzyZaF7QQ^q3ddY$&wcT#%3hGa{qaw3)dlWPLZnpW{57YZj&yV6Ffi0< z-leX4x~r!y`4>2d*v{Z|W2XZIG%vmCzjF=X}K#rj+)Zf^)(Jx$rz z@$9`d-|zfgwS3a{mqu4&ZJL97&Ku0pPhj5p?r(Gd5rzc}E&|MxR^R3~VCk5l#@4`a zz<|#=e$lB!4eN-w`_^lk_=4AdU{*Zwy?NuABmss87MznNgy;z{GamTLz}LLTO|!#c z#jZEA*)A>Nd*m}kC+Bh4aYcRM6Z@w=+F`}Oa$p7z1EYfm%cObiha0p-(-j!vX1_mp z!0jQaIVJ;8L zO+_D@v|~#)ZYg-+Uiezh;Y0%?qXL7F$wXDpjxTd=9OKY()!ckaWv$Fxfb6$M61H%En#s`{ecWk(H?(4Ys?378KyMW=I zVgD{ySXA`y;XL=GA0@NNK%< zc_A_hj3HXh4GgP98Bgh)_r1J1Mqtl{={BoA9{b#S<938|M^XW8_d=A!@#WLA>dK zlb4NndjO;3+ye|+td{Hy50@$2X!Dwsb?#khLj&{9N{`vy0I%(*0Ii1wF67{0p z@Yy!r#0@G8918`+UZ)h*Tw0K?@oi&cl;nKlmCsJ8TTT4@m+$qgB;8rhFRzgGmf!8g zo1d`gn-_oP*)O)cP4_;!Y#zD$YveBWNAJDdw53XG<+86=3WxWB+J>pfpo zb(q&aT6lmT&fZdGW;yMVhehXr3g&$Xp-v>aOiNGAGq)N21)H6KC2s> zb&|LgIXo2ip zRw#09?_TtZgQ;QF#hhq`<{j^v~D_3ZJSbO{EtMW)4@^*Roj>|^lJQ1l2= zXc1&-Vo$uq5j16mqJoD)^M}7q7ap)!G%+!>wl#~pUgFT~N?<%3H%Ih`eZuV*zHv=# z4|j2>bDmIi3tZ4TF{LSXdX{*>opQ}XO_zF~>NDIwVHp&%pjqNr6VGBT4)=*aye-Xi zL(i65>^!~Iuw{;g1cLwzhf-|Y!ylVCJ+`)Jb6W-*{g7i{(8^@SU{m22DWR}&n$?kq zLO(i`6q+phZf`gGSFWL`m*hQvm(Xf8YrYeTOEMK&4;Gw#SzIN)T+y=WIrBa72@GnS z9ST3}6j}{^ns}R2cjhZry^dON%Jbim9a3st9CrOH6nL1e`7SUN&Dr>-uKC@$AomSs zQq8_A4Xy_7`_LfpC+g49U&*n1)=A&mQ$6p6;+=AZh8yNnAIrSkv%ZK+-R0oNP3%dh ziz0q?-n#vFH~Y<#d$T8=kH7ob`~idPvrvl?xtQfAQ(ks)%=~(L|J-Nt|8_~VGiWra zbSbRZWYC!Q?~*`61A_`wH z^z$+@F^B@`E}(irMi#J{96-Jhk{VGc8)U8+l6z#mC>WUQ8ye{wSSSPz9|8>t%ve0x?jfUVc$J0|2f{ucrV2 literal 0 HcmV?d00001 diff --git a/basis/ui/tools/operations/operations.factor b/basis/ui/tools/operations/operations.factor index 881808ea03..5da6402c8e 100644 --- a/basis/ui/tools/operations/operations.factor +++ b/basis/ui/tools/operations/operations.factor @@ -87,9 +87,6 @@ IN: ui.tools.operations } define-operation ! Compiler errors -: edit-error ( error -- ) - [ file>> ] [ line#>> ] bi edit-location ; - [ compiler-error? ] \ edit-error H{ { +primary+ t } { +secondary+ t } @@ -191,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 From bc6dfeea17ff7a649fa2692ab7af38d8dc477f45 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 9 Apr 2009 04:49:54 -0500 Subject: [PATCH 05/19] Move assert-sequence= from mime.multipart to sequences --- basis/mime/multipart/multipart.factor | 3 --- core/sequences/sequences.factor | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/mime/multipart/multipart.factor b/basis/mime/multipart/multipart.factor index 0edfb05a30..0cf7556bcd 100755 --- a/basis/mime/multipart/multipart.factor +++ b/basis/mime/multipart/multipart.factor @@ -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/core/sequences/sequences.factor b/core/sequences/sequences.factor index 564309a6fb..b614c15150 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -568,6 +568,9 @@ M: sequence <=> 2dup [ length ] bi@ = [ mismatch not ] [ 2drop f ] if ; inline +: assert-sequence= ( a b -- ) + 2dup sequence= [ 2drop ] [ assert ] if ; + : sequence-hashcode-step ( oldhash newpart -- newhash ) >fixnum swap [ [ -2 fixnum-shift-fast ] [ 5 fixnum-shift-fast ] bi From 7adb76aaf4e5fee1985df1b09e6ad39b37aa69d0 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 9 Apr 2009 04:50:38 -0500 Subject: [PATCH 06/19] Factor out some compiler error code into source-files.errors --- basis/debugger/debugger.factor | 17 ++++----- .../errors/prettyprint/prettyprint.factor | 2 +- basis/tools/errors/authors.txt | 1 + basis/tools/errors/errors.factor | 25 ++++++++++++ core/compiler/errors/errors.factor | 38 +++++-------------- core/parser/parser-tests.factor | 2 +- core/parser/parser.factor | 1 + core/source-files/errors/authors.txt | 1 + core/source-files/errors/errors.factor | 12 ++++++ core/source-files/source-files.factor | 23 ++++++----- 10 files changed, 69 insertions(+), 53 deletions(-) create mode 100644 basis/tools/errors/authors.txt create mode 100644 basis/tools/errors/errors.factor create mode 100644 core/source-files/errors/authors.txt create mode 100644 core/source-files/errors/errors.factor diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 04f43043b5..202cf7eb5e 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -9,7 +9,8 @@ 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 see ; +generic.parser strings.parser vocabs.loader vocabs.parser see +source-files.errors ; IN: debugger GENERIC: error. ( error -- ) @@ -268,11 +269,6 @@ M: duplicate-slot-names summary M: invalid-slot-name summary drop "Invalid slot name" ; -: file. ( file -- ) path>> . ; - -M: source-file-error error. - [ file>> file. ] [ error>> error. ] bi ; - M: source-file-error summary error>> summary ; @@ -309,12 +305,13 @@ M: lexer-error compute-restarts M: lexer-error error-help error>> error-help ; -M: compiler-error compiler-error. ( error -- ) +M: source-file-error error. [ [ [ - [ line#>> # ": " % ] - [ word>> synopsis % ] bi + [ file>> [ % ": " % ] when* ] + [ line#>> [ # ": " % ] when* ] + [ summary % ] tri ] "" make ] [ [ @@ -324,7 +321,7 @@ M: compiler-error compiler-error. ( error -- ) ] bi format nl ] [ error>> error. ] bi ; -M: compiler-error error. compiler-error. ; +M: compiler-error summary word>> synopsis ; M: bad-effect summary drop "Bad stack effect declaration" ; diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index c111f3bb9f..de73a3e731 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -41,7 +41,7 @@ M: missing-effect summary M: effect-error summary [ - "Stack effect declaration of the word " % + "Stack effect declaration of the word " % word>> name>> % " is wrong" % ] "" make ; diff --git a/basis/tools/errors/authors.txt b/basis/tools/errors/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/basis/tools/errors/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ No newline at end of file diff --git a/basis/tools/errors/errors.factor b/basis/tools/errors/errors.factor new file mode 100644 index 0000000000..a11b60d833 --- /dev/null +++ b/basis/tools/errors/errors.factor @@ -0,0 +1,25 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: assocs compiler.errors debugger io kernel sequences +source-files.errors ; +IN: tools.errors + +#! Tools for source-files.errors. Used by tools.tests and others +#! for error reporting + +: errors. ( errors -- ) + group-by-source-file sort-errors + [ + [ nl "==== " write print nl ] + [ [ nl ] [ error. ] interleave ] + bi* + ] assoc-each ; + +: compiler-errors. ( type -- ) + errors-of-type errors. ; + +: :errors ( -- ) +error+ compiler-errors. ; + +: :warnings ( -- ) +warning+ compiler-errors. ; + +: :linkage ( -- ) +linkage+ compiler-errors. ; diff --git a/core/compiler/errors/errors.factor b/core/compiler/errors/errors.factor index f5e6fda646..9d8ab3deab 100644 --- a/core/compiler/errors/errors.factor +++ b/core/compiler/errors/errors.factor @@ -1,15 +1,13 @@ ! Copyright (C) 2007, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel namespaces make assocs io sequences -sorting continuations math math.order math.parser accessors -definitions ; +continuations math math.parser accessors definitions +source-files.errors ; IN: compiler.errors -SYMBOL: +error+ -SYMBOL: +warning+ -SYMBOL: +linkage+ +SYMBOLS: +error+ +warning+ +linkage+ ; -TUPLE: compiler-error error word file line# ; +TUPLE: compiler-error < source-file-error word ; GENERIC: compiler-error-type ( error -- ? ) @@ -17,8 +15,6 @@ M: object compiler-error-type drop +error+ ; M: compiler-error compiler-error-type error>> compiler-error-type ; -GENERIC: compiler-error. ( error -- ) - SYMBOL: compiler-errors compiler-errors [ H{ } clone ] initialize @@ -30,20 +26,6 @@ SYMBOL: with-compiler-errors? swap [ [ nip compiler-error-type ] dip eq? ] curry assoc-filter ; -: sort-compile-errors ( assoc -- alist ) - [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ; - -: group-by-source-file ( errors -- assoc ) - H{ } clone [ [ push-at ] curry [ nip dup file>> ] prepose assoc-each ] keep ; - -: compiler-errors. ( type -- ) - errors-of-type group-by-source-file sort-compile-errors - [ - [ nl "==== " write print nl ] - [ [ nl ] [ compiler-error. ] interleave ] - bi* - ] assoc-each ; - : (compiler-report) ( what type word -- ) over errors-of-type assoc-empty? [ 3drop ] [ [ @@ -62,14 +44,12 @@ SYMBOL: with-compiler-errors? "semantic warnings" +warning+ "warnings" (compiler-report) "linkage errors" +linkage+ "linkage" (compiler-report) ; -: :errors ( -- ) +error+ compiler-errors. ; - -: :warnings ( -- ) +warning+ compiler-errors. ; - -: :linkage ( -- ) +linkage+ compiler-errors. ; - : ( error word -- compiler-error ) - dup where [ first2 ] [ "" 0 ] if* \ compiler-error boa ; + \ compiler-error new + swap + [ >>word ] + [ where [ first2 ] [ "" 0 ] if* [ >>file ] [ >>line# ] bi* ] bi + swap >>error ; : compiler-error ( error word -- ) compiler-errors get-global pick diff --git a/core/parser/parser-tests.factor b/core/parser/parser-tests.factor index 3ba414fe6b..9e1fcb95bd 100644 --- a/core/parser/parser-tests.factor +++ b/core/parser/parser-tests.factor @@ -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 diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 6d613a8b24..04fa7fa03f 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -190,6 +190,7 @@ SYMBOL: interactive-vocabs "tools.annotations" "tools.crossref" "tools.disassembler" + "tools.errors" "tools.memory" "tools.profiler" "tools.test" diff --git a/core/source-files/errors/authors.txt b/core/source-files/errors/authors.txt new file mode 100644 index 0000000000..d4f5d6b3ae --- /dev/null +++ b/core/source-files/errors/authors.txt @@ -0,0 +1 @@ +Slava Pestov \ 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 index 0000000000..9972a68446 --- /dev/null +++ b/core/source-files/errors/errors.factor @@ -0,0 +1,12 @@ +! Copyright (C) 2009 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs kernel math.order sorting ; +IN: source-files.errors + +TUPLE: source-file-error error file line# ; + +: sort-errors ( assoc -- alist ) + [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ; + +: group-by-source-file ( errors -- assoc ) + H{ } clone [ [ push-at ] curry [ nip dup file>> ] prepose assoc-each ] keep ; diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index c8441ba3b0..8edd62260a 100644 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -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 @@ -77,21 +77,20 @@ M: pathname forget* SYMBOL: file -TUPLE: source-file-error error file ; - -: ( 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 - rethrow - ] recover + source-file + [ file set ] + [ definitions>> old-definitions set ] bi + ] dip + [ wrap-source-file-error ] recover ] with-scope ; inline From e5c28dfa95b850fea9b1f56ce6156ea0a4aaa6fd Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 9 Apr 2009 04:50:47 -0500 Subject: [PATCH 07/19] tools.test: use source-files.errors --- basis/tools/test/test.factor | 179 ++++++++++++++++++++++------------- 1 file changed, 115 insertions(+), 64 deletions(-) diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index c6dea08d18..e45f76d7df 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -1,95 +1,146 @@ -! 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 ; IN: tools.test -SYMBOL: failures +TUPLE: test-failure < source-file-error experiment continuation ; -: ( error what -- triple ) - error-continuation get 3array ; +SYMBOL: passed-tests +SYMBOL: failed-tests -: failure ( error what -- ) + ( error experiment file line# -- triple ) + test-failure new + swap >>line# + swap >>file + swap >>experiment + swap >>error + error-continuation get >>continuation ; + +: failure ( error experiment file line# -- ) "--> test failed!" print - failures get push ; + failed-tests get push ; -SYMBOL: this-test +: success ( experiment -- ) passed-tests get push ; -: (unit-test) ( what quot -- ) - swap dup . flush this-test set - failures get [ - [ this-test get failure ] recover - ] [ - call - ] if ; inline +: file-failure ( error file -- ) + [ f ] [ f ] bi* 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 -- ) - dup word? [ 1quotation ] when - '[ _ infer drop ] [ ] swap unit-test ; +:: (must-infer) ( word/quot -- error ? ) + word/quot dup word? [ '[ _ execute ] ] when :> quot + [ quot infer drop f f ] [ t ] recover ; inline -: must-fail-with ( quot pred -- ) - [ '[ @ f ] ] dip '[ _ _ recover ] [ t ] swap unit-test ; +SINGLETON: did-not-fail -: must-fail ( quot -- ) - [ drop t ] must-fail-with ; +M: did-not-fail summary drop "Did not fail" ; -: (run-test) ( vocab -- ) +:: (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 ; + +MACRO: ( word -- ) + [ stack-effect in>> length dup ] + [ name>> experiment-title ] bi + '[ _ ndup _ narray _ prefix ] ; + +: experiment. ( seq -- ) + [ first write ": " write ] [ rest . ] bi ; + +:: experiment ( word: ( -- error ? ) file line# -- ) + word :> e + e experiment. + word execute [ e file line# failure ] [ drop e success ] if ; inline + +: parse-test ( accum word -- accum ) + literalize parsed + file get dup [ path>> ] when parsed + lexer get line>> parsed + \ experiment parsed ; inline + +<< + +SYNTAX: TEST: + scan + [ create-in ] + [ "(" ")" surround search '[ _ parse-test ] ] bi + define-syntax ; + +>> + +: run-test-file ( path -- ) + [ run-file ] [ swap file-failure ] recover ; + +: collect-results ( quot -- failed passed ) + [ + V{ } clone failed-tests set + V{ } clone passed-tests set + call + failed-tests get + passed-tests get + ] with-scope ; inline + +: 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 ; +: traceback-button. ( failure -- ) + "[" write [ "Traceback" ] dip continuation>> write-object "]" print ; -: failure. ( triple -- ) - dup second . - dup first print-error - "Traceback" swap third write-object ; +PRIVATE> -: test-failures. ( assoc -- ) +TEST: unit-test +TEST: must-infer-as +TEST: must-infer +TEST: must-fail-with +TEST: must-fail + +M: test-failure summary + [ experiment>> experiment. ] with-string-writer ; + +M: test-failure error. ( error -- ) + [ call-next-method ] + [ traceback-button. ] + bi ; + +: results. ( failed passed -- ) [ - nl [ - "==== ALL TESTS PASSED" print - ] [ - "==== FAILING TESTS:" print - [ - swap vocab-heading. - [ failure. nl ] each - ] assoc-each - ] if-empty - ] [ - "==== NOTHING TO TEST" print - ] if* ; + [ length # " tests failed, " % ] + [ length # " tests passed." % ] + bi* + ] "" make print nl + ] [ drop errors. ] 2bi ; -: run-tests ( prefix -- failures ) - child-vocabs [ f ] [ - [ dup run-test ] { } map>assoc - [ second empty? not ] filter - ] if-empty ; +: run-tests ( prefix -- failed passed ) + [ child-vocabs [ run-vocab-tests ] each ] collect-results ; : test ( prefix -- ) - run-tests test-failures. ; + run-tests results. ; -: run-all-tests ( -- failures ) +: run-all-tests ( -- failed passed ) "" run-tests ; : test-all ( -- ) - run-all-tests test-failures. ; + run-all-tests results. ; From af8f98495deaa097e57b8976422c70002cdebecf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 9 Apr 2009 08:11:38 -0500 Subject: [PATCH 08/19] Latest icons from Joe --- .../error-list/icons/compiler-error.tiff | Bin 1298 -> 1110 bytes .../error-list/icons/compiler-warning.tiff | Bin 1194 -> 1036 bytes .../error-list/icons/help-lint-error.tiff | Bin 1060 -> 944 bytes .../tools/error-list/icons/linkage-error.tiff | Bin 0 -> 1054 bytes basis/ui/tools/error-list/icons/note.tiff | Bin 784 -> 628 bytes .../tools/error-list/icons/syntax-error.tiff | Bin 1260 -> 1054 bytes .../error-list/icons/unit-test-error.tiff | Bin 1258 -> 1040 bytes 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 basis/ui/tools/error-list/icons/linkage-error.tiff diff --git a/basis/ui/tools/error-list/icons/compiler-error.tiff b/basis/ui/tools/error-list/icons/compiler-error.tiff index 1d6b1575ee480a2672e42742026ad473cd40343d..7a53d578fa5b5723e153da87da009d51126bd7ce 100644 GIT binary patch delta 884 zcmV-)1B?8U3f2gJNl7XI`T_s|fIr|s2qYE_2ZTalKmcGE21W=1KuL%*!S4PvJs(fi z)Gj?Agg~G22_z^N4kd{KKxF#(z8?y~h)Nd=t+?)e7+$fptd@NRkx%53a2%#qpJ5n8 z0Z@1x1qXP(U%&zKeZe-IPN$S8{RX)RqEV%knq4-ZAgI)T>a}^i=63y_*WlIa{f1Rz zrBf-_AO)tWR;*jAb^D~2?MJd+toO)8`qzQ2TqpQgULNsFTQ=Tc2FtPad!A5f zmM3cpjmXA-NtW;ds_T5g;lL0BP}Cy;31wghl}G@TWjlZfRvWMZsDd_4qEG=DMw+#b zispg3t)ljj6(*_V01M@L$^aiH>PCeQA;2a85yChw038RR_y7;)0oDKyA>b$g0E;*{ z2LP+<+{eHv;1<*f!5UUlI?y^kaGodF02LCZ>ulVAC`BNo4S)g|LIr>X1VjK60$?(d zImcPLoC|>190D80h|m#)Aea&Xs6@${cYp&yXx=VDfKUd211MzDmPX4rD9UO1+Iyd% z0A5TRru?-oOVb3!GAHC&jCOznv37K?f)thj2Y~Pt00SUk2{g2d6!$*Q^bBSJMzOqd z#iPc5F~)lU0ogooFN5%Yn2;g@V!2APx%4h5Fe=L(Bf}wNa{vVCo_HjIU@YPp10X^G zRB9Bf7_JVYP`kEu{ZNCPhm?IkyQg&cgS?0#R4Rjj0H_rK)|6h=x(pf!*dVp@6aXFv z#QGkp&neXKqyR_=@)v^eJ^%+m?Jk8{cZ(!{gx-qQBn0TCqBwPplGJ{mvO; zq}ged>V*>5ZL7{M6}z-{>xF{eES78Krw{N@=vQwc%Z!uI*v zgX#MJ03Vls?yv$ajO+kEyA)8DBmkKv20#TtP&-|0*l6;yPK=sSW6o;v(bW4v-~bFo ziOiCLsE`0=48afp69Ql|7Mm@H3E+L8;J6mFhvf;t*uHEs28B9r(uyY(=NJH4n@5^H zPl@2r05Apsf)+9sP#MN~Errp#dLZQJofio~DrES7xy>p=53w)0^2RgDA!2OBLh)X5 zfCrKCeFh-d%;K3Me z00&9xwlU*4W(a@*&^iSG1hJNPR`k6xxyMo9r&F9Z9gAbxHd^eSy8u}XYyb|m5WIP}FbQx*HR8nU-@N?70dd0>A+D9)gYo zAzq%9{ewNpOk1gmB&5-rcYp&qXmhT>T;>28V^Bvh+-yZQ`73NZ`6j3$ky8^D=EPKz zQWHR%7Ysp+WXI?7D`x2Ebs|42O95FeLY#+`D31#vWoT0hb%v>uXcNi|`pGIrRS_Y7 zN87{z2}LQy02hYw>Y|ZCC@ugFq0lCx>a)XUg>DE&vb50x;aw^e#+l-~O~@fbSAYWT zX7{iZ=G_lo>kd-c}PFH%ljD{;O6|FDiia# z4N6{^rfIK5#r@JhOZ=gTZ~{aKkrW`LSd0;(IR6Oo0TciL0RsR50000W000010RsR5 z0000W000020RsR8000221d|>EE&{X!lTHIJB|rcG02cuS009610ImZ702%=W00961 r0LTOY02=`X009610ML`610w<0lf?r_3&Qny0000$fWq~7lNba(KbNuX diff --git a/basis/ui/tools/error-list/icons/compiler-warning.tiff b/basis/ui/tools/error-list/icons/compiler-warning.tiff index b50afa45f963269d4343eac280be291b90c33f2d..405cfd4761c00b17a9be353006e56125a91d639c 100644 GIT binary patch delta 809 zcmV+^1J?Yi35*DTNl7XIt^xo6fIr|s2qYE_2ZTalKmcGc0!9b~011dQ!QcQiJsyws z)Gj?Agg~G22_z^M3jmVDf4mM7^{%5;*UQmRdV=QFwN{<{XQS8Mc(6)Y=F zx4|sn3Y}KhShrTLGFzR7$9J;cVK=+&s;_OJ;Nf^$P1$U=f;L+?plCJ-X*9tBK&#b8 z`Dv?LD>b+rno(fN*&vT+v=GW=f+>{JQCO}BvROd{LMZk#QGduna#>5R$`<;4K?Xx8 zBUP&i0|B6ajYgypN+p6ko=`-hQV4}Y!2qCK&TIfiBVV!lxFrvnhrCG@DwrXBzJebo z$~-uZC?On2AcsNFf)C^R2t1D{AP52=fZ#aNtq+q_TBPrIMiGDoBk;td=Ly1s1wm70 z+NgygNP-Ar8VEoT2q7?vEX^|-ZkwP0xDA6~0la8`njio|34&_TGEAU@K+wes0)uSa z01gCg94IGg+JXh)cmQw65)_FeNea;xMWBPQ?8PRCAb1`ifXFi@$?7DvE=$JzIwM2z z3`UZe#xe*Uhip*%KOlq&0>wDVw0R#s&3frSq=O*Hf)k|bN)`o(A&_Jskm`v>vC!L> zNifTQv+{);ha~WV9mjGI0DveVR8=5?ps1}>jY|NyHKxI$Y5-ifMbC81pa9x7+|a{M4Oi`AMxfYk za}=lA*Q1h>+iC^!#8H>+OM0+Y3l)LYX#ILu;QUU-J000340096102lxO009950096102lxO z00IF600aO40Hgzxa04y^tOJvv11=_20000N0R#X60001`0ssIS0R;d70002O0{{RU n0R;d70002W1C#UvA_CF_lNba^3vfMJ0000$fN(uplWYV&J2p3u delta 977 zcmeC-SjAcI>8Zuw!_2_YVE@2@Lq&|2y~QapU`GI(OadD-0|$rk#h1d3_E!W>JSnr~ z=sEr*$ihHDfYG+K=>YSgLJNjYN1rwa=8IQeF(}FNxBn9JwD0%G5V5eC6{t1MXl5|O zfh2(!C5~)|GuPZJww`xU+ks0o&)sdxsq-SMQmt$QR)*HAUGBW{sWxt6c%Hy+R;A>8HQht8Z_(kfU2I=(#6uQ^A_jRcmwCJovPQ zXYak!vnM{!|0&Cx?Jj@m(cHch%7H6aG#y^h;-n&=CcOMg{?0dSUXAN_dA_miwP5`6 zt4Y59f=iSh$G`fprg}#WrBq`UEm7rPYucJw9UG6ASRBG_Ji?){OtXQVSKaG^$x)LX^6if}SQ|5x=bi0R>f*?n zwL-y$UtywbZ;GC124na&4V||({{BhN_A{_WPCGkcb;TE3bD{2*O&DFVyj45O007#Z}Nl;g!|;N|vCx2JORX)WcSmn_9?&B|IAD%_gE)Rc9?Wl~dwh5`$tg`wN@ zIV!V?6H5%uwjSzxSe4YdS!Jf#^}?L`pm`_O=W)qBIrw(>ZrAo0>pM@E=AF$wyk|p= zkodk2w`c7$=1S=g%;GehCRz2nC|_bgYuv{0jfsYA(Q5m&b| zhmiRd#SRW&U^6l^FfuSOC;%}d5}OIgW&w&h0SRV^_~hG6s!U!ilbM+H)Et0P;*2a{ vtuDYUDaFVNW+woZOGDWiER(~Sm6!@xCRZ_gav%Cy0o3Er0Hi0MW3~eT>P&4J diff --git a/basis/ui/tools/error-list/icons/help-lint-error.tiff b/basis/ui/tools/error-list/icons/help-lint-error.tiff index 86dcc0afc29d9bea9d5381bf41d0a62ba0ba62d4..464728a70c23770da723e85115f8d06da3bde05d 100644 GIT binary patch delta 718 zcmZ3&v4Oqb(^HEfh>3xr!Tx~*hl&_4dy7+|14DuVlN$#M180Zv!3PW`wsQSnujtvz zw>ZrI#Hpeo#?3J4NRtCoZOuLg)`TNU0*u%0#eeQw>4=bX4Z+&3M-S(jCYEH#8?~M)gob{x3 zz-;MdFBtTg6K*i%OR04*2s9%$6${G*03 z(c;GpXD{d2rxV0+deJ4GHU^JPHvBAG3X*l%RW>eJtm)OU>&)Yg8+H7?nsG0YHaPil z%@PKm4Z>1a4ft|y9rk|l;emxhOQ*8sf`%VydMq@Vz0gVdYdy<{r;D#D*#;YmI`M{D`a5}sYiz!q8nNDVsm%84 zT)YY2u9~E99PlgSdKzo_^=W!?h?#3@s-a);rXm-dH+`FqFaE!4=8>sXYrO0Q>e z#@hoe3JMG&3=E9S42%p63=%-hh{R?BvRQy)9?T33%#6&F-!o}4227S@)>jP$ii$I` ufOUBSQ=}9lE0~=IR4EN*=S|LKR%R@lJdxRpyTCRIsKcQFNKbyoYzF`W{|Zq6 delta 846 zcmdnMzJ#OR(^HG#7!w0SgZ%>s4izz8_7+NB7heiD+Fubk@ubX_ zqv!aOAPWNp0Y=-_rUT4}3N08q9evsym@i&=#h@h5-~LO?)4ty$L&U;nR-o22qnW`B z2a*I{lsK{-&Rlb^*m~YYZ3iyVJa@M#r_PJ4O0}{LSQ%QccDeJ)r`ouQ;duhPS(T1^ zvjt~|HL&`v&RG-vu3+^vKF-pOk@{virl0<1ufDzELXK{=py!^rO$BR8SFO!m^Wf7K zp1t=@&z|@^|EDZ(w!8eLN1FrEv$t^^PCR~;sYC7E_rQJ6H%Mx+?R%-d;hD*YO^!+& zJ7bQYfBr+^N;V67^Mm^4gHQg4PPmY;!ocF)apRso9yS5DZug~E81fs~f^`J*w!i(J zGWX9vHmk=r=c3%c+V&UOyxhL_0fSDrhLX~6dj{qm?=5($e?3y+SK?;an01AN!FGL( zP?KYaiyVX9`!gC_w&rtdG#>7qwVnTn#)m%T1uY+Kn)sBvIBMo=I7qS8FKFphYGQJj z687Ne`cE7N%nM#Hcy9A|dM@Q~QsRc0LbJn#CWZtlNtFd%P95*(q)RZE9emCh71qG; zqet14LuaGaLgtElO+qY9&tkboJnB*9bOkT>Quj&945NBio8?XIqsc#+lo?-5mSy(h SKJ>K$sKcQFNKYqP%2lL};(h0RZtaA6FnkYQ!7 z*cX3*@l)+VvpIgtr)d0T+sUygaOsp;v1aoXR$O_twQ|q1vcL1LKe+npZ(C^c(qPT& z3arakhOLQSUHW^;w72e?;?{gW;ri=(?R5<%s;eKO+28%LFW~9d>{bb9G zpX~2uFzB+bzvNIppZ!f(*qj9nCnTB}7#%X^DKP93xA)7AYnIMDz)&i;q0mmf*@1Z> zuk^|TJ9rxpDDKJVWt4E@Y}CEPqd3K#gTb>?;Q)gu(}qP3*5c_N3_?x$TXx))aOZr( zAjITyW`fk)00x`s?EwrC++~H$9puu3l&M--= zUL}EHPVgKDhRtFPtez|0PQH}Dz{ME!sYXiJ?E^y^&p{!6m%xz3{d|W%a_|anIeqi8 zN&}Ondr+Ih=|3zCy%SfInkF{?`oEx2Ks8i6JQd#Aj;3cuK1+3fvGaEsNLc93Tfs94+fT77Ih5F4Y?DS zm6|@aT=sUtBLy7>wuWmm$2Xt--7-b*t?rY3AqtE=h3B3Ho@SoU{>Z(`YTXV7F{bk$ z8U(Bw{1_*hpONCYsIa|Tvy#EfPBji5(1P18rgv1DXeP2?TmT3}=ARK%2l20J61YjQ{`u literal 0 HcmV?d00001 diff --git a/basis/ui/tools/error-list/icons/note.tiff b/basis/ui/tools/error-list/icons/note.tiff index 01c328f09ed1292af787a28dc3639182ad2c8c0a..834dea6b8248f748c21f53cf27fccecbbf4d4eca 100644 GIT binary patch delta 402 zcmbQh_JyV1(^HElRBC&Ff`XMpZ;D+=9Bvjlf56H_hUtHG1Ea`|$qyJf8SD?3MwrHJj_%%9e}MA?tHE-C^$|K@9=fx( zN(C_RC@@$sK4V}ytY;=IBbCOmJ4)%~0>(KE_6!DkqJLB`*+=X?cB_HWfq`@K&cuWr zHNHj4%{w11l!{orfuWzlgn?V;TeJ46)oF$SUo9B!FkE-I$G}i`J9zQccMJRPWH7#B z$Z3##z-aEYd&=YEmGx#7%`Oc344e+U2N+i{Onv>L=z?vE<243uN6`aJ{mb)D-1)Ag zZNO+P@PL6~@|!mca+Rla^gA%}z2By>IpCtT|7oKR_5{Wr2HppZitN?`EnII8WkhXy zwASSS12Y5Xhg*-GPxCn3UFddzL1aPaO}6_CoL2Jedvjd)+Ty rR4B#B3T7W;VqlPlvd>Mv$f(SCZSq$}GwwrQD}Xv28i4d(^HG#2onQCgZ%>s4izz8_79@X=KBfPU)LMg#;E^@h?D#1oo{{LftB0w0RubZ zfdm#owq%81lY0tmo7a9~Fz;hZ;3#1GpR?xnJHt0iq;);^+-%^Qw)zA^YNTZYJMXl~ zzACZX=Ph7nI(Uk~;T@hXj)#7*~BSI4Q7*^jz{jA!`*O0hDrKZ#|6O_g&9H@mw%MLDO7*3>!(Mi zX>wvtaRZyg5rGEA3?1er?V0cD8W<}L@@9YBQYh;_@k_&ekAM)Lozm>dak7(-Gcd$- zH+*1_Vs`LZt$o_)=6+u1311wJF21bOv5)8Jk{Px0S4!HbHwQNVI({tu!j1(8vUQwV z0s^9bvO6)zsQgtd>^^YUrqk)&gP<$*%x#Yj3dx%6=rE;}=@cyw`FJe;63NpiX62L^7|#1jlWjT01E*b^50cHjN=vP#SK)vP{8^wnlw zPM_Fjc#DC_@CSqc#ZE`2{k?1QD(9rNiz1xqAM?p5@xE+ zWZggA!Qxy&tKy0(rOrhwb{X|9-g!%?p@Bh!fq{{kfsuiMK>~;wk=RT?HVaT}7c&C` zGgO=v$Y%qxC!b)JVLHS-`5CjGS}0IVoRI}=#%^GikYZ#7v#$X4NkiFpm?vAYC^0=@ Xo*c*G%3WX^1=Qov0Hi0cW3dAOHh)gX delta 1039 zcmV+q1n~Qw2QBn0TCqBwPplGJ{mvO; zq}ged>V*>5ZL7{M6}z-{>xF{eES78Krw{gTEDV0Yd!%x&T9ZOTP^;F{4 zfC4#4aR3GMO5Tp~NE(SKwgrV^Sja5@K+tad7_QmXV-Q&zE?}Ni9AE)dDuaLksucms zEYD5Tvs@6o(3d=_@y7Fo)WXhk^uaMt6Dmi4J-aFNrGK$^HU{!a^<1>XVKc15JIsxA zTI@h=oMnnZQldR{<9I~7k71b$K}^q(A`b&GIYU*ILAWL}XR!l8XmfxB$(nb72N>cK zfB@he0>z93(LSMh!Vxx5v9X+U)&U41s1-M$02hMbLP|Urhfo1QoxlJp1vv)*;ie#e z*oI1yYR>L;fPe$Jc}SZlVf2HMLMSf^Ldhu9TIh!{=C%!Cup|Hop%519WO97cpl>Ml zv4L6{pEIfE$|pLJ^ZgF%nqn=Q=hLViOCP&R4R2tg_DT_dP06>7k J^>~xu13pb}r>+11 diff --git a/basis/ui/tools/error-list/icons/unit-test-error.tiff b/basis/ui/tools/error-list/icons/unit-test-error.tiff index 4f46ffa5789229d1128e4bcf44680d929f61a599..b6ea439f5ae218a19715691ccb679e3e5ef9ffdd 100644 GIT binary patch delta 813 zcmaFGIf0|z(^HFK6B7eNgZ%>s4izz8_7y2rv5VIRLP`;L92Z0pBwLd^KUoXy725T-J&|$ zzS|G#Jm8uec0FQy*gB)=xoyYGH{DA#-~D#g`rHK%9#%y8-ul2$X|tfO+(vNU{U#w! z0r%il92YYVYBDf#w9OCP7nODG)Y&|CwJ8xsn*{>2I8u!cO7e6lZn(+P>&VaEp`5yz zB~oWWck8jqJ`4dG3iZu~b6+R+-h7}Ksk8LjNtTE;30C2t(rt#gE*KNdO`%6ggF*4L{7{2EOAr+b(S9k$3Y1< z29XKcLM`);f8sFjeWCoSiLZGPhi-R<0vFRlUMCJ0K@P<&xeBdzX(0IyAYv~VvoCS}p+2Ze}(9ogO zWUZkvPyI57&4kjEK`Cr^)=jK8b&_uTEOLT@o$;u1;2!PllOYCIHjCKtcPK=NDKs6} za5QYf8zu%L4-?K5s23PlS)g@y+f zU-vFxv15qX_Q)}R@pW#2wXPb9Qf>>HSG;;}f2KGy?_Tb%r!nT`yFOPu$gX`6y(sR2 zk$sy@@H@Hfk4*MH%(efK>ztBs;}_Sbr7yeEW<7{l=gOF38O77K@I{we*P<7v%=(_5 zuwoKnU|?isU}RumkN{#vBsLR}%>oo#!8~~bvmVn1=E)D3_0&RvBI1lJU>&P~$z6(( p70f=y%)lTGWuIf7Y{H_%bd7m(1dAtkfo&8}k3$2Hp1g*|4gl2!F;oBm delta 1033 zcmV+k1or!o2jK}0sI4~d(0X>C+zyrc@H~@)3Ool)M(bVbyA|DTj`W8t)k4R_~I6RtBDwZ;t zQvkqX5a@J42E%Er-g7&i(JMd-6>djHl*-Q(s%1JoP^ndaCew-3@_k;BS8foy1tP~w z22*QRfCWygY^+=EaI2OM33ahqFE(s7^8IV8+py4VEqf73yk4?!taYlbZLHw(v<$u8 z%bStsZ}}Y!Yeyf_;a~I>7^>*g?GC1Ua1Gf#CFiRglnNq?-Grp2L{afFEzT zB1IzvR;yrtnWnQ^2#7>M3MCjo91jF77NCsAWDt-@f*y}hK!`@4QNHJ}87qtqI@q%; zVhSM$NFly&po5_3f(OC!2wE11Ad)1Yfq-Cy4Ff_5HH~N?plBe3(KLb^hT;fs8^|CM z1itG_R^+3uWB}-(#-XVS!r%eKaUg)uG}Iuc@%(~+1K|1yLy+hoxGo`%J3hd$kMau{ zv1nvUf(0Q=NfQ7PEP#R^N7RWU00dzef(v5XjQlb3d-#GRGNWdZ3WA~tVwk8Q3b%`* z>IedWs?ls)AcMH>f*&W!2x*#VBg~)4&)ZrsH(&uK*+5DA{ShF983uwO&I5!14I@n) z^PuH_K~W>gAOXN|AdRcy`G65x=Hr}a7yve+HFL8rh{80!08A($NKzn#5d?w-1UP~M0ELEw7e&$tDT-hL!(N;f_&;FV=uKXN2I0C0Cke0yY3VcurXuAhDJ@#NiV7h$0|@IF8%5GX8fc zAueJ|pSlvOCOZzuA*5*_g~4#m>2rD)ry)6l=L6mskN_qLh#>erAcZkZf(?UZxo;tV zdh1%C%1QpjxEdyk2tJRfAPfUL4$uH{oU!bFgYM2!N3b>;gH5S0)l58Tf+UI{sIoADX8zI;fPerL0003400961 z03ZMW009950096103ZMW00IF600aO40D=UQ)&ed9iUgAe11=^&0000N0R#X60001k z0{{RT0R;d70001>1ONaV0R;d70001}1e00=A_A}klYRq93&Qny0000$fWq~7lhOk| D-wvLu From e467f4eea3f389ea6fbe996184e064bc601013be Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 9 Apr 2009 08:17:41 -0500 Subject: [PATCH 09/19] More work on unit test tool --- basis/tools/errors/errors.factor | 2 +- basis/tools/test/test-docs.factor | 14 +++++------ basis/tools/test/test.factor | 5 ++-- .../compiler-errors/compiler-errors.factor | 25 ++++++++----------- core/source-files/errors/errors.factor | 6 ++--- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/basis/tools/errors/errors.factor b/basis/tools/errors/errors.factor index a11b60d833..85a29986a6 100644 --- a/basis/tools/errors/errors.factor +++ b/basis/tools/errors/errors.factor @@ -16,7 +16,7 @@ IN: tools.errors ] assoc-each ; : compiler-errors. ( type -- ) - errors-of-type errors. ; + errors-of-type values errors. ; : :errors ( -- ) +error+ compiler-errors. ; diff --git a/basis/tools/test/test-docs.factor b/basis/tools/test/test-docs.factor index 3cabff457f..7889897c92 100644 --- a/basis/tools/test/test-docs.factor +++ b/basis/tools/test/test-docs.factor @@ -3,13 +3,13 @@ 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 } ; ARTICLE: "tools.test.run" "Running unit tests" "The following words run test harness files; any test failures are collected and printed at the end:" @@ -29,7 +29,7 @@ $nl { $subsection run-tests } { $subsection run-all-tests } "The following word prints failures:" -{ $subsection test-failures. } ; +{ $subsection results. } ; 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." @@ -89,6 +89,6 @@ 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. +HELP: results. { $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 } "." } ; diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index e45f76d7df..cce3279732 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -45,7 +45,8 @@ SYMBOL: failed-tests word/quot dup word? [ '[ _ execute ] ] when :> quot [ quot infer drop f f ] [ t ] recover ; inline -SINGLETON: did-not-fail +TUPLE: did-not-fail ; +CONSTANT: did-not-fail T{ did-not-fail } M: did-not-fail summary drop "Did not fail" ; @@ -130,7 +131,7 @@ M: test-failure error. ( error -- ) [ length # " tests failed, " % ] [ length # " tests passed." % ] bi* - ] "" make print nl + ] "" make nl print nl ] [ drop errors. ] 2bi ; : run-tests ( prefix -- failed passed ) diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/compiler-errors/compiler-errors.factor index 45eb3dee5b..44c17a00f4 100644 --- a/basis/ui/tools/compiler-errors/compiler-errors.factor +++ b/basis/ui/tools/compiler-errors/compiler-errors.factor @@ -3,13 +3,13 @@ USING: accessors arrays sequences sorting assocs colors.constants combinators combinators.smart combinators.short-circuit editors compiler.errors compiler.units fonts kernel io.pathnames -stack-checker.errors math.parser math.order models models.arrow -models.search 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.images ; +stack-checker.errors source-files.errors math.parser math.order models +models.arrow models.search 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.images ; IN: ui.tools.compiler-errors TUPLE: error-list-gadget < tool source-file error source-file-table error-table error-display ; @@ -30,7 +30,7 @@ M: source-file-renderer column-alignment drop { 0 1 } ; M: source-file-renderer filled-column drop 0 ; : ( model -- model' ) - [ group-by-source-file >alist sort-keys f prefix ] ; + [ values group-by-source-file >alist sort-keys f prefix ] ; :: ( error-list -- table ) error-list model>> @@ -53,16 +53,13 @@ GENERIC: error-icon ( error -- icon ) : ( name -- image-name ) "vocab:ui/tools/error-list/icons/" ".tiff" surround ; -M: inference-error error-icon - type>> { +M: compiler-error error-icon + compiler-error-type { { +error+ [ "compiler-error" ] } { +warning+ [ "compiler-warning" ] } + { +linkage+ [ "linkage-error" ] } } case ; -M: object error-icon drop "HAI" ; - -M: compiler-error error-icon error>> error-icon ; - M: error-renderer row-columns drop [ { diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index 9972a68446..ca7c403609 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -1,12 +1,12 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs kernel math.order sorting ; +USING: accessors assocs kernel math.order sorting sequences ; IN: source-files.errors TUPLE: source-file-error error file line# ; -: sort-errors ( assoc -- alist ) +: sort-errors ( errors -- alerrors'ist ) [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ; : group-by-source-file ( errors -- assoc ) - H{ } clone [ [ push-at ] curry [ nip dup file>> ] prepose assoc-each ] keep ; + H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ; From 0a7485190bb88a87f6138efe4e63b065f0b47c95 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 03:52:12 -0500 Subject: [PATCH 10/19] compile-error-type => source-error-type; make test failures global --- basis/bootstrap/stage2.factor | 1 - basis/compiler/codegen/codegen.factor | 7 +-- basis/compiler/compiler.factor | 4 +- basis/debugger/debugger.factor | 2 +- basis/editors/editors.factor | 6 +- basis/stack-checker/errors/errors.factor | 9 +-- basis/tools/errors/errors-docs.factor | 40 +++++++++++++ basis/tools/errors/errors.factor | 6 +- basis/tools/test/test-docs.factor | 36 +++--------- basis/tools/test/test.factor | 58 +++++++------------ .../compiler-errors/compiler-errors.factor | 40 ++++++------- basis/ui/tools/debugger/debugger.factor | 2 +- core/compiler/errors/errors-docs.factor | 44 -------------- core/compiler/errors/errors.factor | 20 +++---- core/source-files/errors/errors.factor | 4 +- 15 files changed, 117 insertions(+), 162 deletions(-) create mode 100644 basis/tools/errors/errors-docs.factor diff --git a/basis/bootstrap/stage2.factor b/basis/bootstrap/stage2.factor index 12741f2170..fd21c9646c 100644 --- a/basis/bootstrap/stage2.factor +++ b/basis/bootstrap/stage2.factor @@ -88,7 +88,6 @@ SYMBOL: bootstrap-time run-bootstrap-init ] with-compiler-errors - :errors f error set-global f error-continuation set-global diff --git a/basis/compiler/codegen/codegen.factor b/basis/compiler/codegen/codegen.factor index 65e70bd042..cf1d81fbc2 100755 --- a/basis/compiler/codegen/codegen.factor +++ b/basis/compiler/codegen/codegen.factor @@ -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 source-file-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 source-file-error-type drop +linkage-error+ ; : no-such-symbol ( name -- ) \ no-such-symbol boa diff --git a/basis/compiler/compiler.factor b/basis/compiler/compiler.factor index 04c1a9c55f..2492b6cc23 100644 --- a/basis/compiler/compiler.factor +++ b/basis/compiler/compiler.factor @@ -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 @@ -54,7 +54,7 @@ SYMBOLS: +optimized+ +unoptimized+ ; : ignore-error? ( word error -- ? ) [ [ inline? ] [ macro? ] bi or ] - [ compiler-error-type +warning+ eq? ] bi* and ; + [ source-file-error-type +compiler-warning+ eq? ] bi* and ; : fail ( word error -- * ) [ 2dup ignore-error? [ 2drop ] [ swap compiler-error ] if ] diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 202cf7eb5e..c088b86c31 100644 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -321,7 +321,7 @@ M: source-file-error error. ] bi format nl ] [ error>> error. ] bi ; -M: compiler-error summary word>> synopsis ; +M: compiler-error summary asset>> summary ; M: bad-effect summary drop "Bad stack effect declaration" ; diff --git a/basis/editors/editors.factor b/basis/editors/editors.factor index 327cdea3c1..b494b52c68 100644 --- a/basis/editors/editors.factor +++ b/basis/editors/editors.factor @@ -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 diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index 07c26ad100..a4d22f8a5b 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -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 source-file-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 ; diff --git a/basis/tools/errors/errors-docs.factor b/basis/tools/errors/errors-docs.factor new file mode 100644 index 0000000000..b66b557a81 --- /dev/null +++ b/basis/tools/errors/errors-docs.factor @@ -0,0 +1,40 @@ +IN: tools.errors +USING: compiler.errors tools.errors help.markup help.syntax vocabs.loader +words quotations io ; + +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-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: 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." } ; + +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 diff --git a/basis/tools/errors/errors.factor b/basis/tools/errors/errors.factor index 85a29986a6..4b717a8bdd 100644 --- a/basis/tools/errors/errors.factor +++ b/basis/tools/errors/errors.factor @@ -18,8 +18,8 @@ IN: tools.errors : compiler-errors. ( type -- ) errors-of-type values errors. ; -: :errors ( -- ) +error+ compiler-errors. ; +: :errors ( -- ) +compiler-error+ compiler-errors. ; -: :warnings ( -- ) +warning+ compiler-errors. ; +: :warnings ( -- ) +compiler-warning+ compiler-errors. ; -: :linkage ( -- ) +linkage+ compiler-errors. ; +: :linkage ( -- ) +linkage-error+ compiler-errors. ; diff --git a/basis/tools/test/test-docs.factor b/basis/tools/test/test-docs.factor index 7889897c92..06a54f0868 100644 --- a/basis/tools/test/test-docs.factor +++ b/basis/tools/test/test-docs.factor @@ -14,22 +14,12 @@ ARTICLE: "tools.test.write" "Writing unit tests" 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 results. } ; +{ $subsection :failures } +"Unit test failurs 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,8 +35,7 @@ $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" @@ -78,17 +67,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: results. -{ $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: :failures +{ $description "Prints all pending unit test failures." } ; diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index cce3279732..01b6bdbf69 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -5,13 +5,18 @@ 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 ; +tools.vocabs tools.errors source-files.errors io.streams.string make +compiler.errors ; IN: tools.test -TUPLE: test-failure < source-file-error experiment continuation ; +TUPLE: test-failure < source-file-error continuation ; -SYMBOL: passed-tests -SYMBOL: failed-tests +SYMBOL: +test-failure+ + +M: test-failure source-file-error-type drop +test-failure+ ; + +SYMBOL: test-failures +test-failures [ V{ } clone ] initialize >line# swap >>file - swap >>experiment + swap >>asset swap >>error error-continuation get >>continuation ; : failure ( error experiment file line# -- ) "--> test failed!" print - failed-tests get push ; - -: success ( experiment -- ) passed-tests get push ; + test-failures get push ; : file-failure ( error file -- ) [ f ] [ f ] bi* failure ; @@ -71,7 +74,7 @@ MACRO: ( word -- ) :: experiment ( word: ( -- error ? ) file line# -- ) word :> e e experiment. - word execute [ e file line# failure ] [ drop e success ] if ; inline + word execute [ e file line# failure ] [ drop ] if ; inline : parse-test ( accum word -- accum ) literalize parsed @@ -90,16 +93,8 @@ SYNTAX: TEST: >> : run-test-file ( path -- ) - [ run-file ] [ swap file-failure ] recover ; - -: collect-results ( quot -- failed passed ) - [ - V{ } clone failed-tests set - V{ } clone passed-tests set - call - failed-tests get - passed-tests get - ] with-scope ; inline + [ [ test-failures get ] dip '[ file>> _ = not ] filter-here ] + [ [ run-file ] [ swap file-failure ] recover ] bi ; : run-vocab-tests ( vocab -- ) dup vocab source-loaded?>> [ @@ -118,30 +113,19 @@ TEST: must-fail-with TEST: must-fail M: test-failure summary - [ experiment>> experiment. ] with-string-writer ; + [ asset>> experiment. ] with-string-writer ; M: test-failure error. ( error -- ) [ call-next-method ] [ traceback-button. ] bi ; -: results. ( failed passed -- ) - [ - [ - [ length # " tests failed, " % ] - [ length # " tests passed." % ] - bi* - ] "" make nl print nl - ] [ drop errors. ] 2bi ; - -: run-tests ( prefix -- failed passed ) - [ child-vocabs [ run-vocab-tests ] each ] collect-results ; +: :failures ( -- ) test-failures get errors. ; : test ( prefix -- ) - run-tests results. ; + [ child-vocabs [ run-vocab-tests ] each ] with-compiler-errors + test-failures get [ + ":failures - show " write length pprint " failing tests." print + ] unless-empty ; -: run-all-tests ( -- failed passed ) - "" run-tests ; - -: test-all ( -- ) - run-all-tests results. ; +: test-all ( -- ) "" test ; diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/compiler-errors/compiler-errors.factor index 44c17a00f4..91fad98633 100644 --- a/basis/ui/tools/compiler-errors/compiler-errors.factor +++ b/basis/ui/tools/compiler-errors/compiler-errors.factor @@ -2,14 +2,14 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays sequences sorting assocs colors.constants combinators combinators.smart combinators.short-circuit editors -compiler.errors compiler.units fonts kernel io.pathnames +compiler.errors compiler.units fonts kernel io.pathnames prettyprint stack-checker.errors source-files.errors math.parser math.order models models.arrow models.search 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.images ; +ui.gadgets.buttons ui.gadgets.borders ui.images tools.test ; IN: ui.tools.compiler-errors TUPLE: error-list-gadget < tool source-file error source-file-table error-table error-display ; @@ -17,7 +17,7 @@ TUPLE: error-list-gadget < tool source-file error source-file-table error-table SINGLETON: source-file-renderer M: source-file-renderer row-columns - drop [ first2 length number>string 2array ] [ { "All" "" } ] if* ; + drop first2 length number>string 2array ; M: source-file-renderer row-value drop dup [ first ] when ; @@ -30,7 +30,7 @@ M: source-file-renderer column-alignment drop { 0 1 } ; M: source-file-renderer filled-column drop 0 ; : ( model -- model' ) - [ values group-by-source-file >alist sort-keys f prefix ] ; + [ group-by-source-file >alist sort-keys ] ; :: ( error-list -- table ) error-list model>> @@ -48,36 +48,33 @@ M: source-file-renderer filled-column drop 0 ; SINGLETON: error-renderer -GENERIC: error-icon ( error -- icon ) - -: ( name -- image-name ) +: error-icon ( type -- icon ) + { + { +compiler-error+ [ "compiler-error" ] } + { +compiler-warning+ [ "compiler-warning" ] } + { +linkage-error+ [ "linkage-error" ] } + { +test-failure+ [ "unit-test-error" ] } + } case "vocab:ui/tools/error-list/icons/" ".tiff" surround ; -M: compiler-error error-icon - compiler-error-type { - { +error+ [ "compiler-error" ] } - { +warning+ [ "compiler-warning" ] } - { +linkage+ [ "linkage-error" ] } - } case ; - M: error-renderer row-columns drop [ { - [ error-icon ] + [ source-file-error-type error-icon ] [ line#>> number>string ] - [ word>> name>> ] + [ asset>> unparse-short ] [ error>> summary ] } cleave ] output>array ; M: error-renderer prototype-row - drop [ "compiler-error" "" "" "" ] output>array ; + drop [ +compiler-error+ error-icon "" "" "" ] output>array ; M: error-renderer row-value drop ; M: error-renderer column-titles - drop { "" "Line" "Word" "Error" } ; + drop { "" "Line" "Asset" "Error" } ; M: error-renderer column-alignment drop { 0 1 0 0 } ; @@ -85,8 +82,8 @@ M: error-renderer column-alignment drop { 0 1 0 0 } ; [ [ [ file>> ] [ line#>> ] bi 2array ] compare ] sort ; : ( error-list -- model ) - [ model>> [ values ] ] [ source-file>> ] bi - [ swap { [ drop not ] [ [ string>> ] [ file>> ] bi* = ] } 2|| ] + [ model>> ] [ source-file>> ] bi + [ [ file>> ] [ string>> ] bi* = ] [ sort-errors ] ; :: ( error-list -- table ) @@ -161,7 +158,8 @@ SINGLETON: updater M: updater definitions-changed 2drop - compiler-errors get-global + compiler-errors get-global values + test-failures get-global append compiler-error-model get-global set-model ; diff --git a/basis/ui/tools/debugger/debugger.factor b/basis/ui/tools/debugger/debugger.factor index e1e176a8c4..42666ab064 100644 --- a/basis/ui/tools/debugger/debugger.factor +++ b/basis/ui/tools/debugger/debugger.factor @@ -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 ; diff --git a/core/compiler/errors/errors-docs.factor b/core/compiler/errors/errors-docs.factor index 8368afeb19..987db582b4 100644 --- a/core/compiler/errors/errors-docs.factor +++ b/core/compiler/errors/errors-docs.factor @@ -2,51 +2,7 @@ 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 index 9d8ab3deab..1f02aaf341 100644 --- a/core/compiler/errors/errors.factor +++ b/core/compiler/errors/errors.factor @@ -5,15 +5,11 @@ continuations math math.parser accessors definitions source-files.errors ; IN: compiler.errors -SYMBOLS: +error+ +warning+ +linkage+ ; +SYMBOLS: +compiler-error+ +compiler-warning+ +linkage-error+ ; -TUPLE: compiler-error < source-file-error word ; +TUPLE: compiler-error < source-file-error ; -GENERIC: compiler-error-type ( error -- ? ) - -M: object compiler-error-type drop +error+ ; - -M: compiler-error compiler-error-type error>> compiler-error-type ; +M: compiler-error source-file-error-type error>> source-file-error-type ; SYMBOL: compiler-errors @@ -23,7 +19,7 @@ SYMBOL: with-compiler-errors? : errors-of-type ( type -- assoc ) compiler-errors get-global - swap [ [ nip compiler-error-type ] dip eq? ] curry + swap [ [ nip source-file-error-type ] dip eq? ] curry assoc-filter ; : (compiler-report) ( what type word -- ) @@ -40,14 +36,14 @@ SYMBOL: with-compiler-errors? ] if ; : compiler-report ( -- ) - "semantic errors" +error+ "errors" (compiler-report) - "semantic warnings" +warning+ "warnings" (compiler-report) - "linkage errors" +linkage+ "linkage" (compiler-report) ; + "compiler errors" +compiler-error+ "errors" (compiler-report) + "compiler warnings" +compiler-warning+ "warnings" (compiler-report) + "linkage errors" +linkage-error+ "linkage" (compiler-report) ; : ( error word -- compiler-error ) \ compiler-error new swap - [ >>word ] + [ >>asset ] [ where [ first2 ] [ "" 0 ] if* [ >>file ] [ >>line# ] bi* ] bi swap >>error ; diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index ca7c403609..7f19d04f84 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -3,10 +3,12 @@ USING: accessors assocs kernel math.order sorting sequences ; IN: source-files.errors -TUPLE: source-file-error error file line# ; +TUPLE: source-file-error error asset file line# ; : sort-errors ( errors -- alerrors'ist ) [ [ [ line#>> ] compare ] sort ] { } assoc-map-as sort-keys ; : group-by-source-file ( errors -- assoc ) H{ } clone [ [ push-at ] curry [ dup file>> ] prepose each ] keep ; + +GENERIC: source-file-error-type ( error -- type ) From 4f41e07147f2ae26404e353f86b4c17cd1e53f00 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 04:41:12 -0500 Subject: [PATCH 11/19] ui.tools.compiler-errors => ui.tools.error-list --- basis/ui/tools/{compiler-errors => error-list}/authors.txt | 0 .../compiler-errors.factor => error-list/error-list.factor} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename basis/ui/tools/{compiler-errors => error-list}/authors.txt (100%) rename basis/ui/tools/{compiler-errors/compiler-errors.factor => error-list/error-list.factor} (98%) diff --git a/basis/ui/tools/compiler-errors/authors.txt b/basis/ui/tools/error-list/authors.txt similarity index 100% rename from basis/ui/tools/compiler-errors/authors.txt rename to basis/ui/tools/error-list/authors.txt diff --git a/basis/ui/tools/compiler-errors/compiler-errors.factor b/basis/ui/tools/error-list/error-list.factor similarity index 98% rename from basis/ui/tools/compiler-errors/compiler-errors.factor rename to basis/ui/tools/error-list/error-list.factor index 91fad98633..b1f3c725d4 100644 --- a/basis/ui/tools/compiler-errors/compiler-errors.factor +++ b/basis/ui/tools/error-list/error-list.factor @@ -10,7 +10,7 @@ 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.images tools.test ; -IN: ui.tools.compiler-errors +IN: ui.tools.error-list TUPLE: error-list-gadget < tool source-file error source-file-table error-table error-display ; From deae1d7bbb55818f039922308689b1413c364ca3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 04:41:26 -0500 Subject: [PATCH 12/19] Fix bootstrap --- basis/bootstrap/tools/tools.factor | 1 + basis/compiler/tree/builder/builder.factor | 4 +++- basis/editors/editors-docs.factor | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/basis/bootstrap/tools/tools.factor b/basis/bootstrap/tools/tools.factor index b0afe4a1d9..cb0792ee1e 100644 --- a/basis/bootstrap/tools/tools.factor +++ b/basis/bootstrap/tools/tools.factor @@ -6,6 +6,7 @@ IN: bootstrap.tools "bootstrap.image" "tools.annotations" "tools.crossref" + "tools.errors" "tools.deploy" "tools.disassembler" "tools.memory" diff --git a/basis/compiler/tree/builder/builder.factor b/basis/compiler/tree/builder/builder.factor index 4cb7650b1d..dc87d596aa 100644 --- a/basis/compiler/tree/builder/builder.factor +++ b/basis/compiler/tree/builder/builder.factor @@ -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 ) [ diff --git a/basis/editors/editors-docs.factor b/basis/editors/editors-docs.factor index e3961aef80..646582beb0 100644 --- a/basis/editors/editors-docs.factor +++ b/basis/editors/editors-docs.factor @@ -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" From 8290624733f6f4df5c0ca5d6e87c8b374e95c706 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 07:08:16 -0500 Subject: [PATCH 13/19] Macro expansion errors are now wrapped --- basis/stack-checker/errors/errors.factor | 5 +++++ .../errors/prettyprint/prettyprint.factor | 9 +++++++++ .../stack-checker/transforms/transforms-tests.factor | 11 +++++++++-- basis/stack-checker/transforms/transforms.factor | 7 ++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/basis/stack-checker/errors/errors.factor b/basis/stack-checker/errors/errors.factor index a4d22f8a5b..799e3f73e3 100644 --- a/basis/stack-checker/errors/errors.factor +++ b/basis/stack-checker/errors/errors.factor @@ -82,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 diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor index de73a3e731..d6cee8e08f 100644 --- a/basis/stack-checker/errors/prettyprint/prettyprint.factor +++ b/basis/stack-checker/errors/prettyprint/prettyprint.factor @@ -79,3 +79,12 @@ M: inconsistent-recursive-call-error summary M: unknown-primitive-error summary drop "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 diff --git a/basis/stack-checker/transforms/transforms-tests.factor b/basis/stack-checker/transforms/transforms-tests.factor index 0aa3876907..abb1f2abdb 100644 --- a/basis/stack-checker/transforms/transforms-tests.factor +++ b/basis/stack-checker/transforms/transforms-tests.factor @@ -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' ) >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 diff --git a/basis/stack-checker/transforms/transforms.factor b/basis/stack-checker/transforms/transforms.factor index c2b348f5f1..541d74bdeb 100755 --- a/basis/stack-checker/transforms/transforms.factor +++ b/basis/stack-checker/transforms/transforms.factor @@ -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 From a0ad6bda39a3d62900bf68036931bfd281ce0222 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 08:11:46 -0500 Subject: [PATCH 14/19] tools.test: store file in a variable while tests are running --- basis/tools/test/test.factor | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/basis/tools/test/test.factor b/basis/tools/test/test.factor index 01b6bdbf69..8c308e6406 100644 --- a/basis/tools/test/test.factor +++ b/basis/tools/test/test.factor @@ -32,8 +32,10 @@ test-failures [ V{ } clone ] initialize "--> test failed!" print test-failures get push ; -: file-failure ( error file -- ) - [ f ] [ f ] bi* failure ; +SYMBOL: file + +: file-failure ( error -- ) + f file get f failure ; :: (unit-test) ( output input -- error ? ) [ { } input with-datastack output assert-sequence= f f ] [ t ] recover ; inline @@ -71,14 +73,17 @@ MACRO: ( word -- ) : experiment. ( seq -- ) [ first write ": " write ] [ rest . ] bi ; -:: experiment ( word: ( -- error ? ) file line# -- ) +:: experiment ( word: ( -- error ? ) line# -- ) word :> e e experiment. - word execute [ e file line# failure ] [ drop ] if ; inline + word execute [ + file get [ + e file get line# failure + ] [ rethrow ] if + ] [ drop ] if ; inline : parse-test ( accum word -- accum ) literalize parsed - file get dup [ path>> ] when parsed lexer get line>> parsed \ experiment parsed ; inline @@ -93,8 +98,10 @@ SYNTAX: TEST: >> : run-test-file ( path -- ) - [ [ test-failures get ] dip '[ file>> _ = not ] filter-here ] - [ [ run-file ] [ swap file-failure ] recover ] bi ; + dup file [ + test-failures get [ file>> file get = not ] filter-here + '[ _ run-file ] [ file-failure ] recover + ] with-variable ; : run-vocab-tests ( vocab -- ) dup vocab source-loaded?>> [ @@ -113,7 +120,7 @@ TEST: must-fail-with TEST: must-fail M: test-failure summary - [ asset>> experiment. ] with-string-writer ; + asset>> [ [ experiment. ] with-string-writer ] [ "Top-level form" ] if* ; M: test-failure error. ( error -- ) [ call-next-method ] From 8480034d6e9179ed1096e61219110a3210f4a44f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 10 Apr 2009 08:13:20 -0500 Subject: [PATCH 15/19] image-name instances can now be passed to