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 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "bin/crypto.h" | 7 #include "bin/crypto.h" |
8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
9 #include "bin/extensions.h" | 9 #include "bin/extensions.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 " on the stand-alone VM. Trying to load" | 427 " on the stand-alone VM. Trying to load" |
428 " '%s'.\n", library_url_string, url_string); | 428 " '%s'.\n", library_url_string, url_string); |
429 } | 429 } |
430 // Prepend the library URI to form a unique script URI for the part. | 430 // Prepend the library URI to form a unique script URI for the part. |
431 intptr_t len = snprintf(NULL, 0, "%s/%s", library_url_string, url_string); | 431 intptr_t len = snprintf(NULL, 0, "%s/%s", library_url_string, url_string); |
432 char* part_uri = reinterpret_cast<char*>(malloc(len + 1)); | 432 char* part_uri = reinterpret_cast<char*>(malloc(len + 1)); |
433 snprintf(part_uri, len + 1, "%s/%s", library_url_string, url_string); | 433 snprintf(part_uri, len + 1, "%s/%s", library_url_string, url_string); |
434 Dart_Handle part_uri_obj = DartUtils::NewString(part_uri); | 434 Dart_Handle part_uri_obj = DartUtils::NewString(part_uri); |
435 free(part_uri); | 435 free(part_uri); |
436 return Dart_LoadSource(library, | 436 return Dart_LoadSource(library, |
437 part_uri_obj, | 437 part_uri_obj, Dart_Null(), |
438 Builtin::PartSource(id, url_string), 0, 0); | 438 Builtin::PartSource(id, url_string), 0, 0); |
439 } | 439 } |
440 // All cases should have been handled above. | 440 // All cases should have been handled above. |
441 UNREACHABLE(); | 441 UNREACHABLE(); |
442 } | 442 } |
443 | 443 |
444 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { | 444 if (DartUtils::IsDartExtensionSchemeURL(url_string)) { |
445 // Load a native code shared library to use in a native extension | 445 // Load a native code shared library to use in a native extension |
446 if (tag != Dart_kImportTag) { | 446 if (tag != Dart_kImportTag) { |
447 return NewError("Dart extensions must use import: '%s'", url_string); | 447 return NewError("Dart extensions must use import: '%s'", url_string); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 DartUtils::SniffForMagicNumber(data, &num_bytes, &is_snapshot); | 563 DartUtils::SniffForMagicNumber(data, &num_bytes, &is_snapshot); |
564 | 564 |
565 if (is_snapshot) { | 565 if (is_snapshot) { |
566 result = Dart_LoadScriptFromSnapshot(payload, num_bytes); | 566 result = Dart_LoadScriptFromSnapshot(payload, num_bytes); |
567 } else { | 567 } else { |
568 Dart_Handle source = Dart_NewStringFromUTF8(data, num_bytes); | 568 Dart_Handle source = Dart_NewStringFromUTF8(data, num_bytes); |
569 if (Dart_IsError(source)) { | 569 if (Dart_IsError(source)) { |
570 result = DartUtils::NewError("%s is not a valid UTF-8 script", | 570 result = DartUtils::NewError("%s is not a valid UTF-8 script", |
571 resolved_script_uri); | 571 resolved_script_uri); |
572 } else { | 572 } else { |
573 result = Dart_LoadScript(resolved_script_uri, source, 0, 0); | 573 result = Dart_LoadScript(resolved_script_uri, Dart_Null(), |
| 574 source, 0, 0); |
574 } | 575 } |
575 } | 576 } |
576 } else { | 577 } else { |
577 int64_t tag = DartUtils::GetIntegerValue(tag_in); | 578 int64_t tag = DartUtils::GetIntegerValue(tag_in); |
578 | 579 |
579 Dart_Handle source = Dart_NewStringFromUTF8(data, num_bytes); | 580 Dart_Handle source = Dart_NewStringFromUTF8(data, num_bytes); |
580 if (Dart_IsError(source)) { | 581 if (Dart_IsError(source)) { |
581 result = DartUtils::NewError("%s is not a valid UTF-8 script", | 582 result = DartUtils::NewError("%s is not a valid UTF-8 script", |
582 resolved_script_uri); | 583 resolved_script_uri); |
583 } else { | 584 } else { |
584 if (tag == Dart_kImportTag) { | 585 if (tag == Dart_kImportTag) { |
585 result = Dart_LoadLibrary(resolved_script_uri, source, 0, 0); | 586 result = Dart_LoadLibrary(resolved_script_uri, Dart_Null(), |
| 587 source, 0, 0); |
586 } else { | 588 } else { |
587 ASSERT(tag == Dart_kSourceTag); | 589 ASSERT(tag == Dart_kSourceTag); |
588 Dart_Handle library = Dart_LookupLibrary(library_uri); | 590 Dart_Handle library = Dart_LookupLibrary(library_uri); |
589 if (Dart_IsError(library)) { | 591 if (Dart_IsError(library)) { |
590 Dart_PropagateError(library); | 592 Dart_PropagateError(library); |
591 } | 593 } |
592 result = Dart_LoadSource(library, resolved_script_uri, source, 0, 0); | 594 result = Dart_LoadSource(library, resolved_script_uri, Dart_Null(), |
| 595 source, 0, 0); |
593 } | 596 } |
594 } | 597 } |
595 } | 598 } |
596 | 599 |
597 if (buffer_copy != NULL) { | 600 if (buffer_copy != NULL) { |
598 free(buffer_copy); | 601 free(buffer_copy); |
599 } | 602 } |
600 | 603 |
601 if (Dart_IsError(result)) { | 604 if (Dart_IsError(result)) { |
602 Dart_PropagateError(result); | 605 Dart_PropagateError(result); |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 new CObjectString(CObject::NewString(os_error->message())); | 1263 new CObjectString(CObject::NewString(os_error->message())); |
1261 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1264 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1262 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1265 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1263 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1266 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1264 result->SetAt(2, error_message); | 1267 result->SetAt(2, error_message); |
1265 return result; | 1268 return result; |
1266 } | 1269 } |
1267 | 1270 |
1268 } // namespace bin | 1271 } // namespace bin |
1269 } // namespace dart | 1272 } // namespace dart |
OLD | NEW |