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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } else { | 180 } else { |
181 return SerializeObject(value, replacer, stack, indent, gap); | 181 return SerializeObject(value, replacer, stack, indent, gap); |
182 } | 182 } |
183 } | 183 } |
184 // Undefined or a callable object. | 184 // Undefined or a callable object. |
185 return UNDEFINED; | 185 return UNDEFINED; |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 function JSONStringify(value, replacer, space) { | 189 function JSONStringify(value, replacer, space) { |
190 if (%_ArgumentsLength() == 1 && !IS_PROXY(value)) { | 190 if (arguments.length === 1 && !IS_PROXY(value)) { |
191 return %BasicJSONStringify(value); | 191 return %BasicJSONStringify(value); |
192 } | 192 } |
193 if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) { | 193 if (!IS_CALLABLE(replacer) && %is_arraylike(replacer)) { |
194 var property_list = new InternalArray(); | 194 var property_list = new InternalArray(); |
195 var seen_properties = new GlobalSet(); | 195 var seen_properties = new GlobalSet(); |
196 var length = TO_LENGTH(replacer.length); | 196 var length = TO_LENGTH(replacer.length); |
197 for (var i = 0; i < length; i++) { | 197 for (var i = 0; i < length; i++) { |
198 var v = replacer[i]; | 198 var v = replacer[i]; |
199 var item; | 199 var item; |
200 if (IS_STRING(v)) { | 200 if (IS_STRING(v)) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 function JsonSerializeAdapter(key, object) { | 271 function JsonSerializeAdapter(key, object) { |
272 var holder = {}; | 272 var holder = {}; |
273 holder[key] = object; | 273 holder[key] = object; |
274 // No need to pass the actual holder since there is no replacer function. | 274 // No need to pass the actual holder since there is no replacer function. |
275 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); | 275 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); |
276 } | 276 } |
277 | 277 |
278 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); | 278 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); |
279 | 279 |
280 }) | 280 }) |
OLD | NEW |