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

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

Issue 2677653003: [ast] Minor cleanup in scopes.cc. (Closed)
Patch Set: 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 | no next file » | 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 DCHECK(proxy->raw_name() != NULL); 987 DCHECK(proxy->raw_name() != NULL);
988 const AstRawString* name = proxy->raw_name(); 988 const AstRawString* name = proxy->raw_name();
989 bool is_function_declaration = declaration->IsFunctionDeclaration(); 989 bool is_function_declaration = declaration->IsFunctionDeclaration();
990 990
991 Variable* var = nullptr; 991 Variable* var = nullptr;
992 if (is_eval_scope() && is_sloppy(language_mode()) && mode == VAR) { 992 if (is_eval_scope() && is_sloppy(language_mode()) && mode == VAR) {
993 // In a var binding in a sloppy direct eval, pollute the enclosing scope 993 // In a var binding in a sloppy direct eval, pollute the enclosing scope
994 // with this new binding by doing the following: 994 // with this new binding by doing the following:
995 // The proxy is bound to a lookup variable to force a dynamic declaration 995 // The proxy is bound to a lookup variable to force a dynamic declaration
996 // using the DeclareEvalVar or DeclareEvalFunction runtime functions. 996 // using the DeclareEvalVar or DeclareEvalFunction runtime functions.
997 VariableKind kind = NORMAL_VARIABLE; 997 var = new (zone())
998 // TODO(sigurds) figure out if kNotAssigned is OK here 998 Variable(this, name, mode, NORMAL_VARIABLE, init, kMaybeAssigned);
999 var = new (zone()) Variable(this, name, mode, kind, init, kNotAssigned);
1000 var->AllocateTo(VariableLocation::LOOKUP, -1); 999 var->AllocateTo(VariableLocation::LOOKUP, -1);
1001 } else { 1000 } else {
1002 // Declare the variable in the declaration scope. 1001 // Declare the variable in the declaration scope.
1003 var = LookupLocal(name); 1002 var = LookupLocal(name);
1004 if (var == NULL) { 1003 if (var == NULL) {
1005 // Declare the name. 1004 // Declare the name.
1006 VariableKind kind = NORMAL_VARIABLE; 1005 VariableKind kind = NORMAL_VARIABLE;
1007 if (is_function_declaration) { 1006 if (is_function_declaration) {
1008 kind = FUNCTION_VARIABLE; 1007 kind = FUNCTION_VARIABLE;
1009 } 1008 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 (is_block_scope() || is_catch_scope()))); 1088 (is_block_scope() || is_catch_scope())));
1090 DCHECK(scope_info_.is_null()); 1089 DCHECK(scope_info_.is_null());
1091 1090
1092 // Declare the variable in the declaration scope. 1091 // Declare the variable in the declaration scope.
1093 if (FLAG_preparser_scope_analysis) { 1092 if (FLAG_preparser_scope_analysis) {
1094 Variable* var = LookupLocal(name); 1093 Variable* var = LookupLocal(name);
1095 DCHECK_NE(var, kDummyPreParserLexicalVariable); 1094 DCHECK_NE(var, kDummyPreParserLexicalVariable);
1096 DCHECK_NE(var, kDummyPreParserVariable); 1095 DCHECK_NE(var, kDummyPreParserVariable);
1097 if (var == nullptr) { 1096 if (var == nullptr) {
1098 var = DeclareLocal(name, mode); 1097 var = DeclareLocal(name, mode);
1099 } else if (!IsLexicalVariableMode(var->mode()) && 1098 } else if (mode == VAR) {
1100 !IsLexicalVariableMode(mode)) { 1099 DCHECK_EQ(var->mode(), VAR);
1101 DCHECK_EQ(mode, VAR);
1102 var->set_maybe_assigned(); 1100 var->set_maybe_assigned();
1103 } 1101 }
1104 var->set_is_used(); 1102 var->set_is_used();
1105 return var; 1103 return var;
1106 } else { 1104 } else {
1107 return variables_.DeclareName(zone(), name, mode); 1105 return variables_.DeclareName(zone(), name, mode);
1108 } 1106 }
1109 } 1107 }
1110 1108
1111 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory, 1109 VariableProxy* Scope::NewUnresolved(AstNodeFactory* factory,
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 Variable* function = 2232 Variable* function =
2235 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2233 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2236 bool is_function_var_in_context = 2234 bool is_function_var_in_context =
2237 function != nullptr && function->IsContextSlot(); 2235 function != nullptr && function->IsContextSlot();
2238 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2236 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2239 (is_function_var_in_context ? 1 : 0); 2237 (is_function_var_in_context ? 1 : 0);
2240 } 2238 }
2241 2239
2242 } // namespace internal 2240 } // namespace internal
2243 } // namespace v8 2241 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698