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

Side by Side Diff: src/scopes.cc

Issue 1240463002: [es6] Implement inner scope for functions with destructuring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add tests for function name Created 5 years, 5 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 | « src/scopes.h ('k') | test/mjsunit/big-array-literal.js » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 kCreatedInitialized); 144 kCreatedInitialized);
145 AllocateHeapSlot(variable); 145 AllocateHeapSlot(variable);
146 } 146 }
147 147
148 148
149 void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope, 149 void Scope::SetDefaults(ScopeType scope_type, Scope* outer_scope,
150 Handle<ScopeInfo> scope_info, 150 Handle<ScopeInfo> scope_info,
151 FunctionKind function_kind) { 151 FunctionKind function_kind) {
152 outer_scope_ = outer_scope; 152 outer_scope_ = outer_scope;
153 scope_type_ = scope_type; 153 scope_type_ = scope_type;
154 is_declaration_scope_ =
155 is_eval_scope() || is_function_scope() ||
156 is_module_scope() || is_script_scope();
154 function_kind_ = function_kind; 157 function_kind_ = function_kind;
155 scope_name_ = ast_value_factory_->empty_string(); 158 scope_name_ = ast_value_factory_->empty_string();
156 dynamics_ = nullptr; 159 dynamics_ = nullptr;
157 receiver_ = nullptr; 160 receiver_ = nullptr;
158 new_target_ = nullptr; 161 new_target_ = nullptr;
159 function_ = nullptr; 162 function_ = nullptr;
160 arguments_ = nullptr; 163 arguments_ = nullptr;
161 this_function_ = nullptr; 164 this_function_ = nullptr;
162 illegal_redecl_ = nullptr; 165 illegal_redecl_ = nullptr;
163 scope_inside_with_ = false; 166 scope_inside_with_ = false;
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 isolate->factory()->arguments_string())) { 1359 isolate->factory()->arguments_string())) {
1357 return true; 1360 return true;
1358 } 1361 }
1359 } 1362 }
1360 return false; 1363 return false;
1361 } 1364 }
1362 1365
1363 1366
1364 void Scope::AllocateStackSlot(Variable* var) { 1367 void Scope::AllocateStackSlot(Variable* var) {
1365 if (is_block_scope()) { 1368 if (is_block_scope()) {
1366 DeclarationScope()->AllocateStackSlot(var); 1369 outer_scope()->DeclarationScope()->AllocateStackSlot(var);
1367 } else { 1370 } else {
1368 var->AllocateTo(VariableLocation::LOCAL, num_stack_slots_++); 1371 var->AllocateTo(VariableLocation::LOCAL, num_stack_slots_++);
1369 } 1372 }
1370 } 1373 }
1371 1374
1372 1375
1373 void Scope::AllocateHeapSlot(Variable* var) { 1376 void Scope::AllocateHeapSlot(Variable* var) {
1374 var->AllocateTo(VariableLocation::CONTEXT, num_heap_slots_++); 1377 var->AllocateTo(VariableLocation::CONTEXT, num_heap_slots_++);
1375 } 1378 }
1376 1379
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 bool is_function_var_in_context = 1616 bool is_function_var_in_context =
1614 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1617 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1615 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1618 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1616 2 * num_global_slots() - (is_function_var_in_context ? 1 : 0); 1619 2 * num_global_slots() - (is_function_var_in_context ? 1 : 0);
1617 } 1620 }
1618 1621
1619 1622
1620 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1623 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1621 } // namespace internal 1624 } // namespace internal
1622 } // namespace v8 1625 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/big-array-literal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698