| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index 17502bce90e8a7c512affbf8318bcb19f1e11136..04e1b89f9a518c740efe8f349a0e209f61394d2f 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,6 +2748,19 @@ 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*>(
|
| @@ -2756,6 +2768,20 @@ Local<Value> JSON::Parse(Local<String> json_string) {
|
| RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value);
|
| }
|
|
|
| +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 ---
|
|
|
|
|