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:io'; | 6 import 'dart:io'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 // import 'root_library'; happens here from C Code | 8 // import 'root_library'; happens here from C Code |
9 | 9 |
10 // The root library (aka the script) is imported into this library. The | 10 // The root library (aka the script) is imported into this library. The |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 String _resolveUri(String base, String userString) { | 209 String _resolveUri(String base, String userString) { |
210 var baseUri = Uri.parse(base); | 210 var baseUri = Uri.parse(base); |
211 _logResolution('# Resolving: $userString from $base'); | 211 _logResolution('# Resolving: $userString from $base'); |
212 | 212 |
213 var uri = Uri.parse(userString); | 213 var uri = Uri.parse(userString); |
214 var resolved; | 214 var resolved; |
215 if ('dart-ext' == uri.scheme) { | 215 if ('dart-ext' == uri.scheme) { |
216 // Relative URIs with scheme dart-ext should be resolved as if with no | 216 // Relative URIs with scheme dart-ext should be resolved as if with no |
217 // scheme. | 217 // scheme. |
218 resolved = baseUri.resolve(uri.path); | 218 resolved = baseUri.resolve(uri.path); |
219 var path = resolved.path; | |
220 if (resolved.scheme == 'package') { | 219 if (resolved.scheme == 'package') { |
221 // If we are resolving relative to a package URI we go directly to the | 220 // If we are resolving relative to a package URI we go directly to the |
222 // file path and keep the dart-ext scheme. Otherwise, we will lose the | 221 // file path and keep the dart-ext scheme. Otherwise, we will lose the |
223 // package URI path part. | 222 // package URI path part. |
224 path = _filePathFromPackageUri(resolved); | 223 var path = _filePathFromPackageUri(resolved); |
| 224 if (path.startsWith('http:')) { |
| 225 throw "Native extensions not supported in " |
| 226 "packages loaded over http: %path"; |
| 227 } |
| 228 resolved = new Uri.file(path); |
225 } | 229 } |
226 resolved = new Uri(scheme: 'dart-ext', path: path); | 230 resolved = new Uri(scheme: 'dart-ext', path: resolved.path); |
227 } else { | 231 } else { |
228 resolved = baseUri.resolve(userString); | 232 resolved = baseUri.resolve(userString); |
229 } | 233 } |
230 _logResolution('# Resolved to: $resolved'); | 234 _logResolution('# Resolved to: $resolved'); |
231 return resolved.toString(); | 235 return resolved.toString(); |
232 } | 236 } |
233 | 237 |
234 | 238 |
235 // Returns either a file path or a URI starting with http:, as a String. | 239 // Returns either a file path or a URI starting with http:, as a String. |
236 String _filePathFromUri(String userUri) { | 240 String _filePathFromUri(String userUri) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 276 |
273 throw "URIs using the 'package:' scheme should look like " | 277 throw "URIs using the 'package:' scheme should look like " |
274 "'$right', not '$wrong'."; | 278 "'$right', not '$wrong'."; |
275 } | 279 } |
276 | 280 |
277 var packageRoot = _packageRoot == null ? | 281 var packageRoot = _packageRoot == null ? |
278 _entryPointScript.resolve('packages/') : | 282 _entryPointScript.resolve('packages/') : |
279 _packageRoot; | 283 _packageRoot; |
280 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); | 284 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); |
281 } | 285 } |
OLD | NEW |