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 -- )
17 SYMBOL: compiler-errors
19 SYMBOL: with-compiler-errors?
21 : errors-of-type ( type -- assoc )
22 compiler-errors get-global
23 swap [ >r nip compiler-error-type r> eq? ] curry
26 : compiler-errors. ( type -- )
27 errors-of-type >alist sort-keys
28 [ swap compiler-error. ] assoc-each ;
30 : (compiler-report) ( what type word -- )
31 over errors-of-type assoc-empty? [ 3drop ] [
36 errors-of-type assoc-size #
43 : compiler-report ( -- )
44 "semantic errors" +error+ "errors" (compiler-report)
45 "semantic warnings" +warning+ "warnings" (compiler-report)
46 "linkage errors" +linkage+ "linkage" (compiler-report) ;
48 : :errors ( -- ) +error+ compiler-errors. ;
50 : :warnings ( -- ) +warning+ compiler-errors. ;
52 : :linkage ( -- ) +linkage+ compiler-errors. ;
54 : compiler-error ( error word -- )
55 with-compiler-errors? get [
56 compiler-errors get pick
57 [ set-at ] [ delete-at drop ] if
60 : with-compiler-errors ( quot -- )
61 with-compiler-errors? get "quiet" get or [ call ] [
63 with-compiler-errors? on
64 V{ } clone compiler-errors set-global
65 [ compiler-report ] [ ] cleanup