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

Side by Side Diff: dart/pkg/compiler/lib/src/apiimpl.dart

Issue 803543002: Resolve libraries against their canonical URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42358. Created 6 years 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/pkg/compiler/lib/src/library_loader.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:async'; 7 import 'dart:async';
8 8
9 import '../compiler.dart' as api; 9 import '../compiler.dart' as api;
10 import 'dart2jslib.dart' as leg; 10 import 'dart2jslib.dart' as leg;
11 import 'tree/tree.dart' as tree; 11 import 'tree/tree.dart' as tree;
12 import 'elements/elements.dart' as elements; 12 import 'elements/elements.dart' as elements;
13 import 'package:_internal/libraries.dart'; 13 import 'package:_internal/libraries.dart' hide LIBRARIES;
14 import 'package:_internal/libraries.dart' as library_info show LIBRARIES;
14 import 'source_file.dart'; 15 import 'source_file.dart';
15 16
16 const bool forceIncrementalSupport = 17 const bool forceIncrementalSupport =
17 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT'); 18 const bool.fromEnvironment('DART2JS_EXPERIMENTAL_INCREMENTAL_SUPPORT');
18 19
19 class Compiler extends leg.Compiler { 20 class Compiler extends leg.Compiler {
20 api.CompilerInputProvider provider; 21 api.CompilerInputProvider provider;
21 api.DiagnosticHandler handler; 22 api.DiagnosticHandler handler;
22 final Uri libraryRoot; 23 final Uri libraryRoot;
23 final Uri packageRoot; 24 final Uri packageRoot;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return new Set<String>.from(result); 146 return new Set<String>.from(result);
146 } 147 }
147 148
148 static bool hasOption(List<String> options, String option) { 149 static bool hasOption(List<String> options, String option) {
149 return options.indexOf(option) >= 0; 150 return options.indexOf(option) >= 0;
150 } 151 }
151 152
152 // TODO(johnniwinther): Merge better with [translateDartUri] when 153 // TODO(johnniwinther): Merge better with [translateDartUri] when
153 // [scanBuiltinLibrary] is removed. 154 // [scanBuiltinLibrary] is removed.
154 String lookupLibraryPath(String dartLibraryName) { 155 String lookupLibraryPath(String dartLibraryName) {
155 LibraryInfo info = LIBRARIES[dartLibraryName]; 156 LibraryInfo info = lookupLibraryInfo(dartLibraryName);
156 if (info == null) return null; 157 if (info == null) return null;
157 if (!info.isDart2jsLibrary) return null; 158 if (!info.isDart2jsLibrary) return null;
158 if (!allowedLibraryCategories.contains(info.category)) return null; 159 if (!allowedLibraryCategories.contains(info.category)) return null;
159 String path = info.dart2jsPath; 160 String path = info.dart2jsPath;
160 if (path == null) { 161 if (path == null) {
161 path = info.path; 162 path = info.path;
162 } 163 }
163 return "lib/$path"; 164 return "lib/$path";
164 } 165 }
165 166
166 String lookupPatchPath(String dartLibraryName) { 167 String lookupPatchPath(String dartLibraryName) {
167 LibraryInfo info = LIBRARIES[dartLibraryName]; 168 LibraryInfo info = lookupLibraryInfo(dartLibraryName);
168 if (info == null) return null; 169 if (info == null) return null;
169 if (!info.isDart2jsLibrary) return null; 170 if (!info.isDart2jsLibrary) return null;
170 String path = info.dart2jsPatchPath; 171 String path = info.dart2jsPatchPath;
171 if (path == null) return null; 172 if (path == null) return null;
172 return "lib/$path"; 173 return "lib/$path";
173 } 174 }
174 175
175 void log(message) { 176 void log(message) {
176 handler(null, null, null, message, api.Diagnostic.VERBOSE_INFO); 177 handler(null, null, null, message, api.Diagnostic.VERBOSE_INFO);
177 } 178 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 */ 253 */
253 Uri translateUri(leg.Spannable node, Uri readableUri) { 254 Uri translateUri(leg.Spannable node, Uri readableUri) {
254 switch (readableUri.scheme) { 255 switch (readableUri.scheme) {
255 case 'package': return translatePackageUri(node, readableUri); 256 case 'package': return translatePackageUri(node, readableUri);
256 default: return readableUri; 257 default: return readableUri;
257 } 258 }
258 } 259 }
259 260
260 Uri translateDartUri(elements.LibraryElement importingLibrary, 261 Uri translateDartUri(elements.LibraryElement importingLibrary,
261 Uri resolvedUri, tree.Node node) { 262 Uri resolvedUri, tree.Node node) {
262 LibraryInfo libraryInfo = LIBRARIES[resolvedUri.path]; 263 LibraryInfo libraryInfo = lookupLibraryInfo(resolvedUri.path);
263 String path = lookupLibraryPath(resolvedUri.path); 264 String path = lookupLibraryPath(resolvedUri.path);
264 if (libraryInfo != null && 265 if (libraryInfo != null &&
265 libraryInfo.category == "Internal") { 266 libraryInfo.category == "Internal") {
266 bool allowInternalLibraryAccess = false; 267 bool allowInternalLibraryAccess = false;
267 if (importingLibrary != null) { 268 if (importingLibrary != null) {
268 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { 269 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) {
269 allowInternalLibraryAccess = true; 270 allowInternalLibraryAccess = true;
270 } else if (importingLibrary.canonicalUri.path.contains( 271 } else if (importingLibrary.canonicalUri.path.contains(
271 'dart/tests/compiler/dart2js_native')) { 272 'dart/tests/compiler/dart2js_native')) {
272 allowInternalLibraryAccess = true; 273 allowInternalLibraryAccess = true;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 379 }
379 } 380 }
380 381
381 void diagnoseCrashInUserCode(String message, exception, stackTrace) { 382 void diagnoseCrashInUserCode(String message, exception, stackTrace) {
382 hasCrashed = true; 383 hasCrashed = true;
383 print('$message: ${tryToString(exception)}'); 384 print('$message: ${tryToString(exception)}');
384 print(tryToString(stackTrace)); 385 print(tryToString(stackTrace));
385 } 386 }
386 387
387 fromEnvironment(String name) => environment[name]; 388 fromEnvironment(String name) => environment[name];
389
390 LibraryInfo lookupLibraryInfo(String libraryName) {
391 return library_info.LIBRARIES[libraryName];
392 }
388 } 393 }
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/library_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698