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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 // Inform the scope that the corresponding code contains an eval call. | 212 // Inform the scope that the corresponding code contains an eval call. |
213 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } | 213 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } |
214 | 214 |
215 // Inform the scope that the corresponding code uses "arguments". | 215 // Inform the scope that the corresponding code uses "arguments". |
216 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | 216 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
217 | 217 |
218 // Inform the scope that the corresponding code uses "super". | 218 // Inform the scope that the corresponding code uses "super". |
219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
220 | 220 |
| 221 // Inform the scope that the corresponding code uses "this". |
| 222 void RecordThisUsage() { scope_uses_this_ = true; } |
| 223 |
221 // Set the language mode flag (unless disabled by a global flag). | 224 // Set the language mode flag (unless disabled by a global flag). |
222 void SetLanguageMode(LanguageMode language_mode) { | 225 void SetLanguageMode(LanguageMode language_mode) { |
223 language_mode_ = language_mode; | 226 language_mode_ = language_mode; |
224 } | 227 } |
225 | 228 |
226 // Set the ASM module flag. | 229 // Set the ASM module flag. |
227 void SetAsmModule() { asm_module_ = true; } | 230 void SetAsmModule() { asm_module_ = true; } |
228 | 231 |
229 // Position in the source where this scope begins and ends. | 232 // Position in the source where this scope begins and ends. |
230 // | 233 // |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // Does this scope access "arguments". | 317 // Does this scope access "arguments". |
315 bool uses_arguments() const { return scope_uses_arguments_; } | 318 bool uses_arguments() const { return scope_uses_arguments_; } |
316 // Does any inner scope access "arguments". | 319 // Does any inner scope access "arguments". |
317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 320 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
318 // Does this scope access "super" property (super.foo). | 321 // Does this scope access "super" property (super.foo). |
319 bool uses_super_property() const { return scope_uses_super_property_; } | 322 bool uses_super_property() const { return scope_uses_super_property_; } |
320 // Does any inner scope access "super" property. | 323 // Does any inner scope access "super" property. |
321 bool inner_uses_super_property() const { | 324 bool inner_uses_super_property() const { |
322 return inner_scope_uses_super_property_; | 325 return inner_scope_uses_super_property_; |
323 } | 326 } |
| 327 // Does this scope access "this". |
| 328 bool uses_this() const { return scope_uses_this_; } |
| 329 // Does any inner scope access "this". |
| 330 bool inner_uses_this() const { return inner_scope_uses_this_; } |
324 | 331 |
325 const Scope* NearestOuterEvalScope() const { | 332 const Scope* NearestOuterEvalScope() const { |
326 if (is_eval_scope()) return this; | 333 if (is_eval_scope()) return this; |
327 if (outer_scope() == nullptr) return nullptr; | 334 if (outer_scope() == nullptr) return nullptr; |
328 return outer_scope()->NearestOuterEvalScope(); | 335 return outer_scope()->NearestOuterEvalScope(); |
329 } | 336 } |
330 | 337 |
331 // --------------------------------------------------------------------------- | 338 // --------------------------------------------------------------------------- |
332 // Accessors. | 339 // Accessors. |
333 | 340 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 bool scope_inside_with_; | 585 bool scope_inside_with_; |
579 // This scope contains a 'with' statement. | 586 // This scope contains a 'with' statement. |
580 bool scope_contains_with_; | 587 bool scope_contains_with_; |
581 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 588 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
582 // the 'eval' call site this scope is the declaration scope. | 589 // the 'eval' call site this scope is the declaration scope. |
583 bool scope_calls_eval_; | 590 bool scope_calls_eval_; |
584 // This scope uses "arguments". | 591 // This scope uses "arguments". |
585 bool scope_uses_arguments_; | 592 bool scope_uses_arguments_; |
586 // This scope uses "super" property ('super.foo'). | 593 // This scope uses "super" property ('super.foo'). |
587 bool scope_uses_super_property_; | 594 bool scope_uses_super_property_; |
| 595 // This scope uses "this". |
| 596 bool scope_uses_this_; |
588 // This scope contains an "use asm" annotation. | 597 // This scope contains an "use asm" annotation. |
589 bool asm_module_; | 598 bool asm_module_; |
590 // This scope's outer context is an asm module. | 599 // This scope's outer context is an asm module. |
591 bool asm_function_; | 600 bool asm_function_; |
592 // The language mode of this scope. | 601 // The language mode of this scope. |
593 LanguageMode language_mode_; | 602 LanguageMode language_mode_; |
594 // Source positions. | 603 // Source positions. |
595 int start_position_; | 604 int start_position_; |
596 int end_position_; | 605 int end_position_; |
597 | 606 |
598 // Computed via PropagateScopeInfo. | 607 // Computed via PropagateScopeInfo. |
599 bool outer_scope_calls_sloppy_eval_; | 608 bool outer_scope_calls_sloppy_eval_; |
600 bool inner_scope_calls_eval_; | 609 bool inner_scope_calls_eval_; |
601 bool inner_scope_uses_arguments_; | 610 bool inner_scope_uses_arguments_; |
602 bool inner_scope_uses_super_property_; | 611 bool inner_scope_uses_super_property_; |
| 612 bool inner_scope_uses_this_; |
603 bool force_eager_compilation_; | 613 bool force_eager_compilation_; |
604 bool force_context_allocation_; | 614 bool force_context_allocation_; |
605 | 615 |
606 // True if it doesn't need scope resolution (e.g., if the scope was | 616 // True if it doesn't need scope resolution (e.g., if the scope was |
607 // constructed based on a serialized scope info or a catch context). | 617 // constructed based on a serialized scope info or a catch context). |
608 bool already_resolved_; | 618 bool already_resolved_; |
609 | 619 |
610 // Computed as variables are declared. | 620 // Computed as variables are declared. |
611 int num_var_or_const_; | 621 int num_var_or_const_; |
612 | 622 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 PendingCompilationErrorHandler pending_error_handler_; | 762 PendingCompilationErrorHandler pending_error_handler_; |
753 | 763 |
754 // For tracking which classes are declared consecutively. Needed for strong | 764 // For tracking which classes are declared consecutively. Needed for strong |
755 // mode. | 765 // mode. |
756 int class_declaration_group_start_; | 766 int class_declaration_group_start_; |
757 }; | 767 }; |
758 | 768 |
759 } } // namespace v8::internal | 769 } } // namespace v8::internal |
760 | 770 |
761 #endif // V8_SCOPES_H_ | 771 #endif // V8_SCOPES_H_ |
OLD | NEW |