зеркало из https://github.com/mozilla/gecko-dev.git
Switch statement start.
This commit is contained in:
Родитель
61c7b053ba
Коммит
19a5012358
|
@ -219,6 +219,23 @@ namespace MetaData {
|
|||
targetList.pop_back();
|
||||
}
|
||||
break;
|
||||
case StmtNode::Switch:
|
||||
{
|
||||
SwitchStmtNode *sw = checked_cast<SwitchStmtNode *>(p);
|
||||
ValidateExpression(cxt, env, sw->expr);
|
||||
StmtNode *s = sw->statements;
|
||||
while (s) {
|
||||
if (s->getKind() == StmtNode::Case) {
|
||||
ExprStmtNode *c = checked_cast<ExprStmtNode *>(s);
|
||||
if (c->expr)
|
||||
ValidateExpression(cxt, env, c->expr);
|
||||
}
|
||||
else
|
||||
ValidateStmt(cxt, env, s);
|
||||
s = s->next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StmtNode::While:
|
||||
case StmtNode::DoWhile:
|
||||
{
|
||||
|
@ -831,6 +848,58 @@ namespace MetaData {
|
|||
bCon->setLabel(f->breakLabelID);
|
||||
}
|
||||
break;
|
||||
case StmtNode::Switch:
|
||||
/*
|
||||
<swexpr>
|
||||
eLexicalWrite <switchTemp>
|
||||
Pop
|
||||
|
||||
// test sequence in source order except
|
||||
// the default is moved to end.
|
||||
|
||||
eLexicalRead <switchTemp>
|
||||
<case1expr>
|
||||
Equal
|
||||
BranchTrue --> case1StmtLabel
|
||||
eLexicalRead <switchTemp>
|
||||
<case2expr>
|
||||
Equal
|
||||
BranchTrue --> case2StmtLabel
|
||||
Branch --> default, if there is one, or break label
|
||||
|
||||
case1StmtLabel:
|
||||
<stmt>
|
||||
case2StmtLabel:
|
||||
<stmt>
|
||||
defaultLabel:
|
||||
<stmt>
|
||||
case3StmtLabel:
|
||||
<stmt>
|
||||
..etc.. // all in source order
|
||||
|
||||
breakLabel:
|
||||
*/
|
||||
{
|
||||
SwitchStmtNode *sw = checked_cast<SwitchStmtNode *>(p);
|
||||
|
||||
Reference *r = EvalExprNode(env, phase, sw->expr);
|
||||
if (r) r->emitReadBytecode(bCon, p->pos);
|
||||
|
||||
StmtNode *s = sw->statements;
|
||||
while (s) {
|
||||
if (s->getKind() == StmtNode::Case) {
|
||||
ExprStmtNode *c = checked_cast<ExprStmtNode *>(s);
|
||||
if (c->expr) {
|
||||
Reference *r = EvalExprNode(env, phase, c->expr);
|
||||
if (r) r->emitReadBytecode(bCon, p->pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
EvalStmt(env, phase, s);
|
||||
s = s->next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StmtNode::While:
|
||||
{
|
||||
UnaryStmtNode *w = checked_cast<UnaryStmtNode *>(p);
|
||||
|
|
|
@ -520,7 +520,9 @@ namespace JavaScript {
|
|||
|
||||
struct ExprStmtNode: StmtNode {
|
||||
ExprNode *expr; // The expression statement's expression. May be nil for default: or return-with-no-expression statements.
|
||||
#ifdef DIKDIK
|
||||
uint32 label; // Used for case statements' code generation
|
||||
#endif
|
||||
|
||||
ExprStmtNode(size_t pos, Kind kind, ExprNode *expr): StmtNode(pos, kind), expr(expr) {}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче