Chromium Code Reviews| 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 | 6 |
| 7 void print(arg) { | 7 void print(arg) { |
| 8 _Logger._printString(arg.toString()); | 8 _Logger._printString(arg.toString()); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/"); | 60 var base = new Uri(scheme: "file", path: cwd.endsWith("/") ? cwd : "$cwd/"); |
| 61 _entrypoint = base.resolve(scriptName); | 61 _entrypoint = base.resolve(scriptName); |
| 62 _logResolution("# Resolved script to: $_entrypoint"); | 62 _logResolution("# Resolved script to: $_entrypoint"); |
| 63 | 63 |
| 64 return _entrypoint.toString(); | 64 return _entrypoint.toString(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 String _resolveUri(String base, String userString) { | 67 String _resolveUri(String base, String userString) { |
| 68 var baseUri = new Uri.fromString(base); | 68 var baseUri = new Uri.fromString(base); |
| 69 _logResolution("# Resolving: $userString from $base"); | 69 _logResolution("# Resolving: $userString from $base"); |
| 70 var resolved = baseUri.resolve(userString); | 70 |
| 71 // Relative URIs with scheme dart-ext should be resolved as if with no scheme. | |
| 72 var uri = new Uri.fromString(userString); | |
| 73 var resolved; | |
| 74 if ('dart-ext' == uri.scheme) { | |
| 75 resolved = baseUri.resolve(uri.path); | |
| 76 resolved = new Uri(scheme: "dart-ext", path: resolved.path); | |
| 77 // resolved.scheme = 'foo'; // Causes a segfault. Verify this is expected. | |
|
Ivan Posva
2012/04/17 18:50:06
Since the bug is filed now, you can remove this co
Bill Hesse
2012/04/18 09:56:39
This line will be removed. A separate bug and rep
| |
| 78 } else { | |
| 79 resolved = baseUri.resolve(userString); | |
| 80 } | |
| 71 _logResolution("# Resolved to: $resolved"); | 81 _logResolution("# Resolved to: $resolved"); |
| 72 return resolved.toString(); | 82 return resolved.toString(); |
| 73 } | 83 } |
| 74 | 84 |
| 75 String _resolveExtensionUri(String base, String userString) { | |
| 76 var uri = new Uri.fromString(userString); | |
| 77 if ("dart-ext" != uri.scheme) { | |
| 78 throw "Not a Dart extension uri: $uri"; | |
| 79 } | |
| 80 var schemelessUri = new Uri(path: uri.path); | |
| 81 var baseUri = new Uri.fromString(base); | |
| 82 _logResolution("# Resolving: $userString from $base"); | |
| 83 var resolved = baseUri.resolveUri(schemelessUri); | |
| 84 resolved = new Uri(scheme: 'dart-ext', path: resolved.path); | |
| 85 _logResolution("# Resolved to: $resolved"); | |
| 86 return resolved.toString(); | |
| 87 } | |
| 88 | 85 |
| 89 String _filePathFromUri(String userUri) { | 86 String _filePathFromUri(String userUri) { |
| 90 var uri = new Uri.fromString(userUri); | 87 var uri = new Uri.fromString(userUri); |
| 91 _logResolution("# Getting file path from: $uri"); | 88 _logResolution("# Getting file path from: $uri"); |
| 92 | 89 |
| 93 var path; | 90 var path; |
| 94 switch (uri.scheme) { | 91 switch (uri.scheme) { |
| 95 case 'file': path = _filePathFromFileUri(uri); break; | 92 case 'file': |
| 93 case 'dart-ext': path = _filePathFromFileUri(uri); break; | |
|
Ivan Posva
2012/04/17 18:50:06
Since dart-ext is not a file URI I am expecting th
Bill Hesse
2012/04/18 09:56:39
Fixed by calling _filePathFromOtherUri.
I wrote c
| |
| 96 case 'package': path = _filePathFromPackageUri(uri); break; | 94 case 'package': path = _filePathFromPackageUri(uri); break; |
| 97 | 95 |
| 98 default: | 96 default: |
| 99 // Only handling file and package URIs in standalone binary. | 97 // Only handling file, dart-ext and package URIs in standalone binary. |
| 100 _logResolution("# Not a file or package URI."); | 98 _logResolution("# Not a file, dart-ext, or package URI."); |
| 101 throw "Not a known scheme: $uri"; | 99 throw "Not a known scheme: $uri"; |
| 102 } | 100 } |
| 103 | 101 |
| 104 if (_is_windows) { | 102 if (_is_windows) { |
| 105 // Drop the leading / before the drive letter. | 103 // Drop the leading / before the drive letter. |
| 106 path = path.substring(1); | 104 path = path.substring(1); |
| 107 _logResolution("# path: $path"); | 105 _logResolution("# path: $path"); |
| 108 } | 106 } |
| 109 | 107 |
| 110 return path; | 108 return path; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 126 var wrong = 'package://$path'; | 124 var wrong = 'package://$path'; |
| 127 | 125 |
| 128 throw "URIs using the 'package:' scheme should look like " + | 126 throw "URIs using the 'package:' scheme should look like " + |
| 129 "'$right', not '$wrong'."; | 127 "'$right', not '$wrong'."; |
| 130 } | 128 } |
| 131 | 129 |
| 132 var path = _entrypoint.resolve('packages/${uri.path}').path; | 130 var path = _entrypoint.resolve('packages/${uri.path}').path; |
| 133 _logResolution("# Package: $path"); | 131 _logResolution("# Package: $path"); |
| 134 return path; | 132 return path; |
| 135 } | 133 } |
| OLD | NEW |