| 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 "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
| 9 | 9 |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return Dart_NewApiError(error_msg); | 622 return Dart_NewApiError(error_msg); |
| 623 } | 623 } |
| 624 bool is_snapshot = false; | 624 bool is_snapshot = false; |
| 625 const uint8_t *payload = SniffForMagicNumber(buffer, &len, &is_snapshot); | 625 const uint8_t *payload = SniffForMagicNumber(buffer, &len, &is_snapshot); |
| 626 Dart_Handle returnValue; | 626 Dart_Handle returnValue; |
| 627 if (is_snapshot) { | 627 if (is_snapshot) { |
| 628 returnValue = Dart_LoadScriptFromSnapshot(payload, len); | 628 returnValue = Dart_LoadScriptFromSnapshot(payload, len); |
| 629 } else { | 629 } else { |
| 630 Dart_Handle source = Dart_NewStringFromUTF8(buffer, len); | 630 Dart_Handle source = Dart_NewStringFromUTF8(buffer, len); |
| 631 if (Dart_IsError(source)) { | 631 if (Dart_IsError(source)) { |
| 632 returnValue = source; | 632 returnValue = NewError("%s is not a valid UTF-8 script", script_uri); |
| 633 } else { | 633 } else { |
| 634 returnValue = Dart_LoadScript(resolved_script_uri, source, 0, 0); | 634 returnValue = Dart_LoadScript(resolved_script_uri, source, 0, 0); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 free(const_cast<uint8_t *>(buffer)); | 637 free(const_cast<uint8_t *>(buffer)); |
| 638 return returnValue; | 638 return returnValue; |
| 639 } | 639 } |
| 640 | 640 |
| 641 | 641 |
| 642 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, | 642 Dart_Handle DartUtils::LoadSource(CommandLineOptions* url_mapping, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 new CObjectString(CObject::NewString(os_error->message())); | 1076 new CObjectString(CObject::NewString(os_error->message())); |
| 1077 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1077 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 1078 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1078 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 1079 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1079 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 1080 result->SetAt(2, error_message); | 1080 result->SetAt(2, error_message); |
| 1081 return result; | 1081 return result; |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 } // namespace bin | 1084 } // namespace bin |
| 1085 } // namespace dart | 1085 } // namespace dart |
| OLD | NEW |