Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index edabdaefa1904b5b927f7d9bdad612eb6bde2efe..61889580fb7f9f249772506b566a9688a608d6b9 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -136,8 +136,12 @@ struct FormalParametersBase { |
| #define CHECK_OK CHECK_OK_CUSTOM(EmptyExpression) |
| -// Common base class shared between parser and pre-parser. Traits encapsulate |
| -// the differences between Parser and PreParser: |
| +// Common base class template shared between parser and pre-parser. |
| +// The Impl parameter is the actual class of the parser/pre-parser, |
| +// following the Curiously Recurring Template Pattern (CRTP). |
| + |
| +// The traits class template encapsulates the differences between |
| +// parser/pre-parser implementations. In particular: |
| // - Return types: For example, Parser functions return Expression* and |
| // PreParser functions return PreParserExpression. |
| @@ -155,33 +159,40 @@ struct FormalParametersBase { |
| // pretenured, and PreParser doesn't care. |
|
marja
2016/08/23 09:09:39
Could you add the "outline" how the classes inheri
nickie
2016/08/23 12:10:12
Done.
|
| // The traits are expected to contain the following typedefs: |
| -// struct Traits { |
| +// template <> |
| +// class ParserBaseTraits<Impl> { |
| // // In particular... |
| // struct Type { |
| -// // Used by FunctionState and BlockState. |
| -// typedef Scope; |
| // typedef GeneratorVariable; |
| +// typedef AstProperties; |
| +// typedef ExpressionClassifier; |
| // // Return types for traversing functions. |
| // typedef Identifier; |
| // typedef Expression; |
| +// typedef YieldExpression; |
| // typedef FunctionLiteral; |
| // typedef ClassLiteral; |
| -// typedef ObjectLiteralProperty; |
| // typedef Literal; |
| +// typedef ObjectLiteralProperty; |
| // typedef ExpressionList; |
| // typedef PropertyList; |
| // typedef FormalParameter; |
| // typedef FormalParameters; |
| +// typedef StatementList; |
| // // For constructing objects returned by the traversing functions. |
| // typedef Factory; |
| // }; |
| // // ... |
| // }; |
| -template <typename Traits> |
| -class ParserBase : public Traits { |
| +template <typename Impl> |
| +class ParserBaseTraits; |
| + |
| +template <typename Impl> |
| +class ParserBase : public ParserBaseTraits<Impl> { |
| public: |
| // Shorten type names defined by Traits. |
| + typedef ParserBaseTraits<Impl> Traits; |
| typedef typename Traits::Type::Expression ExpressionT; |
| typedef typename Traits::Type::Identifier IdentifierT; |
| typedef typename Traits::Type::FormalParameter FormalParameterT; |
| @@ -192,11 +203,14 @@ class ParserBase : public Traits { |
| typedef typename Traits::Type::StatementList StatementListT; |
| typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier; |
| + // All implementation-specific methods must be called through this. |
| + Impl* impl() { return static_cast<Impl*>(this); } |
| + const Impl* impl() const { return static_cast<const Impl*>(this); } |
| + |
| ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| v8::Extension* extension, AstValueFactory* ast_value_factory, |
| - ParserRecorder* log, typename Traits::Type::Parser this_object) |
| - : Traits(this_object), |
| - scope_state_(nullptr), |
| + ParserRecorder* log) |
| + : scope_state_(nullptr), |
| function_state_(nullptr), |
| extension_(extension), |
| fni_(nullptr), |
| @@ -515,8 +529,7 @@ class ParserBase : public Traits { |
| // to this function. Filled in by constructor. |
| bool this_function_is_parenthesized_; |
| - friend class ParserTraits; |
| - friend class PreParserTraits; |
| + friend class ParserBaseTraits<Impl>; |
| friend class Checkpoint; |
| }; |
| @@ -1284,8 +1297,8 @@ class ParserBase : public Traits { |
| friend class DiscardableZoneScope; |
| }; |
| -template <class Traits> |
| -ParserBase<Traits>::FunctionState::FunctionState( |
| +template <typename Impl> |
| +ParserBase<Impl>::FunctionState::FunctionState( |
| FunctionState** function_state_stack, ScopeState** scope_stack, |
| Scope* scope, FunctionKind kind) |
| : ScopeState(scope_stack, scope), |
| @@ -1311,13 +1324,13 @@ ParserBase<Traits>::FunctionState::FunctionState( |
| } |
| -template <class Traits> |
| -ParserBase<Traits>::FunctionState::~FunctionState() { |
| +template <typename Impl> |
| +ParserBase<Impl>::FunctionState::~FunctionState() { |
| *function_state_stack_ = outer_function_state_; |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::GetUnexpectedTokenMessage( |
| +template <typename Impl> |
| +void ParserBase<Impl>::GetUnexpectedTokenMessage( |
| Token::Value token, MessageTemplate::Template* message, |
| Scanner::Location* location, const char** arg, |
| MessageTemplate::Template default_) { |
| @@ -1376,14 +1389,14 @@ void ParserBase<Traits>::GetUnexpectedTokenMessage( |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
| +template <typename Impl> |
| +void ParserBase<Impl>::ReportUnexpectedToken(Token::Value token) { |
| return ReportUnexpectedTokenAt(scanner_->location(), token); |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::ReportUnexpectedTokenAt( |
| +template <typename Impl> |
| +void ParserBase<Impl>::ReportUnexpectedTokenAt( |
| Scanner::Location source_location, Token::Value token, |
| MessageTemplate::Template message) { |
| const char* arg; |
| @@ -1392,8 +1405,8 @@ void ParserBase<Traits>::ReportUnexpectedTokenAt( |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParseIdentifier( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifier( |
| AllowRestrictedIdentifiers allow_restricted_identifiers, bool* ok) { |
| ExpressionClassifier classifier(this); |
| auto result = |
| @@ -1408,10 +1421,10 @@ typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParseIdentifier( |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::IdentifierT |
| -ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::IdentifierT |
| +ParserBase<Impl>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier, |
| + bool* ok) { |
| Token::Value next = Next(); |
| if (next == Token::IDENTIFIER || next == Token::ASYNC || |
| (next == Token::AWAIT && !parsing_module_)) { |
| @@ -1480,10 +1493,11 @@ ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier, |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::IdentifierT |
| -ParserBase<Traits>::ParseIdentifierOrStrictReservedWord( |
| - bool is_generator, bool* is_strict_reserved, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::IdentifierT |
| +ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(bool is_generator, |
| + bool* is_strict_reserved, |
| + bool* ok) { |
| Token::Value next = Next(); |
| if (next == Token::IDENTIFIER || (next == Token::AWAIT && !parsing_module_) || |
| next == Token::ASYNC) { |
| @@ -1500,9 +1514,9 @@ ParserBase<Traits>::ParseIdentifierOrStrictReservedWord( |
| return this->GetSymbol(scanner()); |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::IdentifierT |
| -ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName( |
| + bool* ok) { |
| Token::Value next = Next(); |
| if (next != Token::IDENTIFIER && next != Token::ASYNC && |
| next != Token::ENUM && next != Token::AWAIT && next != Token::LET && |
| @@ -1518,8 +1532,8 @@ ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
| return this->GetSymbol(scanner()); |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseRegExpLiteral( |
| bool* ok) { |
| int pos = peek_position(); |
| if (!scanner()->ScanRegExpPattern()) { |
| @@ -1545,10 +1559,9 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| - bool* is_async, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression( |
| + ExpressionClassifier* classifier, bool* is_async, bool* ok) { |
| // PrimaryExpression :: |
| // 'this' |
| // 'null' |
| @@ -1726,8 +1739,8 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseExpression( |
| bool accept_IN, bool* ok) { |
| ExpressionClassifier classifier(this); |
| ExpressionT result = ParseExpression(accept_IN, &classifier, CHECK_OK); |
| @@ -1735,8 +1748,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| return result; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseExpression( |
| bool accept_IN, ExpressionClassifier* classifier, bool* ok) { |
| // Expression :: |
| // AssignmentExpression |
| @@ -1801,8 +1814,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral( |
| ExpressionClassifier* classifier, bool* ok) { |
| // ArrayLiteral :: |
| // '[' Expression? (',' Expression?)* ']' |
| @@ -1877,8 +1890,8 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral( |
| return result; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName( |
| IdentifierT* name, bool* is_get, bool* is_set, bool* is_await, |
| bool* is_computed_name, ExpressionClassifier* classifier, bool* ok) { |
| Token::Value token = peek(); |
| @@ -1937,9 +1950,9 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( |
| : factory()->NewStringLiteral(*name, pos); |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ObjectLiteralPropertyT |
| -ParserBase<Traits>::ParsePropertyDefinition( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ObjectLiteralPropertyT |
| +ParserBase<Impl>::ParsePropertyDefinition( |
| ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, |
| MethodKind method_kind, bool* is_computed_name, bool* has_seen_constructor, |
| ExpressionClassifier* classifier, IdentifierT* name, bool* ok) { |
| @@ -2162,8 +2175,8 @@ ParserBase<Traits>::ParsePropertyDefinition( |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral( |
| ExpressionClassifier* classifier, bool* ok) { |
| // ObjectLiteral :: |
| // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' |
| @@ -2218,10 +2231,11 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseObjectLiteral( |
| pos); |
| } |
| -template <class Traits> |
| -typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( |
| - Scanner::Location* first_spread_arg_loc, bool maybe_arrow, |
| - ExpressionClassifier* classifier, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::Traits::Type::ExpressionList |
| +ParserBase<Impl>::ParseArguments(Scanner::Location* first_spread_arg_loc, |
| + bool maybe_arrow, |
| + ExpressionClassifier* classifier, bool* ok) { |
| // Arguments :: |
| // '(' (AssignmentExpression)*[','] ')' |
| @@ -2301,11 +2315,11 @@ typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( |
| } |
| // Precedence = 2 |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| - ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, |
| + ExpressionClassifier* classifier, |
| + bool* ok) { |
| // AssignmentExpression :: |
| // ConditionalExpression |
| // ArrowFunction |
| @@ -2319,7 +2333,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| } |
| FuncNameInferrer::State fni_state(fni_); |
| - ParserBase<Traits>::Checkpoint checkpoint(this); |
| + Checkpoint checkpoint(this); |
| ExpressionClassifier arrow_formals_classifier(this, |
| classifier->duplicate_finder()); |
| @@ -2508,11 +2522,9 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| return result; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseYieldExpression(bool accept_IN, |
| - ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression( |
| + bool accept_IN, ExpressionClassifier* classifier, bool* ok) { |
| // YieldExpression :: |
| // 'yield' ([no line terminator] '*'? AssignmentExpression)? |
| int pos = peek_position(); |
| @@ -2561,10 +2573,10 @@ ParserBase<Traits>::ParseYieldExpression(bool accept_IN, |
| return yield; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseTailCallExpression(ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseTailCallExpression(ExpressionClassifier* classifier, |
| + bool* ok) { |
| // TailCallExpression:: |
| // 'continue' MemberExpression Arguments |
| // 'continue' CallExpression Arguments |
| @@ -2624,11 +2636,11 @@ ParserBase<Traits>::ParseTailCallExpression(ExpressionClassifier* classifier, |
| } |
| // Precedence = 3 |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, |
| - ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseConditionalExpression(bool accept_IN, |
| + ExpressionClassifier* classifier, |
| + bool* ok) { |
| // ConditionalExpression :: |
| // LogicalOrExpression |
| // LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression |
| @@ -2657,11 +2669,9 @@ ParserBase<Traits>::ParseConditionalExpression(bool accept_IN, |
| // Precedence >= 4 |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, |
| - ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression( |
| + int prec, bool accept_IN, ExpressionClassifier* classifier, bool* ok) { |
| DCHECK(prec >= 4); |
| ExpressionT x = this->ParseUnaryExpression(classifier, CHECK_OK); |
| for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { |
| @@ -2716,10 +2726,9 @@ ParserBase<Traits>::ParseBinaryExpression(int prec, bool accept_IN, |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression( |
| + ExpressionClassifier* classifier, bool* ok) { |
| // UnaryExpression :: |
| // PostfixExpression |
| // 'delete' UnaryExpression |
| @@ -2821,10 +2830,9 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier, |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression( |
| + ExpressionClassifier* classifier, bool* ok) { |
| // PostfixExpression :: |
| // LeftHandSideExpression ('++' | '--')? |
| @@ -2853,10 +2861,10 @@ ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier, |
| return expression; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseLeftHandSideExpression( |
| - ExpressionClassifier* classifier, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseLeftHandSideExpression(ExpressionClassifier* classifier, |
| + bool* ok) { |
| // LeftHandSideExpression :: |
| // (NewExpression | MemberExpression) ... |
| @@ -3001,9 +3009,9 @@ ParserBase<Traits>::ParseLeftHandSideExpression( |
| } |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseMemberWithNewPrefixesExpression( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseMemberWithNewPrefixesExpression( |
| ExpressionClassifier* classifier, bool* is_async, bool* ok) { |
| // NewExpression :: |
| // ('new')+ MemberExpression |
| @@ -3066,10 +3074,9 @@ ParserBase<Traits>::ParseMemberWithNewPrefixesExpression( |
| return this->ParseMemberExpression(classifier, is_async, ok); |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier, |
| - bool* is_async, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression( |
| + ExpressionClassifier* classifier, bool* is_async, bool* ok) { |
| // MemberExpression :: |
| // (PrimaryExpression | FunctionLiteral | ClassLiteral) |
| // ('[' Expression ']' | '.' Identifier | Arguments | TemplateLiteral)* |
| @@ -3134,9 +3141,9 @@ ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier, |
| return result; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression( |
| + bool is_new, bool* ok) { |
| Expect(Token::SUPER, CHECK_OK); |
| int pos = position(); |
| @@ -3162,10 +3169,10 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) { |
| return this->EmptyExpression(); |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name, |
| - const char* full_name, int pos, |
| - bool* ok) { |
| +template <typename Impl> |
| +void ParserBase<Impl>::ExpectMetaProperty(Vector<const char> property_name, |
| + const char* full_name, int pos, |
| + bool* ok) { |
| Consume(Token::PERIOD); |
| ExpectContextualKeyword(property_name, CHECK_OK_CUSTOM(Void)); |
| if (scanner()->literal_contains_escapes()) { |
| @@ -3176,9 +3183,9 @@ void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name, |
| } |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseNewTargetExpression(bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseNewTargetExpression(bool* ok) { |
| int pos = position(); |
| ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK); |
| @@ -3192,9 +3199,9 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) { |
| return this->NewTargetExpression(pos); |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseMemberExpressionContinuation( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseMemberExpressionContinuation( |
| ExpressionT expression, bool* is_async, ExpressionClassifier* classifier, |
| bool* ok) { |
| // Parses this part of MemberExpression: |
| @@ -3269,9 +3276,10 @@ ParserBase<Traits>::ParseMemberExpressionContinuation( |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::ParseFormalParameter( |
| - FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { |
| +template <typename Impl> |
| +void ParserBase<Impl>::ParseFormalParameter(FormalParametersT* parameters, |
| + ExpressionClassifier* classifier, |
| + bool* ok) { |
| // FormalParameter[Yield,GeneratorParameter] : |
| // BindingElement[?Yield, ?GeneratorParameter] |
| bool is_rest = parameters->has_rest; |
| @@ -3305,8 +3313,8 @@ void ParserBase<Traits>::ParseFormalParameter( |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::ParseFormalParameterList( |
| +template <typename Impl> |
| +void ParserBase<Impl>::ParseFormalParameterList( |
| FormalParametersT* parameters, ExpressionClassifier* classifier, bool* ok) { |
| // FormalParameters[Yield] : |
| // [empty] |
| @@ -3356,12 +3364,12 @@ void ParserBase<Traits>::ParseFormalParameterList( |
| } |
| } |
| -template <class Traits> |
| -void ParserBase<Traits>::CheckArityRestrictions(int param_count, |
| - FunctionKind function_kind, |
| - bool has_rest, |
| - int formals_start_pos, |
| - int formals_end_pos, bool* ok) { |
| +template <typename Impl> |
| +void ParserBase<Impl>::CheckArityRestrictions(int param_count, |
| + FunctionKind function_kind, |
| + bool has_rest, |
| + int formals_start_pos, |
| + int formals_end_pos, bool* ok) { |
| if (IsGetterFunction(function_kind)) { |
| if (param_count != 0) { |
| ReportMessageAt(Scanner::Location(formals_start_pos, formals_end_pos), |
| @@ -3383,8 +3391,8 @@ void ParserBase<Traits>::CheckArityRestrictions(int param_count, |
| } |
| -template <class Traits> |
| -bool ParserBase<Traits>::IsNextLetKeyword() { |
| +template <typename Impl> |
| +bool ParserBase<Impl>::IsNextLetKeyword() { |
| DCHECK(peek() == Token::LET); |
| Token::Value next_next = PeekAhead(); |
| switch (next_next) { |
| @@ -3408,8 +3416,8 @@ bool ParserBase<Traits>::IsNextLetKeyword() { |
| } |
| } |
| -template <class Traits> |
| -bool ParserBase<Traits>::IsTrivialExpression() { |
| +template <typename Impl> |
| +bool ParserBase<Impl>::IsTrivialExpression() { |
| Token::Value peek_token = peek(); |
| if (peek_token == Token::SMI || peek_token == Token::NUMBER || |
| peek_token == Token::NULL_LITERAL || peek_token == Token::TRUE_LITERAL || |
| @@ -3426,9 +3434,9 @@ bool ParserBase<Traits>::IsTrivialExpression() { |
| return false; |
| } |
| -template <class Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseArrowFunctionLiteral( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::ParseArrowFunctionLiteral( |
| bool accept_IN, const FormalParametersT& formal_parameters, bool is_async, |
| const ExpressionClassifier& formals_classifier, bool* ok) { |
| if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| @@ -3545,11 +3553,9 @@ ParserBase<Traits>::ParseArrowFunctionLiteral( |
| } |
| -template <typename Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, |
| - ExpressionClassifier* classifier, |
| - bool* ok) { |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral( |
| + ExpressionT tag, int start, ExpressionClassifier* classifier, bool* ok) { |
| // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal |
| // text followed by a substitution expression), finalized by a single |
| // TEMPLATE_TAIL. |
| @@ -3642,9 +3648,9 @@ ParserBase<Traits>::ParseTemplateLiteral(ExpressionT tag, int start, |
| } |
| -template <typename Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::CheckAndRewriteReferenceExpression( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::CheckAndRewriteReferenceExpression( |
| ExpressionT expression, int beg_pos, int end_pos, |
| MessageTemplate::Template message, bool* ok) { |
| return this->CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos, |
| @@ -3652,9 +3658,9 @@ ParserBase<Traits>::CheckAndRewriteReferenceExpression( |
| } |
| -template <typename Traits> |
| -typename ParserBase<Traits>::ExpressionT |
| -ParserBase<Traits>::CheckAndRewriteReferenceExpression( |
| +template <typename Impl> |
| +typename ParserBase<Impl>::ExpressionT |
| +ParserBase<Impl>::CheckAndRewriteReferenceExpression( |
| ExpressionT expression, int beg_pos, int end_pos, |
| MessageTemplate::Template message, ParseErrorType type, bool* ok) { |
| if (this->IsIdentifier(expression) && is_strict(language_mode()) && |
| @@ -3679,14 +3685,14 @@ ParserBase<Traits>::CheckAndRewriteReferenceExpression( |
| } |
| -template <typename Traits> |
| -bool ParserBase<Traits>::IsValidReferenceExpression(ExpressionT expression) { |
| +template <typename Impl> |
| +bool ParserBase<Impl>::IsValidReferenceExpression(ExpressionT expression) { |
| return this->IsAssignableIdentifier(expression) || expression->IsProperty(); |
| } |
| -template <typename Traits> |
| -void ParserBase<Traits>::CheckDestructuringElement( |
| +template <typename Impl> |
| +void ParserBase<Impl>::CheckDestructuringElement( |
| ExpressionT expression, ExpressionClassifier* classifier, int begin, |
| int end) { |
| if (!IsValidPattern(expression) && !expression->IsAssignment() && |
| @@ -3701,8 +3707,8 @@ void ParserBase<Traits>::CheckDestructuringElement( |
| #undef CHECK_OK |
| #undef CHECK_OK_CUSTOM |
| -template <typename Traits> |
| -void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( |
| +template <typename Impl> |
| +void ParserBase<Impl>::ObjectLiteralChecker::CheckProperty( |
| Token::Value property, PropertyKind type, MethodKind method_type, |
| ExpressionClassifier* classifier, bool* ok) { |
| DCHECK(!IsStaticMethod(method_type)); |
| @@ -3720,8 +3726,8 @@ void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( |
| } |
| } |
| -template <typename Traits> |
| -void ParserBase<Traits>::ClassLiteralChecker::CheckProperty( |
| +template <typename Impl> |
| +void ParserBase<Impl>::ClassLiteralChecker::CheckProperty( |
| Token::Value property, PropertyKind type, MethodKind method_type, |
| ExpressionClassifier* classifier, bool* ok) { |
| DCHECK(type == kMethodProperty || type == kAccessorProperty); |