mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
Bug 1179063 - Cleanup: make StmtType an enum class. (r=efaust)
This commit is contained in:
parent
5e4b6d786c
commit
bd87127dc7
@ -75,12 +75,12 @@ struct frontend::StmtInfoBCE : public StmtInfoBase
|
||||
*/
|
||||
|
||||
ptrdiff_t& gosubs() {
|
||||
MOZ_ASSERT(type == STMT_FINALLY);
|
||||
MOZ_ASSERT(type == StmtType::FINALLY);
|
||||
return breaks;
|
||||
}
|
||||
|
||||
ptrdiff_t& guardJump() {
|
||||
MOZ_ASSERT(type == STMT_TRY || type == STMT_FINALLY);
|
||||
MOZ_ASSERT(type == StmtType::TRY || type == StmtType::FINALLY);
|
||||
return continues;
|
||||
}
|
||||
};
|
||||
@ -376,7 +376,7 @@ static const char * const statementName[] = {
|
||||
"spread", /* SPREAD */
|
||||
};
|
||||
|
||||
static_assert(MOZ_ARRAY_LENGTH(statementName) == STMT_LIMIT,
|
||||
static_assert(MOZ_ARRAY_LENGTH(statementName) == uint16_t(StmtType::LIMIT),
|
||||
"statementName array and StmtType enum must be consistent");
|
||||
|
||||
static const char*
|
||||
@ -384,7 +384,7 @@ StatementName(StmtInfoBCE* topStmt)
|
||||
{
|
||||
if (!topStmt)
|
||||
return js_script_str;
|
||||
return statementName[topStmt->type];
|
||||
return statementName[uint16_t(topStmt->type)];
|
||||
}
|
||||
|
||||
static void
|
||||
@ -613,13 +613,13 @@ NonLocalExitScope::prepareForNonLocalJump(StmtInfoBCE* toStmt)
|
||||
|
||||
for (StmtInfoBCE* stmt = bce->topStmt; stmt != toStmt; stmt = stmt->down) {
|
||||
switch (stmt->type) {
|
||||
case STMT_FINALLY:
|
||||
case StmtType::FINALLY:
|
||||
FLUSH_POPS();
|
||||
if (!bce->emitBackPatchOp(&stmt->gosubs()))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case STMT_WITH:
|
||||
case StmtType::WITH:
|
||||
if (!bce->emit1(JSOP_LEAVEWITH))
|
||||
return false;
|
||||
MOZ_ASSERT(stmt->isNestedScope);
|
||||
@ -627,11 +627,11 @@ NonLocalExitScope::prepareForNonLocalJump(StmtInfoBCE* toStmt)
|
||||
return false;
|
||||
break;
|
||||
|
||||
case STMT_FOR_OF_LOOP:
|
||||
case StmtType::FOR_OF_LOOP:
|
||||
npops += 2;
|
||||
break;
|
||||
|
||||
case STMT_FOR_IN_LOOP:
|
||||
case StmtType::FOR_IN_LOOP:
|
||||
/* The iterator and the current value are on the stack. */
|
||||
npops += 1;
|
||||
FLUSH_POPS();
|
||||
@ -639,11 +639,11 @@ NonLocalExitScope::prepareForNonLocalJump(StmtInfoBCE* toStmt)
|
||||
return false;
|
||||
break;
|
||||
|
||||
case STMT_SPREAD:
|
||||
case StmtType::SPREAD:
|
||||
MOZ_ASSERT_UNREACHABLE("can't break/continue/return from inside a spread");
|
||||
break;
|
||||
|
||||
case STMT_SUBROUTINE:
|
||||
case StmtType::SUBROUTINE:
|
||||
/*
|
||||
* There's a [exception or hole, retsub pc-index] pair on the
|
||||
* stack that we need to pop.
|
||||
@ -742,9 +742,9 @@ BytecodeEmitter::pushLoopStatement(LoopStmtInfo* stmt, StmtType type, ptrdiff_t
|
||||
stmt->loopDepth = downLoop ? downLoop->loopDepth + 1 : 1;
|
||||
|
||||
int loopSlots;
|
||||
if (type == STMT_SPREAD)
|
||||
if (type == StmtType::SPREAD)
|
||||
loopSlots = 3;
|
||||
else if (type == STMT_FOR_IN_LOOP || type == STMT_FOR_OF_LOOP)
|
||||
else if (type == StmtType::FOR_IN_LOOP || type == StmtType::FOR_OF_LOOP)
|
||||
loopSlots = 2;
|
||||
else
|
||||
loopSlots = 0;
|
||||
@ -895,8 +895,8 @@ BytecodeEmitter::computeLocalOffset(Handle<StaticBlockObject*> blockObj)
|
||||
// will emit DEBUGLEAVEBLOCK and may emit POPBLOCKSCOPE. (For "with" scopes it
|
||||
// emits LEAVEWITH, of course.) Pass enterNestedScope a fresh StmtInfoBCE
|
||||
// object, and pass that same object to the corresponding leaveNestedScope. If
|
||||
// the statement is a block scope, pass STMT_BLOCK as stmtType; otherwise for
|
||||
// with scopes pass STMT_WITH.
|
||||
// the statement is a block scope, pass StmtType::BLOCK as stmtType; otherwise for
|
||||
// with scopes pass StmtType::WITH.
|
||||
//
|
||||
bool
|
||||
BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType stmtType)
|
||||
@ -905,7 +905,7 @@ BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType
|
||||
uint32_t scopeObjectIndex = objectList.add(objbox);
|
||||
|
||||
switch (stmtType) {
|
||||
case STMT_BLOCK: {
|
||||
case StmtType::BLOCK: {
|
||||
Rooted<StaticBlockObject*> blockObj(cx, &scopeObj->as<StaticBlockObject>());
|
||||
|
||||
computeLocalOffset(blockObj);
|
||||
@ -919,7 +919,7 @@ BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STMT_WITH:
|
||||
case StmtType::WITH:
|
||||
MOZ_ASSERT(scopeObj->is<StaticWithObject>());
|
||||
if (!emitInternedObjectOp(scopeObjectIndex, JSOP_ENTERWITH))
|
||||
return false;
|
||||
@ -942,7 +942,7 @@ BytecodeEmitter::enterNestedScope(StmtInfoBCE* stmt, ObjectBox* objbox, StmtType
|
||||
scopeObj->initEnclosingNestedScope(enclosingStaticScope());
|
||||
FinishPushNestedScope(this, stmt, *scopeObj);
|
||||
MOZ_ASSERT(stmt->isNestedScope);
|
||||
stmt->isBlockScope = (stmtType == STMT_BLOCK);
|
||||
stmt->isBlockScope = (stmtType == StmtType::BLOCK);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -965,7 +965,7 @@ BytecodeEmitter::leaveNestedScope(StmtInfoBCE* stmt)
|
||||
{
|
||||
MOZ_ASSERT(stmt == topStmt);
|
||||
MOZ_ASSERT(stmt->isNestedScope);
|
||||
MOZ_ASSERT(stmt->isBlockScope == !(stmt->type == STMT_WITH));
|
||||
MOZ_ASSERT(stmt->isBlockScope == !(stmt->type == StmtType::WITH));
|
||||
uint32_t blockScopeIndex = stmt->blockScopeIndex;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -1524,7 +1524,7 @@ BytecodeEmitter::tryConvertFreeName(ParseNode* pn)
|
||||
// The only statements within a lazy function which can push lexical
|
||||
// scopes are try/catch blocks. Use generic ops in this case.
|
||||
for (StmtInfoBCE* stmt = topStmt; stmt; stmt = stmt->down) {
|
||||
if (stmt->type == STMT_CATCH)
|
||||
if (stmt->type == StmtType::CATCH)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2351,7 +2351,7 @@ BytecodeEmitter::needsImplicitThis()
|
||||
return true;
|
||||
|
||||
for (StmtInfoBCE* stmt = topStmt; stmt; stmt = stmt->down) {
|
||||
if (stmt->type == STMT_WITH)
|
||||
if (stmt->type == StmtType::WITH)
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3035,7 +3035,7 @@ BytecodeEmitter::enterBlockScope(StmtInfoBCE* stmtInfo, ObjectBox* objbox, JSOp
|
||||
if (!pushInitialConstants(initialValueOp, blockObj->numVariables() - alreadyPushed))
|
||||
return false;
|
||||
|
||||
if (!enterNestedScope(stmtInfo, objbox, STMT_BLOCK))
|
||||
if (!enterNestedScope(stmtInfo, objbox, StmtType::BLOCK))
|
||||
return false;
|
||||
|
||||
if (!initializeBlockScopedLocalsFromStack(blockObj))
|
||||
@ -3065,14 +3065,14 @@ BytecodeEmitter::emitSwitch(ParseNode* pn)
|
||||
if (!enterBlockScope(&stmtInfo, cases->pn_objbox, JSOP_UNINITIALIZED, 0))
|
||||
return false;
|
||||
|
||||
stmtInfo.type = STMT_SWITCH;
|
||||
stmtInfo.type = StmtType::SWITCH;
|
||||
stmtInfo.update = top = offset();
|
||||
/* Advance |cases| to refer to the switch case list. */
|
||||
cases = cases->expr();
|
||||
} else {
|
||||
MOZ_ASSERT(cases->isKind(PNK_STATEMENTLIST));
|
||||
top = offset();
|
||||
pushStatement(&stmtInfo, STMT_SWITCH, top);
|
||||
pushStatement(&stmtInfo, StmtType::SWITCH, top);
|
||||
}
|
||||
|
||||
/* Switch bytecodes run from here till end of final case. */
|
||||
@ -4773,16 +4773,16 @@ bool
|
||||
BytecodeEmitter::emitCatch(ParseNode* pn)
|
||||
{
|
||||
/*
|
||||
* Morph STMT_BLOCK to STMT_CATCH, note the block entry code offset,
|
||||
* Morph StmtType::BLOCK to StmtType::CATCH, note the block entry code offset,
|
||||
* and save the block object atom.
|
||||
*/
|
||||
StmtInfoBCE* stmt = topStmt;
|
||||
MOZ_ASSERT(stmt->type == STMT_BLOCK && stmt->isBlockScope);
|
||||
stmt->type = STMT_CATCH;
|
||||
MOZ_ASSERT(stmt->type == StmtType::BLOCK && stmt->isBlockScope);
|
||||
stmt->type = StmtType::CATCH;
|
||||
|
||||
/* Go up one statement info record to the TRY or FINALLY record. */
|
||||
stmt = stmt->down;
|
||||
MOZ_ASSERT(stmt->type == STMT_TRY || stmt->type == STMT_FINALLY);
|
||||
MOZ_ASSERT(stmt->type == StmtType::TRY || stmt->type == StmtType::FINALLY);
|
||||
|
||||
/* Pick up the pending exception and bind it to the catch variable. */
|
||||
if (!emit1(JSOP_EXCEPTION))
|
||||
@ -4872,12 +4872,12 @@ BytecodeEmitter::emitTry(ParseNode* pn)
|
||||
// Push stmtInfo to track jumps-over-catches and gosubs-to-finally
|
||||
// for later fixup.
|
||||
//
|
||||
// When a finally block is active (STMT_FINALLY in our parse context),
|
||||
// When a finally block is active (StmtType::FINALLY in our parse context),
|
||||
// non-local jumps (including jumps-over-catches) result in a GOSUB
|
||||
// being written into the bytecode stream and fixed-up later (c.f.
|
||||
// emitBackPatchOp and backPatch).
|
||||
//
|
||||
pushStatement(&stmtInfo, pn->pn_kid3 ? STMT_FINALLY : STMT_TRY, offset());
|
||||
pushStatement(&stmtInfo, pn->pn_kid3 ? StmtType::FINALLY : StmtType::TRY, offset());
|
||||
|
||||
// Since an exception can be thrown at any place inside the try block,
|
||||
// we need to restore the stack and the scope chain before we transfer
|
||||
@ -4998,7 +4998,7 @@ BytecodeEmitter::emitTry(ParseNode* pn)
|
||||
finallyStart = offset();
|
||||
|
||||
// Indicate that we're emitting a subroutine body.
|
||||
stmtInfo.type = STMT_SUBROUTINE;
|
||||
stmtInfo.type = StmtType::SUBROUTINE;
|
||||
if (!updateSourceCoordNotes(pn->pn_kid3->pn_pos.begin))
|
||||
return false;
|
||||
if (!emit1(JSOP_FINALLY) ||
|
||||
@ -5039,7 +5039,7 @@ BytecodeEmitter::emitIf(ParseNode* pn)
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
|
||||
/* Initialize so we can detect else-if chains and avoid recursion. */
|
||||
stmtInfo.type = STMT_IF;
|
||||
stmtInfo.type = StmtType::IF;
|
||||
ptrdiff_t beq = -1;
|
||||
ptrdiff_t jmp = -1;
|
||||
unsigned noteIndex = -1;
|
||||
@ -5049,16 +5049,16 @@ BytecodeEmitter::emitIf(ParseNode* pn)
|
||||
if (!emitTree(pn->pn_kid1))
|
||||
return false;
|
||||
ptrdiff_t top = offset();
|
||||
if (stmtInfo.type == STMT_IF) {
|
||||
pushStatement(&stmtInfo, STMT_IF, top);
|
||||
if (stmtInfo.type == StmtType::IF) {
|
||||
pushStatement(&stmtInfo, StmtType::IF, top);
|
||||
} else {
|
||||
/*
|
||||
* We came here from the goto further below that detects else-if
|
||||
* chains, so we must mutate stmtInfo back into a STMT_IF record.
|
||||
* chains, so we must mutate stmtInfo back into a StmtType::IF record.
|
||||
* Also we need a note offset for SRC_IF_ELSE to help IonMonkey.
|
||||
*/
|
||||
MOZ_ASSERT(stmtInfo.type == STMT_ELSE);
|
||||
stmtInfo.type = STMT_IF;
|
||||
MOZ_ASSERT(stmtInfo.type == StmtType::ELSE);
|
||||
stmtInfo.type = StmtType::IF;
|
||||
stmtInfo.update = top;
|
||||
if (!setSrcNoteOffset(noteIndex, 0, jmp - beq))
|
||||
return false;
|
||||
@ -5076,7 +5076,7 @@ BytecodeEmitter::emitIf(ParseNode* pn)
|
||||
return false;
|
||||
if (pn3) {
|
||||
/* Modify stmtInfo so we know we're in the else part. */
|
||||
stmtInfo.type = STMT_ELSE;
|
||||
stmtInfo.type = StmtType::ELSE;
|
||||
|
||||
/*
|
||||
* Emit a JSOP_BACKPATCH op to jump from the end of our then part
|
||||
@ -5179,7 +5179,7 @@ BytecodeEmitter::emitWith(ParseNode* pn)
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
if (!emitTree(pn->pn_left))
|
||||
return false;
|
||||
if (!enterNestedScope(&stmtInfo, pn->pn_binary_obj, STMT_WITH))
|
||||
if (!enterNestedScope(&stmtInfo, pn->pn_binary_obj, StmtType::WITH))
|
||||
return false;
|
||||
if (!emitTree(pn->pn_right))
|
||||
return false;
|
||||
@ -5278,9 +5278,9 @@ BytecodeEmitter::emitForInOrOfVariables(ParseNode* pn, bool* letDecl)
|
||||
bool
|
||||
BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
{
|
||||
MOZ_ASSERT(type == STMT_FOR_OF_LOOP || type == STMT_SPREAD);
|
||||
MOZ_ASSERT_IF(type == STMT_FOR_OF_LOOP, pn && pn->pn_left->isKind(PNK_FOROF));
|
||||
MOZ_ASSERT_IF(type == STMT_SPREAD, !pn);
|
||||
MOZ_ASSERT(type == StmtType::FOR_OF_LOOP || type == StmtType::SPREAD);
|
||||
MOZ_ASSERT_IF(type == StmtType::FOR_OF_LOOP, pn && pn->pn_left->isKind(PNK_FOROF));
|
||||
MOZ_ASSERT_IF(type == StmtType::SPREAD, !pn);
|
||||
|
||||
ParseNode* forHead = pn ? pn->pn_left : nullptr;
|
||||
ParseNode* forHeadExpr = forHead ? forHead->pn_kid3 : nullptr;
|
||||
@ -5291,7 +5291,7 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
if (pn1 && !emitForInOrOfVariables(pn1, &letDecl))
|
||||
return false;
|
||||
|
||||
if (type == STMT_FOR_OF_LOOP) {
|
||||
if (type == StmtType::FOR_OF_LOOP) {
|
||||
// For-of loops run with two values on the stack: the iterator and the
|
||||
// current result object.
|
||||
|
||||
@ -5333,7 +5333,7 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
if (!emitLoopHead(nullptr))
|
||||
return false;
|
||||
|
||||
if (type == STMT_SPREAD)
|
||||
if (type == StmtType::SPREAD)
|
||||
this->stackDepth++;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -5341,13 +5341,13 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
#endif
|
||||
|
||||
// Emit code to assign result.value to the iteration variable.
|
||||
if (type == STMT_FOR_OF_LOOP) {
|
||||
if (type == StmtType::FOR_OF_LOOP) {
|
||||
if (!emit1(JSOP_DUP)) // ITER RESULT RESULT
|
||||
return false;
|
||||
}
|
||||
if (!emitAtomOp(cx->names().value, JSOP_GETPROP)) // ... RESULT VALUE
|
||||
return false;
|
||||
if (type == STMT_FOR_OF_LOOP) {
|
||||
if (type == StmtType::FOR_OF_LOOP) {
|
||||
if (!emitAssignment(forHead->pn_kid2, JSOP_NOP, nullptr)) // ITER RESULT VALUE
|
||||
return false;
|
||||
if (!emit1(JSOP_POP)) // ITER RESULT
|
||||
@ -5364,14 +5364,14 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
StmtInfoBCE* stmt = &stmtInfo;
|
||||
do {
|
||||
stmt->update = offset();
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == STMT_LABEL);
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == StmtType::LABEL);
|
||||
} else {
|
||||
if (!emit1(JSOP_INITELEM_INC)) // ITER ARR (I+1)
|
||||
return false;
|
||||
|
||||
MOZ_ASSERT(this->stackDepth == loopDepth - 1);
|
||||
|
||||
// STMT_SPREAD never contain continue, so do not set "update" offset.
|
||||
// StmtType::SPREAD never contain continue, so do not set "update" offset.
|
||||
}
|
||||
|
||||
// COME FROM the beginning of the loop to here.
|
||||
@ -5379,7 +5379,7 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
if (!emitLoopEntry(forHeadExpr))
|
||||
return false;
|
||||
|
||||
if (type == STMT_FOR_OF_LOOP) {
|
||||
if (type == StmtType::FOR_OF_LOOP) {
|
||||
if (!emit1(JSOP_POP)) // ITER
|
||||
return false;
|
||||
if (!emit1(JSOP_DUP)) // ITER ITER
|
||||
@ -5406,7 +5406,7 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
return false;
|
||||
|
||||
// Fixup breaks and continues.
|
||||
// For STMT_SPREAD, just pop pc->topStmt.
|
||||
// For StmtType::SPREAD, just pop pc->topStmt.
|
||||
popStatement();
|
||||
|
||||
if (!tryNoteList.append(JSTRY_FOR_OF, stackDepth, top, offset()))
|
||||
@ -5417,7 +5417,7 @@ BytecodeEmitter::emitForOf(StmtType type, ParseNode* pn, ptrdiff_t top)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == STMT_SPREAD) {
|
||||
if (type == StmtType::SPREAD) {
|
||||
if (!emit2(JSOP_PICK, (jsbytecode)3)) // ARR I RESULT ITER
|
||||
return false;
|
||||
}
|
||||
@ -5465,7 +5465,7 @@ BytecodeEmitter::emitForIn(ParseNode* pn, ptrdiff_t top)
|
||||
}
|
||||
|
||||
LoopStmtInfo stmtInfo(cx);
|
||||
pushLoopStatement(&stmtInfo, STMT_FOR_IN_LOOP, top);
|
||||
pushLoopStatement(&stmtInfo, StmtType::FOR_IN_LOOP, top);
|
||||
|
||||
/* Annotate so IonMonkey can find the loop-closing jump. */
|
||||
unsigned noteIndex;
|
||||
@ -5505,7 +5505,7 @@ BytecodeEmitter::emitForIn(ParseNode* pn, ptrdiff_t top)
|
||||
StmtInfoBCE* stmt = &stmtInfo;
|
||||
do {
|
||||
stmt->update = offset();
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == STMT_LABEL);
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == StmtType::LABEL);
|
||||
|
||||
/*
|
||||
* Fixup the goto that starts the loop to jump down to JSOP_MOREITER.
|
||||
@ -5551,7 +5551,7 @@ bool
|
||||
BytecodeEmitter::emitNormalFor(ParseNode* pn, ptrdiff_t top)
|
||||
{
|
||||
LoopStmtInfo stmtInfo(cx);
|
||||
pushLoopStatement(&stmtInfo, STMT_FOR_LOOP, top);
|
||||
pushLoopStatement(&stmtInfo, StmtType::FOR_LOOP, top);
|
||||
|
||||
ParseNode* forHead = pn->pn_left;
|
||||
ParseNode* forBody = pn->pn_right;
|
||||
@ -5626,7 +5626,7 @@ BytecodeEmitter::emitNormalFor(ParseNode* pn, ptrdiff_t top)
|
||||
StmtInfoBCE* stmt = &stmtInfo;
|
||||
do {
|
||||
stmt->update = offset();
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == STMT_LABEL);
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == StmtType::LABEL);
|
||||
|
||||
// Freshen the block on the scope chain to expose distinct bindings for each loop
|
||||
// iteration.
|
||||
@ -5637,7 +5637,7 @@ BytecodeEmitter::emitNormalFor(ParseNode* pn, ptrdiff_t top)
|
||||
// let-statement for the guarding condition to have held) and freshen
|
||||
// if the block object needs cloning.
|
||||
StmtInfoBCE* parent = stmtInfo.down;
|
||||
MOZ_ASSERT(parent->type == STMT_BLOCK);
|
||||
MOZ_ASSERT(parent->type == StmtType::BLOCK);
|
||||
MOZ_ASSERT(parent->isBlockScope);
|
||||
|
||||
if (parent->staticScope->as<StaticBlockObject>().needsClone()) {
|
||||
@ -5710,7 +5710,7 @@ BytecodeEmitter::emitFor(ParseNode* pn, ptrdiff_t top)
|
||||
return emitForIn(pn, top);
|
||||
|
||||
if (pn->pn_left->isKind(PNK_FOROF))
|
||||
return emitForOf(STMT_FOR_OF_LOOP, pn, top);
|
||||
return emitForOf(StmtType::FOR_OF_LOOP, pn, top);
|
||||
|
||||
MOZ_ASSERT(pn->pn_left->isKind(PNK_FORHEAD));
|
||||
return emitNormalFor(pn, top);
|
||||
@ -5904,7 +5904,7 @@ BytecodeEmitter::emitDo(ParseNode* pn)
|
||||
return false;
|
||||
|
||||
LoopStmtInfo stmtInfo(cx);
|
||||
pushLoopStatement(&stmtInfo, STMT_DO_LOOP, top);
|
||||
pushLoopStatement(&stmtInfo, StmtType::DO_LOOP, top);
|
||||
|
||||
if (!emitLoopEntry(nullptr))
|
||||
return false;
|
||||
@ -5917,7 +5917,7 @@ BytecodeEmitter::emitDo(ParseNode* pn)
|
||||
StmtInfoBCE* stmt = &stmtInfo;
|
||||
do {
|
||||
stmt->update = off;
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == STMT_LABEL);
|
||||
} while ((stmt = stmt->down) != nullptr && stmt->type == StmtType::LABEL);
|
||||
|
||||
/* Compile the loop condition, now that continues know where to go. */
|
||||
if (!emitTree(pn->pn_right))
|
||||
@ -5963,7 +5963,7 @@ BytecodeEmitter::emitWhile(ParseNode* pn, ptrdiff_t top)
|
||||
* N N*(ifeq-fail; goto); ifeq-pass goto; N*ifne-pass; ifne-fail
|
||||
*/
|
||||
LoopStmtInfo stmtInfo(cx);
|
||||
pushLoopStatement(&stmtInfo, STMT_WHILE_LOOP, top);
|
||||
pushLoopStatement(&stmtInfo, StmtType::WHILE_LOOP, top);
|
||||
|
||||
unsigned noteIndex;
|
||||
if (!newSrcNote(SRC_WHILE, ¬eIndex))
|
||||
@ -6006,13 +6006,13 @@ BytecodeEmitter::emitBreak(PropertyName* label)
|
||||
StmtInfoBCE* stmt = topStmt;
|
||||
SrcNoteType noteType;
|
||||
if (label) {
|
||||
while (stmt->type != STMT_LABEL || stmt->label != label)
|
||||
while (stmt->type != StmtType::LABEL || stmt->label != label)
|
||||
stmt = stmt->down;
|
||||
noteType = SRC_BREAK2LABEL;
|
||||
} else {
|
||||
while (!stmt->isLoop() && stmt->type != STMT_SWITCH)
|
||||
while (!stmt->isLoop() && stmt->type != StmtType::SWITCH)
|
||||
stmt = stmt->down;
|
||||
noteType = (stmt->type == STMT_SWITCH) ? SRC_SWITCHBREAK : SRC_BREAK;
|
||||
noteType = (stmt->type == StmtType::SWITCH) ? SRC_SWITCHBREAK : SRC_BREAK;
|
||||
}
|
||||
|
||||
return emitGoto(stmt, &stmt->breaks, noteType);
|
||||
@ -6025,7 +6025,7 @@ BytecodeEmitter::emitContinue(PropertyName* label)
|
||||
if (label) {
|
||||
/* Find the loop statement enclosed by the matching label. */
|
||||
StmtInfoBCE* loop = nullptr;
|
||||
while (stmt->type != STMT_LABEL || stmt->label != label) {
|
||||
while (stmt->type != StmtType::LABEL || stmt->label != label) {
|
||||
if (stmt->isLoop())
|
||||
loop = stmt;
|
||||
stmt = stmt->down;
|
||||
@ -6043,7 +6043,7 @@ bool
|
||||
BytecodeEmitter::inTryBlockWithFinally()
|
||||
{
|
||||
for (StmtInfoBCE* stmt = topStmt; stmt; stmt = stmt->down) {
|
||||
if (stmt->type == STMT_FINALLY)
|
||||
if (stmt->type == StmtType::FINALLY)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -6202,7 +6202,7 @@ BytecodeEmitter::emitYieldStar(ParseNode* iter, ParseNode* gen)
|
||||
|
||||
// Try prologue. // ITER RESULT
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
pushStatement(&stmtInfo, STMT_TRY, offset());
|
||||
pushStatement(&stmtInfo, StmtType::TRY, offset());
|
||||
unsigned noteIndex;
|
||||
if (!newSrcNote(SRC_TRY, ¬eIndex))
|
||||
return false;
|
||||
@ -6336,7 +6336,7 @@ BytecodeEmitter::emitStatementList(ParseNode* pn, ptrdiff_t top)
|
||||
MOZ_ASSERT(pn->isArity(PN_LIST));
|
||||
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
pushStatement(&stmtInfo, STMT_BLOCK, top);
|
||||
pushStatement(&stmtInfo, StmtType::BLOCK, top);
|
||||
|
||||
for (ParseNode* pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {
|
||||
if (!emitTree(pn2))
|
||||
@ -6387,7 +6387,7 @@ BytecodeEmitter::emitStatement(ParseNode* pn)
|
||||
* compound statement.
|
||||
*/
|
||||
if (topStmt &&
|
||||
topStmt->type == STMT_LABEL &&
|
||||
topStmt->type == StmtType::LABEL &&
|
||||
topStmt->update >= offset())
|
||||
{
|
||||
useful = true;
|
||||
@ -6948,7 +6948,7 @@ BytecodeEmitter::emitLabeledStatement(const LabeledStatement* pn)
|
||||
|
||||
/* Emit code for the labeled statement. */
|
||||
StmtInfoBCE stmtInfo(cx);
|
||||
pushStatement(&stmtInfo, STMT_LABEL, offset());
|
||||
pushStatement(&stmtInfo, StmtType::LABEL, offset());
|
||||
stmtInfo.label = pn->label();
|
||||
|
||||
if (!emitTree(pn->statement()))
|
||||
@ -7200,7 +7200,7 @@ BytecodeEmitter::emitArrayComp(ParseNode* pn)
|
||||
bool
|
||||
BytecodeEmitter::emitSpread()
|
||||
{
|
||||
return emitForOf(STMT_SPREAD, nullptr, -1);
|
||||
return emitForOf(StmtType::SPREAD, nullptr, -1);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -592,10 +592,10 @@ struct BytecodeEmitter
|
||||
// iteration count). The stack after iteration will look like |ARRAY INDEX|.
|
||||
bool emitSpread();
|
||||
|
||||
// If type is STMT_FOR_OF_LOOP, emit bytecode for a for-of loop.
|
||||
// If type is StmtType::FOR_OF_LOOP, emit bytecode for a for-of loop.
|
||||
// pn should be PNK_FOR, and pn->pn_left should be PNK_FOROF.
|
||||
//
|
||||
// If type is STMT_SPREAD, emit bytecode for spread operator.
|
||||
// If type is StmtType::SPREAD, emit bytecode for spread operator.
|
||||
// pn should be nullptr.
|
||||
//
|
||||
// Please refer the comment above emitSpread for additional information about
|
||||
|
@ -1326,7 +1326,7 @@ IsNonDominatingInScopedSwitch(ParseContext<FullParseHandler>* pc, HandleAtom nam
|
||||
{
|
||||
MOZ_ASSERT(dn->isLexical());
|
||||
StmtInfoPC* stmt = LexicalLookup(pc, name);
|
||||
if (stmt && stmt->type == STMT_SWITCH)
|
||||
if (stmt && stmt->type == StmtType::SWITCH)
|
||||
return dn->pn_cookie.slot() < stmt->firstDominatingLexicalInCase;
|
||||
return false;
|
||||
}
|
||||
@ -2954,7 +2954,7 @@ Parser<ParseHandler>::reportRedeclaration(Node pn, Definition::Kind redeclKind,
|
||||
return false;
|
||||
|
||||
StmtInfoPC* stmt = LexicalLookup(pc, name);
|
||||
if (stmt && stmt->type == STMT_CATCH) {
|
||||
if (stmt && stmt->type == StmtType::CATCH) {
|
||||
report(ParseError, false, pn, JSMSG_REDECLARED_CATCH_IDENTIFIER, printable.ptr());
|
||||
} else {
|
||||
if (redeclKind == Definition::ARG) {
|
||||
@ -3167,7 +3167,7 @@ LexicalLookup(ContextT* ct, HandleAtom atom, typename ContextT::StmtInfo* stmt)
|
||||
* can potentially override any static bindings introduced by statements
|
||||
* further up the stack, we have to abort the search.
|
||||
*/
|
||||
if (stmt->type == STMT_WITH && !ct->sc->isDotVariable(atom))
|
||||
if (stmt->type == StmtType::WITH && !ct->sc->isDotVariable(atom))
|
||||
break;
|
||||
|
||||
// Skip statements that do not introduce a new scope
|
||||
@ -3191,7 +3191,7 @@ OuterLet(ParseContext<ParseHandler>* pc, StmtInfoPC* stmt, HandleAtom atom)
|
||||
stmt = LexicalLookup(pc, atom, stmt->downScope);
|
||||
if (!stmt)
|
||||
return false;
|
||||
if (stmt->type == STMT_BLOCK)
|
||||
if (stmt->type == StmtType::BLOCK)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -3215,7 +3215,7 @@ Parser<ParseHandler>::bindVarOrGlobalConst(BindData<ParseHandler>* data,
|
||||
|
||||
StmtInfoPC* stmt = LexicalLookup(pc, name);
|
||||
|
||||
if (stmt && stmt->type == STMT_WITH) {
|
||||
if (stmt && stmt->type == StmtType::WITH) {
|
||||
parser->handler.setFlag(pn, PND_DEOPTIMIZED);
|
||||
if (pc->sc->isFunctionBox()) {
|
||||
FunctionBox* funbox = pc->sc->asFunctionBox();
|
||||
@ -3264,7 +3264,7 @@ Parser<ParseHandler>::bindVarOrGlobalConst(BindData<ParseHandler>* data,
|
||||
if (!parser->report(ParseExtraWarning, false, pn, JSMSG_VAR_HIDES_ARG, bytes.ptr()))
|
||||
return false;
|
||||
} else {
|
||||
bool inCatchBody = (stmt && stmt->type == STMT_CATCH);
|
||||
bool inCatchBody = (stmt && stmt->type == StmtType::CATCH);
|
||||
bool error = (isConstDecl ||
|
||||
dn_kind == Definition::CONST ||
|
||||
dn_kind == Definition::GLOBALCONST ||
|
||||
@ -3349,9 +3349,9 @@ Parser<ParseHandler>::noteNameUse(HandlePropertyName name, Node pn)
|
||||
handler.linkUseToDef(pn, dn);
|
||||
|
||||
if (stmt) {
|
||||
if (stmt->type == STMT_WITH) {
|
||||
if (stmt->type == StmtType::WITH) {
|
||||
handler.setFlag(pn, PND_DEOPTIMIZED);
|
||||
} else if (stmt->type == STMT_SWITCH && stmt->isBlockScope) {
|
||||
} else if (stmt->type == StmtType::SWITCH && stmt->isBlockScope) {
|
||||
// See comments above StmtInfoPC and switchStatement for how
|
||||
// firstDominatingLexicalInCase is computed.
|
||||
MOZ_ASSERT(stmt->firstDominatingLexicalInCase <= stmt->staticBlock().numVariables());
|
||||
@ -3633,7 +3633,7 @@ Parser<ParseHandler>::pushLexicalScope(HandleStaticBlockObject blockObj, StmtInf
|
||||
if (!blockbox)
|
||||
return null();
|
||||
|
||||
PushStatementPC(pc, stmt, STMT_BLOCK);
|
||||
PushStatementPC(pc, stmt, StmtType::BLOCK);
|
||||
blockObj->initEnclosingNestedScopeFromParser(pc->staticScope);
|
||||
FinishPushNestedScope(pc, stmt, *blockObj.get());
|
||||
stmt->isBlockScope = true;
|
||||
@ -3766,7 +3766,7 @@ Parser<ParseHandler>::blockStatement(YieldHandling yieldHandling)
|
||||
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_LC));
|
||||
|
||||
StmtInfoPC stmtInfo(context);
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, STMT_BLOCK, pc))
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, StmtType::BLOCK, pc))
|
||||
return null();
|
||||
|
||||
Node list = statements(yieldHandling);
|
||||
@ -4079,10 +4079,10 @@ Parser<FullParseHandler>::checkAndPrepareLexical(bool isConst, const TokenPos& e
|
||||
*/
|
||||
MOZ_ASSERT(!stmt->isBlockScope);
|
||||
MOZ_ASSERT(stmt != pc->topScopeStmt);
|
||||
MOZ_ASSERT(stmt->type == STMT_BLOCK ||
|
||||
stmt->type == STMT_SWITCH ||
|
||||
stmt->type == STMT_TRY ||
|
||||
stmt->type == STMT_FINALLY);
|
||||
MOZ_ASSERT(stmt->type == StmtType::BLOCK ||
|
||||
stmt->type == StmtType::SWITCH ||
|
||||
stmt->type == StmtType::TRY ||
|
||||
stmt->type == StmtType::FINALLY);
|
||||
MOZ_ASSERT(!stmt->downScope);
|
||||
|
||||
/* Convert the block statement into a scope statement. */
|
||||
@ -4695,7 +4695,7 @@ Parser<ParseHandler>::doWhileStatement(YieldHandling yieldHandling)
|
||||
{
|
||||
uint32_t begin = pos().begin;
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_DO_LOOP);
|
||||
PushStatementPC(pc, &stmtInfo, StmtType::DO_LOOP);
|
||||
Node body = statement(yieldHandling);
|
||||
if (!body)
|
||||
return null();
|
||||
@ -4722,7 +4722,7 @@ Parser<ParseHandler>::whileStatement(YieldHandling yieldHandling)
|
||||
{
|
||||
uint32_t begin = pos().begin;
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_WHILE_LOOP);
|
||||
PushStatementPC(pc, &stmtInfo, StmtType::WHILE_LOOP);
|
||||
Node cond = condition(InAllowed, yieldHandling);
|
||||
if (!cond)
|
||||
return null();
|
||||
@ -4796,7 +4796,7 @@ Parser<FullParseHandler>::forStatement(YieldHandling yieldHandling)
|
||||
uint32_t begin = pos().begin;
|
||||
|
||||
StmtInfoPC forStmt(context);
|
||||
PushStatementPC(pc, &forStmt, STMT_FOR_LOOP);
|
||||
PushStatementPC(pc, &forStmt, StmtType::FOR_LOOP);
|
||||
|
||||
bool isForEach = false;
|
||||
unsigned iflags = 0;
|
||||
@ -4948,13 +4948,13 @@ Parser<FullParseHandler>::forStatement(YieldHandling yieldHandling)
|
||||
* rhs of 'in'.
|
||||
*/
|
||||
if (headKind == PNK_FOROF) {
|
||||
forStmt.type = STMT_FOR_OF_LOOP;
|
||||
forStmt.type = StmtType::FOR_OF_LOOP;
|
||||
if (isForEach) {
|
||||
report(ParseError, false, null(), JSMSG_BAD_FOR_EACH_LOOP);
|
||||
return null();
|
||||
}
|
||||
} else {
|
||||
forStmt.type = STMT_FOR_IN_LOOP;
|
||||
forStmt.type = StmtType::FOR_IN_LOOP;
|
||||
iflags |= JSITER_ENUMERATE;
|
||||
}
|
||||
|
||||
@ -5151,7 +5151,7 @@ Parser<SyntaxParseHandler>::forStatement(YieldHandling yieldHandling)
|
||||
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_FOR));
|
||||
|
||||
StmtInfoPC forStmt(context);
|
||||
PushStatementPC(pc, &forStmt, STMT_FOR_LOOP);
|
||||
PushStatementPC(pc, &forStmt, StmtType::FOR_LOOP);
|
||||
|
||||
/* Don't parse 'for each' loops. */
|
||||
if (allowsForEachIn()) {
|
||||
@ -5209,7 +5209,7 @@ Parser<SyntaxParseHandler>::forStatement(YieldHandling yieldHandling)
|
||||
}
|
||||
if (isForIn || isForOf) {
|
||||
/* Parse the rest of the for/in or for/of head. */
|
||||
forStmt.type = isForOf ? STMT_FOR_OF_LOOP : STMT_FOR_IN_LOOP;
|
||||
forStmt.type = isForOf ? StmtType::FOR_OF_LOOP : StmtType::FOR_IN_LOOP;
|
||||
|
||||
/* Check that the left side of the 'in' or 'of' is valid. */
|
||||
if (!isForDecl &&
|
||||
@ -5278,7 +5278,7 @@ Parser<ParseHandler>::switchStatement(YieldHandling yieldHandling)
|
||||
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_SWITCH);
|
||||
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_SWITCH);
|
||||
PushStatementPC(pc, &stmtInfo, StmtType::SWITCH);
|
||||
|
||||
if (!GenerateBlockId(tokenStream, pc, pc->topStmt->blockid))
|
||||
return null();
|
||||
@ -5415,7 +5415,7 @@ Parser<ParseHandler>::continueStatement(YieldHandling yieldHandling)
|
||||
report(ParseError, false, null(), JSMSG_LABEL_NOT_FOUND);
|
||||
return null();
|
||||
}
|
||||
if (stmt->type == STMT_LABEL) {
|
||||
if (stmt->type == StmtType::LABEL) {
|
||||
if (stmt->label == label) {
|
||||
if (!stmt2 || !stmt2->isLoop()) {
|
||||
report(ParseError, false, null(), JSMSG_BAD_CONTINUE);
|
||||
@ -5461,7 +5461,7 @@ Parser<ParseHandler>::breakStatement(YieldHandling yieldHandling)
|
||||
report(ParseError, false, null(), JSMSG_LABEL_NOT_FOUND);
|
||||
return null();
|
||||
}
|
||||
if (stmt->type == STMT_LABEL && stmt->label == label)
|
||||
if (stmt->type == StmtType::LABEL && stmt->label == label)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -5470,7 +5470,7 @@ Parser<ParseHandler>::breakStatement(YieldHandling yieldHandling)
|
||||
report(ParseError, false, null(), JSMSG_TOUGH_BREAK);
|
||||
return null();
|
||||
}
|
||||
if (stmt->isLoop() || stmt->type == STMT_SWITCH)
|
||||
if (stmt->isLoop() || stmt->type == StmtType::SWITCH)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -5702,7 +5702,7 @@ Parser<FullParseHandler>::withStatement(YieldHandling yieldHandling)
|
||||
pc->parsingWith = true;
|
||||
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_WITH);
|
||||
PushStatementPC(pc, &stmtInfo, StmtType::WITH);
|
||||
Rooted<StaticWithObject*> staticWith(context, StaticWithObject::create(context));
|
||||
if (!staticWith)
|
||||
return null();
|
||||
@ -5750,7 +5750,7 @@ Parser<ParseHandler>::labeledStatement(YieldHandling yieldHandling)
|
||||
uint32_t begin = pos().begin;
|
||||
RootedPropertyName label(context, tokenStream.currentName());
|
||||
for (StmtInfoPC* stmt = pc->topStmt; stmt; stmt = stmt->down) {
|
||||
if (stmt->type == STMT_LABEL && stmt->label == label) {
|
||||
if (stmt->type == StmtType::LABEL && stmt->label == label) {
|
||||
report(ParseError, false, null(), JSMSG_DUPLICATE_LABEL);
|
||||
return null();
|
||||
}
|
||||
@ -5760,7 +5760,7 @@ Parser<ParseHandler>::labeledStatement(YieldHandling yieldHandling)
|
||||
|
||||
/* Push a label struct and parse the statement. */
|
||||
StmtInfoPC stmtInfo(context);
|
||||
PushStatementPC(pc, &stmtInfo, STMT_LABEL);
|
||||
PushStatementPC(pc, &stmtInfo, StmtType::LABEL);
|
||||
stmtInfo.label = label;
|
||||
Node pn = statement(yieldHandling);
|
||||
if (!pn)
|
||||
@ -5829,7 +5829,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||
|
||||
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_TRY);
|
||||
StmtInfoPC stmtInfo(context);
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, STMT_TRY, pc))
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, StmtType::TRY, pc))
|
||||
return null();
|
||||
Node innerBlock = statements(yieldHandling);
|
||||
if (!innerBlock)
|
||||
@ -5864,7 +5864,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||
pnblock = pushLexicalScope(&stmtInfo);
|
||||
if (!pnblock)
|
||||
return null();
|
||||
stmtInfo.type = STMT_CATCH;
|
||||
stmtInfo.type = StmtType::CATCH;
|
||||
|
||||
/*
|
||||
* Legal catch forms are:
|
||||
@ -5965,7 +5965,7 @@ Parser<ParseHandler>::tryStatement(YieldHandling yieldHandling)
|
||||
|
||||
if (tt == TOK_FINALLY) {
|
||||
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_FINALLY);
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, STMT_FINALLY, pc))
|
||||
if (!PushBlocklikeStatement(tokenStream, &stmtInfo, StmtType::FINALLY, pc))
|
||||
return null();
|
||||
finallyBlock = statements(yieldHandling);
|
||||
if (!finallyBlock)
|
||||
|
@ -35,7 +35,7 @@ struct StmtInfoPC : public StmtInfoBase {
|
||||
// case's lexical declarations start at so we may generate dead zone
|
||||
// checks for other cases' declarations.
|
||||
//
|
||||
// Only valid if type is STMT_SWITCH.
|
||||
// Only valid if type is StmtType::SWITCH.
|
||||
uint16_t firstDominatingLexicalInCase;
|
||||
|
||||
explicit StmtInfoPC(ExclusiveContext* cx)
|
||||
|
@ -449,25 +449,25 @@ SharedContext::allLocalsAliased()
|
||||
* Also remember to keep the statementName array in BytecodeEmitter.cpp in
|
||||
* sync.
|
||||
*/
|
||||
enum StmtType {
|
||||
STMT_LABEL, /* labeled statement: L: s */
|
||||
STMT_IF, /* if (then) statement */
|
||||
STMT_ELSE, /* else clause of if statement */
|
||||
STMT_SEQ, /* synthetic sequence of statements */
|
||||
STMT_BLOCK, /* compound statement: { s1[;... sN] } */
|
||||
STMT_SWITCH, /* switch statement */
|
||||
STMT_WITH, /* with statement */
|
||||
STMT_CATCH, /* catch block */
|
||||
STMT_TRY, /* try block */
|
||||
STMT_FINALLY, /* finally block */
|
||||
STMT_SUBROUTINE, /* gosub-target subroutine body */
|
||||
STMT_DO_LOOP, /* do/while loop statement */
|
||||
STMT_FOR_LOOP, /* for loop statement */
|
||||
STMT_FOR_IN_LOOP, /* for/in loop statement */
|
||||
STMT_FOR_OF_LOOP, /* for/of loop statement */
|
||||
STMT_WHILE_LOOP, /* while loop statement */
|
||||
STMT_SPREAD, /* spread operator (pseudo for/of) */
|
||||
STMT_LIMIT
|
||||
enum class StmtType : uint16_t {
|
||||
LABEL, /* labeled statement: L: s */
|
||||
IF, /* if (then) statement */
|
||||
ELSE, /* else clause of if statement */
|
||||
SEQ, /* synthetic sequence of statements */
|
||||
BLOCK, /* compound statement: { s1[;... sN] } */
|
||||
SWITCH, /* switch statement */
|
||||
WITH, /* with statement */
|
||||
CATCH, /* catch block */
|
||||
TRY, /* try block */
|
||||
FINALLY, /* finally block */
|
||||
SUBROUTINE, /* gosub-target subroutine body */
|
||||
DO_LOOP, /* do/while loop statement */
|
||||
FOR_LOOP, /* for loop statement */
|
||||
FOR_IN_LOOP, /* for/in loop statement */
|
||||
FOR_OF_LOOP, /* for/of loop statement */
|
||||
WHILE_LOOP, /* while loop statement */
|
||||
SPREAD, /* spread operator (pseudo for/of) */
|
||||
LIMIT
|
||||
};
|
||||
|
||||
/*
|
||||
@ -498,14 +498,14 @@ enum StmtType {
|
||||
|
||||
struct StmtInfoBase {
|
||||
// Statement type (StmtType).
|
||||
uint16_t type;
|
||||
StmtType type;
|
||||
|
||||
// True if type is STMT_BLOCK, STMT_TRY, STMT_SWITCH, or STMT_FINALLY and
|
||||
// the block contains at least one let-declaration, or if type is
|
||||
// STMT_CATCH.
|
||||
// True if type is StmtType::BLOCK, StmtType::TRY, StmtType::SWITCH, or
|
||||
// StmtType::FINALLY and the block contains at least one let-declaration,
|
||||
// or if type is StmtType::CATCH.
|
||||
bool isBlockScope:1;
|
||||
|
||||
// True if isBlockScope or type == STMT_WITH.
|
||||
// True if isBlockScope or type == StmtType::WITH.
|
||||
bool isNestedScope:1;
|
||||
|
||||
// for (let ...) induced block scope
|
||||
@ -524,16 +524,14 @@ struct StmtInfoBase {
|
||||
{}
|
||||
|
||||
bool maybeScope() const {
|
||||
return STMT_BLOCK <= type && type <= STMT_SUBROUTINE && type != STMT_WITH;
|
||||
return StmtType::BLOCK <= type && type <= StmtType::SUBROUTINE &&
|
||||
type != StmtType::WITH;
|
||||
}
|
||||
|
||||
bool linksScope() const {
|
||||
return isNestedScope;
|
||||
}
|
||||
|
||||
void setStaticScope() {
|
||||
}
|
||||
|
||||
StaticBlockObject& staticBlock() const {
|
||||
MOZ_ASSERT(isNestedScope);
|
||||
MOZ_ASSERT(isBlockScope);
|
||||
@ -541,11 +539,11 @@ struct StmtInfoBase {
|
||||
}
|
||||
|
||||
bool isLoop() const {
|
||||
return type >= STMT_DO_LOOP;
|
||||
return type >= StmtType::DO_LOOP;
|
||||
}
|
||||
|
||||
bool isTrying() const {
|
||||
return STMT_TRY <= type && type <= STMT_SUBROUTINE;
|
||||
return StmtType::TRY <= type && type <= StmtType::SUBROUTINE;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user