| OLD | NEW |
| 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 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:package_config/packages.dart'; | 10 import 'package:package_config/packages.dart'; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return "lib/$path"; | 211 return "lib/$path"; |
| 212 } | 212 } |
| 213 | 213 |
| 214 void log(message) { | 214 void log(message) { |
| 215 callUserHandler( | 215 callUserHandler( |
| 216 null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); | 216 null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); |
| 217 } | 217 } |
| 218 | 218 |
| 219 /// See [leg.Compiler.translateResolvedUri]. | 219 /// See [leg.Compiler.translateResolvedUri]. |
| 220 Uri translateResolvedUri(elements.LibraryElement importingLibrary, | 220 Uri translateResolvedUri(elements.LibraryElement importingLibrary, |
| 221 Uri resolvedUri, tree.Node node) { | 221 Uri resolvedUri, Spannable spannable) { |
| 222 if (resolvedUri.scheme == 'dart') { | 222 if (resolvedUri.scheme == 'dart') { |
| 223 return translateDartUri(importingLibrary, resolvedUri, node); | 223 return translateDartUri(importingLibrary, resolvedUri, spannable); |
| 224 } | 224 } |
| 225 return resolvedUri; | 225 return resolvedUri; |
| 226 } | 226 } |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * Reads the script designated by [readableUri]. | 229 * Reads the script designated by [readableUri]. |
| 230 */ | 230 */ |
| 231 Future<Script> readScript(Spannable node, Uri readableUri) { | 231 Future<Script> readScript(Spannable node, Uri readableUri) { |
| 232 if (!readableUri.isAbsolute) { | 232 if (!readableUri.isAbsolute) { |
| 233 if (node == null) node = NO_LOCATION_SPANNABLE; | 233 if (node == null) node = NO_LOCATION_SPANNABLE; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 * See [LibraryLoader] for terminology on URIs. | 307 * See [LibraryLoader] for terminology on URIs. |
| 308 */ | 308 */ |
| 309 Uri translateUri(Spannable node, Uri readableUri) { | 309 Uri translateUri(Spannable node, Uri readableUri) { |
| 310 switch (readableUri.scheme) { | 310 switch (readableUri.scheme) { |
| 311 case 'package': return translatePackageUri(node, readableUri); | 311 case 'package': return translatePackageUri(node, readableUri); |
| 312 default: return readableUri; | 312 default: return readableUri; |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 Uri translateDartUri(elements.LibraryElement importingLibrary, | 316 Uri translateDartUri(elements.LibraryElement importingLibrary, |
| 317 Uri resolvedUri, tree.Node node) { | 317 Uri resolvedUri, Spannable spannable) { |
| 318 LibraryInfo libraryInfo = lookupLibraryInfo(resolvedUri.path); | 318 LibraryInfo libraryInfo = lookupLibraryInfo(resolvedUri.path); |
| 319 String path = lookupLibraryPath(libraryInfo); | 319 String path = lookupLibraryPath(libraryInfo); |
| 320 if (libraryInfo != null && | 320 if (libraryInfo != null && |
| 321 libraryInfo.category == "Internal") { | 321 libraryInfo.category == "Internal") { |
| 322 bool allowInternalLibraryAccess = false; | 322 bool allowInternalLibraryAccess = false; |
| 323 if (importingLibrary != null) { | 323 if (importingLibrary != null) { |
| 324 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { | 324 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { |
| 325 allowInternalLibraryAccess = true; | 325 allowInternalLibraryAccess = true; |
| 326 } else if (importingLibrary.canonicalUri.path.contains( | 326 } else if (importingLibrary.canonicalUri.path.contains( |
| 327 'sdk/tests/compiler/dart2js_native')) { | 327 'sdk/tests/compiler/dart2js_native')) { |
| 328 allowInternalLibraryAccess = true; | 328 allowInternalLibraryAccess = true; |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 if (!allowInternalLibraryAccess) { | 331 if (!allowInternalLibraryAccess) { |
| 332 if (importingLibrary != null) { | 332 if (importingLibrary != null) { |
| 333 reportError( | 333 reportError( |
| 334 node, | 334 spannable, |
| 335 MessageKind.INTERNAL_LIBRARY_FROM, | 335 MessageKind.INTERNAL_LIBRARY_FROM, |
| 336 {'resolvedUri': resolvedUri, | 336 {'resolvedUri': resolvedUri, |
| 337 'importingUri': importingLibrary.canonicalUri}); | 337 'importingUri': importingLibrary.canonicalUri}); |
| 338 } else { | 338 } else { |
| 339 reportError( | 339 reportError( |
| 340 node, | 340 spannable, |
| 341 MessageKind.INTERNAL_LIBRARY, | 341 MessageKind.INTERNAL_LIBRARY, |
| 342 {'resolvedUri': resolvedUri}); | 342 {'resolvedUri': resolvedUri}); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 if (path == null) { | 346 if (path == null) { |
| 347 reportError(node, MessageKind.LIBRARY_NOT_FOUND, | 347 reportError(spannable, MessageKind.LIBRARY_NOT_FOUND, |
| 348 {'resolvedUri': resolvedUri}); | 348 {'resolvedUri': resolvedUri}); |
| 349 return null; | 349 return null; |
| 350 } | 350 } |
| 351 if (resolvedUri.path == 'html' || | 351 if (resolvedUri.path == 'html' || |
| 352 resolvedUri.path == 'io') { | 352 resolvedUri.path == 'io') { |
| 353 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart | 353 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart |
| 354 // supports this use case better. | 354 // supports this use case better. |
| 355 mockableLibraryUsed = true; | 355 mockableLibraryUsed = true; |
| 356 } | 356 } |
| 357 return libraryRoot.resolve(path); | 357 return libraryRoot.resolve(path); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 print('$message: ${tryToString(exception)}'); | 514 print('$message: ${tryToString(exception)}'); |
| 515 print(tryToString(stackTrace)); | 515 print(tryToString(stackTrace)); |
| 516 } | 516 } |
| 517 | 517 |
| 518 fromEnvironment(String name) => environment[name]; | 518 fromEnvironment(String name) => environment[name]; |
| 519 | 519 |
| 520 LibraryInfo lookupLibraryInfo(String libraryName) { | 520 LibraryInfo lookupLibraryInfo(String libraryName) { |
| 521 return library_info.LIBRARIES[libraryName]; | 521 return library_info.LIBRARIES[libraryName]; |
| 522 } | 522 } |
| 523 } | 523 } |
| OLD | NEW |