Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: src/parsing/parser.h

Issue 2479213002: [parser] Only track parsing-mode (and possibly switch to the preparser) in the parser (Closed)
Patch Set: addressed comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.h
diff --git a/src/parsing/parser.h b/src/parsing/parser.h
index 00075f46e142303e0fc4c6cdfeda2d2d64ef90ad..19384f6fdba3581cc78d0c55a68ed2c1d5a98966 100644
--- a/src/parsing/parser.h
+++ b/src/parsing/parser.h
@@ -235,6 +235,22 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
original_scope_);
}
+ bool parse_lazily() const { return mode_ == PARSE_LAZILY; }
+ enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
+
+ class ParsingModeScope BASE_EMBEDDED {
+ public:
+ ParsingModeScope(Parser* parser, Mode mode)
+ : parser_(parser), old_mode_(parser->mode_) {
+ parser_->mode_ = mode;
+ }
+ ~ParsingModeScope() { parser_->mode_ = old_mode_; }
+
+ private:
+ Parser* parser_;
+ Mode old_mode_;
+ };
+
// Runtime encoding of different completion modes.
enum CompletionKind {
kNormalCompletion,
@@ -1119,6 +1135,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
Scanner scanner_;
PreParser* reusable_preparser_;
Scope* original_scope_; // for ES5 function declarations in sloppy eval
+ Mode mode_;
friend class ParserTarget;
friend class ParserTargetScope;
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698