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 builtin; | 5 library builtin; |
6 // NOTE: Do not import 'dart:io' in builtin. | 6 // NOTE: Do not import 'dart:io' in builtin. |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:_internal'; | 9 import 'dart:_internal'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 _log("Skipping dummy deferred request."); | 507 _log("Skipping dummy deferred request."); |
508 } | 508 } |
509 }); | 509 }); |
510 | 510 |
511 if (_traceLoading) { | 511 if (_traceLoading) { |
512 _log("Requested packages map at '$packagesUri'."); | 512 _log("Requested packages map at '$packagesUri'."); |
513 } | 513 } |
514 } | 514 } |
515 | 515 |
516 | 516 |
| 517 // Embedder Entrypoint: |
| 518 // Add mapping from package name to URI. |
| 519 void _addPackageMapEntry(String key, String value) { |
| 520 if (!_setupCompleted) { |
| 521 _setupHooks(); |
| 522 } |
| 523 if (_traceLoading) { |
| 524 _log("Adding packages map entry: $key -> $value"); |
| 525 } |
| 526 if (_packageRoot != null) { |
| 527 if (_traceLoading) { |
| 528 _log("_packageRoot already set: $_packageRoot"); |
| 529 } |
| 530 throw "Cannot add package map entry to an exisiting package root."; |
| 531 } |
| 532 if (_packagesPort != null) { |
| 533 if (_traceLoading) { |
| 534 _log("Package map load request already pending."); |
| 535 } |
| 536 throw "Cannot add package map entry during package map resolution."; |
| 537 } |
| 538 if (_packageMap == null) { |
| 539 _packageMap = new Map<String, Uri>(); |
| 540 } |
| 541 _packageMap[key] = _workingDirectory.resolve(value); |
| 542 } |
| 543 |
| 544 |
517 void _asyncLoadError(_LoadRequest req, _LoadError error, StackTrace stack) { | 545 void _asyncLoadError(_LoadRequest req, _LoadError error, StackTrace stack) { |
518 if (_traceLoading) { | 546 if (_traceLoading) { |
519 _log("_asyncLoadError(${req._uri}), error: $error\nstack: $stack"); | 547 _log("_asyncLoadError(${req._uri}), error: $error\nstack: $stack"); |
520 } | 548 } |
521 if (req._tag == _Dart_kResourceLoad) { | 549 if (req._tag == _Dart_kResourceLoad) { |
522 Completer c = req._context; | 550 Completer c = req._context; |
523 c.completeError(error, stack); | 551 c.completeError(error, stack); |
524 } else { | 552 } else { |
525 String libraryUri = req._context; | 553 String libraryUri = req._context; |
526 if (req._tag == _Dart_kImportTag) { | 554 if (req._tag == _Dart_kImportTag) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 } | 827 } |
800 | 828 |
801 | 829 |
802 // Register callbacks and hooks with the rest of the core libraries. | 830 // Register callbacks and hooks with the rest of the core libraries. |
803 _setupHooks() { | 831 _setupHooks() { |
804 _setupCompleted = true; | 832 _setupCompleted = true; |
805 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; | 833 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; |
806 VMLibraryHooks.getPackageRoot = _getPackageRoot; | 834 VMLibraryHooks.getPackageRoot = _getPackageRoot; |
807 VMLibraryHooks.getPackageMap = _getPackageMap; | 835 VMLibraryHooks.getPackageMap = _getPackageMap; |
808 } | 836 } |
OLD | NEW |