Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: runtime/bin/builtin.dart

Issue 538373002: Don't do Uri->String->Uri when resolving package imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:convert'; 8 import 'dart:convert';
9 // import 'root_library'; happens here from C Code 9 // import 'root_library'; happens here from C Code
10 10
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (_logBuiltin) { 169 if (_logBuiltin) {
170 _print('# Getting file path from: $uri'); 170 _print('# Getting file path from: $uri');
171 } 171 }
172 172
173 var path; 173 var path;
174 switch (uri.scheme) { 174 switch (uri.scheme) {
175 case '': 175 case '':
176 case 'file': 176 case 'file':
177 return uri.toFilePath(); 177 return uri.toFilePath();
178 case 'package': 178 case 'package':
179 return _filePathFromPackageUri(uri); 179 return _filePathFromUri(_resolvePackageUri(uri).toString());
180 case 'http': 180 case 'http':
181 return uri.toString(); 181 return uri.toString();
182 default: 182 default:
183 // Only handling file, http, and package URIs 183 // Only handling file, http, and package URIs
184 // in standalone binary. 184 // in standalone binary.
185 if (_logBuiltin) { 185 if (_logBuiltin) {
186 _print('# Unknown scheme (${uri.scheme}) in $uri.'); 186 _print('# Unknown scheme (${uri.scheme}) in $uri.');
187 } 187 }
188 throw 'Not a known scheme: $uri'; 188 throw 'Not a known scheme: $uri';
189 } 189 }
190 } 190 }
191 191
192 192
193 String _filePathFromPackageUri(Uri uri) { 193 Uri _resolvePackageUri(Uri uri) {
194 if (!uri.host.isEmpty) { 194 if (!uri.host.isEmpty) {
195 var path = '${uri.host}${uri.path}'; 195 var path = '${uri.host}${uri.path}';
196 var right = 'package:$path'; 196 var right = 'package:$path';
197 var wrong = 'package://$path'; 197 var wrong = 'package://$path';
198 198
199 throw "URIs using the 'package:' scheme should look like " 199 throw "URIs using the 'package:' scheme should look like "
200 "'$right', not '$wrong'."; 200 "'$right', not '$wrong'.";
201 } 201 }
202 202
203 var packageRoot = _packageRoot == null ? 203 var packageRoot = _packageRoot == null ?
204 _entryPointScript.resolve('packages/') : 204 _entryPointScript.resolve('packages/') :
205 _packageRoot; 205 _packageRoot;
206 return _filePathFromUri(packageRoot.resolve(uri.path).toString()); 206 return packageRoot.resolve(uri.path);
207 } 207 }
208 208
209 209
210 int _numOutstandingLoadRequests = 0; 210 int _numOutstandingLoadRequests = 0;
211 var _httpClient; 211 var _httpClient;
212 212
213 void _httpGet(Uri uri, String libraryUri, loadCallback(List<int> data)) { 213 void _httpGet(Uri uri, String libraryUri, loadCallback(List<int> data)) {
214 if (_httpClient == null) { 214 if (_httpClient == null) {
215 _httpClient = new HttpClient()..maxConnectionsPerHost = 6; 215 _httpClient = new HttpClient()..maxConnectionsPerHost = 6;
216 } 216 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 if (_logBuiltin) { 296 if (_logBuiltin) {
297 _print('# Creating uri for: $uri'); 297 _print('# Creating uri for: $uri');
298 } 298 }
299 299
300 switch (uri.scheme) { 300 switch (uri.scheme) {
301 case '': 301 case '':
302 case 'file': 302 case 'file':
303 case 'http': 303 case 'http':
304 return uri; 304 return uri;
305 case 'package': 305 case 'package':
306 return Uri.parse(_filePathFromPackageUri(uri)); 306 return _resolvePackageUri(uri);
307 default: 307 default:
308 // Only handling file, http, and package URIs 308 // Only handling file, http, and package URIs
309 // in standalone binary. 309 // in standalone binary.
310 _logResolution('# Unknown scheme (${uri.scheme}) in $uri.'); 310 _logResolution('# Unknown scheme (${uri.scheme}) in $uri.');
311 throw 'Not a known scheme: $uri'; 311 throw 'Not a known scheme: $uri';
312 } 312 }
313 } 313 }
314 314
315 315
316 // Asynchronously loads script data through a http or file uri. 316 // Asynchronously loads script data through a http or file uri.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 filename = '$name.dll'; 378 filename = '$name.dll';
379 } else { 379 } else {
380 if (_logBuiltin) { 380 if (_logBuiltin) {
381 _print('Native extensions not supported on ${Platform.operatingSystem}'); 381 _print('Native extensions not supported on ${Platform.operatingSystem}');
382 } 382 }
383 throw 'Native extensions not supported on ${Platform.operatingSystem}'; 383 throw 'Native extensions not supported on ${Platform.operatingSystem}';
384 } 384 }
385 385
386 return [path, filename, name]; 386 return [path, filename, name];
387 } 387 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698