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

Side by Side Diff: src/ast/scopes.cc

Issue 2658063005: [parser] Skipping inner funcs: produce correct data for var redeclarations. (Closed)
Patch Set: moar 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
« no previous file with comments | « no previous file | test/cctest/test-parsing.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 #include "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 // catch scopes: Parser::RewriteCatchPattern bypasses DeclareVariable by 1076 // catch scopes: Parser::RewriteCatchPattern bypasses DeclareVariable by
1077 // calling DeclareLocal directly, and it doesn't make sense to add a similar 1077 // calling DeclareLocal directly, and it doesn't make sense to add a similar
1078 // bypass mechanism for PreParser. 1078 // bypass mechanism for PreParser.
1079 DCHECK(is_declaration_scope() || (IsLexicalVariableMode(mode) && 1079 DCHECK(is_declaration_scope() || (IsLexicalVariableMode(mode) &&
1080 (is_block_scope() || is_catch_scope()))); 1080 (is_block_scope() || is_catch_scope())));
1081 DCHECK(scope_info_.is_null()); 1081 DCHECK(scope_info_.is_null());
1082 1082
1083 // Declare the variable in the declaration scope. 1083 // Declare the variable in the declaration scope.
1084 if (FLAG_preparser_scope_analysis) { 1084 if (FLAG_preparser_scope_analysis) {
1085 Variable* var = LookupLocal(name); 1085 Variable* var = LookupLocal(name);
1086 DCHECK_NE(var, kDummyPreParserLexicalVariable);
1087 DCHECK_NE(var, kDummyPreParserVariable);
1086 if (var == nullptr) { 1088 if (var == nullptr) {
1087 var = DeclareLocal(name, mode); 1089 var = DeclareLocal(name, mode);
1090 } else if (!IsLexicalVariableMode(var->mode()) &&
1091 !IsLexicalVariableMode(mode)) {
1092 DCHECK_EQ(mode, VAR);
1093 var->set_maybe_assigned();
1088 } 1094 }
1089 var->set_is_used(); 1095 var->set_is_used();
1090 } else { 1096 } else {
1091 variables_.DeclareName(zone(), name, mode); 1097 variables_.DeclareName(zone(), name, mode);
1092 } 1098 }
1093 } 1099 }
1094 1100
1095 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, 1101 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory,
1096 const AstRawString* name, 1102 const AstRawString* name,
1097 int start_position, VariableKind kind) { 1103 int start_position, VariableKind kind) {
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2201 Variable* function = 2207 Variable* function =
2202 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2208 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2203 bool is_function_var_in_context = 2209 bool is_function_var_in_context =
2204 function != nullptr && function->IsContextSlot(); 2210 function != nullptr && function->IsContextSlot();
2205 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2211 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2206 (is_function_var_in_context ? 1 : 0); 2212 (is_function_var_in_context ? 1 : 0);
2207 } 2213 }
2208 2214
2209 } // namespace internal 2215 } // namespace internal
2210 } // namespace v8 2216 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698