Chromium Code Reviews| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 space = MaxSimple(0, MinSimple(TO_INTEGER(space), 10)); | 226 space = MaxSimple(0, MinSimple(TO_INTEGER(space), 10)); |
| 227 gap = %_SubString(" ", 0, space); | 227 gap = %_SubString(" ", 0, space); |
| 228 } else if (IS_STRING(space)) { | 228 } else if (IS_STRING(space)) { |
| 229 if (space.length > 10) { | 229 if (space.length > 10) { |
| 230 gap = %_SubString(space, 0, 10); | 230 gap = %_SubString(space, 0, 10); |
| 231 } else { | 231 } else { |
| 232 gap = space; | 232 gap = space; |
| 233 } | 233 } |
| 234 } else { | 234 } else { |
| 235 gap = ""; | 235 gap = ""; |
| 236 } | 236 } |
|
Yang
2016/02/19 10:36:34
whitespace before "!gap".
| |
| 237 if (!IS_CALLABLE(replacer) && !property_list &&!gap && !IS_PROXY(value)) { | |
| 238 return %BasicJSONStringify(value); | |
| 239 } | |
| 237 return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap); | 240 return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap); |
| 238 } | 241 } |
| 239 | 242 |
| 240 // ------------------------------------------------------------------- | 243 // ------------------------------------------------------------------- |
| 241 | 244 |
| 242 %AddNamedProperty(GlobalJSON, toStringTagSymbol, "JSON", READ_ONLY | DONT_ENUM); | 245 %AddNamedProperty(GlobalJSON, toStringTagSymbol, "JSON", READ_ONLY | DONT_ENUM); |
| 243 | 246 |
| 244 // Set up non-enumerable properties of the JSON object. | 247 // Set up non-enumerable properties of the JSON object. |
| 245 utils.InstallFunctions(GlobalJSON, DONT_ENUM, [ | 248 utils.InstallFunctions(GlobalJSON, DONT_ENUM, [ |
| 246 "parse", JSONParse, | 249 "parse", JSONParse, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 271 function JsonSerializeAdapter(key, object) { | 274 function JsonSerializeAdapter(key, object) { |
| 272 var holder = {}; | 275 var holder = {}; |
| 273 holder[key] = object; | 276 holder[key] = object; |
| 274 // No need to pass the actual holder since there is no replacer function. | 277 // No need to pass the actual holder since there is no replacer function. |
| 275 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); | 278 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); |
| 276 } | 279 } |
| 277 | 280 |
| 278 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); | 281 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); |
| 279 | 282 |
| 280 }) | 283 }) |
| OLD | NEW |