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

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

Issue 10407092: Add --package-root option to the compiler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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
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');
11 #import('tree/tree.dart', prefix: 'tree'); 11 #import('tree/tree.dart', prefix: 'tree');
12 #import('elements/elements.dart', prefix: 'elements'); 12 #import('elements/elements.dart', prefix: 'elements');
13 #import('ssa/tracer.dart', prefix: 'ssa'); 13 #import('ssa/tracer.dart', prefix: 'ssa');
14 #import('library_map.dart'); 14 #import('library_map.dart');
15 #import('source_file.dart'); 15 #import('source_file.dart');
16 16
17 class Compiler extends leg.Compiler { 17 class Compiler extends leg.Compiler {
18 api.ReadUriFromString provider; 18 api.ReadUriFromString provider;
19 api.DiagnosticHandler handler; 19 api.DiagnosticHandler handler;
20 Uri libraryRoot; 20 final Uri libraryRoot;
21 Uri packageRoot; 21 final Uri packageRoot;
22 List<String> options; 22 List<String> options;
23 bool mockableLibraryUsed = false; 23 bool mockableLibraryUsed = false;
24 24
25 Compiler(this.provider, this.handler, this.libraryRoot, List<String> options) 25 Compiler(this.provider, this.handler, this.libraryRoot, this.packageRoot,
26 List<String> options)
26 : this.options = options, 27 : this.options = options,
27 super( 28 super(
28 tracer: new ssa.HTracer(), 29 tracer: new ssa.HTracer(),
29 enableTypeAssertions: options.indexOf('--enable-checked-mode') != -1, 30 enableTypeAssertions: options.indexOf('--enable-checked-mode') != -1,
30 emitJavascript: options.indexOf('--output-type=dart') == -1); 31 emitJavascript: options.indexOf('--output-type=dart') == -1);
31 32
32 elements.LibraryElement scanBuiltinLibrary(String path) { 33 elements.LibraryElement scanBuiltinLibrary(String path) {
33 Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]); 34 Uri uri = libraryRoot.resolve(DART2JS_LIBRARY_MAP[path]);
34 elements.LibraryElement library = scanner.loadLibrary(uri, null); 35 elements.LibraryElement library = scanner.loadLibrary(uri, null);
35 return library; 36 return library;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart 75 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart
75 // supports this use case better. 76 // supports this use case better.
76 mockableLibraryUsed = true; 77 mockableLibraryUsed = true;
77 } 78 }
78 return libraryRoot.resolve(path); 79 return libraryRoot.resolve(path);
79 } 80 }
80 81
81 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path); 82 translatePackageUri(Uri uri, tree.Node node) => packageRoot.resolve(uri.path);
82 83
83 bool run(Uri uri) { 84 bool run(Uri uri) {
84 try { 85 bool success = super.run(uri);
85 packageRoot = uri.resolve('packages/'); 86 for (final task in tasks) {
86 bool success = super.run(uri); 87 log('${task.name} took ${task.timing}msec');
87 for (final task in tasks) {
88 log('${task.name} took ${task.timing}msec');
89 }
90 return success;
91 } finally {
92 packageRoot = null;
93 } 88 }
89 return success;
94 } 90 }
95 91
96 void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) { 92 void reportDiagnostic(leg.SourceSpan span, String message, bool fatal) {
97 if (span === null) { 93 if (span === null) {
98 handler(null, null, null, message, fatal); 94 handler(null, null, null, message, fatal);
99 } else { 95 } else {
100 handler(span.uri, span.begin, span.end, message, fatal); 96 handler(span.uri, span.begin, span.end, message, fatal);
101 } 97 }
102 } 98 }
103 99
104 bool get isMockCompilation() { 100 bool get isMockCompilation() {
105 return mockableLibraryUsed 101 return mockableLibraryUsed
106 && (options.indexOf('--allow-mock-compilation') !== -1); 102 && (options.indexOf('--allow-mock-compilation') !== -1);
107 } 103 }
108 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698