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

Side by Side Diff: runtime/bin/gen_snapshot.cc

Issue 2031103002: Fix canonicalization of --url_mapping URIs in gen_snapshot (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Generate a snapshot file after loading all the scripts specified on the 5 // Generate a snapshot file after loading all the scripts specified on the
6 // command line. 6 // command line.
7 7
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } 436 }
437 } 437 }
438 438
439 Dart_Handle result = failed ? Dart_NewApiError(result_string) : 439 Dart_Handle result = failed ? Dart_NewApiError(result_string) :
440 DartUtils::NewString(result_string); 440 DartUtils::NewString(result_string);
441 free(result_string); 441 free(result_string);
442 return result; 442 return result;
443 } 443 }
444 444
445 445
446 static Dart_Handle ResolveUri(const char* library_uri, const char* uri) {
447 bool failed = false;
448 char* result_string = NULL;
449
450 {
451 UriResolverIsolateScope scope;
452
453 // Run DartUtils::ResolveUri in context of uri resolver isolate.
454 Dart_Handle result = DartUtils::ResolveUri(
455 DartUtils::NewString(library_uri), DartUtils::NewString(uri));
456 if (Dart_IsError(result)) {
457 failed = true;
458 result_string = strdup(Dart_GetError(result));
459 } else {
460 result_string = strdup(DartUtils::GetStringValue(result));
461 }
462 }
463
464 Dart_Handle result = failed ? Dart_NewApiError(result_string) :
465 DartUtils::NewString(result_string);
466 free(result_string);
467 return result;
468 }
469
470
471
446 static Builtin::BuiltinLibraryId BuiltinId(const char* url) { 472 static Builtin::BuiltinLibraryId BuiltinId(const char* url) {
447 if (DartUtils::IsDartBuiltinLibURL(url)) { 473 if (DartUtils::IsDartBuiltinLibURL(url)) {
448 return Builtin::kBuiltinLibrary; 474 return Builtin::kBuiltinLibrary;
449 } 475 }
450 if (DartUtils::IsDartIOLibURL(url)) { 476 if (DartUtils::IsDartIOLibURL(url)) {
451 return Builtin::kIOLibrary; 477 return Builtin::kIOLibrary;
452 } 478 }
453 return Builtin::kInvalidLibrary; 479 return Builtin::kInvalidLibrary;
454 } 480 }
455 481
(...skipping 25 matching lines...) Expand all
481 507
482 Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string); 508 Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string);
483 if (tag == Dart_kCanonicalizeUrl) { 509 if (tag == Dart_kCanonicalizeUrl) {
484 if (mapped_url_string) { 510 if (mapped_url_string) {
485 return url; 511 return url;
486 } 512 }
487 // Parts of internal libraries are handled internally. 513 // Parts of internal libraries are handled internally.
488 if (libraryBuiltinId != Builtin::kInvalidLibrary) { 514 if (libraryBuiltinId != Builtin::kInvalidLibrary) {
489 return url; 515 return url;
490 } 516 }
491 return Dart_DefaultCanonicalizeUrl(library, url); 517 return ResolveUri(library_url_string, url_string);
492 } 518 }
493 519
494 Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string); 520 Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string);
495 if ((builtinId != Builtin::kInvalidLibrary) && (mapped_url_string == NULL)) { 521 if ((builtinId != Builtin::kInvalidLibrary) && (mapped_url_string == NULL)) {
496 // Special case for importing a builtin library that isn't remapped. 522 // Special case for importing a builtin library that isn't remapped.
497 if (tag == Dart_kImportTag) { 523 if (tag == Dart_kImportTag) {
498 return Builtin::LoadLibrary(url, builtinId); 524 return Builtin::LoadLibrary(url, builtinId);
499 } 525 }
500 ASSERT(tag == Dart_kSourceTag); 526 ASSERT(tag == Dart_kSourceTag);
501 return DartUtils::NewError("Unable to part '%s' ", url_string); 527 return DartUtils::NewError("Unable to part '%s' ", url_string);
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 EventHandler::Stop(); 1349 EventHandler::Stop();
1324 return 0; 1350 return 0;
1325 } 1351 }
1326 1352
1327 } // namespace bin 1353 } // namespace bin
1328 } // namespace dart 1354 } // namespace dart
1329 1355
1330 int main(int argc, char** argv) { 1356 int main(int argc, char** argv) {
1331 return dart::bin::main(argc, argv); 1357 return dart::bin::main(argc, argv);
1332 } 1358 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698