OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 } | 2735 } |
2736 | 2736 |
2737 | 2737 |
2738 // --- J S O N --- | 2738 // --- J S O N --- |
2739 | 2739 |
2740 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { | 2740 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { |
2741 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2741 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
2742 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, JSON, Parse, Value); | 2742 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, JSON, Parse, Value); |
2743 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2743 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
2744 i::Handle<i::String> source = i::String::Flatten(string); | 2744 i::Handle<i::String> source = i::String::Flatten(string); |
| 2745 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2745 auto maybe = source->IsSeqOneByteString() | 2746 auto maybe = source->IsSeqOneByteString() |
2746 ? i::JsonParser<true>::Parse(source) | 2747 ? i::JsonParser<true>::Parse(isolate, source, undefined) |
2747 : i::JsonParser<false>::Parse(source); | 2748 : i::JsonParser<false>::Parse(isolate, source, undefined); |
2748 Local<Value> result; | 2749 Local<Value> result; |
2749 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2750 has_pending_exception = !ToLocal<Value>(maybe, &result); |
2750 RETURN_ON_FAILED_EXECUTION(Value); | 2751 RETURN_ON_FAILED_EXECUTION(Value); |
2751 RETURN_ESCAPED(result); | 2752 RETURN_ESCAPED(result); |
2752 } | 2753 } |
2753 | 2754 |
2754 MaybeLocal<Value> JSON::Parse(Local<Context> context, | 2755 MaybeLocal<Value> JSON::Parse(Local<Context> context, |
2755 Local<String> json_string) { | 2756 Local<String> json_string) { |
2756 PREPARE_FOR_EXECUTION(context, JSON, Parse, Value); | 2757 PREPARE_FOR_EXECUTION(context, JSON, Parse, Value); |
2757 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2758 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
2758 i::Handle<i::String> source = i::String::Flatten(string); | 2759 i::Handle<i::String> source = i::String::Flatten(string); |
| 2760 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2759 auto maybe = source->IsSeqOneByteString() | 2761 auto maybe = source->IsSeqOneByteString() |
2760 ? i::JsonParser<true>::Parse(source) | 2762 ? i::JsonParser<true>::Parse(isolate, source, undefined) |
2761 : i::JsonParser<false>::Parse(source); | 2763 : i::JsonParser<false>::Parse(isolate, source, undefined); |
2762 Local<Value> result; | 2764 Local<Value> result; |
2763 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2765 has_pending_exception = !ToLocal<Value>(maybe, &result); |
2764 RETURN_ON_FAILED_EXECUTION(Value); | 2766 RETURN_ON_FAILED_EXECUTION(Value); |
2765 RETURN_ESCAPED(result); | 2767 RETURN_ESCAPED(result); |
2766 } | 2768 } |
2767 | 2769 |
2768 Local<Value> JSON::Parse(Local<String> json_string) { | 2770 Local<Value> JSON::Parse(Local<String> json_string) { |
2769 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); | 2771 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); |
2770 } | 2772 } |
2771 | 2773 |
(...skipping 6043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8815 Address callback_address = | 8817 Address callback_address = |
8816 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8818 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8817 VMState<EXTERNAL> state(isolate); | 8819 VMState<EXTERNAL> state(isolate); |
8818 ExternalCallbackScope call_scope(isolate, callback_address); | 8820 ExternalCallbackScope call_scope(isolate, callback_address); |
8819 callback(info); | 8821 callback(info); |
8820 } | 8822 } |
8821 | 8823 |
8822 | 8824 |
8823 } // namespace internal | 8825 } // namespace internal |
8824 } // namespace v8 | 8826 } // namespace v8 |
OLD | NEW |