| Index: src/parsing/preparser.h
|
| diff --git a/src/parsing/preparser.h b/src/parsing/preparser.h
|
| index e93f3f998dc27687069e47412b6db94f8de4c46c..410c20b98bbf50cc085d1706c0b0dcef6660d94d 100644
|
| --- a/src/parsing/preparser.h
|
| +++ b/src/parsing/preparser.h
|
| @@ -143,10 +143,7 @@ class ParserBase : public Traits {
|
| kDontAllowRestrictedIdentifiers
|
| };
|
|
|
| - enum Mode {
|
| - PARSE_LAZILY,
|
| - PARSE_EAGERLY
|
| - };
|
| + enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
|
|
|
| enum VariableDeclarationContext {
|
| kStatementListItem,
|
| @@ -292,13 +289,10 @@ class ParserBase : public Traits {
|
| class ParsingModeScope BASE_EMBEDDED {
|
| public:
|
| ParsingModeScope(ParserBase* parser, Mode mode)
|
| - : parser_(parser),
|
| - old_mode_(parser->mode()) {
|
| + : parser_(parser), old_mode_(parser->mode()) {
|
| parser_->mode_ = mode;
|
| }
|
| - ~ParsingModeScope() {
|
| - parser_->mode_ = old_mode_;
|
| - }
|
| + ~ParsingModeScope() { parser_->mode_ = old_mode_; }
|
|
|
| private:
|
| ParserBase* parser_;
|
| @@ -384,8 +378,7 @@ class ParserBase : public Traits {
|
| Next();
|
| return;
|
| }
|
| - if (scanner()->HasAnyLineTerminatorBeforeNext() ||
|
| - tok == Token::RBRACE ||
|
| + if (scanner()->HasAnyLineTerminatorBeforeNext() || tok == Token::RBRACE ||
|
| tok == Token::EOS) {
|
| return;
|
| }
|
| @@ -760,11 +753,7 @@ class ParserBase : public Traits {
|
| MessageTemplate::Template message, ParseErrorType type, bool* ok);
|
|
|
| // Used to validate property names in object literals and class literals
|
| - enum PropertyKind {
|
| - kAccessorProperty,
|
| - kValueProperty,
|
| - kMethodProperty
|
| - };
|
| + enum PropertyKind { kAccessorProperty, kValueProperty, kMethodProperty };
|
|
|
| class ObjectLiteralCheckerBase {
|
| public:
|
| @@ -1163,6 +1152,7 @@ class PreParserList {
|
| PreParserList* operator->() { return this; }
|
| void Add(T, void*) { ++length_; }
|
| int length() const { return length_; }
|
| +
|
| private:
|
| int length_;
|
| };
|
| @@ -1202,23 +1192,15 @@ class PreParserStatement {
|
| return Default();
|
| }
|
|
|
| - bool IsStringLiteral() {
|
| - return code_ == kStringLiteralExpressionStatement;
|
| - }
|
| + bool IsStringLiteral() { return code_ == kStringLiteralExpressionStatement; }
|
|
|
| - bool IsUseStrictLiteral() {
|
| - return code_ == kUseStrictExpressionStatement;
|
| - }
|
| + bool IsUseStrictLiteral() { return code_ == kUseStrictExpressionStatement; }
|
|
|
| bool IsUseStrongLiteral() { return code_ == kUseStrongExpressionStatement; }
|
|
|
| - bool IsFunctionDeclaration() {
|
| - return code_ == kFunctionDeclaration;
|
| - }
|
| + bool IsFunctionDeclaration() { return code_ == kFunctionDeclaration; }
|
|
|
| - bool IsJumpStatement() {
|
| - return code_ == kJumpStatement;
|
| - }
|
| + bool IsJumpStatement() { return code_ == kJumpStatement; }
|
|
|
| private:
|
| enum Type {
|
| @@ -1245,8 +1227,7 @@ class PreParserFactory {
|
| int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| - PreParserExpression NewNumberLiteral(double number,
|
| - int pos) {
|
| + PreParserExpression NewNumberLiteral(double number, int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern,
|
| @@ -1255,8 +1236,7 @@ class PreParserFactory {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewArrayLiteral(PreParserExpressionList values,
|
| - int literal_index,
|
| - bool is_strong,
|
| + int literal_index, bool is_strong,
|
| int pos) {
|
| return PreParserExpression::ArrayLiteral();
|
| }
|
| @@ -1281,8 +1261,7 @@ class PreParserFactory {
|
| PreParserExpression NewObjectLiteral(PreParserExpressionList properties,
|
| int literal_index,
|
| int boilerplate_properties,
|
| - bool has_function,
|
| - bool is_strong,
|
| + bool has_function, bool is_strong,
|
| int pos) {
|
| return PreParserExpression::ObjectLiteral();
|
| }
|
| @@ -1290,8 +1269,7 @@ class PreParserFactory {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewProperty(PreParserExpression obj,
|
| - PreParserExpression key,
|
| - int pos) {
|
| + PreParserExpression key, int pos) {
|
| if (obj.IsThis()) {
|
| return PreParserExpression::ThisProperty();
|
| }
|
| @@ -1312,16 +1290,13 @@ class PreParserFactory {
|
| PreParserExpression right, int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| - PreParserExpression NewAssignment(Token::Value op,
|
| - PreParserExpression left,
|
| - PreParserExpression right,
|
| - int pos) {
|
| + PreParserExpression NewAssignment(Token::Value op, PreParserExpression left,
|
| + PreParserExpression right, int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewYield(PreParserExpression generator_object,
|
| PreParserExpression expression,
|
| - Yield::Kind yield_kind,
|
| - int pos) {
|
| + Yield::Kind yield_kind, int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewConditional(PreParserExpression condition,
|
| @@ -1330,20 +1305,17 @@ class PreParserFactory {
|
| int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| - PreParserExpression NewCountOperation(Token::Value op,
|
| - bool is_prefix,
|
| + PreParserExpression NewCountOperation(Token::Value op, bool is_prefix,
|
| PreParserExpression expression,
|
| int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewCall(PreParserExpression expression,
|
| - PreParserExpressionList arguments,
|
| - int pos) {
|
| + PreParserExpressionList arguments, int pos) {
|
| return PreParserExpression::Call();
|
| }
|
| PreParserExpression NewCallNew(PreParserExpression expression,
|
| - PreParserExpressionList arguments,
|
| - int pos) {
|
| + PreParserExpressionList arguments, int pos) {
|
| return PreParserExpression::Default();
|
| }
|
| PreParserExpression NewCallRuntime(const AstRawString* name,
|
| @@ -1527,8 +1499,7 @@ class PreParserTraits {
|
|
|
| bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x,
|
| PreParserExpression y,
|
| - Token::Value op,
|
| - int pos,
|
| + Token::Value op, int pos,
|
| PreParserFactory* factory) {
|
| return false;
|
| }
|
| @@ -1628,9 +1599,9 @@ class PreParserTraits {
|
| return PreParserExpression::Default();
|
| }
|
|
|
| - static PreParserExpression ExpressionFromLiteral(
|
| - Token::Value token, int pos, Scanner* scanner,
|
| - PreParserFactory* factory) {
|
| + static PreParserExpression ExpressionFromLiteral(Token::Value token, int pos,
|
| + Scanner* scanner,
|
| + PreParserFactory* factory) {
|
| return PreParserExpression::Default();
|
| }
|
|
|
| @@ -1640,8 +1611,7 @@ class PreParserTraits {
|
| return PreParserExpression::FromIdentifier(name);
|
| }
|
|
|
| - PreParserExpression ExpressionFromString(int pos,
|
| - Scanner* scanner,
|
| + PreParserExpression ExpressionFromString(int pos, Scanner* scanner,
|
| PreParserFactory* factory = NULL);
|
|
|
| PreParserExpression GetIterator(PreParserExpression iterable,
|
| @@ -1662,8 +1632,8 @@ class PreParserTraits {
|
| }
|
|
|
| static void AddParameterInitializationBlock(
|
| - const PreParserFormalParameters& parameters,
|
| - PreParserStatementList list, bool* ok) {}
|
| + const PreParserFormalParameters& parameters, PreParserStatementList list,
|
| + bool* ok) {}
|
|
|
| V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count,
|
| int* expected_property_count, bool* ok) {
|
| @@ -1676,9 +1646,9 @@ class PreParserTraits {
|
| FunctionLiteral::FunctionType function_type, bool* ok);
|
|
|
| V8_INLINE void ParseArrowFunctionFormalParameterList(
|
| - PreParserFormalParameters* parameters,
|
| - PreParserExpression expression, const Scanner::Location& params_loc,
|
| - Scanner::Location* duplicate_loc, bool* ok);
|
| + PreParserFormalParameters* parameters, PreParserExpression expression,
|
| + const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
|
| + bool* ok);
|
|
|
| void ReindexLiterals(const PreParserFormalParameters& paramaters) {}
|
|
|
| @@ -1772,10 +1742,7 @@ class PreParser : public ParserBase<PreParserTraits> {
|
| typedef PreParserExpression Expression;
|
| typedef PreParserStatement Statement;
|
|
|
| - enum PreParseResult {
|
| - kPreParseStackOverflow,
|
| - kPreParseSuccess
|
| - };
|
| + enum PreParseResult { kPreParseStackOverflow, kPreParseSuccess };
|
|
|
| PreParser(Zone* zone, Scanner* scanner, AstValueFactory* ast_value_factory,
|
| ParserRecorder* log, uintptr_t stack_limit)
|
| @@ -1917,9 +1884,9 @@ PreParserExpression PreParserTraits::SpreadCallNew(PreParserExpression function,
|
|
|
|
|
| void PreParserTraits::ParseArrowFunctionFormalParameterList(
|
| - PreParserFormalParameters* parameters,
|
| - PreParserExpression params, const Scanner::Location& params_loc,
|
| - Scanner::Location* duplicate_loc, bool* ok) {
|
| + PreParserFormalParameters* parameters, PreParserExpression params,
|
| + const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
|
| + bool* ok) {
|
| // TODO(wingo): Detect duplicated identifiers in paramlists. Detect parameter
|
| // lists that are too long.
|
|
|
| @@ -2200,8 +2167,7 @@ ParserBase<Traits>::ParseIdentifierName(bool* ok) {
|
|
|
| template <class Traits>
|
| typename ParserBase<Traits>::IdentifierT
|
| -ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get,
|
| - bool* is_set,
|
| +ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, bool* is_set,
|
| bool* ok) {
|
| IdentifierT result = ParseIdentifierName(ok);
|
| if (!*ok) return Traits::EmptyIdentifier();
|
| @@ -2238,7 +2204,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral(
|
| }
|
|
|
|
|
| -#define CHECK_OK ok); \
|
| +#define CHECK_OK ok); \
|
| if (!*ok) return this->EmptyExpression(); \
|
| ((void)0
|
| #define DUMMY ) // to make indentation work
|
| @@ -2246,7 +2212,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral(
|
|
|
| // Used in functions where the return type is not ExpressionT.
|
| #define CHECK_OK_CUSTOM(x) ok); \
|
| - if (!*ok) return this->x(); \
|
| + if (!*ok) return this->x(); \
|
| ((void)0
|
| #define DUMMY ) // to make indentation work
|
| #undef DUMMY
|
| @@ -2881,12 +2847,9 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral(
|
| // Computation of literal_index must happen before pre parse bailout.
|
| int literal_index = function_state_->NextMaterializedLiteralIndex();
|
|
|
| - return factory()->NewObjectLiteral(properties,
|
| - literal_index,
|
| - number_of_boilerplate_properties,
|
| - has_function,
|
| - is_strong(language_mode()),
|
| - pos);
|
| + return factory()->NewObjectLiteral(
|
| + properties, literal_index, number_of_boilerplate_properties, has_function,
|
| + is_strong(language_mode()), pos);
|
| }
|
|
|
|
|
| @@ -3107,10 +3070,9 @@ ParserBase<Traits>::ParseYieldExpression(ExpressionClassifier* classifier,
|
| // after an AssignmentExpression, and none of them can start an
|
| // AssignmentExpression. This allows us to avoid looking for an RHS for
|
| // a Yield::kSuspend operation, given only one look-ahead token.
|
| - if (kind == Yield::kSuspend)
|
| - break;
|
| + if (kind == Yield::kSuspend) break;
|
| DCHECK_EQ(Yield::kDelegating, kind);
|
| - // Delegating yields require an RHS; fall through.
|
| + // Delegating yields require an RHS; fall through.
|
| default:
|
| expression = ParseAssignmentExpression(false, classifier, CHECK_OK);
|
| break;
|
| @@ -3186,9 +3148,14 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN,
|
| // We have a comparison.
|
| Token::Value cmp = op;
|
| switch (op) {
|
| - case Token::NE: cmp = Token::EQ; break;
|
| - case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
|
| - default: break;
|
| + case Token::NE:
|
| + cmp = Token::EQ;
|
| + break;
|
| + case Token::NE_STRICT:
|
| + cmp = Token::EQ_STRICT;
|
| + break;
|
| + default:
|
| + break;
|
| }
|
| if (cmp == Token::EQ && is_strong(language_mode())) {
|
| ReportMessageAt(op_location, MessageTemplate::kStrongEqual);
|
| @@ -3262,9 +3229,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
|
| MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
|
| this->MarkExpressionAsAssigned(expression);
|
|
|
| - return factory()->NewCountOperation(op,
|
| - true /* prefix */,
|
| - expression,
|
| + return factory()->NewCountOperation(op, true /* prefix */, expression,
|
| position());
|
|
|
| } else {
|
| @@ -3294,11 +3259,8 @@ ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier,
|
| expression = this->MarkExpressionAsAssigned(expression);
|
|
|
| Token::Value next = Next();
|
| - expression =
|
| - factory()->NewCountOperation(next,
|
| - false /* postfix */,
|
| - expression,
|
| - position());
|
| + expression = factory()->NewCountOperation(next, false /* postfix */,
|
| + expression, position());
|
| }
|
| return expression;
|
| }
|
| @@ -3796,8 +3758,9 @@ ParserBase<Traits>::ParseMemberExpressionContinuation(
|
|
|
|
|
| template <class Traits>
|
| -void ParserBase<Traits>::ParseFormalParameter(
|
| - FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) {
|
| +void ParserBase<Traits>::ParseFormalParameter(FormalParametersT* parameters,
|
| + ExpressionClassifier* classifier,
|
| + bool* ok) {
|
| // FormalParameter[Yield,GeneratorParameter] :
|
| // BindingElement[?Yield, ?GeneratorParameter]
|
| bool is_rest = parameters->has_rest;
|
| @@ -3881,7 +3844,7 @@ void ParserBase<Traits>::ParseFormalParameterList(
|
| classifier->RecordNonSimpleParameter();
|
| if (peek() == Token::COMMA) {
|
| ReportMessageAt(scanner()->peek_location(),
|
| - MessageTemplate::kParamAfterRest);
|
| + MessageTemplate::kParamAfterRest);
|
| *ok = false;
|
| return;
|
| }
|
|
|