зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450574 - Remove expressionClosureHandling from Parser. r=jorendorff
--HG-- extra : rebase_source : ad0fb4129ffc06a7ae76a1677fda3c178c2a5b55 extra : histedit_source : d94f615af149c215de008404b04520cc83731b7a
This commit is contained in:
Родитель
479a00ac23
Коммит
0912a15fe5
|
@ -982,7 +982,7 @@ BinASTParser::parseFunctionAux(const BinKind kind, const BinFields& fields)
|
|||
syntax = Statement;
|
||||
break;
|
||||
case BinKind::FunctionExpression:
|
||||
syntax = PrimaryExpression; // FIXME: Probably doesn't work.
|
||||
syntax = Expression; // FIXME: Probably doesn't work.
|
||||
break;
|
||||
case BinKind::ObjectMethod:
|
||||
syntax = Method;
|
||||
|
|
|
@ -1440,21 +1440,8 @@ AccessorTypeToJSOp(AccessorType atype)
|
|||
|
||||
enum FunctionSyntaxKind
|
||||
{
|
||||
// A non-arrow function expression that is a PrimaryExpression and *also* a
|
||||
// complete AssignmentExpression. For example, in
|
||||
//
|
||||
// var x = (function y() {});
|
||||
//
|
||||
// |y| is such a function expression.
|
||||
AssignmentExpression,
|
||||
|
||||
// A non-arrow function expression that is a PrimaryExpression but *not* a
|
||||
// complete AssignmentExpression. For example, in
|
||||
//
|
||||
// var x = (1 + function y() {});
|
||||
//
|
||||
// |y| is such a function expression.
|
||||
PrimaryExpression,
|
||||
// A non-arrow function expression.
|
||||
Expression,
|
||||
|
||||
// A named function appearing as a Statement.
|
||||
Statement,
|
||||
|
@ -1467,12 +1454,6 @@ enum FunctionSyntaxKind
|
|||
Setter,
|
||||
};
|
||||
|
||||
static inline bool
|
||||
IsFunctionExpression(FunctionSyntaxKind kind)
|
||||
{
|
||||
return kind == AssignmentExpression || kind == PrimaryExpression;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
IsConstructorKind(FunctionSyntaxKind kind)
|
||||
{
|
||||
|
|
|
@ -2794,8 +2794,7 @@ ParserBase::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
|||
bool isGlobalSelfHostedBuiltin = false;
|
||||
#endif
|
||||
switch (kind) {
|
||||
case AssignmentExpression:
|
||||
case PrimaryExpression:
|
||||
case Expression:
|
||||
flags = (generatorKind == GeneratorKind::NotGenerator &&
|
||||
asyncKind == FunctionAsyncKind::SyncFunction
|
||||
? JSFunction::INTERPRETED_LAMBDA
|
||||
|
@ -3798,7 +3797,7 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
|
|||
}
|
||||
|
||||
// Revalidate the function name when we transitioned to strict mode.
|
||||
if ((kind == Statement || IsFunctionExpression(kind)) &&
|
||||
if ((kind == Statement || kind == Expression) &&
|
||||
fun->explicitName() &&
|
||||
!inheritedStrict &&
|
||||
pc->sc()->strict())
|
||||
|
@ -3808,7 +3807,7 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
|
|||
|
||||
PropertyName* propertyName = fun->explicitName()->asPropertyName();
|
||||
YieldHandling nameYieldHandling;
|
||||
if (IsFunctionExpression(kind)) {
|
||||
if (kind == Expression) {
|
||||
// Named lambda has binding inside it.
|
||||
nameYieldHandling = bodyYieldHandling;
|
||||
} else {
|
||||
|
@ -3948,7 +3947,6 @@ GeneralParser<ParseHandler, CharT>::functionStmt(uint32_t toStringStart,
|
|||
template <class ParseHandler, typename CharT>
|
||||
typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
InvokedPrediction invoked,
|
||||
FunctionAsyncKind asyncKind)
|
||||
{
|
||||
|
@ -3984,12 +3982,8 @@ GeneralParser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart,
|
|||
if (invoked)
|
||||
pn = handler.setLikelyIIFE(pn);
|
||||
|
||||
FunctionSyntaxKind kind = expressionClosureHandling == ExpressionClosure::Allowed
|
||||
? AssignmentExpression
|
||||
: PrimaryExpression;
|
||||
|
||||
return functionDefinition(pn, toStringStart, InAllowed, yieldHandling, name, kind,
|
||||
generatorKind, asyncKind);
|
||||
return functionDefinition(pn, toStringStart, InAllowed, yieldHandling, name,
|
||||
FunctionSyntaxKind::Expression, generatorKind, asyncKind);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -7234,8 +7228,7 @@ GeneralParser<ParseHandler, CharT>::classDefinition(YieldHandling yieldHandling,
|
|||
if (hasHeritage) {
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
classHeritage = memberExpr(yieldHandling, TripledotProhibited,
|
||||
ExpressionClosure::Forbidden, tt);
|
||||
classHeritage = memberExpr(yieldHandling, TripledotProhibited, tt);
|
||||
if (!classHeritage)
|
||||
return null();
|
||||
}
|
||||
|
@ -7972,7 +7965,6 @@ template <class ParseHandler, typename CharT>
|
|||
MOZ_ALWAYS_INLINE typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::orExpr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */)
|
||||
{
|
||||
|
@ -7986,13 +7978,10 @@ GeneralParser<ParseHandler, CharT>::orExpr(InHandling inHandling, YieldHandling
|
|||
int depth = 0;
|
||||
Node pn;
|
||||
for (;;) {
|
||||
pn = unaryExpr(yieldHandling, tripledotHandling, expressionClosureHandling, possibleError,
|
||||
invoked);
|
||||
pn = unaryExpr(yieldHandling, tripledotHandling, possibleError, invoked);
|
||||
if (!pn)
|
||||
return null();
|
||||
|
||||
expressionClosureHandling = ExpressionClosure::Forbidden;
|
||||
|
||||
// If a binary operator follows, consume it and compute the
|
||||
// corresponding operator.
|
||||
TokenKind tok;
|
||||
|
@ -8057,12 +8046,10 @@ template <class ParseHandler, typename CharT>
|
|||
MOZ_ALWAYS_INLINE typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::condExpr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */)
|
||||
{
|
||||
Node condition = orExpr(inHandling, yieldHandling, tripledotHandling,
|
||||
expressionClosureHandling, possibleError, invoked);
|
||||
Node condition = orExpr(inHandling, yieldHandling, tripledotHandling, possibleError, invoked);
|
||||
if (!condition)
|
||||
return null();
|
||||
|
||||
|
@ -8190,8 +8177,7 @@ GeneralParser<ParseHandler, CharT>::assignExpr(InHandling inHandling, YieldHandl
|
|||
|
||||
isArrow = true;
|
||||
} else {
|
||||
lhs = condExpr(inHandling, yieldHandling, tripledotHandling, ExpressionClosure::Allowed,
|
||||
&possibleErrorInner, invoked);
|
||||
lhs = condExpr(inHandling, yieldHandling, tripledotHandling, &possibleErrorInner, invoked);
|
||||
if (!lhs)
|
||||
return null();
|
||||
|
||||
|
@ -8383,7 +8369,7 @@ typename ParseHandler::Node
|
|||
GeneralParser<ParseHandler, CharT>::unaryOpExpr(YieldHandling yieldHandling, ParseNodeKind kind,
|
||||
uint32_t begin)
|
||||
{
|
||||
Node kid = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden);
|
||||
Node kid = unaryExpr(yieldHandling, TripledotProhibited);
|
||||
if (!kid)
|
||||
return null();
|
||||
return handler.newUnary(kind, begin, kid);
|
||||
|
@ -8393,7 +8379,6 @@ template <class ParseHandler, typename CharT>
|
|||
typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError /* = nullptr */,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */)
|
||||
{
|
||||
|
@ -8428,7 +8413,7 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
|||
// // Evaluates expression, triggering a runtime ReferenceError for
|
||||
// // the undefined name.
|
||||
// typeof (1, nonExistentName);
|
||||
Node kid = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden);
|
||||
Node kid = unaryExpr(yieldHandling, TripledotProhibited);
|
||||
if (!kid)
|
||||
return null();
|
||||
|
||||
|
@ -8444,7 +8429,7 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
|||
|
||||
uint32_t operandOffset = pos().begin;
|
||||
Node operand =
|
||||
memberExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden, tt2);
|
||||
memberExpr(yieldHandling, TripledotProhibited, tt2);
|
||||
if (!operand || !checkIncDecOperand(operand, operandOffset))
|
||||
return null();
|
||||
ParseNodeKind pnk = (tt == TokenKind::Inc)
|
||||
|
@ -8458,7 +8443,7 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
|||
if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand))
|
||||
return null();
|
||||
|
||||
Node expr = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden);
|
||||
Node expr = unaryExpr(yieldHandling, TripledotProhibited);
|
||||
if (!expr)
|
||||
return null();
|
||||
|
||||
|
@ -8476,8 +8461,7 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
|||
|
||||
case TokenKind::Await: {
|
||||
if (pc->isAsync()) {
|
||||
Node kid = unaryExpr(yieldHandling, tripledotHandling, ExpressionClosure::Forbidden,
|
||||
possibleError, invoked);
|
||||
Node kid = unaryExpr(yieldHandling, tripledotHandling, possibleError, invoked);
|
||||
if (!kid)
|
||||
return null();
|
||||
pc->lastAwaitOffset = begin;
|
||||
|
@ -8488,7 +8472,7 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
|
|||
MOZ_FALLTHROUGH;
|
||||
|
||||
default: {
|
||||
Node expr = memberExpr(yieldHandling, tripledotHandling, expressionClosureHandling, tt,
|
||||
Node expr = memberExpr(yieldHandling, tripledotHandling, tt,
|
||||
/* allowCallSyntax = */ true, possibleError, invoked);
|
||||
if (!expr)
|
||||
return null();
|
||||
|
@ -8602,7 +8586,6 @@ template <class ParseHandler, typename CharT>
|
|||
typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::memberExpr(YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
TokenKind tt, bool allowCallSyntax /* = true */,
|
||||
PossibleError* possibleError /* = nullptr */,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */)
|
||||
|
@ -8626,8 +8609,7 @@ GeneralParser<ParseHandler, CharT>::memberExpr(YieldHandling yieldHandling,
|
|||
} else {
|
||||
// Gotten by tryNewTarget
|
||||
tt = anyChars.currentToken().type;
|
||||
Node ctorExpr = memberExpr(yieldHandling, TripledotProhibited,
|
||||
ExpressionClosure::Forbidden, tt,
|
||||
Node ctorExpr = memberExpr(yieldHandling, TripledotProhibited, tt,
|
||||
/* allowCallSyntax = */ false,
|
||||
/* possibleError = */ nullptr, PredictInvoked);
|
||||
if (!ctorExpr)
|
||||
|
@ -8656,8 +8638,7 @@ GeneralParser<ParseHandler, CharT>::memberExpr(YieldHandling yieldHandling,
|
|||
if (!lhs)
|
||||
return null();
|
||||
} else {
|
||||
lhs = primaryExpr(yieldHandling, tripledotHandling, expressionClosureHandling, tt,
|
||||
possibleError, invoked);
|
||||
lhs = primaryExpr(yieldHandling, tripledotHandling, tt, possibleError, invoked);
|
||||
if (!lhs)
|
||||
return null();
|
||||
}
|
||||
|
@ -9832,7 +9813,6 @@ template <class ParseHandler, typename CharT>
|
|||
typename ParseHandler::Node
|
||||
GeneralParser<ParseHandler, CharT>::primaryExpr(YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
TokenKind tt, PossibleError* possibleError,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */)
|
||||
{
|
||||
|
@ -9842,8 +9822,7 @@ GeneralParser<ParseHandler, CharT>::primaryExpr(YieldHandling yieldHandling,
|
|||
|
||||
switch (tt) {
|
||||
case TokenKind::Function:
|
||||
return functionExpr(pos().begin, expressionClosureHandling, invoked,
|
||||
FunctionAsyncKind::SyncFunction);
|
||||
return functionExpr(pos().begin, invoked, FunctionAsyncKind::SyncFunction);
|
||||
|
||||
case TokenKind::Class:
|
||||
return classDefinition(yieldHandling, ClassExpression, NameRequired);
|
||||
|
@ -9908,8 +9887,7 @@ GeneralParser<ParseHandler, CharT>::primaryExpr(YieldHandling yieldHandling,
|
|||
if (nextSameLine == TokenKind::Function) {
|
||||
uint32_t toStringStart = pos().begin;
|
||||
tokenStream.consumeKnownToken(TokenKind::Function);
|
||||
return functionExpr(toStringStart, expressionClosureHandling, PredictUninvoked,
|
||||
FunctionAsyncKind::AsyncFunction);
|
||||
return functionExpr(toStringStart, PredictUninvoked, FunctionAsyncKind::AsyncFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -616,8 +616,6 @@ PerHandlerParser<FullParseHandler>::clearAbortedSyntaxParse()
|
|||
{
|
||||
}
|
||||
|
||||
enum class ExpressionClosure { Allowed, Forbidden };
|
||||
|
||||
template<class Parser>
|
||||
class ParserAnyCharsAccess
|
||||
{
|
||||
|
@ -974,8 +972,8 @@ class GeneralParser
|
|||
Node functionStmt(uint32_t toStringStart,
|
||||
YieldHandling yieldHandling, DefaultHandling defaultHandling,
|
||||
FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction);
|
||||
Node functionExpr(uint32_t toStringStart, ExpressionClosure expressionClosureHandling,
|
||||
InvokedPrediction invoked, FunctionAsyncKind asyncKind);
|
||||
Node functionExpr(uint32_t toStringStart, InvokedPrediction invoked,
|
||||
FunctionAsyncKind asyncKind);
|
||||
|
||||
Node statement(YieldHandling yieldHandling);
|
||||
bool maybeParseDirective(Node list, Node pn, bool* cont);
|
||||
|
@ -1094,24 +1092,20 @@ class GeneralParser
|
|||
Node assignExprWithoutYieldOrAwait(YieldHandling yieldHandling);
|
||||
Node yieldExpression(InHandling inHandling);
|
||||
Node condExpr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling, ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError,
|
||||
TripledotHandling tripledotHandling, PossibleError* possibleError,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node orExpr(InHandling inHandling, YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling, ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError,
|
||||
TripledotHandling tripledotHandling, PossibleError* possibleError,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node unaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling,
|
||||
PossibleError* possibleError = nullptr,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node memberExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling, TokenKind tt,
|
||||
Node memberExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, TokenKind tt,
|
||||
bool allowCallSyntax = true, PossibleError* possibleError = nullptr,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node primaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling,
|
||||
ExpressionClosure expressionClosureHandling, TokenKind tt,
|
||||
PossibleError* possibleError, InvokedPrediction invoked = PredictUninvoked);
|
||||
TokenKind tt, PossibleError* possibleError,
|
||||
InvokedPrediction invoked = PredictUninvoked);
|
||||
Node exprInParens(InHandling inHandling, YieldHandling yieldHandling,
|
||||
TripledotHandling tripledotHandling, PossibleError* possibleError = nullptr);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче