| OLD | NEW | 
|---|
| 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 "src/accessors.h" | 7 #include "src/accessors.h" | 
| 8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" | 
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" | 
| 10 #include "src/messages.h" | 10 #include "src/messages.h" | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 164   function_kind_ = function_kind; | 164   function_kind_ = function_kind; | 
| 165   scope_name_ = ast_value_factory_->empty_string(); | 165   scope_name_ = ast_value_factory_->empty_string(); | 
| 166   dynamics_ = nullptr; | 166   dynamics_ = nullptr; | 
| 167   receiver_ = nullptr; | 167   receiver_ = nullptr; | 
| 168   new_target_ = nullptr; | 168   new_target_ = nullptr; | 
| 169   function_ = nullptr; | 169   function_ = nullptr; | 
| 170   arguments_ = nullptr; | 170   arguments_ = nullptr; | 
| 171   this_function_ = nullptr; | 171   this_function_ = nullptr; | 
| 172   illegal_redecl_ = nullptr; | 172   illegal_redecl_ = nullptr; | 
| 173   scope_inside_with_ = false; | 173   scope_inside_with_ = false; | 
|  | 174   scope_inside_module_ = false; | 
| 174   scope_contains_with_ = false; | 175   scope_contains_with_ = false; | 
| 175   scope_calls_eval_ = false; | 176   scope_calls_eval_ = false; | 
| 176   scope_uses_arguments_ = false; | 177   scope_uses_arguments_ = false; | 
| 177   scope_uses_super_property_ = false; | 178   scope_uses_super_property_ = false; | 
| 178   asm_module_ = false; | 179   asm_module_ = false; | 
| 179   asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 180   asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 
| 180   // Inherit the language mode from the parent scope. | 181   // Inherit the language mode from the parent scope. | 
| 181   language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 182   language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 
| 182   outer_scope_calls_sloppy_eval_ = false; | 183   outer_scope_calls_sloppy_eval_ = false; | 
| 183   inner_scope_calls_eval_ = false; | 184   inner_scope_calls_eval_ = false; | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 304 } | 305 } | 
| 305 | 306 | 
| 306 | 307 | 
| 307 void Scope::Initialize() { | 308 void Scope::Initialize() { | 
| 308   DCHECK(!already_resolved()); | 309   DCHECK(!already_resolved()); | 
| 309 | 310 | 
| 310   // Add this scope as a new inner scope of the outer scope. | 311   // Add this scope as a new inner scope of the outer scope. | 
| 311   if (outer_scope_ != NULL) { | 312   if (outer_scope_ != NULL) { | 
| 312     outer_scope_->inner_scopes_.Add(this, zone()); | 313     outer_scope_->inner_scopes_.Add(this, zone()); | 
| 313     scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); | 314     scope_inside_with_ = outer_scope_->scope_inside_with_ || is_with_scope(); | 
|  | 315     scope_inside_module_ = | 
|  | 316         outer_scope_->scope_inside_module_ || is_module_scope(); | 
| 314   } else { | 317   } else { | 
| 315     scope_inside_with_ = is_with_scope(); | 318     scope_inside_with_ = is_with_scope(); | 
|  | 319     scope_inside_module_ = is_module_scope(); | 
| 316   } | 320   } | 
| 317 | 321 | 
| 318   // Declare convenience variables and the receiver. | 322   // Declare convenience variables and the receiver. | 
| 319   if (is_declaration_scope() && has_this_declaration()) { | 323   if (is_declaration_scope() && has_this_declaration()) { | 
| 320     bool subclass_constructor = IsSubclassConstructor(function_kind_); | 324     bool subclass_constructor = IsSubclassConstructor(function_kind_); | 
| 321     Variable* var = variables_.Declare( | 325     Variable* var = variables_.Declare( | 
| 322         this, ast_value_factory_->this_string(), | 326         this, ast_value_factory_->this_string(), | 
| 323         subclass_constructor ? CONST : VAR, Variable::THIS, | 327         subclass_constructor ? CONST : VAR, Variable::THIS, | 
| 324         subclass_constructor ? kNeedsInitialization : kCreatedInitialized); | 328         subclass_constructor ? kNeedsInitialization : kCreatedInitialized); | 
| 325     receiver_ = var; | 329     receiver_ = var; | 
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 992   } | 996   } | 
| 993 | 997 | 
| 994   // Scope info. | 998   // Scope info. | 
| 995   if (HasTrivialOuterContext()) { | 999   if (HasTrivialOuterContext()) { | 
| 996     Indent(n1, "// scope has trivial outer context\n"); | 1000     Indent(n1, "// scope has trivial outer context\n"); | 
| 997   } | 1001   } | 
| 998   if (is_strict(language_mode())) { | 1002   if (is_strict(language_mode())) { | 
| 999     Indent(n1, "// strict mode scope\n"); | 1003     Indent(n1, "// strict mode scope\n"); | 
| 1000   } | 1004   } | 
| 1001   if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 1005   if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 
|  | 1006   if (scope_inside_module_) Indent(n1, "// scope inside module code\n"); | 
| 1002   if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 1007   if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 
| 1003   if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 1008   if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 
| 1004   if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 1009   if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 
| 1005   if (scope_uses_super_property_) | 1010   if (scope_uses_super_property_) | 
| 1006     Indent(n1, "// scope uses 'super' property\n"); | 1011     Indent(n1, "// scope uses 'super' property\n"); | 
| 1007   if (outer_scope_calls_sloppy_eval_) { | 1012   if (outer_scope_calls_sloppy_eval_) { | 
| 1008     Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 1013     Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 
| 1009   } | 1014   } | 
| 1010   if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 1015   if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 
| 1011   if (num_stack_slots_ > 0) { | 1016   if (num_stack_slots_ > 0) { | 
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1547       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1552       function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 
| 1548   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1553   return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 
| 1549          (is_function_var_in_context ? 1 : 0); | 1554          (is_function_var_in_context ? 1 : 0); | 
| 1550 } | 1555 } | 
| 1551 | 1556 | 
| 1552 | 1557 | 
| 1553 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1558 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 
| 1554 | 1559 | 
| 1555 }  // namespace internal | 1560 }  // namespace internal | 
| 1556 }  // namespace v8 | 1561 }  // namespace v8 | 
| OLD | NEW | 
|---|