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

Side by Side Diff: src/parsing/parser.h

Issue 2297643002: Move DeclarationDescriptor to ParserBase. (Closed)
Patch Set: Created 4 years, 3 months 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/parsing/parser-base.h" 10 #include "src/parsing/parser-base.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags, 288 Statement* ParseHoistableDeclaration(int pos, ParseFunctionFlags flags,
289 ZoneList<const AstRawString*>* names, 289 ZoneList<const AstRawString*>* names,
290 bool default_export, bool* ok); 290 bool default_export, bool* ok);
291 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names, 291 Statement* ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
292 bool default_export, bool* ok); 292 bool default_export, bool* ok);
293 Expression* ParseAsyncFunctionExpression(bool* ok); 293 Expression* ParseAsyncFunctionExpression(bool* ok);
294 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names, 294 Statement* ParseClassDeclaration(ZoneList<const AstRawString*>* names,
295 bool default_export, bool* ok); 295 bool default_export, bool* ok);
296 Statement* ParseNativeDeclaration(bool* ok); 296 Statement* ParseNativeDeclaration(bool* ok);
297 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); 297 Block* ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
298 Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result,
299 ZoneList<const AstRawString*>* names,
300 bool* ok);
301
298 Block* ParseVariableStatement(VariableDeclarationContext var_context, 302 Block* ParseVariableStatement(VariableDeclarationContext var_context,
299 ZoneList<const AstRawString*>* names, 303 ZoneList<const AstRawString*>* names,
300 bool* ok); 304 bool* ok);
301 DoExpression* ParseDoExpression(bool* ok); 305 DoExpression* ParseDoExpression(bool* ok);
302 Expression* ParseYieldStarExpression(bool* ok); 306 Expression* ParseYieldStarExpression(bool* ok);
303 307
304 struct DeclarationDescriptor {
305 enum Kind { NORMAL, PARAMETER };
306 Parser* parser;
307 Scope* scope;
308 Scope* hoist_scope;
309 VariableMode mode;
310 int declaration_pos;
311 int initialization_pos;
312 Kind declaration_kind;
313 };
314
315 struct DeclarationParsingResult {
316 struct Declaration {
317 Declaration(Expression* pattern, int initializer_position,
318 Expression* initializer)
319 : pattern(pattern),
320 initializer_position(initializer_position),
321 initializer(initializer) {}
322
323 Expression* pattern;
324 int initializer_position;
325 Expression* initializer;
326 };
327
328 DeclarationParsingResult()
329 : declarations(4),
330 first_initializer_loc(Scanner::Location::invalid()),
331 bindings_loc(Scanner::Location::invalid()) {}
332
333 Block* BuildInitializationBlock(ZoneList<const AstRawString*>* names,
334 bool* ok);
335
336 DeclarationDescriptor descriptor;
337 List<Declaration> declarations;
338 Scanner::Location first_initializer_loc;
339 Scanner::Location bindings_loc;
340 };
341
342 class PatternRewriter final : public AstVisitor<PatternRewriter> { 308 class PatternRewriter final : public AstVisitor<PatternRewriter> {
343 public: 309 public:
344 static void DeclareAndInitializeVariables( 310 static void DeclareAndInitializeVariables(
345 Block* block, const DeclarationDescriptor* declaration_descriptor, 311 Parser* parser, Block* block,
312 const DeclarationDescriptor* declaration_descriptor,
346 const DeclarationParsingResult::Declaration* declaration, 313 const DeclarationParsingResult::Declaration* declaration,
347 ZoneList<const AstRawString*>* names, bool* ok); 314 ZoneList<const AstRawString*>* names, bool* ok);
348 315
349 static void RewriteDestructuringAssignment(Parser* parser, 316 static void RewriteDestructuringAssignment(Parser* parser,
350 RewritableExpression* expr, 317 RewritableExpression* expr,
351 Scope* Scope); 318 Scope* Scope);
352 319
353 static Expression* RewriteDestructuringAssignment(Parser* parser, 320 static Expression* RewriteDestructuringAssignment(Parser* parser,
354 Assignment* assignment, 321 Assignment* assignment,
355 Scope* scope); 322 Scope* scope);
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 static const int kLiteralTypeSlot = 0; 1054 static const int kLiteralTypeSlot = 0;
1088 static const int kElementsSlot = 1; 1055 static const int kElementsSlot = 1;
1089 1056
1090 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 1057 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
1091 }; 1058 };
1092 1059
1093 } // namespace internal 1060 } // namespace internal
1094 } // namespace v8 1061 } // namespace v8
1095 1062
1096 #endif // V8_PARSING_PARSER_H_ 1063 #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