зеркало из https://github.com/mozilla/gecko-dev.git
Bug 872735, part 4 - Remove setBinaryRHS from the ParseHandler protocol. It was only used in parsing switch statements. It is replaced by a newCaseOrDefault method. r=Waldo.
This commit is contained in:
Родитель
dca3ea32f8
Коммит
0fd058b967
|
@ -162,11 +162,6 @@ class FullParseHandler
|
|||
ParseContext<FullParseHandler> *pc, JSOp op = JSOP_NOP) {
|
||||
return ParseNode::newBinaryOrAppend(kind, op, left, right, this, pc, foldConstants);
|
||||
}
|
||||
void setBinaryRHS(ParseNode *pn, ParseNode *rhs) {
|
||||
JS_ASSERT(pn->isArity(PN_BINARY));
|
||||
pn->pn_right = rhs;
|
||||
pn->pn_pos.end = rhs->pn_pos.end;
|
||||
}
|
||||
|
||||
ParseNode *newTernary(ParseNodeKind kind,
|
||||
ParseNode *first, ParseNode *second, ParseNode *third,
|
||||
|
@ -178,12 +173,18 @@ class FullParseHandler
|
|||
return new_<LabeledStatement>(label, stmt, begin);
|
||||
}
|
||||
|
||||
ParseNode *newCaseOrDefault(uint32_t begin, ParseNode *expr, ParseNode *body) {
|
||||
TokenPos pos = TokenPos::make(begin, body->pn_pos.end);
|
||||
return new_<BinaryNode>(expr ? PNK_CASE : PNK_DEFAULT, JSOP_NOP, pos, expr, body);
|
||||
}
|
||||
|
||||
ParseNode *newBreak(PropertyName *label, uint32_t begin, uint32_t end) {
|
||||
return new_<BreakStatement>(label, begin, end);
|
||||
}
|
||||
ParseNode *newContinue(PropertyName *label, uint32_t begin, uint32_t end) {
|
||||
return new_<ContinueStatement>(label, begin, end);
|
||||
}
|
||||
|
||||
ParseNode *newDebuggerStatement(const TokenPos &pos) {
|
||||
return new_<DebuggerStatement>(pos);
|
||||
}
|
||||
|
|
|
@ -3525,7 +3525,10 @@ Parser<ParseHandler>::switchStatement()
|
|||
bool seenDefault = false;
|
||||
TokenKind tt;
|
||||
while ((tt = tokenStream.getToken()) != TOK_RC) {
|
||||
Node casepn;
|
||||
uint32_t caseBegin = tokenStream.currentToken().pos.begin;
|
||||
|
||||
ParseNodeKind caseKind;
|
||||
Node caseExpr;
|
||||
switch (tt) {
|
||||
case TOK_DEFAULT:
|
||||
if (seenDefault) {
|
||||
|
@ -3533,21 +3536,16 @@ Parser<ParseHandler>::switchStatement()
|
|||
return null();
|
||||
}
|
||||
seenDefault = true;
|
||||
casepn = handler.newBinary(PNK_DEFAULT);
|
||||
if (!casepn)
|
||||
return null();
|
||||
caseKind = PNK_DEFAULT;
|
||||
caseExpr = null();
|
||||
break;
|
||||
|
||||
case TOK_CASE:
|
||||
{
|
||||
Node left = expr();
|
||||
if (!left)
|
||||
return null();
|
||||
casepn = handler.newBinary(PNK_CASE, left);
|
||||
if (!casepn)
|
||||
caseKind = PNK_CASE;
|
||||
caseExpr = expr();
|
||||
if (!caseExpr)
|
||||
return null();
|
||||
break;
|
||||
}
|
||||
|
||||
case TOK_ERROR:
|
||||
return null();
|
||||
|
@ -3557,8 +3555,6 @@ Parser<ParseHandler>::switchStatement()
|
|||
return null();
|
||||
}
|
||||
|
||||
handler.addList(caseList, casepn);
|
||||
|
||||
MUST_MATCH_TOKEN(TOK_COLON, JSMSG_COLON_AFTER_CASE);
|
||||
|
||||
Node body = handler.newList(PNK_STATEMENTLIST);
|
||||
|
@ -3576,7 +3572,10 @@ Parser<ParseHandler>::switchStatement()
|
|||
handler.addList(body, stmt);
|
||||
}
|
||||
|
||||
handler.setBinaryRHS(casepn, body);
|
||||
Node casepn = handler.newCaseOrDefault(caseBegin, caseExpr, body);
|
||||
if (!casepn)
|
||||
return null();
|
||||
handler.addList(caseList, casepn);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -90,7 +90,6 @@ class SyntaxParseHandler
|
|||
ParseContext<SyntaxParseHandler> *pc, JSOp op = JSOP_NOP) {
|
||||
return NodeGeneric;
|
||||
}
|
||||
void setBinaryRHS(Node pn, Node rhs) {}
|
||||
|
||||
Node newTernary(ParseNodeKind kind, Node first, Node second, Node third, JSOp op = JSOP_NOP) {
|
||||
return NodeGeneric;
|
||||
|
@ -99,6 +98,9 @@ class SyntaxParseHandler
|
|||
Node newLabeledStatement(PropertyName *label, Node stmt, uint32_t begin) {
|
||||
return NodeGeneric;
|
||||
}
|
||||
Node newCaseOrDefault(uint32_t begin, Node expr, Node body) {
|
||||
return NodeGeneric;
|
||||
}
|
||||
Node newBreak(PropertyName *label, uint32_t begin, uint32_t end) {
|
||||
return NodeGeneric;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче