2008-08-24 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authorcwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Aug 2008 04:08:01 +0000 (04:08 +0000)
committercwzwarich@webkit.org <cwzwarich@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Aug 2008 04:08:01 +0000 (04:08 +0000)
        Reviewed by Oliver Hunt.

        Bug 20093: JSC shell does not clear exceptions after it executes toString on an expression
        <https://bugs.webkit.org/show_bug.cgi?id=20093>

        Clear exceptions after evaluating any code in the JSC shell. We do not
        report exceptions that are caused by calling toString on the final
        valued, but at least we avoid incorrect behaviour.

        Also, print any exceptions that occurred while evaluating code at the
        interactive prompt, not just while evaluating code from a file.

        * kjs/Shell.cpp:
        (runWithScripts):
        (runInteractive):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35911 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/Shell.cpp

index 9d3b24d..04a3287 100644 (file)
@@ -1,3 +1,21 @@
+2008-08-24  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Oliver Hunt.
+
+        Bug 20093: JSC shell does not clear exceptions after it executes toString on an expression
+        <https://bugs.webkit.org/show_bug.cgi?id=20093>
+
+        Clear exceptions after evaluating any code in the JSC shell. We do not
+        report exceptions that are caused by calling toString on the final
+        valued, but at least we avoid incorrect behaviour.
+
+        Also, print any exceptions that occurred while evaluating code at the
+        interactive prompt, not just while evaluating code from a file.
+
+        * kjs/Shell.cpp:
+        (runWithScripts):
+        (runInteractive):
+
 2008-08-24  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Oliver Hunt.
index c2569a8..a37d464 100644 (file)
@@ -350,12 +350,14 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<UString>& fi
             Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 1, script.data());
             success = success && completion.complType() != Throw;
             if (dump) {
-                if (success)
-                    printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
-                else
+                if (completion.complType() == Throw)
                     printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
+                else
+                    printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
             }
 
+            globalObject->globalExec()->clearException();
+
 #if ENABLE(SAMPLING_TOOL)
             machine->m_sampler->stop();
             machine->m_sampler->dump(globalObject->globalExec());
@@ -390,8 +392,12 @@ static void runInteractive(GlobalObject* globalObject)
         line.append('\0');
         Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), interpreterName, 1, line.data());
 #endif
-        if (completion.isValueCompletion())
+        if (completion.complType() == Throw)
+            printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
+        else
             printf("%s\n", completion.value()->toString(globalObject->globalExec()).UTF8String().c_str());
+
+        globalObject->globalExec()->clearException();
     }
     printf("\n");
 }