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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 // --------------------------------------------------------------------------- | 206 // --------------------------------------------------------------------------- |
207 // Scope-specific info. | 207 // Scope-specific info. |
208 | 208 |
209 // Inform the scope that the corresponding code contains a with statement. | 209 // Inform the scope that the corresponding code contains a with statement. |
210 void RecordWithStatement() { scope_contains_with_ = true; } | 210 void RecordWithStatement() { scope_contains_with_ = true; } |
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". |
| 216 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
| 217 |
215 // Inform the scope that the corresponding code uses "super". | 218 // Inform the scope that the corresponding code uses "super". |
216 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
217 | 220 |
218 // Set the language mode flag (unless disabled by a global flag). | 221 // Set the language mode flag (unless disabled by a global flag). |
219 void SetLanguageMode(LanguageMode language_mode) { | 222 void SetLanguageMode(LanguageMode language_mode) { |
220 language_mode_ = language_mode; | 223 language_mode_ = language_mode; |
221 } | 224 } |
222 | 225 |
223 // Set the ASM module flag. | 226 // Set the ASM module flag. |
224 void SetAsmModule() { asm_module_ = true; } | 227 void SetAsmModule() { asm_module_ = true; } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 return outer_scope_calls_sloppy_eval_; | 304 return outer_scope_calls_sloppy_eval_; |
302 } | 305 } |
303 bool asm_module() const { return asm_module_; } | 306 bool asm_module() const { return asm_module_; } |
304 bool asm_function() const { return asm_function_; } | 307 bool asm_function() const { return asm_function_; } |
305 | 308 |
306 // Is this scope inside a with statement. | 309 // Is this scope inside a with statement. |
307 bool inside_with() const { return scope_inside_with_; } | 310 bool inside_with() const { return scope_inside_with_; } |
308 // Does this scope contain a with statement. | 311 // Does this scope contain a with statement. |
309 bool contains_with() const { return scope_contains_with_; } | 312 bool contains_with() const { return scope_contains_with_; } |
310 | 313 |
| 314 // Does this scope access "arguments". |
| 315 bool uses_arguments() const { return scope_uses_arguments_; } |
| 316 // Does any inner scope access "arguments". |
| 317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
311 // Does this scope access "super" property (super.foo). | 318 // Does this scope access "super" property (super.foo). |
312 bool uses_super_property() const { return scope_uses_super_property_; } | 319 bool uses_super_property() const { return scope_uses_super_property_; } |
313 // Does any inner scope access "super" property. | 320 // Does any inner scope access "super" property. |
314 bool inner_uses_super_property() const { | 321 bool inner_uses_super_property() const { |
315 return inner_scope_uses_super_property_; | 322 return inner_scope_uses_super_property_; |
316 } | 323 } |
317 | 324 |
318 const Scope* NearestOuterEvalScope() const { | 325 const Scope* NearestOuterEvalScope() const { |
319 if (is_eval_scope()) return this; | 326 if (is_eval_scope()) return this; |
320 if (outer_scope() == nullptr) return nullptr; | 327 if (outer_scope() == nullptr) return nullptr; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 | 574 |
568 // Scope-specific information computed during parsing. | 575 // Scope-specific information computed during parsing. |
569 // | 576 // |
570 // This scope is inside a 'with' of some outer scope. | 577 // This scope is inside a 'with' of some outer scope. |
571 bool scope_inside_with_; | 578 bool scope_inside_with_; |
572 // This scope contains a 'with' statement. | 579 // This scope contains a 'with' statement. |
573 bool scope_contains_with_; | 580 bool scope_contains_with_; |
574 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 581 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
575 // the 'eval' call site this scope is the declaration scope. | 582 // the 'eval' call site this scope is the declaration scope. |
576 bool scope_calls_eval_; | 583 bool scope_calls_eval_; |
| 584 // This scope uses "arguments". |
| 585 bool scope_uses_arguments_; |
577 // This scope uses "super" property ('super.foo'). | 586 // This scope uses "super" property ('super.foo'). |
578 bool scope_uses_super_property_; | 587 bool scope_uses_super_property_; |
579 // This scope contains an "use asm" annotation. | 588 // This scope contains an "use asm" annotation. |
580 bool asm_module_; | 589 bool asm_module_; |
581 // This scope's outer context is an asm module. | 590 // This scope's outer context is an asm module. |
582 bool asm_function_; | 591 bool asm_function_; |
583 // The language mode of this scope. | 592 // The language mode of this scope. |
584 LanguageMode language_mode_; | 593 LanguageMode language_mode_; |
585 // Source positions. | 594 // Source positions. |
586 int start_position_; | 595 int start_position_; |
587 int end_position_; | 596 int end_position_; |
588 | 597 |
589 // Computed via PropagateScopeInfo. | 598 // Computed via PropagateScopeInfo. |
590 bool outer_scope_calls_sloppy_eval_; | 599 bool outer_scope_calls_sloppy_eval_; |
591 bool inner_scope_calls_eval_; | 600 bool inner_scope_calls_eval_; |
| 601 bool inner_scope_uses_arguments_; |
592 bool inner_scope_uses_super_property_; | 602 bool inner_scope_uses_super_property_; |
593 bool force_eager_compilation_; | 603 bool force_eager_compilation_; |
594 bool force_context_allocation_; | 604 bool force_context_allocation_; |
595 | 605 |
596 // True if it doesn't need scope resolution (e.g., if the scope was | 606 // True if it doesn't need scope resolution (e.g., if the scope was |
597 // constructed based on a serialized scope info or a catch context). | 607 // constructed based on a serialized scope info or a catch context). |
598 bool already_resolved_; | 608 bool already_resolved_; |
599 | 609 |
600 // Computed as variables are declared. | 610 // Computed as variables are declared. |
601 int num_var_or_const_; | 611 int num_var_or_const_; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 PendingCompilationErrorHandler pending_error_handler_; | 752 PendingCompilationErrorHandler pending_error_handler_; |
743 | 753 |
744 // For tracking which classes are declared consecutively. Needed for strong | 754 // For tracking which classes are declared consecutively. Needed for strong |
745 // mode. | 755 // mode. |
746 int class_declaration_group_start_; | 756 int class_declaration_group_start_; |
747 }; | 757 }; |
748 | 758 |
749 } } // namespace v8::internal | 759 } } // namespace v8::internal |
750 | 760 |
751 #endif // V8_SCOPES_H_ | 761 #endif // V8_SCOPES_H_ |
OLD | NEW |