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

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

Issue 2638333002: Parsing:Create the same scopes for non-simple params in PreParser & Parser. (Closed)
Patch Set: rest of the impl Created 3 years, 11 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') | 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 Expression* RewriteReturn(Expression* return_value, int pos); 333 Expression* RewriteReturn(Expression* return_value, int pos);
334 Statement* RewriteSwitchStatement(Expression* tag, 334 Statement* RewriteSwitchStatement(Expression* tag,
335 SwitchStatement* switch_statement, 335 SwitchStatement* switch_statement,
336 ZoneList<CaseClause*>* cases, Scope* scope); 336 ZoneList<CaseClause*>* cases, Scope* scope);
337 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok); 337 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok);
338 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok); 338 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok);
339 Statement* RewriteTryStatement(Block* try_block, Block* catch_block, 339 Statement* RewriteTryStatement(Block* try_block, Block* catch_block,
340 Block* finally_block, 340 Block* finally_block,
341 const CatchInfo& catch_info, int pos); 341 const CatchInfo& catch_info, int pos);
342 342
343 void ParseAndRewriteGeneratorFunctionBody(int pos, FunctionKind kind,
344 ZoneList<Statement*>* body,
345 bool* ok);
346 void CreateFunctionNameAssignment(const AstRawString* function_name, int pos,
347 FunctionLiteral::FunctionType function_type,
348 DeclarationScope* function_scope,
349 ZoneList<Statement*>* result, int index);
350
343 Statement* DeclareFunction(const AstRawString* variable_name, 351 Statement* DeclareFunction(const AstRawString* variable_name,
344 FunctionLiteral* function, VariableMode mode, 352 FunctionLiteral* function, VariableMode mode,
345 int pos, bool is_generator, bool is_async, 353 int pos, bool is_generator, bool is_async,
346 bool is_sloppy_block_function, 354 bool is_sloppy_block_function,
347 ZoneList<const AstRawString*>* names, bool* ok); 355 ZoneList<const AstRawString*>* names, bool* ok);
348 V8_INLINE Statement* DeclareClass(const AstRawString* variable_name, 356 V8_INLINE Statement* DeclareClass(const AstRawString* variable_name,
349 Expression* value, 357 Expression* value,
350 ZoneList<const AstRawString*>* names, 358 ZoneList<const AstRawString*>* names,
351 int class_token_pos, int end_pos, bool* ok); 359 int class_token_pos, int end_pos, bool* ok);
352 V8_INLINE void DeclareClassVariable(const AstRawString* name, 360 V8_INLINE void DeclareClassVariable(const AstRawString* name,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 // If may_abort == true, the (pre-)parser may decide to abort skipping 534 // If may_abort == true, the (pre-)parser may decide to abort skipping
527 // in order to force the function to be eagerly parsed, after all. 535 // in order to force the function to be eagerly parsed, after all.
528 LazyParsingResult SkipFunction( 536 LazyParsingResult SkipFunction(
529 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters, 537 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters,
530 int* function_length, bool* has_duplicate_parameters, 538 int* function_length, bool* has_duplicate_parameters,
531 int* materialized_literal_count, int* expected_property_count, 539 int* materialized_literal_count, int* expected_property_count,
532 bool is_inner_function, bool may_abort, bool* ok); 540 bool is_inner_function, bool may_abort, bool* ok);
533 541
534 Block* BuildParameterInitializationBlock( 542 Block* BuildParameterInitializationBlock(
535 const ParserFormalParameters& parameters, bool* ok); 543 const ParserFormalParameters& parameters, bool* ok);
536 Block* BuildRejectPromiseOnException(Block* block, bool* ok); 544 Block* BuildRejectPromiseOnException(Block* block);
537
538 // Consumes the ending }.
539 ZoneList<Statement*>* ParseEagerFunctionBody(
540 const AstRawString* function_name, int pos,
541 const ParserFormalParameters& parameters, FunctionKind kind,
542 FunctionLiteral::FunctionType function_type, bool* ok);
543 545
544 ZoneList<Statement*>* ParseFunction( 546 ZoneList<Statement*>* ParseFunction(
545 const AstRawString* function_name, int pos, FunctionKind kind, 547 const AstRawString* function_name, int pos, FunctionKind kind,
546 FunctionLiteral::FunctionType function_type, 548 FunctionLiteral::FunctionType function_type,
547 DeclarationScope* function_scope, int* num_parameters, 549 DeclarationScope* function_scope, int* num_parameters,
548 int* function_length, bool* has_duplicate_parameters, 550 int* function_length, bool* has_duplicate_parameters,
549 int* materialized_literal_count, int* expected_property_count, bool* ok); 551 int* materialized_literal_count, int* expected_property_count, bool* ok);
550 552
551 void ThrowPendingError(Isolate* isolate, Handle<Script> script); 553 void ThrowPendingError(Isolate* isolate, Handle<Script> script);
552 554
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 factory()->NewThrow(exception, pos), pos); 1020 factory()->NewThrow(exception, pos), pos);
1019 } 1021 }
1020 1022
1021 V8_INLINE void AddParameterInitializationBlock( 1023 V8_INLINE void AddParameterInitializationBlock(
1022 const ParserFormalParameters& parameters, ZoneList<Statement*>* body, 1024 const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
1023 bool is_async, bool* ok) { 1025 bool is_async, bool* ok) {
1024 if (parameters.is_simple) return; 1026 if (parameters.is_simple) return;
1025 auto* init_block = BuildParameterInitializationBlock(parameters, ok); 1027 auto* init_block = BuildParameterInitializationBlock(parameters, ok);
1026 if (!*ok) return; 1028 if (!*ok) return;
1027 if (is_async) { 1029 if (is_async) {
1028 init_block = BuildRejectPromiseOnException(init_block, ok); 1030 init_block = BuildRejectPromiseOnException(init_block);
1029 if (!*ok) return;
1030 } 1031 }
1031 if (init_block != nullptr) body->Add(init_block, zone()); 1032 if (init_block != nullptr) body->Add(init_block, zone());
1032 } 1033 }
1033 1034
1034 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, 1035 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
1035 Expression* pattern, 1036 Expression* pattern,
1036 Expression* initializer, 1037 Expression* initializer,
1037 int initializer_end_position, 1038 int initializer_end_position,
1038 bool is_rest) { 1039 bool is_rest) {
1039 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest); 1040 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 1176
1176 private: 1177 private:
1177 ParserTarget** variable_; 1178 ParserTarget** variable_;
1178 ParserTarget* previous_; 1179 ParserTarget* previous_;
1179 }; 1180 };
1180 1181
1181 } // namespace internal 1182 } // namespace internal
1182 } // namespace v8 1183 } // namespace v8
1183 1184
1184 #endif // V8_PARSING_PARSER_H_ 1185 #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