| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Inform the scope that the corresponding code contains a with statement. | 207 // Inform the scope that the corresponding code contains a with statement. |
| 208 void RecordWithStatement() { scope_contains_with_ = true; } | 208 void RecordWithStatement() { scope_contains_with_ = true; } |
| 209 | 209 |
| 210 // Inform the scope that the corresponding code contains an eval call. | 210 // Inform the scope that the corresponding code contains an eval call. |
| 211 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } | 211 void RecordEvalCall() { if (!is_script_scope()) scope_calls_eval_ = true; } |
| 212 | 212 |
| 213 // Inform the scope that the corresponding code uses "arguments". | 213 // Inform the scope that the corresponding code uses "arguments". |
| 214 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | 214 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
| 215 | 215 |
| 216 // Inform the scope that the corresponding code uses "super". | 216 // Inform the scope that the corresponding code uses "super". |
| 217 void RecordSuperUsage() { scope_uses_super_ = true; } | 217 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
| 218 |
| 219 // Inform the scope that the corresponding code invokes "super" constructor. |
| 220 void RecordSuperConstructorCallUsage() { |
| 221 scope_uses_super_constructor_call_ = true; |
| 222 } |
| 218 | 223 |
| 219 // Inform the scope that the corresponding code uses "this". | 224 // Inform the scope that the corresponding code uses "this". |
| 220 void RecordThisUsage() { scope_uses_this_ = true; } | 225 void RecordThisUsage() { scope_uses_this_ = true; } |
| 221 | 226 |
| 222 // Set the strict mode flag (unless disabled by a global flag). | 227 // Set the strict mode flag (unless disabled by a global flag). |
| 223 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } | 228 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } |
| 224 | 229 |
| 225 // Set the ASM module flag. | 230 // Set the ASM module flag. |
| 226 void SetAsmModule() { asm_module_ = true; } | 231 void SetAsmModule() { asm_module_ = true; } |
| 227 | 232 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 305 |
| 301 // Is this scope inside a with statement. | 306 // Is this scope inside a with statement. |
| 302 bool inside_with() const { return scope_inside_with_; } | 307 bool inside_with() const { return scope_inside_with_; } |
| 303 // Does this scope contain a with statement. | 308 // Does this scope contain a with statement. |
| 304 bool contains_with() const { return scope_contains_with_; } | 309 bool contains_with() const { return scope_contains_with_; } |
| 305 | 310 |
| 306 // Does this scope access "arguments". | 311 // Does this scope access "arguments". |
| 307 bool uses_arguments() const { return scope_uses_arguments_; } | 312 bool uses_arguments() const { return scope_uses_arguments_; } |
| 308 // Does any inner scope access "arguments". | 313 // Does any inner scope access "arguments". |
| 309 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | 314 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
| 310 // Does this scope access "super". | 315 // Does this scope access "super" property (super.foo). |
| 311 bool uses_super() const { return scope_uses_super_; } | 316 bool uses_super_property() const { return scope_uses_super_property_; } |
| 312 // Does any inner scope access "super". | 317 // Does any inner scope access "super" property. |
| 313 bool inner_uses_super() const { return inner_scope_uses_super_; } | 318 bool inner_uses_super_property() const { |
| 319 return inner_scope_uses_super_property_; |
| 320 } |
| 321 // Does this scope calls "super" constructor. |
| 322 bool uses_super_constructor_call() const { |
| 323 return scope_uses_super_constructor_call_; |
| 324 } |
| 325 // Does any inner scope calls "super" constructor. |
| 326 bool inner_uses_super_constructor_call() const { |
| 327 return inner_scope_uses_super_constructor_call_; |
| 328 } |
| 314 // Does this scope access "this". | 329 // Does this scope access "this". |
| 315 bool uses_this() const { return scope_uses_this_; } | 330 bool uses_this() const { return scope_uses_this_; } |
| 316 // Does any inner scope access "this". | 331 // Does any inner scope access "this". |
| 317 bool inner_uses_this() const { return inner_scope_uses_this_; } | 332 bool inner_uses_this() const { return inner_scope_uses_this_; } |
| 318 | 333 |
| 319 // --------------------------------------------------------------------------- | 334 // --------------------------------------------------------------------------- |
| 320 // Accessors. | 335 // Accessors. |
| 321 | 336 |
| 322 // The type of this scope. | 337 // The type of this scope. |
| 323 ScopeType scope_type() const { return scope_type_; } | 338 ScopeType scope_type() const { return scope_type_; } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // | 504 // |
| 490 // This scope is inside a 'with' of some outer scope. | 505 // This scope is inside a 'with' of some outer scope. |
| 491 bool scope_inside_with_; | 506 bool scope_inside_with_; |
| 492 // This scope contains a 'with' statement. | 507 // This scope contains a 'with' statement. |
| 493 bool scope_contains_with_; | 508 bool scope_contains_with_; |
| 494 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 509 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 495 // the 'eval' call site this scope is the declaration scope. | 510 // the 'eval' call site this scope is the declaration scope. |
| 496 bool scope_calls_eval_; | 511 bool scope_calls_eval_; |
| 497 // This scope uses "arguments". | 512 // This scope uses "arguments". |
| 498 bool scope_uses_arguments_; | 513 bool scope_uses_arguments_; |
| 499 // This scope uses "super". | 514 // This scope uses "super" property ('super.foo'). |
| 500 bool scope_uses_super_; | 515 bool scope_uses_super_property_; |
| 516 // This scope uses "super" constructor ('super(..)'). |
| 517 bool scope_uses_super_constructor_call_; |
| 501 // This scope uses "this". | 518 // This scope uses "this". |
| 502 bool scope_uses_this_; | 519 bool scope_uses_this_; |
| 503 // This scope contains an "use asm" annotation. | 520 // This scope contains an "use asm" annotation. |
| 504 bool asm_module_; | 521 bool asm_module_; |
| 505 // This scope's outer context is an asm module. | 522 // This scope's outer context is an asm module. |
| 506 bool asm_function_; | 523 bool asm_function_; |
| 507 // The strict mode of this scope. | 524 // The strict mode of this scope. |
| 508 StrictMode strict_mode_; | 525 StrictMode strict_mode_; |
| 509 // Source positions. | 526 // Source positions. |
| 510 int start_position_; | 527 int start_position_; |
| 511 int end_position_; | 528 int end_position_; |
| 512 | 529 |
| 513 // Computed via PropagateScopeInfo. | 530 // Computed via PropagateScopeInfo. |
| 514 bool outer_scope_calls_sloppy_eval_; | 531 bool outer_scope_calls_sloppy_eval_; |
| 515 bool inner_scope_calls_eval_; | 532 bool inner_scope_calls_eval_; |
| 516 bool inner_scope_uses_arguments_; | 533 bool inner_scope_uses_arguments_; |
| 517 bool inner_scope_uses_super_; | 534 bool inner_scope_uses_super_property_; |
| 535 bool inner_scope_uses_super_constructor_call_; |
| 518 bool inner_scope_uses_this_; | 536 bool inner_scope_uses_this_; |
| 519 bool force_eager_compilation_; | 537 bool force_eager_compilation_; |
| 520 bool force_context_allocation_; | 538 bool force_context_allocation_; |
| 521 | 539 |
| 522 // True if it doesn't need scope resolution (e.g., if the scope was | 540 // True if it doesn't need scope resolution (e.g., if the scope was |
| 523 // constructed based on a serialized scope info or a catch context). | 541 // constructed based on a serialized scope info or a catch context). |
| 524 bool already_resolved_; | 542 bool already_resolved_; |
| 525 | 543 |
| 526 // Computed as variables are declared. | 544 // Computed as variables are declared. |
| 527 int num_var_or_const_; | 545 int num_var_or_const_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 Scope* outer_scope, | 670 Scope* outer_scope, |
| 653 Handle<ScopeInfo> scope_info); | 671 Handle<ScopeInfo> scope_info); |
| 654 | 672 |
| 655 AstValueFactory* ast_value_factory_; | 673 AstValueFactory* ast_value_factory_; |
| 656 Zone* zone_; | 674 Zone* zone_; |
| 657 }; | 675 }; |
| 658 | 676 |
| 659 } } // namespace v8::internal | 677 } } // namespace v8::internal |
| 660 | 678 |
| 661 #endif // V8_SCOPES_H_ | 679 #endif // V8_SCOPES_H_ |
| OLD | NEW |