Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: src/builtins/builtins-json.cc

Issue 2165593002: [builtins] Move builtins into own files (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove builtins-error.cc from BUILD.gn Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-internal.cc ('k') | src/builtins/builtins-math.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h"
7
8 #include "src/json-parser.h"
9 #include "src/json-stringifier.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // ES6 section 24.3.1 JSON.parse.
15 BUILTIN(JsonParse) {
16 HandleScope scope(isolate);
17 Handle<Object> source = args.atOrUndefined(isolate, 1);
18 Handle<Object> reviver = args.atOrUndefined(isolate, 2);
19 Handle<String> string;
20 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
21 Object::ToString(isolate, source));
22 string = String::Flatten(string);
23 RETURN_RESULT_OR_FAILURE(
24 isolate, string->IsSeqOneByteString()
25 ? JsonParser<true>::Parse(isolate, string, reviver)
26 : JsonParser<false>::Parse(isolate, string, reviver));
27 }
28
29 // ES6 section 24.3.2 JSON.stringify.
30 BUILTIN(JsonStringify) {
31 HandleScope scope(isolate);
32 JsonStringifier stringifier(isolate);
33 Handle<Object> object = args.atOrUndefined(isolate, 1);
34 Handle<Object> replacer = args.atOrUndefined(isolate, 2);
35 Handle<Object> indent = args.atOrUndefined(isolate, 3);
36 RETURN_RESULT_OR_FAILURE(isolate,
37 stringifier.Stringify(object, replacer, indent));
38 }
39
40 } // namespace internal
41 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-internal.cc ('k') | src/builtins/builtins-math.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698