| 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/zone.h" | 9 #include "src/zone.h" |
| 10 | 10 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 // Inform the scope that the corresponding code contains an eval call. | 211 // Inform the scope that the corresponding code contains an eval call. |
| 212 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } | 212 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } |
| 213 | 213 |
| 214 // Inform the scope that the corresponding code uses "arguments". | 214 // Inform the scope that the corresponding code uses "arguments". |
| 215 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | 215 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
| 216 | 216 |
| 217 // Inform the scope that the corresponding code uses "super". | 217 // Inform the scope that the corresponding code uses "super". |
| 218 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 218 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
| 219 | 219 |
| 220 // Inform the scope that the corresponding code invokes "super" constructor. | |
| 221 void RecordSuperConstructorCallUsage() { | |
| 222 scope_uses_super_constructor_call_ = true; | |
| 223 } | |
| 224 | |
| 225 // Inform the scope that the corresponding code uses "this". | 220 // Inform the scope that the corresponding code uses "this". |
| 226 void RecordThisUsage() { scope_uses_this_ = true; } | 221 void RecordThisUsage() { scope_uses_this_ = true; } |
| 227 | 222 |
| 228 // Set the language mode flag (unless disabled by a global flag). | 223 // Set the language mode flag (unless disabled by a global flag). |
| 229 void SetLanguageMode(LanguageMode language_mode) { | 224 void SetLanguageMode(LanguageMode language_mode) { |
| 230 language_mode_ = language_mode; | 225 language_mode_ = language_mode; |
| 231 } | 226 } |
| 232 | 227 |
| 233 // Set the ASM module flag. | 228 // Set the ASM module flag. |
| 234 void SetAsmModule() { asm_module_ = true; } | 229 void SetAsmModule() { asm_module_ = true; } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // Does this scope access "arguments". | 309 // Does this scope access "arguments". |
| 315 bool uses_arguments() const { return scope_uses_arguments_; } | 310 bool uses_arguments() const { return scope_uses_arguments_; } |
| 316 // Does any inner scope access "arguments". | 311 // Does any inner scope access "arguments". |
| 317 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 312 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
| 318 // Does this scope access "super" property (super.foo). | 313 // Does this scope access "super" property (super.foo). |
| 319 bool uses_super_property() const { return scope_uses_super_property_; } | 314 bool uses_super_property() const { return scope_uses_super_property_; } |
| 320 // Does any inner scope access "super" property. | 315 // Does any inner scope access "super" property. |
| 321 bool inner_uses_super_property() const { | 316 bool inner_uses_super_property() const { |
| 322 return inner_scope_uses_super_property_; | 317 return inner_scope_uses_super_property_; |
| 323 } | 318 } |
| 324 // Does this scope calls "super" constructor. | |
| 325 bool uses_super_constructor_call() const { | |
| 326 return scope_uses_super_constructor_call_; | |
| 327 } | |
| 328 // Does any inner scope calls "super" constructor. | |
| 329 bool inner_uses_super_constructor_call() const { | |
| 330 return inner_scope_uses_super_constructor_call_; | |
| 331 } | |
| 332 // Does this scope access "this". | 319 // Does this scope access "this". |
| 333 bool uses_this() const { return scope_uses_this_; } | 320 bool uses_this() const { return scope_uses_this_; } |
| 334 // Does any inner scope access "this". | 321 // Does any inner scope access "this". |
| 335 bool inner_uses_this() const { return inner_scope_uses_this_; } | 322 bool inner_uses_this() const { return inner_scope_uses_this_; } |
| 336 | 323 |
| 337 // --------------------------------------------------------------------------- | 324 // --------------------------------------------------------------------------- |
| 338 // Accessors. | 325 // Accessors. |
| 339 | 326 |
| 340 // The type of this scope. | 327 // The type of this scope. |
| 341 ScopeType scope_type() const { return scope_type_; } | 328 ScopeType scope_type() const { return scope_type_; } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 bool scope_inside_with_; | 523 bool scope_inside_with_; |
| 537 // This scope contains a 'with' statement. | 524 // This scope contains a 'with' statement. |
| 538 bool scope_contains_with_; | 525 bool scope_contains_with_; |
| 539 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 526 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 540 // the 'eval' call site this scope is the declaration scope. | 527 // the 'eval' call site this scope is the declaration scope. |
| 541 bool scope_calls_eval_; | 528 bool scope_calls_eval_; |
| 542 // This scope uses "arguments". | 529 // This scope uses "arguments". |
| 543 bool scope_uses_arguments_; | 530 bool scope_uses_arguments_; |
| 544 // This scope uses "super" property ('super.foo'). | 531 // This scope uses "super" property ('super.foo'). |
| 545 bool scope_uses_super_property_; | 532 bool scope_uses_super_property_; |
| 546 // This scope uses "super" constructor ('super(..)'). | |
| 547 bool scope_uses_super_constructor_call_; | |
| 548 // This scope uses "this". | 533 // This scope uses "this". |
| 549 bool scope_uses_this_; | 534 bool scope_uses_this_; |
| 550 // This scope contains an "use asm" annotation. | 535 // This scope contains an "use asm" annotation. |
| 551 bool asm_module_; | 536 bool asm_module_; |
| 552 // This scope's outer context is an asm module. | 537 // This scope's outer context is an asm module. |
| 553 bool asm_function_; | 538 bool asm_function_; |
| 554 // The language mode of this scope. | 539 // The language mode of this scope. |
| 555 LanguageMode language_mode_; | 540 LanguageMode language_mode_; |
| 556 // Source positions. | 541 // Source positions. |
| 557 int start_position_; | 542 int start_position_; |
| 558 int end_position_; | 543 int end_position_; |
| 559 | 544 |
| 560 // Computed via PropagateScopeInfo. | 545 // Computed via PropagateScopeInfo. |
| 561 bool outer_scope_calls_sloppy_eval_; | 546 bool outer_scope_calls_sloppy_eval_; |
| 562 bool inner_scope_calls_eval_; | 547 bool inner_scope_calls_eval_; |
| 563 bool inner_scope_uses_arguments_; | 548 bool inner_scope_uses_arguments_; |
| 564 bool inner_scope_uses_super_property_; | 549 bool inner_scope_uses_super_property_; |
| 565 bool inner_scope_uses_super_constructor_call_; | |
| 566 bool inner_scope_uses_this_; | 550 bool inner_scope_uses_this_; |
| 567 bool force_eager_compilation_; | 551 bool force_eager_compilation_; |
| 568 bool force_context_allocation_; | 552 bool force_context_allocation_; |
| 569 | 553 |
| 570 // True if it doesn't need scope resolution (e.g., if the scope was | 554 // True if it doesn't need scope resolution (e.g., if the scope was |
| 571 // constructed based on a serialized scope info or a catch context). | 555 // constructed based on a serialized scope info or a catch context). |
| 572 bool already_resolved_; | 556 bool already_resolved_; |
| 573 | 557 |
| 574 // Computed as variables are declared. | 558 // Computed as variables are declared. |
| 575 int num_var_or_const_; | 559 int num_var_or_const_; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 Scope* outer_scope, | 687 Scope* outer_scope, |
| 704 Handle<ScopeInfo> scope_info); | 688 Handle<ScopeInfo> scope_info); |
| 705 | 689 |
| 706 AstValueFactory* ast_value_factory_; | 690 AstValueFactory* ast_value_factory_; |
| 707 Zone* zone_; | 691 Zone* zone_; |
| 708 }; | 692 }; |
| 709 | 693 |
| 710 } } // namespace v8::internal | 694 } } // namespace v8::internal |
| 711 | 695 |
| 712 #endif // V8_SCOPES_H_ | 696 #endif // V8_SCOPES_H_ |
| OLD | NEW |