| OLD | NEW |
| (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 }) | |
| OLD | NEW |