Bug 1221737 - Drop some BytecodeEmitter checks for cases that the Parser rules out. r=jonco.

--HG--
extra : commitid : AdGjcp4XF2w
extra : rebase_source : 29da4df939bcdf4a078f55a87c8f8eb12bf9091f
This commit is contained in:
Jason Orendorff 2015-10-22 16:17:39 -05:00
Родитель 5d6913aa24
Коммит 8d209e7ee4
3 изменённых файлов: 6 добавлений и 24 удалений

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

@ -8034,13 +8034,11 @@ BytecodeEmitter::emitTree(ParseNode* pn, EmitLineNumberNote emitLineNote)
break;
case PNK_IMPORT:
if (!checkIsModule())
return false;
MOZ_ASSERT(sc->isModuleBox());
break;
case PNK_EXPORT:
if (!checkIsModule())
return false;
MOZ_ASSERT(sc->isModuleBox());
if (pn->pn_kid->getKind() != PNK_EXPORT_SPEC_LIST) {
if (!emitTree(pn->pn_kid))
return false;
@ -8048,8 +8046,7 @@ BytecodeEmitter::emitTree(ParseNode* pn, EmitLineNumberNote emitLineNote)
break;
case PNK_EXPORT_DEFAULT:
if (!checkIsModule())
return false;
MOZ_ASSERT(sc->isModuleBox());
if (!emitTree(pn->pn_kid))
return false;
if (pn->pn_right) {
@ -8061,8 +8058,7 @@ BytecodeEmitter::emitTree(ParseNode* pn, EmitLineNumberNote emitLineNote)
break;
case PNK_EXPORT_FROM:
if (!checkIsModule())
return false;
MOZ_ASSERT(sc->isModuleBox());
break;
case PNK_ARRAYPUSH:
@ -8170,16 +8166,6 @@ BytecodeEmitter::emitTree(ParseNode* pn, EmitLineNumberNote emitLineNote)
return true;
}
bool
BytecodeEmitter::checkIsModule()
{
if (!sc->isModuleBox()) {
reportError(nullptr, JSMSG_INVALID_OUTSIDE_MODULE);
return false;
}
return true;
}
static bool
AllocSrcNote(ExclusiveContext* cx, SrcNotesVector& notes, unsigned* index)
{

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

@ -351,9 +351,6 @@ struct BytecodeEmitter
// Emit module code for the tree rooted at body.
bool emitModuleScript(ParseNode* body);
// Report an error if we are not processing a module.
bool checkIsModule();
// If op is JOF_TYPESET (see the type barriers comment in TypeInference.h),
// reserve a type set to store its result.
void checkTypeSet(JSOp op);

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

@ -255,16 +255,15 @@ MSG_DEF(JSMSG_DUPLICATE_LABEL, 0, JSEXN_SYNTAXERR, "duplicate label")
MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal")
MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?")
MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?")
MSG_DEF(JSMSG_EXPORT_DECL_AT_TOP_LEVEL,0, JSEXN_SYNTAXERR, "export declarations may only appear at top level")
MSG_DEF(JSMSG_EXPORT_DECL_AT_TOP_LEVEL,0, JSEXN_SYNTAXERR, "export declarations may only appear at top level of a module")
MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 0, JSEXN_SYNTAXERR, "finally without try")
MSG_DEF(JSMSG_FROM_AFTER_IMPORT_CLAUSE, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after import clause")
MSG_DEF(JSMSG_FROM_AFTER_EXPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after export *")
MSG_DEF(JSMSG_GARBAGE_AFTER_INPUT, 2, JSEXN_SYNTAXERR, "unexpected garbage after {0}, starting with {1}")
MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal")
MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 0, JSEXN_SYNTAXERR, "illegal character")
MSG_DEF(JSMSG_IMPORT_DECL_AT_TOP_LEVEL, 0, JSEXN_SYNTAXERR, "import declarations may only appear at top level")
MSG_DEF(JSMSG_IMPORT_DECL_AT_TOP_LEVEL, 0, JSEXN_SYNTAXERR, "import declarations may only appear at top level of a module")
MSG_DEF(JSMSG_INVALID_FOR_INOF_DECL_WITH_INIT,1,JSEXN_SYNTAXERR,"for-{0} loop head declarations may not have initializers")
MSG_DEF(JSMSG_INVALID_OUTSIDE_MODULE, 0, JSEXN_SYNTAXERR, "import and export declarations are only valid at the top level of a module")
MSG_DEF(JSMSG_IN_AFTER_FOR_NAME, 0, JSEXN_SYNTAXERR, "missing 'in' or 'of' after for")
MSG_DEF(JSMSG_LABEL_NOT_FOUND, 0, JSEXN_SYNTAXERR, "label not found")
MSG_DEF(JSMSG_LET_CLASS_BINDING, 0, JSEXN_SYNTAXERR, "'let' is not a valid name for a class")