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

Side by Side Diff: src/js/json.js

Issue 2026643003: [json] replace remaining json.js code with C++ builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix error message Created 4 years, 6 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.cc ('k') | src/runtime/runtime.h » ('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 2009 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 (function(global, utils) {
6
7 "use strict";
8
9 %CheckIsBootstrapping();
10
11 // -------------------------------------------------------------------
12 // Imports
13
14 var GlobalDate = global.Date;
15 var GlobalJSON = global.JSON;
16 var GlobalSet = global.Set;
17 var InternalArray = utils.InternalArray;
18 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
19
20 // -------------------------------------------------------------------
21
22 function JSONParse(text, reviver) {
23 return %ParseJson(text, reviver);
24 }
25
26 // -------------------------------------------------------------------
27
28 %AddNamedProperty(GlobalJSON, toStringTagSymbol, "JSON", READ_ONLY | DONT_ENUM);
29
30 // Set up non-enumerable properties of the JSON object.
31 utils.InstallFunctions(GlobalJSON, DONT_ENUM, [
32 "parse", JSONParse,
33 ]);
34
35 // -------------------------------------------------------------------
36 // Date.toJSON
37
38 // 20.3.4.37 Date.prototype.toJSON ( key )
39 function DateToJSON(key) {
40 var o = TO_OBJECT(this);
41 var tv = TO_PRIMITIVE_NUMBER(o);
42 if (IS_NUMBER(tv) && !NUMBER_IS_FINITE(tv)) {
43 return null;
44 }
45 return o.toISOString();
46 }
47
48 // Set up non-enumerable functions of the Date prototype object.
49 utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
50 "toJSON", DateToJSON
51 ]);
52
53 })
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698