# HG changeset patch # User Tom Schuster # Date 1522601272 -7200 # Sun Apr 01 18:47:52 2018 +0200 # Node ID 0a136c8bccf1eaf5898731497aaff70a953bfae4 # Parent fb1d3fddab8088642f95d9480c3fec27514b5660 Bug 1450574 - Remove NoExpressionClosure FunctionSyntaxKind values. r=jorendorff diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h --- a/js/src/frontend/ParseNode.h +++ b/js/src/frontend/ParseNode.h @@ -1459,50 +1459,36 @@ enum FunctionSyntaxKind // A named function appearing as a Statement. Statement, Arrow, Method, ClassConstructor, DerivedClassConstructor, Getter, - GetterNoExpressionClosure, Setter, - SetterNoExpressionClosure }; static inline bool IsFunctionExpression(FunctionSyntaxKind kind) { return kind == AssignmentExpression || kind == PrimaryExpression; } static inline bool IsConstructorKind(FunctionSyntaxKind kind) { return kind == ClassConstructor || kind == DerivedClassConstructor; } static inline bool -IsGetterKind(FunctionSyntaxKind kind) -{ - return kind == Getter || kind == GetterNoExpressionClosure; -} - -static inline bool -IsSetterKind(FunctionSyntaxKind kind) -{ - return kind == Setter || kind == SetterNoExpressionClosure; -} - -static inline bool IsMethodDefinitionKind(FunctionSyntaxKind kind) { return kind == Method || IsConstructorKind(kind) || - IsGetterKind(kind) || IsSetterKind(kind); + kind == Getter || kind == Setter; } static inline ParseNode* FunctionFormalParametersList(ParseNode* fn, unsigned* numFormals) { MOZ_ASSERT(fn->isKind(ParseNodeKind::Function)); ParseNode* argsBody = fn->pn_body; MOZ_ASSERT(argsBody->isKind(ParseNodeKind::ParamsBody)); diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2810,22 +2810,20 @@ ParserBase::newFunction(HandleAtom atom, allocKind = gc::AllocKind::FUNCTION_EXTENDED; break; case ClassConstructor: case DerivedClassConstructor: flags = JSFunction::INTERPRETED_CLASS_CONSTRUCTOR; allocKind = gc::AllocKind::FUNCTION_EXTENDED; break; case Getter: - case GetterNoExpressionClosure: flags = JSFunction::INTERPRETED_GETTER; allocKind = gc::AllocKind::FUNCTION_EXTENDED; break; case Setter: - case SetterNoExpressionClosure: flags = JSFunction::INTERPRETED_SETTER; allocKind = gc::AllocKind::FUNCTION_EXTENDED; break; default: MOZ_ASSERT(kind == Statement); #ifdef DEBUG if (options().selfHostingMode && !pc->isFunctionBox()) { isGlobalSelfHostedBuiltin = true; @@ -2927,20 +2925,20 @@ ParserBase::leaveInnerFunction(ParseCont return true; } JSAtom* ParserBase::prefixAccessorName(PropertyType propType, HandleAtom propAtom) { RootedAtom prefix(context); - if (propType == PropertyType::Setter || propType == PropertyType::SetterNoExpressionClosure) { + if (propType == PropertyType::Setter) { prefix = context->names().setPrefix; } else { - MOZ_ASSERT(propType == PropertyType::Getter || propType == PropertyType::GetterNoExpressionClosure); + MOZ_ASSERT(propType == PropertyType::Getter); prefix = context->names().getPrefix; } RootedString str(context, ConcatStrings(context, prefix, propAtom)); if (!str) return nullptr; return AtomizeString(context, str); @@ -3033,17 +3031,17 @@ GeneralParser::func } if (hasArguments) { bool hasRest = false; bool hasDefault = false; bool duplicatedParam = false; bool disallowDuplicateParams = kind == Arrow || kind == Method || kind == ClassConstructor; AtomVector& positionalFormals = pc->positionalFormalParameterNames(); - if (IsGetterKind(kind)) { + if (kind == Getter) { error(JSMSG_ACCESSOR_WRONG_ARGS, "getter", "no", "s"); return false; } while (true) { if (hasRest) { error(JSMSG_PARAMETER_AFTER_REST); return false; @@ -3051,17 +3049,17 @@ GeneralParser::func TokenKind tt; if (!tokenStream.getToken(&tt, argModifier)) return false; argModifier = TokenStream::Operand; MOZ_ASSERT_IF(parenFreeArrow, TokenKindIsPossibleIdentifier(tt)); if (tt == TokenKind::TripleDot) { - if (IsSetterKind(kind)) { + if (kind == Setter) { error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", ""); return false; } disallowDuplicateParams = true; if (duplicatedParam) { // Has duplicated args before the rest parameter. error(JSMSG_BAD_DUP_ARGS); @@ -3178,17 +3176,17 @@ GeneralParser::func Node def_expr = assignExprWithoutYieldOrAwait(yieldHandling); if (!def_expr) return false; if (!handler.setLastFunctionFormalParameterDefault(funcpn, def_expr)) return false; } // Setter syntax uniquely requires exactly one argument. - if (IsSetterKind(kind)) + if (kind == Setter) break; if (!tokenStream.matchToken(&matched, TokenKind::Comma, TokenStream::Operand)) return false; if (!matched) break; if (!hasRest) { @@ -3199,34 +3197,34 @@ GeneralParser::func } } if (!parenFreeArrow) { TokenKind tt; if (!tokenStream.getToken(&tt, TokenStream::Operand)) return false; if (tt != TokenKind::Rp) { - if (IsSetterKind(kind)) { + if (kind == Setter) { error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", ""); return false; } error(JSMSG_PAREN_AFTER_FORMAL); return false; } } if (!hasDefault) funbox->length = positionalFormals.length() - hasRest; if (funbox->hasParameterExprs && funbox->hasDirectEval()) funbox->hasDirectEvalInParameterExpr = true; funbox->function()->setArgCount(positionalFormals.length()); - } else if (IsSetterKind(kind)) { + } else if (kind == Setter) { error(JSMSG_ACCESSOR_WRONG_ARGS, "setter", "one", ""); return false; } return true; } template @@ -7161,20 +7159,18 @@ GeneralParser::debu return handler.newDebuggerStatement(p); } static AccessorType ToAccessorType(PropertyType propType) { switch (propType) { case PropertyType::Getter: - case PropertyType::GetterNoExpressionClosure: return AccessorType::Getter; case PropertyType::Setter: - case PropertyType::SetterNoExpressionClosure: return AccessorType::Setter; case PropertyType::Normal: case PropertyType::Method: case PropertyType::GeneratorMethod: case PropertyType::AsyncMethod: case PropertyType::AsyncGeneratorMethod: case PropertyType::Constructor: case PropertyType::DerivedConstructor: @@ -7301,21 +7297,16 @@ GeneralParser::clas propType != PropertyType::Method && propType != PropertyType::GeneratorMethod && propType != PropertyType::AsyncMethod && propType != PropertyType::AsyncGeneratorMethod) { errorAt(nameOffset, JSMSG_BAD_METHOD_DEF); return null(); } - if (propType == PropertyType::Getter) - propType = PropertyType::GetterNoExpressionClosure; - if (propType == PropertyType::Setter) - propType = PropertyType::SetterNoExpressionClosure; - bool isConstructor = !isStatic && propAtom == context->names().constructor; if (isConstructor) { if (propType != PropertyType::Method) { errorAt(nameOffset, JSMSG_BAD_METHOD_DEF); return null(); } if (classStmt.constructorBox) { errorAt(nameOffset, JSMSG_DUPLICATE_PROPERTY, "constructor"); @@ -7324,18 +7315,18 @@ GeneralParser::clas propType = hasHeritage ? PropertyType::DerivedConstructor : PropertyType::Constructor; } else if (isStatic && propAtom == context->names().prototype) { errorAt(nameOffset, JSMSG_BAD_METHOD_DEF); return null(); } RootedAtom funName(context); switch (propType) { - case PropertyType::GetterNoExpressionClosure: - case PropertyType::SetterNoExpressionClosure: + case PropertyType::Getter: + case PropertyType::Setter: if (!anyChars.isCurrentTokenType(TokenKind::Rb)) { funName = prefixAccessorName(propType, propAtom); if (!funName) return null(); } break; case PropertyType::Constructor: case PropertyType::DerivedConstructor: @@ -9768,28 +9759,20 @@ GeneralParser::meth HandleAtom funName) { FunctionSyntaxKind kind; switch (propType) { case PropertyType::Getter: kind = Getter; break; - case PropertyType::GetterNoExpressionClosure: - kind = GetterNoExpressionClosure; - break; - case PropertyType::Setter: kind = Setter; break; - case PropertyType::SetterNoExpressionClosure: - kind = SetterNoExpressionClosure; - break; - case PropertyType::Method: case PropertyType::GeneratorMethod: case PropertyType::AsyncMethod: case PropertyType::AsyncGeneratorMethod: kind = Method; break; case PropertyType::Constructor: diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -229,19 +229,17 @@ Directives::Directives(ParseContext* par enum VarContext { HoistVars, DontHoistVars }; enum PropListType { ObjectLiteral, ClassBody, DerivedClassBody }; enum class PropertyType { Normal, Shorthand, CoverInitializedName, Getter, - GetterNoExpressionClosure, Setter, - SetterNoExpressionClosure, Method, GeneratorMethod, AsyncMethod, AsyncGeneratorMethod, Constructor, DerivedConstructor };