]> gitweb.factorcode.org Git - factor.git/blob - basis/compiler/errors/errors.factor
basis: ERROR: changes.
[factor.git] / basis / compiler / errors / errors.factor
1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs command-line fry kernel namespaces
4 source-files.errors summary ;
5 IN: compiler.errors
6
7 SYMBOL: +compiler-error+
8 SYMBOL: compiler-errors
9
10 compiler-errors [ H{ } clone ] initialize
11
12 TUPLE: compiler-error < source-file-error ;
13
14 M: compiler-error error-type drop +compiler-error+ ;
15
16 SYMBOL: +linkage-error+
17 SYMBOL: linkage-errors
18
19 linkage-errors [ H{ } clone ] initialize
20
21 TUPLE: linkage-error < source-file-error ;
22
23 M: linkage-error error-type drop +linkage-error+ ;
24
25 : clear-compiler-error ( word -- )
26     compiler-errors linkage-errors
27     [ get-global delete-at ] bi-curry@ bi ;
28
29 : save-compiler-error ( error -- )
30     dup asset>> compiler-errors get-global set-at ;
31
32 T{ error-type-holder
33    { type +compiler-error+ }
34    { word ":errors" }
35    { plural "compiler errors" }
36    { icon "vocab:ui/tools/error-list/icons/compiler-error.tiff" }
37    { quot [ compiler-errors get values ] }
38    { forget-quot [ compiler-errors get delete-at ] }
39 } define-error-type
40
41 : <compiler-error> ( error word -- compiler-error )
42     \ compiler-error <definition-error> ;
43
44 : <linkage-error> ( error word -- linkage-error )
45     \ linkage-error <definition-error> ;
46
47 : set-linkage-error ( name message word class -- )
48     '[ _ boa ] dip <linkage-error> dup asset>> linkage-errors get set-at ; inline
49
50 T{ error-type-holder
51    { type +linkage-error+ }
52    { word ":linkage" }
53    { plural "linkage errors" }
54    { icon "vocab:ui/tools/error-list/icons/linkage-error.tiff" }
55    { quot [ linkage-errors get values ] }
56    { forget-quot [ linkage-errors get delete-at ] }
57    { fatal? f }
58 } define-error-type
59
60 ERROR: no-such-library name message ;
61
62 M: no-such-library summary drop "Library not found" ;
63
64 : no-such-library-error ( name message word -- )
65     \ no-such-library set-linkage-error ;
66
67 ERROR: no-such-symbol name message ;
68
69 M: no-such-symbol summary drop "Symbol not found" ;
70
71 : no-such-symbol-error ( name message word -- )
72     \ no-such-symbol set-linkage-error ;
73
74 ERROR: not-compiled word error ;
75
76 T{ error-type-holder
77     { type +user-init-error+ }
78     { word ":user-init-errors" }
79     { plural "rc file errors" }
80     { icon "vocab:ui/tools/error-list/icons/user-init-error.tiff" }
81     { quot [ user-init-errors get-global values ] }
82     { forget-quot [ user-init-errors get-global delete-at ] }
83 } define-error-type