1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel namespaces make assocs io sequences
4 sorting continuations math math.parser ;
11 GENERIC: compiler-error-type ( error -- ? )
13 M: object compiler-error-type drop +error+ ;
15 GENERIC# compiler-error. 1 ( error word -- )
19 SYMBOL: compiler-errors
21 SYMBOL: with-compiler-errors?
23 : errors-of-type ( type -- assoc )
24 compiler-errors get-global
25 swap [ >r nip compiler-error-type r> eq? ] curry
28 : compiler-errors. ( type -- )
29 errors-of-type >alist sort-keys
30 [ swap compiler-error. ] assoc-each ;
32 : (compiler-report) ( what type word -- )
33 over errors-of-type assoc-empty? [ 3drop ] [
38 errors-of-type assoc-size #
45 : compiler-report ( -- )
46 "semantic errors" +error+ "errors" (compiler-report)
47 "semantic warnings" +warning+ "warnings" (compiler-report)
48 "linkage errors" +linkage+ "linkage" (compiler-report) ;
52 : :errors ( -- ) +error+ compiler-errors. ;
54 : :warnings ( -- ) +warning+ compiler-errors. ;
56 : :linkage ( -- ) +linkage+ compiler-errors. ;
58 : compiler-error ( error word -- )
59 with-compiler-errors? get [
60 compiler-errors get pick
61 [ set-at ] [ delete-at drop ] if
64 : with-compiler-errors ( quot -- )
65 with-compiler-errors? get "quiet" get or [ call ] [
67 with-compiler-errors? on
68 V{ } clone compiler-errors set-global
69 [ compiler-report ] [ ] cleanup