Chromium Code Reviews| Index: src/parser.h |
| diff --git a/src/parser.h b/src/parser.h |
| index 2b0995ace283838ea5a324a41f1c212d865f629d..dc6ed64bd7caa2acfcf2c40495f9d4977261b420 100644 |
| --- a/src/parser.h |
| +++ b/src/parser.h |
| @@ -407,7 +407,43 @@ class RegExpParser BASE_EMBEDDED { |
| // Forward declaration. |
| class SingletonLogger; |
| -class Parser : public ParserBase { |
| + |
| +class Parser; |
|
Michael Starzinger
2014/02/10 13:28:03
nit: Can we group this forward declaration togethe
marja
2014/02/10 15:02:07
Done.
|
| + |
| +class ParserTraits { |
| + public: |
| + // Return types for traversing functions. |
| + typedef Handle<String> IdentifierType; |
| + |
| + explicit ParserTraits(Parser* parser) : parser_(parser) { } |
| + |
| + // Helper functions for recursive descent. |
| + bool is_classic_mode() const; |
| + bool is_generator() const; |
| + bool IsEvalOrArguments(Handle<String> identifier) const; |
| + |
| + // Reporting errors. |
| + void ReportMessageAt(Scanner::Location source_location, |
| + const char* message, |
| + Vector<const char*> args); |
| + void ReportMessage(const char* message, Vector<Handle<String> > args); |
| + void ReportMessageAt(Scanner::Location source_location, |
| + const char* message, |
| + Vector<Handle<String> > args); |
| + |
| + // Identifiers: |
| + static IdentifierType EmptyIdentifier() { |
| + return Handle<String>(); |
| + } |
| + |
| + IdentifierType GetSymbol(); |
| + |
| + private: |
| + Parser* parser_; |
| +}; |
| + |
| + |
| +class Parser : public ParserBase<ParserTraits> { |
| public: |
| explicit Parser(CompilationInfo* info); |
| ~Parser() { |
| @@ -427,6 +463,8 @@ class Parser : public ParserBase { |
| bool Parse(); |
| private: |
| + friend class ParserTraits; |
| + |
| static const int kMaxNumFunctionLocals = 131071; // 2^17-1 |
| enum Mode { |
| @@ -521,10 +559,6 @@ class Parser : public ParserBase { |
| Mode old_mode_; |
| }; |
| - virtual bool is_classic_mode() { |
| - return top_scope_->is_classic_mode(); |
| - } |
| - |
| // Returns NULL if parsing failed. |
| FunctionLiteral* ParseProgram(); |
| @@ -541,17 +575,6 @@ class Parser : public ParserBase { |
| // Report syntax error |
| void ReportInvalidPreparseData(Handle<String> name, bool* ok); |
| - void ReportMessage(const char* message, Vector<const char*> args); |
| - void ReportMessage(const char* message, Vector<Handle<String> > args); |
| - void ReportMessageAt(Scanner::Location location, const char* type) { |
| - ReportMessageAt(location, type, Vector<const char*>::empty()); |
| - } |
| - void ReportMessageAt(Scanner::Location loc, |
| - const char* message, |
| - Vector<const char*> args); |
| - void ReportMessageAt(Scanner::Location loc, |
| - const char* message, |
| - Vector<Handle<String> > args); |
| void set_pre_parse_data(ScriptDataImpl *data) { |
| pre_parse_data_ = data; |
| @@ -571,9 +594,6 @@ class Parser : public ParserBase { |
| ? top_scope_ : top_scope_->DeclarationScope(); |
| } |
| - // Check if the given string is 'eval' or 'arguments'. |
| - bool IsEvalOrArguments(Handle<String> string); |
| - |
| // All ParseXXX functions take as the last argument an *ok parameter |
| // which is set to false if parsing failed; it is unchanged otherwise. |
| // By making the 'exception handling' explicit, we are forced to check |
| @@ -660,8 +680,6 @@ class Parser : public ParserBase { |
| // Magical syntax support. |
| Expression* ParseV8Intrinsic(bool* ok); |
| - bool is_generator() const { return current_function_state_->is_generator(); } |
| - |
| bool CheckInOrOf(bool accept_OF, ForEachStatement::VisitMode* visit_mode); |
| Handle<String> LiteralString(PretenureFlag tenured) { |
| @@ -684,20 +702,10 @@ class Parser : public ParserBase { |
| } |
| } |
| - Handle<String> GetSymbol(); |
| - |
| // Get odd-ball literals. |
| Literal* GetLiteralUndefined(int position); |
| Literal* GetLiteralTheHole(int position); |
| - Handle<String> ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool* ok); |
| - Handle<String> ParseIdentifierOrStrictReservedWord( |
| - bool* is_strict_reserved, bool* ok); |
| - Handle<String> ParseIdentifierName(bool* ok); |
| - Handle<String> ParseIdentifierNameOrGetOrSet(bool* is_get, |
| - bool* is_set, |
| - bool* ok); |
| - |
| // Determine if the expression is a variable proxy and mark it as being used |
| // in an assignment or with a increment/decrement operator. This is currently |
| // used on for the statically checking assignments to harmony const bindings. |