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 #ifndef V8_SCOPES_H_ | 5 #ifndef V8_SCOPES_H_ |
6 #define V8_SCOPES_H_ | 6 #define V8_SCOPES_H_ |
7 | 7 |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/pending-compilation-error-handler.h" | 9 #include "src/pending-compilation-error-handler.h" |
10 #include "src/zone.h" | 10 #include "src/zone.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 bool inside_with() const { return scope_inside_with_; } | 310 bool inside_with() const { return scope_inside_with_; } |
311 // Does this scope contain a with statement. | 311 // Does this scope contain a with statement. |
312 bool contains_with() const { return scope_contains_with_; } | 312 bool contains_with() const { return scope_contains_with_; } |
313 | 313 |
314 // Does this scope access "arguments". | 314 // Does this scope access "arguments". |
315 bool uses_arguments() const { return scope_uses_arguments_; } | 315 bool uses_arguments() const { return scope_uses_arguments_; } |
316 // Does any inner scope access "arguments". | 316 // Does any inner scope access "arguments". |
317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
318 // Does this scope access "super" property (super.foo). | 318 // Does this scope access "super" property (super.foo). |
319 bool uses_super_property() const { return scope_uses_super_property_; } | 319 bool uses_super_property() const { return scope_uses_super_property_; } |
320 // Does any inner scope access "super" property. | 320 |
321 bool inner_uses_super_property() const { | 321 bool NeedsHomeObject() const { |
322 return inner_scope_uses_super_property_; | 322 return scope_uses_super_property_ || |
| 323 (scope_calls_eval_ && (IsConciseMethod(function_kind()) || |
| 324 IsAccessorFunction(function_kind()) || |
| 325 IsConstructor(function_kind()))); |
323 } | 326 } |
324 | 327 |
325 const Scope* NearestOuterEvalScope() const { | 328 const Scope* NearestOuterEvalScope() const { |
326 if (is_eval_scope()) return this; | 329 if (is_eval_scope()) return this; |
327 if (outer_scope() == nullptr) return nullptr; | 330 if (outer_scope() == nullptr) return nullptr; |
328 return outer_scope()->NearestOuterEvalScope(); | 331 return outer_scope()->NearestOuterEvalScope(); |
329 } | 332 } |
330 | 333 |
331 // --------------------------------------------------------------------------- | 334 // --------------------------------------------------------------------------- |
332 // Accessors. | 335 // Accessors. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 // The language mode of this scope. | 607 // The language mode of this scope. |
605 LanguageMode language_mode_; | 608 LanguageMode language_mode_; |
606 // Source positions. | 609 // Source positions. |
607 int start_position_; | 610 int start_position_; |
608 int end_position_; | 611 int end_position_; |
609 | 612 |
610 // Computed via PropagateScopeInfo. | 613 // Computed via PropagateScopeInfo. |
611 bool outer_scope_calls_sloppy_eval_; | 614 bool outer_scope_calls_sloppy_eval_; |
612 bool inner_scope_calls_eval_; | 615 bool inner_scope_calls_eval_; |
613 bool inner_scope_uses_arguments_; | 616 bool inner_scope_uses_arguments_; |
614 bool inner_scope_uses_super_property_; | |
615 bool force_eager_compilation_; | 617 bool force_eager_compilation_; |
616 bool force_context_allocation_; | 618 bool force_context_allocation_; |
617 | 619 |
618 // True if it doesn't need scope resolution (e.g., if the scope was | 620 // True if it doesn't need scope resolution (e.g., if the scope was |
619 // constructed based on a serialized scope info or a catch context). | 621 // constructed based on a serialized scope info or a catch context). |
620 bool already_resolved_; | 622 bool already_resolved_; |
621 | 623 |
622 // Computed as variables are declared. | 624 // Computed as variables are declared. |
623 int num_var_or_const_; | 625 int num_var_or_const_; |
624 | 626 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 PendingCompilationErrorHandler pending_error_handler_; | 766 PendingCompilationErrorHandler pending_error_handler_; |
765 | 767 |
766 // For tracking which classes are declared consecutively. Needed for strong | 768 // For tracking which classes are declared consecutively. Needed for strong |
767 // mode. | 769 // mode. |
768 int class_declaration_group_start_; | 770 int class_declaration_group_start_; |
769 }; | 771 }; |
770 | 772 |
771 } } // namespace v8::internal | 773 } } // namespace v8::internal |
772 | 774 |
773 #endif // V8_SCOPES_H_ | 775 #endif // V8_SCOPES_H_ |
OLD | NEW |