Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 17502bce90e8a7c512affbf8318bcb19f1e11136..fe214d72a14f7d1a3dd0e6f4fb6bc778c4659ebc 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -49,12 +49,12 @@ |
#include "src/profiler/heap-snapshot-generator-inl.h" |
#include "src/profiler/profile-generator-inl.h" |
#include "src/profiler/sampler.h" |
-#include "src/property.h" |
#include "src/property-descriptor.h" |
#include "src/property-details.h" |
+#include "src/property.h" |
#include "src/prototype.h" |
-#include "src/runtime/runtime.h" |
#include "src/runtime-profiler.h" |
+#include "src/runtime/runtime.h" |
#include "src/simulator.h" |
#include "src/snapshot/natives.h" |
#include "src/snapshot/snapshot.h" |
@@ -66,7 +66,6 @@ |
#include "src/version.h" |
#include "src/vm-state-inl.h" |
- |
namespace v8 { |
#define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
@@ -2749,13 +2748,38 @@ MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { |
RETURN_ESCAPED(result); |
} |
+MaybeLocal<Value> JSON::Parse(Local<Context> context, |
+ Local<String> json_string) { |
+ PREPARE_FOR_EXECUTION(context, "JSON::Parse", Value); |
+ i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
+ i::Handle<i::String> source = i::String::Flatten(string); |
+ auto maybe = source->IsSeqOneByteString() |
+ ? i::JsonParser<true>::Parse(source) |
+ : i::JsonParser<false>::Parse(source); |
+ Local<Value> result; |
+ has_pending_exception = !ToLocal<Value>(maybe, &result); |
+ RETURN_ON_FAILED_EXECUTION(Value); |
+ RETURN_ESCAPED(result); |
+} |
Local<Value> JSON::Parse(Local<String> json_string) { |
- auto isolate = reinterpret_cast<v8::Isolate*>( |
- Utils::OpenHandle(*json_string)->GetIsolate()); |
- RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value); |
+ RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); |
haavardm
2016/04/15 12:31:58
Is using an empty context correct here? (alternati
|
} |
+MaybeLocal<String> JSON::Stringify(Local<Context> context, |
+ Local<Object> json_object) { |
+ PREPARE_FOR_EXECUTION(context, "JSON::Stringify", String); |
+ i::Handle<i::Object> object = Utils::OpenHandle(*json_object); |
+ i::Handle<i::Object> maybe; |
+ has_pending_exception = |
+ !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); |
+ RETURN_ON_FAILED_EXECUTION(String); |
+ Local<String> result; |
+ has_pending_exception = |
+ !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); |
+ RETURN_ON_FAILED_EXECUTION(String); |
+ RETURN_ESCAPED(result); |
+} |
// --- D a t a --- |