Bug 889714 - Removed unused ShouldReportWarnings and ShouldCompoleOnly [sic] machinery. r=mrbkap
authorBobby Holley <bobbyholley@gmail.com>
Wed, 31 Jul 2013 10:59:25 -0700
changeset 148165 ad0360cc0bcdb9335621e7ca2492ced9e46e1264
parent 148164 772aac97a20ccae01d6a50f88d43ebae8877db29
child 148166 b1f6174317519cd9efa2c522d2e17d48946dee26
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs889714
milestone24.0a2
Bug 889714 - Removed unused ShouldReportWarnings and ShouldCompoleOnly [sic] machinery. r=mrbkap lol @ 'ShouldCompoleOnly'.
ipc/testshell/XPCShellEnvironment.cpp
ipc/testshell/XPCShellEnvironment.h
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -1,9 +1,10 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
+/* vim: set ts=8 sts=4 et sw=4 tw=80:
+ * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdlib.h>
 #include <errno.h>
 #ifdef HAVE_IO_H
 #include <io.h>     /* for isatty() */
 #endif
@@ -114,22 +115,16 @@ ScriptErrorReporter(JSContext *cx,
         }
     }
 
     if (!report) {
         fprintf(stderr, "%s\n", message);
         return;
     }
 
-    /* Conditionally ignore reported warnings. */
-    if (JSREPORT_IS_WARNING(report->flags) &&
-        !Environment(cx)->ShouldReportWarnings()) {
-        return;
-    }
-
     if (report->filename)
         prefix = JS_smprintf("%s:", report->filename);
     if (report->lineno) {
         tmp = prefix;
         prefix = JS_smprintf("%s%u: ", tmp ? tmp : "", report->lineno);
         JS_free(cx, tmp);
     }
     if (JSREPORT_IS_WARNING(report->flags)) {
@@ -285,18 +280,17 @@ Load(JSContext *cx,
                .setFileAndLine(filename.ptr(), 1)
                .setPrincipals(Environment(cx)->GetPrincipal());
         JS::RootedObject rootedObj(cx, obj);
         JSScript *script = JS::Compile(cx, rootedObj, options, file);
         fclose(file);
         if (!script)
             return JS_FALSE;
 
-        if (!Environment(cx)->ShouldCompileOnly() &&
-            !JS_ExecuteScript(cx, obj, script, result.address())) {
+        if (!JS_ExecuteScript(cx, obj, script, result.address())) {
             return JS_FALSE;
         }
     }
     JS_SET_RVAL(cx, vp, JSVAL_VOID);
     return JS_TRUE;
 }
 
 static JSBool
@@ -549,17 +543,17 @@ ProcessFile(JSContext *cx,
         JSAutoRequest ar(cx);
         JSAutoCompartment ac(cx, obj);
 
         JS::CompileOptions options(cx);
         options.setUTF8(true)
                .setFileAndLine(filename, 1)
                .setPrincipals(env->GetPrincipal());
         JSScript* script = JS::Compile(cx, obj, options, file);
-        if (script && !env->ShouldCompileOnly())
+        if (script)
             (void)JS_ExecuteScript(cx, obj, script, result.address());
 
         return;
     }
 
     /* It's an interactive filehandle; drop into read-eval-print loop. */
     lineno = 1;
     hitEOF = JS_FALSE;
@@ -589,32 +583,30 @@ ProcessFile(JSContext *cx,
         /* Clear any pending exception from previous failed compiles.  */
         JS_ClearPendingException(cx);
         script =
             JS_CompileScriptForPrincipals(cx, obj, env->GetPrincipal(), buffer,
                                           strlen(buffer), "typein", startline);
         if (script) {
             JSErrorReporter older;
 
-            if (!env->ShouldCompileOnly()) {
-                ok = JS_ExecuteScript(cx, obj, script, result.address());
-                if (ok && result != JSVAL_VOID) {
-                    /* Suppress error reports from JS_ValueToString(). */
-                    older = JS_SetErrorReporter(cx, NULL);
-                    str = JS_ValueToString(cx, result);
-                    JSAutoByteString bytes;
-                    if (str)
-                        bytes.encodeLatin1(cx, str);
-                    JS_SetErrorReporter(cx, older);
+            ok = JS_ExecuteScript(cx, obj, script, result.address());
+            if (ok && result != JSVAL_VOID) {
+                /* Suppress error reports from JS_ValueToString(). */
+                older = JS_SetErrorReporter(cx, NULL);
+                str = JS_ValueToString(cx, result);
+                JSAutoByteString bytes;
+                if (str)
+                    bytes.encodeLatin1(cx, str);
+                JS_SetErrorReporter(cx, older);
 
-                    if (!!bytes)
-                        fprintf(stdout, "%s\n", bytes.ptr());
-                    else
-                        ok = JS_FALSE;
-                }
+                if (!!bytes)
+                    fprintf(stdout, "%s\n", bytes.ptr());
+                else
+                    ok = JS_FALSE;
             }
         }
     } while (!hitEOF && !env->IsQuitting());
 
     fprintf(stdout, "\n");
 }
 
 } /* anonymous namespace */
@@ -665,19 +657,17 @@ XPCShellEnvironment::CreateEnvironment()
     }
     return env;
 }
 
 XPCShellEnvironment::XPCShellEnvironment()
 :   mCx(NULL),
     mJSPrincipals(NULL),
     mExitCode(0),
-    mQuitting(JS_FALSE),
-    mReportWarnings(JS_TRUE),
-    mCompileOnly(JS_FALSE)
+    mQuitting(JS_FALSE)
 {
 }
 
 XPCShellEnvironment::~XPCShellEnvironment()
 {
     if (mCx) {
         JS_BeginRequest(mCx);
 
@@ -846,31 +836,29 @@ XPCShellEnvironment::EvaluateString(cons
   JSScript* script =
       JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
                                       aString.get(), aString.Length(),
                                       "typein", 0);
   if (!script) {
      return false;
   }
 
-  if (!ShouldCompileOnly()) {
-      if (aResult) {
-          aResult->Truncate();
-      }
+  if (aResult) {
+      aResult->Truncate();
+  }
 
-      JS::Rooted<JS::Value> result(mCx);
-      JSBool ok = JS_ExecuteScript(mCx, global, script, result.address());
-      if (ok && result != JSVAL_VOID) {
-          JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
-          JSString* str = JS_ValueToString(mCx, result);
-          nsDependentJSString depStr;
-          if (str)
-              depStr.init(mCx, str);
-          JS_SetErrorReporter(mCx, old);
+  JS::Rooted<JS::Value> result(mCx);
+  JSBool ok = JS_ExecuteScript(mCx, global, script, result.address());
+  if (ok && result != JSVAL_VOID) {
+      JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
+      JSString* str = JS_ValueToString(mCx, result);
+      nsDependentJSString depStr;
+      if (str)
+          depStr.init(mCx, str);
+      JS_SetErrorReporter(mCx, old);
 
-          if (!depStr.IsEmpty() && aResult) {
-              aResult->Assign(depStr);
-          }
+      if (!depStr.IsEmpty() && aResult) {
+          aResult->Assign(depStr);
       }
   }
 
   return true;
 }
--- a/ipc/testshell/XPCShellEnvironment.h
+++ b/ipc/testshell/XPCShellEnvironment.h
@@ -52,41 +52,25 @@ public:
 
     void SetIsQuitting() {
         mQuitting = JS_TRUE;
     }
     JSBool IsQuitting() {
         return mQuitting;
     }
 
-    void SetShouldReportWarnings(JSBool aReportWarnings) {
-        mReportWarnings = aReportWarnings;
-    }
-    JSBool ShouldReportWarnings() {
-        return mReportWarnings;
-    }
-
-    void SetShouldCompoleOnly(JSBool aCompileOnly) {
-        mCompileOnly = aCompileOnly;
-    }
-    JSBool ShouldCompileOnly() {
-        return mCompileOnly;
-    }
-
 protected:
     XPCShellEnvironment();
     bool Init();
 
 private:
     JSContext* mCx;
     nsAutoJSValHolder mGlobalHolder;
     JSPrincipals* mJSPrincipals;
 
     int mExitCode;
     JSBool mQuitting;
-    JSBool mReportWarnings;
-    JSBool mCompileOnly;
 };
 
 } /* namespace ipc */
 } /* namespace mozilla */
 
 #endif /* _IPC_TESTSHELL_XPCSHELLENVIRONMENT_H_ */