OLD | NEW |
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 Loading... |
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 static Builtin::BuiltinLibraryId BuiltinId(const char* url) { | 446 static Builtin::BuiltinLibraryId BuiltinId(const char* url) { |
472 if (DartUtils::IsDartBuiltinLibURL(url)) { | 447 if (DartUtils::IsDartBuiltinLibURL(url)) { |
473 return Builtin::kBuiltinLibrary; | 448 return Builtin::kBuiltinLibrary; |
474 } | 449 } |
475 if (DartUtils::IsDartIOLibURL(url)) { | 450 if (DartUtils::IsDartIOLibURL(url)) { |
476 return Builtin::kIOLibrary; | 451 return Builtin::kIOLibrary; |
477 } | 452 } |
478 return Builtin::kInvalidLibrary; | 453 return Builtin::kInvalidLibrary; |
479 } | 454 } |
480 | 455 |
(...skipping 25 matching lines...) Expand all Loading... |
506 | 481 |
507 Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string); | 482 Builtin::BuiltinLibraryId libraryBuiltinId = BuiltinId(library_url_string); |
508 if (tag == Dart_kCanonicalizeUrl) { | 483 if (tag == Dart_kCanonicalizeUrl) { |
509 if (mapped_url_string) { | 484 if (mapped_url_string) { |
510 return url; | 485 return url; |
511 } | 486 } |
512 // Parts of internal libraries are handled internally. | 487 // Parts of internal libraries are handled internally. |
513 if (libraryBuiltinId != Builtin::kInvalidLibrary) { | 488 if (libraryBuiltinId != Builtin::kInvalidLibrary) { |
514 return url; | 489 return url; |
515 } | 490 } |
516 return ResolveUri(library_url_string, url_string); | 491 return Dart_DefaultCanonicalizeUrl(library, url); |
517 } | 492 } |
518 | 493 |
519 Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string); | 494 Builtin::BuiltinLibraryId builtinId = BuiltinId(url_string); |
520 if ((builtinId != Builtin::kInvalidLibrary) && (mapped_url_string == NULL)) { | 495 if ((builtinId != Builtin::kInvalidLibrary) && (mapped_url_string == NULL)) { |
521 // Special case for importing a builtin library that isn't remapped. | 496 // Special case for importing a builtin library that isn't remapped. |
522 if (tag == Dart_kImportTag) { | 497 if (tag == Dart_kImportTag) { |
523 return Builtin::LoadLibrary(url, builtinId); | 498 return Builtin::LoadLibrary(url, builtinId); |
524 } | 499 } |
525 ASSERT(tag == Dart_kSourceTag); | 500 ASSERT(tag == Dart_kSourceTag); |
526 return DartUtils::NewError("Unable to part '%s' ", url_string); | 501 return DartUtils::NewError("Unable to part '%s' ", url_string); |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 EventHandler::Stop(); | 1323 EventHandler::Stop(); |
1349 return 0; | 1324 return 0; |
1350 } | 1325 } |
1351 | 1326 |
1352 } // namespace bin | 1327 } // namespace bin |
1353 } // namespace dart | 1328 } // namespace dart |
1354 | 1329 |
1355 int main(int argc, char** argv) { | 1330 int main(int argc, char** argv) { |
1356 return dart::bin::main(argc, argv); | 1331 return dart::bin::main(argc, argv); |
1357 } | 1332 } |
OLD | NEW |