Chromium Code Reviews| Index: src/parser.h |
| diff --git a/src/parser.h b/src/parser.h |
| index c65a4ca5f3a46b08a91e139849301e736f3bd888..4b4a105d2a0b348733b157ece31dbcf32fa04892 100644 |
| --- a/src/parser.h |
| +++ b/src/parser.h |
| @@ -163,17 +163,17 @@ class ScriptDataImpl : public ScriptData { |
| }; |
| -class ParserApi { |
| +class PreParserApi { |
| public: |
| - // Parses the source code represented by the compilation info and sets its |
| - // function literal. Returns false (and deallocates any allocated AST |
| - // nodes) if parsing failed. |
| - static bool Parse(CompilationInfo* info, int flags); |
| - |
| - // Generic preparser generating full preparse data. |
| + // Pre-parser a character stream, and return full preparse data. |
|
Michael Starzinger
2013/04/05 10:30:33
nit: s/Pre-parser/Pre-parse/ (minus the 'r').
wingo
2013/04/05 12:00:14
Done.
|
| + // |
| + // This interface is here instead of in preparser.h because it instantiates a |
| + // preparser recorder object that is suited to the parser's purposes. Also, |
| + // the preparser doesn't know about ScriptDataImpl. |
| static ScriptDataImpl* PreParse(Utf16CharacterStream* source); |
| }; |
| + |
| // ---------------------------------------------------------------------------- |
| // REGEXP PARSING |
| @@ -425,18 +425,34 @@ class SingletonLogger; |
| class Parser { |
| public: |
| - Parser(CompilationInfo* info, |
| - int parsing_flags, // Combination of ParsingFlags |
| - v8::Extension* extension, |
| - ScriptDataImpl* pre_data); |
| + explicit Parser(CompilationInfo* info); |
| virtual ~Parser() { |
| delete reusable_preparser_; |
| reusable_preparser_ = NULL; |
| } |
| + bool allow_natives_syntax() const { return allow_natives_syntax_; } |
| + bool allow_lazy() const { return allow_lazy_; } |
| + bool allow_modules() { return scanner().HarmonyModules(); } |
| + bool allow_harmony_scoping() { return scanner().HarmonyScoping(); } |
| + bool allow_generators() const { return allow_generators_; } |
| + |
| + void set_allow_natives_syntax(bool allow) { allow_natives_syntax_ = allow; } |
| + void set_allow_lazy(bool allow) { allow_lazy_ = allow; } |
| + void set_allow_modules(bool allow) { scanner().SetHarmonyModules(allow); } |
| + void set_allow_harmony_scoping(bool allow) { |
| + scanner().SetHarmonyScoping(allow); |
| + } |
| + void set_allow_generators(bool allow) { allow_generators_ = allow; } |
| + |
| + // Parses the source code represented by the compilation info and sets its |
| + // function literal. Returns false (and deallocates any allocated AST |
| + // nodes) if parsing failed. |
| + static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } |
| + bool Parse(); |
| + |
| // Returns NULL if parsing failed. |
| FunctionLiteral* ParseProgram(); |
| - FunctionLiteral* ParseLazy(); |
| void ReportMessageAt(Scanner::Location loc, |
| const char* message, |
| @@ -550,6 +566,7 @@ class Parser { |
| Mode old_mode_; |
| }; |
| + FunctionLiteral* ParseLazy(); |
| FunctionLiteral* ParseLazy(Utf16CharacterStream* source, |
| ZoneScope* zone_scope); |
| @@ -568,10 +585,15 @@ class Parser { |
| void ReportMessage(const char* message, Vector<const char*> args); |
| void ReportMessage(const char* message, Vector<Handle<String> > args); |
| + void set_pre_parse_data(ScriptDataImpl *data) { |
| + pre_parse_data_ = data; |
| + symbol_cache_.Initialize(data ? data->symbol_count() : 0, zone()); |
| + } |
| + |
| bool inside_with() const { return top_scope_->inside_with(); } |
| Scanner& scanner() { return scanner_; } |
| Mode mode() const { return mode_; } |
| - ScriptDataImpl* pre_data() const { return pre_data_; } |
| + ScriptDataImpl* pre_parse_data() const { return pre_parse_data_; } |
| bool is_extended_mode() { |
| ASSERT(top_scope_ != NULL); |
| return top_scope_->is_extended_mode(); |
| @@ -833,13 +855,13 @@ class Parser { |
| FunctionState* current_function_state_; |
| Target* target_stack_; // for break, continue statements |
| v8::Extension* extension_; |
| - ScriptDataImpl* pre_data_; |
| + ScriptDataImpl* pre_parse_data_; |
| FuncNameInferrer* fni_; |
| Mode mode_; |
| bool allow_natives_syntax_; |
| bool allow_lazy_; |
| - bool allow_modules_; |
| + bool allow_generators_; |
| bool stack_overflow_; |
| // If true, the next (and immediately following) function literal is |
| // preceded by a parenthesis. |