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

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

Issue 2662183002: [parser] Remove hoist_scope from DeclarationDescriptor (Closed)
Patch Set: Factored out helper function Created 3 years, 10 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
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 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 void Parser::RewriteCatchPattern(CatchInfo* catch_info, bool* ok) { 1667 void Parser::RewriteCatchPattern(CatchInfo* catch_info, bool* ok) {
1668 if (catch_info->name == nullptr) { 1668 if (catch_info->name == nullptr) {
1669 DCHECK_NOT_NULL(catch_info->pattern); 1669 DCHECK_NOT_NULL(catch_info->pattern);
1670 catch_info->name = ast_value_factory()->dot_catch_string(); 1670 catch_info->name = ast_value_factory()->dot_catch_string();
1671 } 1671 }
1672 catch_info->variable = catch_info->scope->DeclareLocal(catch_info->name, VAR); 1672 catch_info->variable = catch_info->scope->DeclareLocal(catch_info->name, VAR);
1673 if (catch_info->pattern != nullptr) { 1673 if (catch_info->pattern != nullptr) {
1674 DeclarationDescriptor descriptor; 1674 DeclarationDescriptor descriptor;
1675 descriptor.declaration_kind = DeclarationDescriptor::NORMAL; 1675 descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
1676 descriptor.scope = scope(); 1676 descriptor.scope = scope();
1677 descriptor.hoist_scope = nullptr;
1678 descriptor.mode = LET; 1677 descriptor.mode = LET;
1679 descriptor.declaration_pos = catch_info->pattern->position(); 1678 descriptor.declaration_pos = catch_info->pattern->position();
1680 descriptor.initialization_pos = catch_info->pattern->position(); 1679 descriptor.initialization_pos = catch_info->pattern->position();
1681 1680
1682 // Initializer position for variables declared by the pattern. 1681 // Initializer position for variables declared by the pattern.
1683 const int initializer_position = position(); 1682 const int initializer_position = position();
1684 1683
1685 DeclarationParsingResult::Declaration decl( 1684 DeclarationParsingResult::Declaration decl(
1686 catch_info->pattern, initializer_position, 1685 catch_info->pattern, initializer_position,
1687 factory()->NewVariableProxy(catch_info->variable)); 1686 factory()->NewVariableProxy(catch_info->variable));
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 const ParserFormalParameters& parameters, bool* ok) { 2902 const ParserFormalParameters& parameters, bool* ok) {
2904 DCHECK(!parameters.is_simple); 2903 DCHECK(!parameters.is_simple);
2905 DCHECK(scope()->is_function_scope()); 2904 DCHECK(scope()->is_function_scope());
2906 Block* init_block = factory()->NewBlock(NULL, 1, true, kNoSourcePosition); 2905 Block* init_block = factory()->NewBlock(NULL, 1, true, kNoSourcePosition);
2907 int index = 0; 2906 int index = 0;
2908 for (auto parameter : parameters.params) { 2907 for (auto parameter : parameters.params) {
2909 if (parameter->is_rest && parameter->pattern->IsVariableProxy()) break; 2908 if (parameter->is_rest && parameter->pattern->IsVariableProxy()) break;
2910 DeclarationDescriptor descriptor; 2909 DeclarationDescriptor descriptor;
2911 descriptor.declaration_kind = DeclarationDescriptor::PARAMETER; 2910 descriptor.declaration_kind = DeclarationDescriptor::PARAMETER;
2912 descriptor.scope = scope(); 2911 descriptor.scope = scope();
2913 descriptor.hoist_scope = nullptr;
2914 descriptor.mode = LET; 2912 descriptor.mode = LET;
2915 descriptor.declaration_pos = parameter->pattern->position(); 2913 descriptor.declaration_pos = parameter->pattern->position();
2916 // The position that will be used by the AssignmentExpression 2914 // The position that will be used by the AssignmentExpression
2917 // which copies from the temp parameter to the pattern. 2915 // which copies from the temp parameter to the pattern.
2918 // 2916 //
2919 // TODO(adamk): Should this be kNoSourcePosition, since 2917 // TODO(adamk): Should this be kNoSourcePosition, since
2920 // it's just copying from a temp var to the real param var? 2918 // it's just copying from a temp var to the real param var?
2921 descriptor.initialization_pos = parameter->pattern->position(); 2919 descriptor.initialization_pos = parameter->pattern->position();
2922 Expression* initial_value = 2920 Expression* initial_value =
2923 factory()->NewVariableProxy(parameters.scope->parameter(index)); 2921 factory()->NewVariableProxy(parameters.scope->parameter(index));
(...skipping 14 matching lines...) Expand all
2938 2936
2939 Scope* param_scope = scope(); 2937 Scope* param_scope = scope();
2940 Block* param_block = init_block; 2938 Block* param_block = init_block;
2941 if (!parameter->is_simple() && scope()->calls_sloppy_eval()) { 2939 if (!parameter->is_simple() && scope()->calls_sloppy_eval()) {
2942 param_scope = NewVarblockScope(); 2940 param_scope = NewVarblockScope();
2943 param_scope->set_start_position(descriptor.initialization_pos); 2941 param_scope->set_start_position(descriptor.initialization_pos);
2944 param_scope->set_end_position(parameter->initializer_end_position); 2942 param_scope->set_end_position(parameter->initializer_end_position);
2945 param_scope->RecordEvalCall(); 2943 param_scope->RecordEvalCall();
2946 param_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); 2944 param_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition);
2947 param_block->set_scope(param_scope); 2945 param_block->set_scope(param_scope);
2948 descriptor.hoist_scope = scope();
2949 // Pass the appropriate scope in so that PatternRewriter can appropriately 2946 // Pass the appropriate scope in so that PatternRewriter can appropriately
2950 // rewrite inner initializers of the pattern to param_scope 2947 // rewrite inner initializers of the pattern to param_scope
2951 descriptor.scope = param_scope; 2948 descriptor.scope = param_scope;
2952 // Rewrite the outer initializer to point to param_scope 2949 // Rewrite the outer initializer to point to param_scope
2953 ReparentParameterExpressionScope(stack_limit(), initial_value, 2950 ReparentParameterExpressionScope(stack_limit(), initial_value,
2954 param_scope); 2951 param_scope);
2955 } 2952 }
2956 2953
2957 BlockState block_state(&scope_state_, param_scope); 2954 BlockState block_state(&scope_state_, param_scope);
2958 DeclarationParsingResult::Declaration decl( 2955 DeclarationParsingResult::Declaration decl(
(...skipping 2062 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 5018
5022 return final_loop; 5019 return final_loop;
5023 } 5020 }
5024 5021
5025 #undef CHECK_OK 5022 #undef CHECK_OK
5026 #undef CHECK_OK_VOID 5023 #undef CHECK_OK_VOID
5027 #undef CHECK_FAILED 5024 #undef CHECK_FAILED
5028 5025
5029 } // namespace internal 5026 } // namespace internal
5030 } // namespace v8 5027 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | src/parsing/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698