Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1017)

Unified Diff: src/json.js

Issue 5862002: Version 3.0.2. (Closed)
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/json.js
diff --git a/src/json.js b/src/json.js
index c0af9d0e4630460c4429052f6d667b198b122e9d..e8b732a52aa81fc3f32ee6c9f5aeb2deb303afa8 100644
--- a/src/json.js
+++ b/src/json.js
@@ -66,10 +66,21 @@ function JSONParse(text, reviver) {
}
}
+function StackContains(stack, val) {
+ var length = stack.length;
+ for (var i = 0; i < length; i++) {
+ if (stack[i] === val) {
+ return true;
+ }
+ }
+ return false;
+}
+
function SerializeArray(value, replacer, stack, indent, gap) {
- if (!%PushIfAbsent(stack, value)) {
+ if (StackContains(stack, value)) {
throw MakeTypeError('circular_structure', []);
}
+ stack.push(value);
var stepback = indent;
indent += gap;
var partial = [];
@@ -97,9 +108,10 @@ function SerializeArray(value, replacer, stack, indent, gap) {
}
function SerializeObject(value, replacer, stack, indent, gap) {
- if (!%PushIfAbsent(stack, value)) {
+ if (StackContains(stack, value)) {
throw MakeTypeError('circular_structure', []);
}
+ stack.push(value);
var stepback = indent;
indent += gap;
var partial = [];
@@ -185,9 +197,10 @@ function JSONSerialize(key, holder, replacer, stack, indent, gap) {
function BasicSerializeArray(value, stack, builder) {
- if (!%PushIfAbsent(stack, value)) {
+ if (StackContains(stack, value)) {
throw MakeTypeError('circular_structure', []);
}
+ stack.push(value);
builder.push("[");
var len = value.length;
for (var i = 0; i < len; i++) {
@@ -207,9 +220,10 @@ function BasicSerializeArray(value, stack, builder) {
function BasicSerializeObject(value, stack, builder) {
- if (!%PushIfAbsent(stack, value)) {
+ if (StackContains(stack, value)) {
throw MakeTypeError('circular_structure', []);
}
+ stack.push(value);
builder.push("{");
for (var p in value) {
if (%HasLocalProperty(value, p)) {
« ChangeLog ('K') | « src/ia32/macro-assembler-ia32.cc ('k') | src/lithium-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698