1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel namespaces assocs prettyprint io sequences
4 sorting continuations debugger math math.parser ;
11 GENERIC: compiler-error-type ( error -- ? )
13 M: object compiler-error-type drop +error+ ;
17 SYMBOL: compiler-errors
19 SYMBOL: with-compiler-errors?
21 : compiler-error. ( error word -- )
23 "While compiling " write pprint ": " print
27 : errors-of-type ( type -- assoc )
28 compiler-errors get-global
29 swap [ >r nip compiler-error-type r> eq? ] curry
32 : compiler-errors. ( type -- )
33 errors-of-type >alist sort-keys
34 [ swap compiler-error. ] assoc-each ;
36 : (compiler-report) ( what type word -- )
37 over errors-of-type assoc-empty? [ 3drop ] [
42 errors-of-type assoc-size #
49 : compiler-report ( -- )
50 "semantic errors" +error+ "errors" (compiler-report)
51 "semantic warnings" +warning+ "warnings" (compiler-report)
52 "linkage errors" +linkage+ "linkage" (compiler-report) ;
56 : compiler-error ( error word -- )
57 with-compiler-errors? get [
58 compiler-errors get pick
59 [ set-at ] [ delete-at drop ] if
62 : :errors +error+ compiler-errors. ;
64 : :warnings +warning+ compiler-errors. ;
66 : :linkage +linkage+ compiler-errors. ;
68 : with-compiler-errors ( quot -- )
69 with-compiler-errors? get "quiet" get or [ call ] [
71 with-compiler-errors? on
72 V{ } clone compiler-errors set-global
73 [ compiler-report ] [ ] cleanup