| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } else { | 181 } else { |
| 182 return SerializeObject(value, replacer, stack, indent, gap); | 182 return SerializeObject(value, replacer, stack, indent, gap); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 // Undefined or a callable object. | 185 // Undefined or a callable object. |
| 186 return UNDEFINED; | 186 return UNDEFINED; |
| 187 } | 187 } |
| 188 | 188 |
| 189 | 189 |
| 190 function JSONStringify(value, replacer, space) { | 190 function JSONStringify(value, replacer, space) { |
| 191 if (%_ArgumentsLength() == 1 && !%_IsJSProxy(value)) { | 191 if (%_ArgumentsLength() == 1 && !IS_PROXY(value)) { |
| 192 return %BasicJSONStringify(value); | 192 return %BasicJSONStringify(value); |
| 193 } | 193 } |
| 194 if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) { | 194 if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) { |
| 195 var property_list = new InternalArray(); | 195 var property_list = new InternalArray(); |
| 196 var seen_properties = new GlobalSet(); | 196 var seen_properties = new GlobalSet(); |
| 197 var length = TO_LENGTH(replacer.length); | 197 var length = TO_LENGTH(replacer.length); |
| 198 for (var i = 0; i < length; i++) { | 198 for (var i = 0; i < length; i++) { |
| 199 var v = replacer[i]; | 199 var v = replacer[i]; |
| 200 var item; | 200 var item; |
| 201 if (IS_STRING(v)) { | 201 if (IS_STRING(v)) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 function JsonSerializeAdapter(key, object) { | 254 function JsonSerializeAdapter(key, object) { |
| 255 var holder = {}; | 255 var holder = {}; |
| 256 holder[key] = object; | 256 holder[key] = object; |
| 257 // No need to pass the actual holder since there is no replacer function. | 257 // No need to pass the actual holder since there is no replacer function. |
| 258 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); | 258 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); |
| 259 } | 259 } |
| 260 | 260 |
| 261 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); | 261 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); |
| 262 | 262 |
| 263 }) | 263 }) |
| OLD | NEW |