| 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 #import("dart:uri"); | 6 #import("dart:uri"); |
| 7 | 7 |
| 8 void print(arg) { | |
| 9 _Logger._printString(arg.toString()); | |
| 10 } | |
| 11 | |
| 12 class _Logger { | |
| 13 static void _printString(String s) native "Logger_PrintString"; | |
| 14 } | |
| 15 | |
| 16 | |
| 17 // The URI that the entrypoint script was loaded from. Remembered so that | 8 // The URI that the entrypoint script was loaded from. Remembered so that |
| 18 // package imports can be resolved relative to it. | 9 // package imports can be resolved relative to it. |
| 19 var _entrypoint; | 10 var _entrypoint; |
| 20 | 11 |
| 21 // The directory to look in to resolve "package:" scheme URIs. | 12 // The directory to look in to resolve "package:" scheme URIs. |
| 22 var _packageRoot; | 13 var _packageRoot; |
| 23 | 14 |
| 24 void _logResolution(String msg) { | 15 void _logResolution(String msg) { |
| 25 final enabled = false; | 16 final enabled = false; |
| 26 if (enabled) { | 17 if (enabled) { |
| 27 _Logger._printString(msg); | 18 print(msg); |
| 28 } | 19 } |
| 29 } | 20 } |
| 30 | 21 |
| 31 String _setPackageRoot(String packageRoot) { | 22 String _setPackageRoot(String packageRoot) { |
| 32 // TODO(mattsh) - refactor windows drive and path handling code | 23 // TODO(mattsh) - refactor windows drive and path handling code |
| 33 // so it can be used here if needed. | 24 // so it can be used here if needed. |
| 34 _packageRoot = packageRoot; | 25 _packageRoot = packageRoot; |
| 35 } | 26 } |
| 36 | 27 |
| 37 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { | 28 String _resolveScriptUri(String cwd, String scriptName, bool isWindows) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 var path; | 138 var path; |
| 148 if (_packageRoot !== null) { | 139 if (_packageRoot !== null) { |
| 149 path = "${_packageRoot}${uri.path}"; | 140 path = "${_packageRoot}${uri.path}"; |
| 150 } else { | 141 } else { |
| 151 path = _entrypoint.resolve('packages/${uri.path}').path; | 142 path = _entrypoint.resolve('packages/${uri.path}').path; |
| 152 } | 143 } |
| 153 | 144 |
| 154 _logResolution("# Package: $path"); | 145 _logResolution("# Package: $path"); |
| 155 return path; | 146 return path; |
| 156 } | 147 } |
| OLD | NEW |