Bug 823978 - Rename JSOPTION_STRICT to JSOPTION_EXTRA_WARNINGS. r=Waldo

--HG--
extra : rebase_source : f5c0e9c743dadb0431eacef6b46b6e274264d3aa
This commit is contained in:
Benjamin Peterson 2013-06-11 10:55:21 -07:00
Родитель 7996f69d48
Коммит 6a8ee25998
16 изменённых файлов: 56 добавлений и 54 удалений

Просмотреть файл

@ -988,9 +988,9 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
bool strict = Preferences::GetBool(js_strict_option_str);
if (strict)
newDefaultJSOptions |= JSOPTION_STRICT;
newDefaultJSOptions |= JSOPTION_EXTRA_WARNINGS;
else
newDefaultJSOptions &= ~JSOPTION_STRICT;
newDefaultJSOptions &= ~JSOPTION_EXTRA_WARNINGS;
// The vanilla GetGlobalObject returns null if a global isn't set up on
// the context yet. We can sometimes be call midway through context init,
@ -1056,9 +1056,9 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
// In debug builds, warnings are enabled in chrome context if
// javascript.options.strict.debug is true
bool strictDebug = Preferences::GetBool(js_strict_debug_option_str);
if (strictDebug && (newDefaultJSOptions & JSOPTION_STRICT) == 0) {
if (strictDebug && (newDefaultJSOptions & JSOPTION_EXTRA_WARNINGS) == 0) {
if (chromeWindow || !contentWindow)
newDefaultJSOptions |= JSOPTION_STRICT;
newDefaultJSOptions |= JSOPTION_WARNINGS;
}
#endif

Просмотреть файл

@ -285,7 +285,7 @@ LoadJSContextOptions(const char* aPrefName, void* /* aClosure */)
// Common options.
uint32_t commonOptions = kRequiredJSContextOptions;
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict"))) {
commonOptions |= JSOPTION_STRICT;
commonOptions |= JSOPTION_EXTRA_WARNINGS;
}
if (GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror"))) {
commonOptions |= JSOPTION_WERROR;

Просмотреть файл

@ -1319,7 +1319,7 @@ class ObjectBox {
enum ParseReportKind {
ParseError,
ParseWarning,
ParseStrictWarning,
ParseExtraWarning,
ParseStrictError
};

Просмотреть файл

@ -350,7 +350,7 @@ Parser<ParseHandler>::reportHelper(ParseReportKind kind, bool strict, uint32_t o
result =
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_WARNING, errorNumber, args);
break;
case ParseStrictWarning:
case ParseExtraWarning:
result = tokenStream.reportStrictWarningErrorNumberVA(offset, errorNumber, args);
break;
case ParseStrictError:
@ -424,10 +424,10 @@ Parser<ParseHandler>::Parser(JSContext *cx, const CompileOptions &options,
cx->runtime()->activeCompilations++;
// The Mozilla specific 'strict' option adds extra warnings which are not
// generated if functions are parsed lazily. Note that the standard
// "use strict" does not inhibit lazy parsing.
if (context->hasStrictOption())
// The Mozilla specific JSOPTION_EXTRA_WARNINGS option adds extra warnings
// which are not generated if functions are parsed lazily. Note that the
// standard "use strict" does not inhibit lazy parsing.
if (context->hasExtraWarningsOption())
handler.disableSyntaxParser();
tempPoolMark = cx->tempLifoAlloc().mark();
@ -792,7 +792,7 @@ Parser<ParseHandler>::checkFinalReturn(Node pn)
{
JS_ASSERT(pc->sc->isFunctionBox());
return HasFinalReturn(pn) == ENDS_IN_RETURN ||
reportBadReturn(pn, ParseStrictWarning,
reportBadReturn(pn, ParseExtraWarning,
JSMSG_NO_RETURN_VALUE, JSMSG_ANON_NO_RETURN_VALUE);
}
@ -1060,7 +1060,7 @@ Parser<ParseHandler>::functionBody(FunctionSyntaxKind kind, FunctionBodyType typ
}
/* Check for falling off the end of a function that returns a value. */
if (context->hasStrictOption() && pc->funHasReturnExpr && !checkFinalReturn(pn))
if (context->hasExtraWarningsOption() && pc->funHasReturnExpr && !checkFinalReturn(pn))
return null();
if (kind != Arrow) {
@ -1716,10 +1716,10 @@ Parser<FullParseHandler>::checkFunctionDefinition(HandlePropertyName funName,
JS_ASSERT(!dn->isUsed());
JS_ASSERT(dn->isDefn());
if (context->hasStrictOption() || dn->kind() == Definition::CONST) {
if (context->hasExtraWarningsOption() || dn->kind() == Definition::CONST) {
JSAutoByteString name;
ParseReportKind reporter = (dn->kind() != Definition::CONST)
? ParseStrictWarning
? ParseExtraWarning
: ParseError;
if (!js_AtomToPrintableString(context, funName, &name) ||
!report(reporter, false, NULL, JSMSG_REDECLARED_VAR,
@ -2610,7 +2610,7 @@ Parser<ParseHandler>::condition()
/* Check for (a = b) and warn about possible (a == b) mistype. */
if (handler.isOperationWithoutParens(pn, PNK_ASSIGN) &&
!report(ParseStrictWarning, false, null(), JSMSG_EQUAL_AS_ASSIGN))
!report(ParseExtraWarning, false, null(), JSMSG_EQUAL_AS_ASSIGN))
{
return null();
}
@ -2884,7 +2884,7 @@ Parser<ParseHandler>::bindVarOrConst(JSContext *cx, BindData<ParseHandler> *data
parser->report(ParseError, false, pn, JSMSG_REDECLARED_PARAM, bytes.ptr());
return false;
}
if (!parser->report(ParseStrictWarning, false, pn, JSMSG_VAR_HIDES_ARG, bytes.ptr()))
if (!parser->report(ParseExtraWarning, false, pn, JSMSG_VAR_HIDES_ARG, bytes.ptr()))
return false;
} else {
bool error = (isConstDecl ||
@ -2892,12 +2892,12 @@ Parser<ParseHandler>::bindVarOrConst(JSContext *cx, BindData<ParseHandler> *data
(dn_kind == Definition::LET &&
(stmt->type != STMT_CATCH || OuterLet(pc, stmt, name))));
if (cx->hasStrictOption()
if (cx->hasExtraWarningsOption()
? data->op != JSOP_DEFVAR || dn_kind != Definition::VAR
: error)
{
JSAutoByteString bytes;
ParseReportKind reporter = error ? ParseError : ParseStrictWarning;
ParseReportKind reporter = error ? ParseError : ParseExtraWarning;
if (!js_AtomToPrintableString(cx, name, &bytes) ||
!parser->report(reporter, false, pn, JSMSG_REDECLARED_VAR,
Definition::kindString(dn_kind), bytes.ptr()))
@ -3288,8 +3288,8 @@ Parser<ParseHandler>::returnOrYield(bool useAssignExpr)
return null();
}
if (context->hasStrictOption() && pc->funHasReturnExpr && pc->funHasReturnVoid &&
!reportBadReturn(pn, ParseStrictWarning,
if (context->hasExtraWarningsOption() && pc->funHasReturnExpr && pc->funHasReturnVoid &&
!reportBadReturn(pn, ParseExtraWarning,
JSMSG_NO_RETURN_VALUE, JSMSG_ANON_NO_RETURN_VALUE))
{
return null();
@ -4320,10 +4320,10 @@ Parser<ParseHandler>::withStatement()
uint32_t begin = tokenStream.currentToken().pos.begin;
// In most cases, we want the constructs forbidden in strict mode code to be
// a subset of those that JSOPTION_STRICT warns about, and we should use
// reportStrictModeError. However, 'with' is the sole instance of a
// a subset of those that JSOPTION_EXTRA_WARNINGS warns about, and we should
// use reportStrictModeError. However, 'with' is the sole instance of a
// construct that is forbidden in strict mode code, but doesn't even merit a
// warning under JSOPTION_STRICT. See
// warning under JSOPTION_EXTRA_WARNINGS. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=514576#c1.
if (pc->sc->strict && !report(ParseStrictError, true, null(), JSMSG_STRICT_CODE_WITH))
return null();
@ -4571,7 +4571,7 @@ Parser<ParseHandler>::statement()
return null();
if (handler.isEmptySemicolon(thenBranch) &&
!report(ParseStrictWarning, false, null(), JSMSG_EMPTY_CONSEQUENT))
!report(ParseExtraWarning, false, null(), JSMSG_EMPTY_CONSEQUENT))
{
return null();
}

Просмотреть файл

@ -24,7 +24,7 @@ SharedContext::SharedContext(JSContext *cx, bool strict)
inline bool
SharedContext::needStrictChecks()
{
return context->hasStrictOption() || strict;
return context->hasExtraWarningsOption() || strict;
}
inline GlobalSharedContext *

Просмотреть файл

@ -168,7 +168,7 @@ class SharedContext
void setBindingsAccessedDynamically() { anyCxFlags.bindingsAccessedDynamically = true; }
void setHasDebuggerStatement() { anyCxFlags.hasDebuggerStatement = true; }
// JSOPTION_STRICT warnings or strict mode errors.
// JSOPTION_EXTRA_WARNINGS warnings or strict mode errors.
inline bool needStrictChecks();
};

Просмотреть файл

@ -605,7 +605,7 @@ TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, uns
unsigned flags = JSREPORT_STRICT;
if (strictMode)
flags |= JSREPORT_ERROR;
else if (cx->hasStrictOption())
else if (cx->hasExtraWarningsOption())
flags |= JSREPORT_WARNING;
else
return true;
@ -784,7 +784,7 @@ TokenStream::reportWarning(unsigned errorNumber, ...)
bool
TokenStream::reportStrictWarningErrorNumberVA(uint32_t offset, unsigned errorNumber, va_list args)
{
if (!cx->hasStrictOption())
if (!cx->hasExtraWarningsOption())
return true;
return reportCompileErrorNumberVA(offset, JSREPORT_STRICT|JSREPORT_WARNING, errorNumber, args);

Просмотреть файл

@ -2,6 +2,6 @@
options("werror");
// This construct causes a strict warning, but we shouldn't get one since
// JSOPTION_STRICT isn't enabled.
// JSOPTION_EXTRA_WARNINGS isn't enabled.
var x;
eval("if (x = 3) {}");

Просмотреть файл

@ -1906,7 +1906,7 @@ JS_StringToVersion(const char *string);
* JSOPTION_VAROBJFIX is recommended -- see the comments associated with the
* prototypes for JS_ExecuteScript, JS_EvaluateScript, etc.
*/
#define JSOPTION_STRICT JS_BIT(0) /* warn on dubious practice */
#define JSOPTION_EXTRA_WARNINGS JS_BIT(0) /* warn on dubious practices */
#define JSOPTION_WERROR JS_BIT(1) /* convert warning to error */
#define JSOPTION_VAROBJFIX JS_BIT(2) /* make JS_EvaluateScript use
the last object on its 'obj'

Просмотреть файл

@ -677,7 +677,7 @@ js::WouldDefinePastNonwritableLength(JSContext *cx, HandleObject obj, uint32_t i
}
*definesPast = true;
if (!strict && !cx->hasStrictOption())
if (!strict && !cx->hasExtraWarningsOption())
return true;
// Error in strict mode code or warn with strict option.

Просмотреть файл

@ -540,20 +540,20 @@ checkReportFlags(JSContext *cx, unsigned *flags)
{
if (JSREPORT_IS_STRICT_MODE_ERROR(*flags)) {
/*
* Error in strict code; warning with strict option; okay otherwise.
* We assume that if the top frame is a native, then it is strict if
* the nearest scripted frame is strict, see bug 536306.
* Error in strict code; warning with extra warnings option; okay
* otherwise. We assume that if the top frame is a native, then it is
* strict if the nearest scripted frame is strict, see bug 536306.
*/
JSScript *script = cx->stack.currentScript();
if (script && script->strict)
*flags &= ~JSREPORT_WARNING;
else if (cx->hasStrictOption())
else if (cx->hasExtraWarningsOption())
*flags |= JSREPORT_WARNING;
else
return true;
} else if (JSREPORT_IS_STRICT(*flags)) {
/* Warning/error only when JSOPTION_STRICT is set. */
if (!cx->hasStrictOption())
if (!cx->hasExtraWarningsOption())
return true;
}

Просмотреть файл

@ -1709,7 +1709,7 @@ struct JSContext : js::ContextFriendFields,
return !!(options_ & opt);
}
bool hasStrictOption() const { return hasOption(JSOPTION_STRICT); }
bool hasExtraWarningsOption() const { return hasOption(JSOPTION_EXTRA_WARNINGS); }
bool hasWErrorOption() const { return hasOption(JSOPTION_WERROR); }
js::LifoAlloc &tempLifoAlloc() { return runtime()->tempLifoAlloc; }

Просмотреть файл

@ -3941,8 +3941,8 @@ GetPropertyHelperInline(JSContext *cx,
return false;
}
/* Don't warn if not strict or for random getprop operations. */
if (!cx->hasStrictOption() || (op != JSOP_GETPROP && op != JSOP_GETELEM))
/* Don't warn if extra warnings not enabled or for random getprop operations. */
if (!cx->hasExtraWarningsOption() || (op != JSOP_GETPROP && op != JSOP_GETELEM))
return true;
/* Don't warn repeatedly for the same script. */
@ -4162,8 +4162,9 @@ MaybeReportUndeclaredVarAssignment(JSContext *cx, JSString *propname)
if (!script)
return true;
/* If neither cx nor the code is strict, then no check is needed. */
if (!script->strict && !cx->hasStrictOption())
// If the code is not strict and extra warnings aren't enabled, then no
// check is needed.
if (!script->strict && !cx->hasExtraWarningsOption())
return true;
}
@ -4185,8 +4186,9 @@ js::ReportIfUndeclaredVarAssignment(JSContext *cx, HandleString propname)
if (!script)
return true;
/* If neither cx nor the code is strict, then no check is needed. */
if (!script->strict && !cx->hasStrictOption())
// If the code is not strict and extra warnings aren't enabled, then no
// check is needed.
if (!script->strict && !cx->hasExtraWarningsOption())
return true;
/*
@ -4288,7 +4290,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
if (pd.attrs & JSPROP_READONLY) {
if (strict)
return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR);
if (cx->hasStrictOption())
if (cx->hasExtraWarningsOption())
return JSObject::reportReadOnly(cx, id, JSREPORT_STRICT | JSREPORT_WARNING);
return true;
}
@ -4332,10 +4334,10 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
JS_ASSERT(shape->isDataDescriptor());
if (!shape->writable()) {
/* Error in strict mode code, warn with strict option, otherwise do nothing. */
/* Error in strict mode code, warn with extra warnings options, otherwise do nothing. */
if (strict)
return JSObject::reportReadOnly(cx, id, JSREPORT_ERROR);
if (cx->hasStrictOption())
if (cx->hasExtraWarningsOption())
return JSObject::reportReadOnly(cx, id, JSREPORT_STRICT | JSREPORT_WARNING);
return JS_TRUE;
}
@ -4409,10 +4411,10 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
if (!shape) {
if (!obj->isExtensible()) {
/* Error in strict mode code, warn with strict option, otherwise do nothing. */
/* Error in strict mode code, warn with extra warnings option, otherwise do nothing. */
if (strict)
return obj->reportNotExtensible(cx);
if (cx->hasStrictOption())
if (cx->hasExtraWarningsOption())
return obj->reportNotExtensible(cx, JSREPORT_STRICT | JSREPORT_WARNING);
return true;
}

Просмотреть файл

@ -583,7 +583,7 @@ static const struct JSOption {
const char *name;
uint32_t flag;
} js_options[] = {
{"strict", JSOPTION_STRICT},
{"strict", JSOPTION_EXTRA_WARNINGS},
{"typeinfer", JSOPTION_TYPE_INFERENCE},
{"werror", JSOPTION_WERROR},
{"strict_mode", JSOPTION_STRICT_MODE},
@ -4934,7 +4934,7 @@ ProcessArgs(JSContext *cx, JSObject *obj_, OptionParser *op)
reportWarnings = JS_FALSE;
if (op->getBoolOption('s'))
JS_ToggleOptions(cx, JSOPTION_STRICT);
JS_ToggleOptions(cx, JSOPTION_EXTRA_WARNINGS);
if (op->getBoolOption('d')) {
JS_SetRuntimeDebugMode(JS_GetRuntime(cx), true);

Просмотреть файл

@ -698,7 +698,7 @@ static const struct JSOption {
const char *name;
uint32_t flag;
} js_options[] = {
{"strict", JSOPTION_STRICT},
{"strict", JSOPTION_EXTRA_WARNINGS},
{"werror", JSOPTION_WERROR},
{"strict_mode", JSOPTION_STRICT_MODE},
};
@ -1150,7 +1150,7 @@ ProcessArgsForCompartment(JSContext *cx, char **argv, int argc)
case 'S':
JS_ToggleOptions(cx, JSOPTION_WERROR);
case 's':
JS_ToggleOptions(cx, JSOPTION_STRICT);
JS_ToggleOptions(cx, JSOPTION_EXTRA_WARNINGS);
break;
case 'I':
JS_ToggleOptions(cx, JSOPTION_COMPILE_N_GO);

Просмотреть файл

@ -4453,7 +4453,7 @@ SetBoolOption(JSContext* cx, uint32_t aOption, bool aValue)
return SetBoolOption(cx, _flag, aValue); \
}
GENERATE_JSOPTION_GETTER_SETTER(Strict, JSOPTION_STRICT)
GENERATE_JSOPTION_GETTER_SETTER(Strict, JSOPTION_EXTRA_WARNINGS)
GENERATE_JSOPTION_GETTER_SETTER(Werror, JSOPTION_WERROR)
GENERATE_JSOPTION_GETTER_SETTER(Strict_mode, JSOPTION_STRICT_MODE)
GENERATE_JSOPTION_GETTER_SETTER(Ion, JSOPTION_ION)