Merge mozilla-central to tracemonkey.

This commit is contained in:
Chris Leary
2011-03-29 09:05:25 -07:00
289 changed files with 10416 additions and 7528 deletions

View File

@@ -309,8 +309,7 @@ Load(JSContext *cx,
{
uintN i;
JSString *str;
JSScript *script;
JSBool ok;
JSObject *scriptObj;
jsval result;
FILE *file;
@@ -332,18 +331,16 @@ Load(JSContext *cx,
JS_ReportError(cx, "cannot open file '%s' for reading", filename.ptr());
return JS_FALSE;
}
script = JS_CompileFileHandleForPrincipals(cx, obj, filename.ptr(), file,
Environment(cx)->GetPrincipal());
scriptObj = JS_CompileFileHandleForPrincipals(cx, obj, filename.ptr(), file,
Environment(cx)->GetPrincipal());
fclose(file);
if (!script)
if (!scriptObj)
return JS_FALSE;
ok = !Environment(cx)->ShouldCompileOnly()
? JS_ExecuteScript(cx, obj, script, &result)
: JS_TRUE;
JS_DestroyScript(cx, script);
if (!ok)
if (!Environment(cx)->ShouldCompileOnly() &&
!JS_ExecuteScript(cx, obj, scriptObj, &result)) {
return JS_FALSE;
}
}
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
@@ -595,7 +592,7 @@ ProcessFile(JSContext *cx,
XPCShellEnvironment* env = Environment(cx);
XPCShellEnvironment::AutoContextPusher pusher(env);
JSScript *script;
JSObject *scriptObj;
jsval result;
int lineno, startline;
JSBool ok, hitEOF;
@@ -635,14 +632,11 @@ ProcessFile(JSContext *cx,
return;
}
JSScript* script =
JSObject* scriptObj =
JS_CompileFileHandleForPrincipals(cx, obj, filename, file,
env->GetPrincipal());
if (script) {
if (!env->ShouldCompileOnly())
(void)JS_ExecuteScript(cx, obj, script, &result);
JS_DestroyScript(cx, script);
}
if (scriptObj && !env->ShouldCompileOnly())
(void)JS_ExecuteScript(cx, obj, scriptObj, &result);
return;
}
@@ -680,14 +674,14 @@ ProcessFile(JSContext *cx,
/* Clear any pending exception from previous failed compiles. */
JS_ClearPendingException(cx);
script =
scriptObj =
JS_CompileScriptForPrincipals(cx, obj, env->GetPrincipal(), buffer,
strlen(buffer), "typein", startline);
if (script) {
if (scriptObj) {
JSErrorReporter older;
if (!env->ShouldCompileOnly()) {
ok = JS_ExecuteScript(cx, obj, script, &result);
ok = JS_ExecuteScript(cx, obj, scriptObj, &result);
if (ok && result != JSVAL_VOID) {
/* Suppress error reports from JS_ValueToString(). */
older = JS_SetErrorReporter(cx, NULL);
@@ -703,7 +697,6 @@ ProcessFile(JSContext *cx,
ok = JS_FALSE;
}
}
JS_DestroyScript(cx, script);
}
} while (!hitEOF && !env->IsQuitting());
@@ -1254,11 +1247,11 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
return false;
}
JSScript* script =
JSObject* scriptObj =
JS_CompileUCScriptForPrincipals(mCx, global, GetPrincipal(),
aString.get(), aString.Length(),
"typein", 0);
if (!script) {
if (!scriptObj) {
return false;
}
@@ -1268,7 +1261,7 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
}
jsval result;
JSBool ok = JS_ExecuteScript(mCx, global, script, &result);
JSBool ok = JS_ExecuteScript(mCx, global, scriptObj, &result);
if (ok && result != JSVAL_VOID) {
JSErrorReporter old = JS_SetErrorReporter(mCx, NULL);
JSString* str = JS_ValueToString(mCx, result);
@@ -1283,7 +1276,5 @@ XPCShellEnvironment::EvaluateString(const nsString& aString,
}
}
JS_DestroyScript(mCx, script);
return true;
}