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

Side by Side Diff: dart/lib/compiler/implementation/apiimpl.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 | « dart/lib/compiler/compiler.dart ('k') | dart/lib/compiler/implementation/colors.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('leg_apiimpl'); 5 #library('leg_apiimpl');
6 6
7 #import('dart:uri'); 7 #import('dart:uri');
8 8
9 #import('../compiler.dart', prefix: 'api'); 9 #import('../compiler.dart', prefix: 'api');
10 #import('leg.dart', prefix: 'leg'); 10 #import('leg.dart', prefix: 'leg');
(...skipping 21 matching lines...) Expand all
32 emitJavascript: options.indexOf('--output-type=dart') == -1, 32 emitJavascript: options.indexOf('--output-type=dart') == -1,
33 validateUnparse: options.indexOf('--unparse-validation') !== -1); 33 validateUnparse: options.indexOf('--unparse-validation') !== -1);
34 34
35 elements.LibraryElement scanBuiltinLibrary(String path) { 35 elements.LibraryElement scanBuiltinLibrary(String path) {
36 Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); 36 Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]);
37 elements.LibraryElement library = scanner.loadLibrary(uri, null); 37 elements.LibraryElement library = scanner.loadLibrary(uri, null);
38 return library; 38 return library;
39 } 39 }
40 40
41 void log(message) { 41 void log(message) {
42 handler(null, null, null, message, false); 42 handler(null, null, null, message, api.Diagnostic.VERBOSE_INFO);
43 } 43 }
44 44
45 leg.Script readScript(Uri uri, [tree.Node node]) { 45 leg.Script readScript(Uri uri, [tree.Node node]) {
46 if (uri.scheme == 'dart') uri = translateDartUri(uri, node); 46 if (uri.scheme == 'dart') uri = translateDartUri(uri, node);
47 var translated = translateUri(uri, node); 47 var translated = translateUri(uri, node);
48 String text = ""; 48 String text = "";
49 try { 49 try {
50 // TODO(ahe): We expect the future to be complete and call value 50 // TODO(ahe): We expect the future to be complete and call value
51 // directly. In effect, we don't support truly asynchronous API. 51 // directly. In effect, we don't support truly asynchronous API.
52 text = provider(translated).value; 52 text = provider(translated).value;
53 } catch (var exception) { 53 } catch (var exception) {
54 if (node !== null) { 54 if (node !== null) {
55 cancel("$exception", node: node); 55 cancel("$exception", node: node);
56 } else { 56 } else {
57 reportDiagnostic(const leg.SourceSpan(null, null, null), 57 reportDiagnostic(const leg.SourceSpan(null, null, null),
58 "$exception", true); 58 "$exception", api.Diagnostic.ERROR);
59 throw new leg.CompilerCancelledException("$exception"); 59 throw new leg.CompilerCancelledException("$exception");
60 } 60 }
61 } 61 }
62 SourceFile sourceFile = new SourceFile(uri.toString(), text); 62 SourceFile sourceFile = new SourceFile(uri.toString(), text);
63 return new leg.Script(uri, sourceFile); 63 return new leg.Script(uri, sourceFile);
64 } 64 }
65 65
66 Uri translateUri(Uri uri, tree.Node node) { 66 Uri translateUri(Uri uri, tree.Node node) {
67 switch (uri.scheme) { 67 switch (uri.scheme) {
68 case 'package': return translatePackageUri(uri, node); 68 case 'package': return translatePackageUri(uri, node);
(...skipping 19 matching lines...) Expand all
88 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path); 88 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path);
89 89
90 bool run(Uri uri) { 90 bool run(Uri uri) {
91 bool success = super.run(uri); 91 bool success = super.run(uri);
92 for (final task in tasks) { 92 for (final task in tasks) {
93 log('${task.name} took ${task.timing}msec'); 93 log('${task.name} took ${task.timing}msec');
94 } 94 }
95 return success; 95 return success;
96 } 96 }
97 97
98 void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) { 98 void reportDiagnostic(leg.SourceSpan span, String message,
99 api.Diagnostic kind) {
99 if (span === null) { 100 if (span === null) {
100 handler(null, null, null, message, fatal); 101 handler(null, null, null, message, kind);
101 } else { 102 } else {
102 handler(translateUri(span.uri, null), span.begin, span.end, 103 handler(translateUri(span.uri, null), span.begin, span.end,
103 message, fatal); 104 message, kind);
104 } 105 }
105 } 106 }
106 107
107 bool get isMockCompilation() { 108 bool get isMockCompilation() {
108 return mockableLibraryUsed 109 return mockableLibraryUsed
109 && (options.indexOf('--allow-mock-compilation') !== -1); 110 && (options.indexOf('--allow-mock-compilation') !== -1);
110 } 111 }
111 } 112 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/compiler.dart ('k') | dart/lib/compiler/implementation/colors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698