From 830d0378210e5a0987789150c805dad5d6361e8f Mon Sep 17 00:00:00 2001 From: "rogerl%netscape.com" Date: Wed, 3 Nov 1999 23:57:56 +0000 Subject: [PATCH] Fix nested finally endless loop. Replaced Closure object with FunctionObject clone. git-svn-id: svn://10.0.0.236/trunk@52754 18797224-902f-48f8-a5cc-f745e15eee43 --- .../org/mozilla/javascript/Interpreter.java | 16 +++++++++++++--- .../src/org/mozilla/javascript/Interpreter.java | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/mozilla/js/rhino/org/mozilla/javascript/Interpreter.java b/mozilla/js/rhino/org/mozilla/javascript/Interpreter.java index 1f682da6cb0..a593cc23890 100644 --- a/mozilla/js/rhino/org/mozilla/javascript/Interpreter.java +++ b/mozilla/js/rhino/org/mozilla/javascript/Interpreter.java @@ -1803,9 +1803,16 @@ public class Interpreter extends LabelTable { stack[++stackTop] = scope; break; case TokenStream.CLOSURE : - i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF); - stack[++stackTop] = new NativeClosure(cx, scope, - theData.itsNestedFunctions[i]); + i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF); + if (theData.itsNestedFunctions[i] + instanceof InterpretedFunction) + stack[++stackTop] + = new InterpretedFunction( + (InterpretedFunction) + (theData.itsNestedFunctions[i]), + scope); + else + stack[++stackTop] = ScriptRuntime.createFunctionObject(scope, theData.itsNestedFunctions[i].getClass(), cx); pc += 2; break; case TokenStream.OBJECT : @@ -1841,6 +1848,7 @@ public class Interpreter extends LabelTable { if (pc == 0) throw ee; stack[0] = ee.getErrorObject(); + tryStackTop--; } else stack[0] = ee.getErrorObject(); @@ -1862,6 +1870,7 @@ public class Interpreter extends LabelTable { if (pc == 0) throw jsx; stack[0] = jsx; + tryStackTop--; } else stack[0] = ScriptRuntime.unwrapJavaScriptException(jsx); @@ -1886,6 +1895,7 @@ public class Interpreter extends LabelTable { pc = finallyStack[tryStackTop - 1]; scope = scopeStack[tryStackTop - 1]; if (pc == 0) throw jx; + tryStackTop--; } else throw jx; diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java b/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java index 1f682da6cb0..a593cc23890 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/Interpreter.java @@ -1803,9 +1803,16 @@ public class Interpreter extends LabelTable { stack[++stackTop] = scope; break; case TokenStream.CLOSURE : - i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF); - stack[++stackTop] = new NativeClosure(cx, scope, - theData.itsNestedFunctions[i]); + i = (iCode[pc + 1] << 8) | (iCode[pc + 2] & 0xFF); + if (theData.itsNestedFunctions[i] + instanceof InterpretedFunction) + stack[++stackTop] + = new InterpretedFunction( + (InterpretedFunction) + (theData.itsNestedFunctions[i]), + scope); + else + stack[++stackTop] = ScriptRuntime.createFunctionObject(scope, theData.itsNestedFunctions[i].getClass(), cx); pc += 2; break; case TokenStream.OBJECT : @@ -1841,6 +1848,7 @@ public class Interpreter extends LabelTable { if (pc == 0) throw ee; stack[0] = ee.getErrorObject(); + tryStackTop--; } else stack[0] = ee.getErrorObject(); @@ -1862,6 +1870,7 @@ public class Interpreter extends LabelTable { if (pc == 0) throw jsx; stack[0] = jsx; + tryStackTop--; } else stack[0] = ScriptRuntime.unwrapJavaScriptException(jsx); @@ -1886,6 +1895,7 @@ public class Interpreter extends LabelTable { pc = finallyStack[tryStackTop - 1]; scope = scopeStack[tryStackTop - 1]; if (pc == 0) throw jx; + tryStackTop--; } else throw jx;