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

Side by Side Diff: dart/frog/leg/apiimpl.dart

Issue 9646030: Find diagnostic locations for use in new compiler API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix crashes and address review comments Created 8 years, 9 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/frog/leg/compiler.dart » ('j') | dart/frog/leg/compiler.dart » ('J')
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('leg.dart', prefix: 'leg'); 7 #import('leg.dart', prefix: 'leg');
8 #import('ssa/tracer.dart', prefix: 'ssa'); 8 #import('ssa/tracer.dart', prefix: 'ssa');
9 #import('../lang.dart', prefix: 'frog'); 9 #import('../lang.dart', prefix: 'frog');
10 10
11 class Compiler extends leg.Compiler { 11 class Compiler extends leg.Compiler {
12 ReadUriFromString provider; 12 ReadUriFromString provider;
13 DiagnosticHandler handler; 13 DiagnosticHandler handler;
14 Uri libraryRoot; 14 Uri libraryRoot;
15 15
16 Compiler(this.provider, this.handler, this.libraryRoot) 16 Compiler(this.provider, this.handler, this.libraryRoot)
17 : super.withCurrentDirectory(null, tracer: new ssa.HTracer()); 17 : super.withCurrentDirectory(null, tracer: new ssa.HTracer());
18 18
19 LibraryElement scanBuiltinLibrary(String filename) { 19 LibraryElement scanBuiltinLibrary(String filename) {
20 Uri uri = libraryRoot.resolve(filename); 20 Uri uri = libraryRoot.resolve(filename);
21 LibraryElement library = scanner.loadLibrary(uri, null); 21 LibraryElement library = scanner.loadLibrary(uri, null);
22 return library; 22 return library;
23 } 23 }
24 24
25 void log(message) {
26 handler(null, null, null, message, false);
27 }
28
29 Script readScript(Uri uri, [ScriptTag node]) { 25 Script readScript(Uri uri, [ScriptTag node]) {
30 String uriName = uri.toString(); 26 String uriName = uri.toString();
31 // TODO(ahe): Clean this up. 27 // TODO(ahe): Clean this up.
32 if (uriName == 'dart:dom') { 28 if (uriName == 'dart:dom') {
33 uri = libraryRoot.resolve('../../../client/dom/frog/dom_frog.dart'); 29 uri = libraryRoot.resolve('../../../client/dom/frog/dom_frog.dart');
34 } else if (uriName == 'dart:html') { 30 } else if (uriName == 'dart:html') {
35 uri = libraryRoot.resolve('../../../client/html/frog/html_frog.dart'); 31 uri = libraryRoot.resolve('../../../client/html/frog/html_frog.dart');
36 } else if (uriName == 'dart:json') { 32 } else if (uriName == 'dart:json') {
37 uri = libraryRoot.resolve('../../../lib/json/json.dart'); 33 uri = libraryRoot.resolve('../../../lib/json/json.dart');
38 } 34 }
39 String text = ""; 35 String text = "";
40 try { 36 try {
41 // TODO(ahe): We expect the future to be complete and call value 37 // TODO(ahe): We expect the future to be complete and call value
42 // directly. In effect, we don't support truly asynchronous API. 38 // directly. In effect, we don't support truly asynchronous API.
43 text = provider(uri).value; 39 text = provider(uri).value;
44 } catch (var exception) { 40 } catch (var exception) {
45 cancel("${uri.path}: $exception", node: node); 41 cancel("${uri.path}: $exception", node: node);
46 } 42 }
47 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text); 43 frog.SourceFile sourceFile = new frog.SourceFile(uri.toString(), text);
48 return new leg.Script(uri, sourceFile); 44 return new leg.Script(uri, sourceFile);
49 } 45 }
50 46
51 bool run(Uri uri) { 47 bool run(Uri uri) {
52 bool success = super.run(uri); 48 bool success = super.run(uri);
53 for (final task in tasks) { 49 for (final task in tasks) {
54 log('${task.name} took ${task.timing}msec'); 50 log('${task.name} took ${task.timing}msec');
55 } 51 }
56 return success; 52 return success;
57 } 53 }
54
55 void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) {
56 if (span === null) {
57 handler(null, null, null, message, fatal);
58 } else {
59 handler(span.uri, span.begin, span.end, message, fatal);
60 }
61 }
58 } 62 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/compiler.dart » ('j') | dart/frog/leg/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698