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

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: 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') | src/parsing/parser-base.h » ('J')
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 class ParsingModeScope BASE_EMBEDDED {
239 public:
240 ParsingModeScope(Parser* parser, Mode mode)
241 : parser_(parser), old_mode_(parser->mode()) {
vogelheim 2016/11/07 14:56:17 Why not just access parser_->mode_, since we're di
242 parser_->mode_ = mode;
243 }
244 ~ParsingModeScope() { parser_->mode_ = old_mode_; }
245
246 private:
247 Parser* parser_;
248 Mode old_mode_;
249 };
250
251 Mode mode() const { return mode_; }
252
238 // Runtime encoding of different completion modes. 253 // Runtime encoding of different completion modes.
239 enum CompletionKind { 254 enum CompletionKind {
240 kNormalCompletion, 255 kNormalCompletion,
241 kThrowCompletion, 256 kThrowCompletion,
242 kAbruptCompletion 257 kAbruptCompletion
243 }; 258 };
244 259
245 Variable* NewTemporary(const AstRawString* name) { 260 Variable* NewTemporary(const AstRawString* name) {
246 return scope()->NewTemporary(name); 261 return scope()->NewTemporary(name);
247 } 262 }
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 } 1127 }
1113 1128
1114 // Parser's private field members. 1129 // Parser's private field members.
1115 friend class DiscardableZoneScope; // Uses reusable_preparser_. 1130 friend class DiscardableZoneScope; // Uses reusable_preparser_.
1116 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call 1131 // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call
1117 // DeleteAll after each function), so this won't be needed. 1132 // DeleteAll after each function), so this won't be needed.
1118 1133
1119 Scanner scanner_; 1134 Scanner scanner_;
1120 PreParser* reusable_preparser_; 1135 PreParser* reusable_preparser_;
1121 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1136 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1137 Mode mode_;
vogelheim 2016/11/07 14:56:17 If Parser/parser.h "owns" the parsing mode now, it
1122 1138
1123 friend class ParserTarget; 1139 friend class ParserTarget;
1124 friend class ParserTargetScope; 1140 friend class ParserTargetScope;
1125 ParserTarget* target_stack_; // for break, continue statements 1141 ParserTarget* target_stack_; // for break, continue statements
1126 1142
1127 ScriptCompiler::CompileOptions compile_options_; 1143 ScriptCompiler::CompileOptions compile_options_;
1128 ParseData* cached_parse_data_; 1144 ParseData* cached_parse_data_;
1129 1145
1130 PendingCompilationErrorHandler pending_error_handler_; 1146 PendingCompilationErrorHandler pending_error_handler_;
1131 1147
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1192
1177 private: 1193 private:
1178 ParserTarget** variable_; 1194 ParserTarget** variable_;
1179 ParserTarget* previous_; 1195 ParserTarget* previous_;
1180 }; 1196 };
1181 1197
1182 } // namespace internal 1198 } // namespace internal
1183 } // namespace v8 1199 } // namespace v8
1184 1200
1185 #endif // V8_PARSING_PARSER_H_ 1201 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | src/parsing/parser-base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698