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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 private: 229 private:
230 friend class ParserBase<Parser>; 230 friend class ParserBase<Parser>;
231 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>; 231 friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>;
232 232
233 bool AllowsLazyParsingWithoutUnresolvedVariables() const { 233 bool AllowsLazyParsingWithoutUnresolvedVariables() const {
234 return scope()->AllowsLazyParsingWithoutUnresolvedVariables( 234 return scope()->AllowsLazyParsingWithoutUnresolvedVariables(
235 original_scope_); 235 original_scope_);
236 } 236 }
237 237
238 bool parse_lazily() const { return mode_ == PARSE_LAZILY; }
239 enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
240
241 class ParsingModeScope BASE_EMBEDDED {
242 public:
243 ParsingModeScope(Parser* parser, Mode mode)
244 : parser_(parser), old_mode_(parser->mode_) {
245 parser_->mode_ = mode;
246 }
247 ~ParsingModeScope() { parser_->mode_ = old_mode_; }
248
249 private:
250 Parser* parser_;
251 Mode old_mode_;
252 };
253
238 // Runtime encoding of different completion modes. 254 // Runtime encoding of different completion modes.
239 enum CompletionKind { 255 enum CompletionKind {
240 kNormalCompletion, 256 kNormalCompletion,
241 kThrowCompletion, 257 kThrowCompletion,
242 kAbruptCompletion 258 kAbruptCompletion
243 }; 259 };
244 260
245 Variable* NewTemporary(const AstRawString* name) { 261 Variable* NewTemporary(const AstRawString* name) {
246 return scope()->NewTemporary(name); 262 return scope()->NewTemporary(name);
247 } 263 }
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1128 }
1113 1129
1114 // Parser's private field members. 1130 // Parser's private field members.
1115 friend class DiscardableZoneScope; // Uses reusable_preparser_. 1131 friend class DiscardableZoneScope; // Uses reusable_preparser_.
1116 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call 1132 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call
1117 // DeleteAll after each function), so this won't be needed. 1133 // DeleteAll after each function), so this won't be needed.
1118 1134
1119 Scanner scanner_; 1135 Scanner scanner_;
1120 PreParser* reusable_preparser_; 1136 PreParser* reusable_preparser_;
1121 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1137 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1138 Mode mode_;
1122 1139
1123 friend class ParserTarget; 1140 friend class ParserTarget;
1124 friend class ParserTargetScope; 1141 friend class ParserTargetScope;
1125 ParserTarget* target_stack_; // for break, continue statements 1142 ParserTarget* target_stack_; // for break, continue statements
1126 1143
1127 ScriptCompiler::CompileOptions compile_options_; 1144 ScriptCompiler::CompileOptions compile_options_;
1128 ParseData* cached_parse_data_; 1145 ParseData* cached_parse_data_;
1129 1146
1130 PendingCompilationErrorHandler pending_error_handler_; 1147 PendingCompilationErrorHandler pending_error_handler_;
1131 1148
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1193
1177 private: 1194 private:
1178 ParserTarget** variable_; 1195 ParserTarget** variable_;
1179 ParserTarget* previous_; 1196 ParserTarget* previous_;
1180 }; 1197 };
1181 1198
1182 } // namespace internal 1199 } // namespace internal
1183 } // namespace v8 1200 } // namespace v8
1184 1201
1185 #endif // V8_PARSING_PARSER_H_ 1202 #endif // V8_PARSING_PARSER_H_
OLDNEW
« 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