Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: dart/lib/compiler/compiler.dart

Issue 10579015: Update dart2js to use diagnostic kinds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/apiimpl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library('compiler'); 5 #library('compiler');
6 6
7 #import('dart:uri'); 7 #import('dart:uri');
8 #import('implementation/apiimpl.dart'); 8 #import('implementation/apiimpl.dart');
9 9
10 // Unless explicitly allowed, passing [:null:] for any argument to the 10 // Unless explicitly allowed, passing [:null:] for any argument to the
(...skipping 11 matching lines...) Expand all
22 * Invoked by the compiler to report diagnostics. If [uri] is 22 * Invoked by the compiler to report diagnostics. If [uri] is
23 * [:null:], so are [begin] and [end]. No other arguments may be 23 * [:null:], so are [begin] and [end]. No other arguments may be
24 * [:null:]. If [uri] is not [:null:], neither are [begin] and 24 * [:null:]. If [uri] is not [:null:], neither are [begin] and
25 * [end]. [uri] indicates the compilation unit from where the 25 * [end]. [uri] indicates the compilation unit from where the
26 * diagnostic originates. [begin] and [end] are zero-based character 26 * diagnostic originates. [begin] and [end] are zero-based character
27 * offsets from the beginning of the compilaton unit. [message] is the 27 * offsets from the beginning of the compilaton unit. [message] is the
28 * diagnostic message, and [kind] indicates indicates what kind of 28 * diagnostic message, and [kind] indicates indicates what kind of
29 * diagnostic it is. 29 * diagnostic it is.
30 */ 30 */
31 typedef void DiagnosticHandler(Uri uri, int begin, int end, 31 typedef void DiagnosticHandler(Uri uri, int begin, int end,
32 String message, var kind); 32 String message, Diagnostic kind);
33 33
34 /** 34 /**
35 * Returns a future that completes to [script] compiled to JavaScript. If 35 * Returns a future that completes to [script] compiled to JavaScript. If
36 * the compilation fails, the future's value will be [:null:] and 36 * the compilation fails, the future's value will be [:null:] and
37 * [handler] will have been invoked at least once with [:kind == 37 * [handler] will have been invoked at least once with [:kind ==
38 * Diagnostic.ERROR:] or [:kind == Diagnostic.CRASH:]. 38 * Diagnostic.ERROR:] or [:kind == Diagnostic.CRASH:].
39 */ 39 */
40 Future<String> compile(Uri script, 40 Future<String> compile(Uri script,
41 Uri libraryRoot, 41 Uri libraryRoot,
42 Uri packageRoot, 42 Uri packageRoot,
(...skipping 21 matching lines...) Expand all
64 * reporting a compilation error. The specification says: 64 * reporting a compilation error. The specification says:
65 * 65 *
66 * "A compile-time error must be reported by a Dart compiler before 66 * "A compile-time error must be reported by a Dart compiler before
67 * the erroneous code is executed." and "If a compile-time error 67 * the erroneous code is executed." and "If a compile-time error
68 * occurs within the code of a running isolate A, A is immediately 68 * occurs within the code of a running isolate A, A is immediately
69 * suspended." 69 * suspended."
70 * 70 *
71 * This means that the compiler can generate code that when executed 71 * This means that the compiler can generate code that when executed
72 * terminates execution. 72 * terminates execution.
73 */ 73 */
74 static final Diagnostic ERROR = const Diagnostic(1); 74 static final Diagnostic ERROR = const Diagnostic(1, 'error');
75 75
76 /** 76 /**
77 * A warning as identified by the "Dart Programming Language 77 * A warning as identified by the "Dart Programming Language
78 * Specification" [http://www.dartlang.org/docs/spec/]. 78 * Specification" [http://www.dartlang.org/docs/spec/].
79 */ 79 */
80 static final Diagnostic WARNING = const Diagnostic(2); 80 static final Diagnostic WARNING = const Diagnostic(2, 'warning');
81 81
82 /** 82 /**
83 * Any other warning that is not covered by [WARNING]. 83 * Any other warning that is not covered by [WARNING].
84 */ 84 */
85 static final Diagnostic LINT = const Diagnostic(4); 85 static final Diagnostic LINT = const Diagnostic(4, 'lint');
86 86
87 /** 87 /**
88 * Informational messages. 88 * Informational messages.
89 */ 89 */
90 static final Diagnostic INFO = const Diagnostic(8); 90 static final Diagnostic INFO = const Diagnostic(8, 'info');
91 91
92 /** 92 /**
93 * Informational messages that shouldn't be printed unless 93 * Informational messages that shouldn't be printed unless
94 * explicitly requested by the user of a compiler. 94 * explicitly requested by the user of a compiler.
95 */ 95 */
96 static final Diagnostic VERBOSE_INFO = const Diagnostic(16); 96 static final Diagnostic VERBOSE_INFO = const Diagnostic(16, 'verbose info');
97 97
98 /** 98 /**
99 * An internal error in the compiler. 99 * An internal error in the compiler.
100 */ 100 */
101 static final Diagnostic CRASH = const Diagnostic(32); 101 static final Diagnostic CRASH = const Diagnostic(32, 'crash');
102 102
103 /** 103 /**
104 * An [int] representation of this kind. The ordinals are designed 104 * An [int] representation of this kind. The ordinals are designed
105 * to be used as bitsets. 105 * to be used as bitsets.
106 */ 106 */
107 final int ordinal; 107 final int ordinal;
108 108
109 /** 109 /**
110 * The name of this kind.
111 */
112 final String name;
113
114 /**
110 * This constructor is not private to support user-defined 115 * This constructor is not private to support user-defined
111 * diagnostic kinds. 116 * diagnostic kinds.
112 */ 117 */
113 const Diagnostic(this.ordinal); 118 const Diagnostic(this.ordinal, this.name);
119
120 String toString() => name;
114 } 121 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/apiimpl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698