LCOV - code coverage report
Current view: top level - src/builtins - builtins-json.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 12 100.0 %
Date: 2017-04-26 Functions: 4 6 66.7 %

          Line data    Source code
       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/counters.h"
       9             : #include "src/json-parser.h"
      10             : #include "src/json-stringifier.h"
      11             : #include "src/objects-inl.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // ES6 section 24.3.1 JSON.parse.
      17     2077431 : BUILTIN(JsonParse) {
      18             :   HandleScope scope(isolate);
      19      692477 :   Handle<Object> source = args.atOrUndefined(isolate, 1);
      20      692477 :   Handle<Object> reviver = args.atOrUndefined(isolate, 2);
      21             :   Handle<String> string;
      22     1384954 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, string,
      23             :                                      Object::ToString(isolate, source));
      24      692477 :   string = String::Flatten(string);
      25     2076350 :   RETURN_RESULT_OR_FAILURE(
      26             :       isolate, string->IsSeqOneByteString()
      27             :                    ? JsonParser<true>::Parse(isolate, string, reviver)
      28             :                    : JsonParser<false>::Parse(isolate, string, reviver));
      29             : }
      30             : 
      31             : // ES6 section 24.3.2 JSON.stringify.
      32     5207934 : BUILTIN(JsonStringify) {
      33             :   HandleScope scope(isolate);
      34     1735978 :   JsonStringifier stringifier(isolate);
      35     1735978 :   Handle<Object> object = args.atOrUndefined(isolate, 1);
      36     1735978 :   Handle<Object> replacer = args.atOrUndefined(isolate, 2);
      37     1735978 :   Handle<Object> indent = args.atOrUndefined(isolate, 3);
      38     5207652 :   RETURN_RESULT_OR_FAILURE(isolate,
      39             :                            stringifier.Stringify(object, replacer, indent));
      40             : }
      41             : 
      42             : }  // namespace internal
      43             : }  // namespace v8

Generated by: LCOV version 1.10