| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 BasicJSONSerialize(0, val, stack, builder); | 230 BasicJSONSerialize(0, val, stack, builder); |
| 231 if (before == builder.length) builder.push("null"); | 231 if (before == builder.length) builder.push("null"); |
| 232 for (var i = 1; i < len; i++) { | 232 for (var i = 1; i < len; i++) { |
| 233 builder.push(","); | 233 builder.push(","); |
| 234 before = builder.length; | 234 before = builder.length; |
| 235 BasicJSONSerialize(i, value[i], stack, builder); | 235 BasicJSONSerialize(i, value[i], stack, builder); |
| 236 if (before == builder.length) builder[before - 1] = ",null"; | 236 if (before == builder.length) builder[before - 1] = ",null"; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 stack.pop(); | 239 stack.pop(); |
| 240 builder.push("]"); | 240 builder.push("]"); |
| 241 } | 241 } |
| 242 | 242 |
| 243 | 243 |
| 244 function BasicSerializeObject(value, stack, builder) { | 244 function BasicSerializeObject(value, stack, builder) { |
| 245 if (!%PushIfAbsent(stack, value)) { | 245 if (!%PushIfAbsent(stack, value)) { |
| 246 throw MakeTypeError('circular_structure', $Array()); | 246 throw MakeTypeError('circular_structure', $Array()); |
| 247 } | 247 } |
| 248 builder.push("{"); | 248 builder.push("{"); |
| 249 var first = true; | 249 var first = true; |
| 250 for (var p in value) { | 250 for (var p in value) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 338 } |
| 339 | 339 |
| 340 function SetupJSON() { | 340 function SetupJSON() { |
| 341 InstallFunctions($JSON, DONT_ENUM, $Array( | 341 InstallFunctions($JSON, DONT_ENUM, $Array( |
| 342 "parse", JSONParse, | 342 "parse", JSONParse, |
| 343 "stringify", JSONStringify | 343 "stringify", JSONStringify |
| 344 )); | 344 )); |
| 345 } | 345 } |
| 346 | 346 |
| 347 SetupJSON(); | 347 SetupJSON(); |
| OLD | NEW |