| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 // --------------------------------------------------------------------------- | 205 // --------------------------------------------------------------------------- |
| 206 // Scope-specific info. | 206 // Scope-specific info. |
| 207 | 207 |
| 208 // Inform the scope that the corresponding code contains a with statement. | 208 // Inform the scope that the corresponding code contains a with statement. |
| 209 void RecordWithStatement() { scope_contains_with_ = true; } | 209 void RecordWithStatement() { scope_contains_with_ = true; } |
| 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_global_scope()) scope_calls_eval_ = true; } | 212 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } |
| 213 | 213 |
| 214 // Inform the scope that the corresponding code uses "arguments". |
| 215 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } |
| 216 |
| 217 // Inform the scope that the corresponding code uses "super". |
| 218 void RecordSuperUsage() { scope_uses_super_ = true; } |
| 219 |
| 214 // Inform the scope that the corresponding code uses "this". | 220 // Inform the scope that the corresponding code uses "this". |
| 215 void RecordThisUsage() { scope_uses_this_ = true; } | 221 void RecordThisUsage() { scope_uses_this_ = true; } |
| 216 | 222 |
| 217 // Inform the scope that the corresponding code uses "arguments". | |
| 218 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | |
| 219 | |
| 220 // Set the strict mode flag (unless disabled by a global flag). | 223 // Set the strict mode flag (unless disabled by a global flag). |
| 221 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } | 224 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } |
| 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; } |
| 225 | 228 |
| 226 // Position in the source where this scope begins and ends. | 229 // Position in the source where this scope begins and ends. |
| 227 // | 230 // |
| 228 // * For the scope of a with statement | 231 // * For the scope of a with statement |
| 229 // with (obj) stmt | 232 // with (obj) stmt |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return outer_scope_calls_sloppy_eval_; | 297 return outer_scope_calls_sloppy_eval_; |
| 295 } | 298 } |
| 296 bool asm_module() const { return asm_module_; } | 299 bool asm_module() const { return asm_module_; } |
| 297 bool asm_function() const { return asm_function_; } | 300 bool asm_function() const { return asm_function_; } |
| 298 | 301 |
| 299 // Is this scope inside a with statement. | 302 // Is this scope inside a with statement. |
| 300 bool inside_with() const { return scope_inside_with_; } | 303 bool inside_with() const { return scope_inside_with_; } |
| 301 // Does this scope contain a with statement. | 304 // Does this scope contain a with statement. |
| 302 bool contains_with() const { return scope_contains_with_; } | 305 bool contains_with() const { return scope_contains_with_; } |
| 303 | 306 |
| 307 // Does this scope access "arguments". |
| 308 bool uses_arguments() const { return scope_uses_arguments_; } |
| 309 // Does any inner scope access "arguments". |
| 310 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } |
| 311 // Does this scope access "super". |
| 312 bool uses_super() const { return scope_uses_super_; } |
| 313 // Does any inner scope access "super". |
| 314 bool inner_uses_super() const { return inner_scope_uses_super_; } |
| 304 // Does this scope access "this". | 315 // Does this scope access "this". |
| 305 bool uses_this() const { return scope_uses_this_; } | 316 bool uses_this() const { return scope_uses_this_; } |
| 306 // Does any inner scope access "this". | 317 // Does any inner scope access "this". |
| 307 bool inner_uses_this() const { return inner_scope_uses_this_; } | 318 bool inner_uses_this() const { return inner_scope_uses_this_; } |
| 308 // Does this scope access "arguments". | |
| 309 bool uses_arguments() const { return scope_uses_arguments_; } | |
| 310 // Does any inner scope access "arguments". | |
| 311 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; } | |
| 312 | 319 |
| 313 // --------------------------------------------------------------------------- | 320 // --------------------------------------------------------------------------- |
| 314 // Accessors. | 321 // Accessors. |
| 315 | 322 |
| 316 // The type of this scope. | 323 // The type of this scope. |
| 317 ScopeType scope_type() const { return scope_type_; } | 324 ScopeType scope_type() const { return scope_type_; } |
| 318 | 325 |
| 319 // The language mode of this scope. | 326 // The language mode of this scope. |
| 320 StrictMode strict_mode() const { return strict_mode_; } | 327 StrictMode strict_mode() const { return strict_mode_; } |
| 321 | 328 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 486 |
| 480 // Scope-specific information computed during parsing. | 487 // Scope-specific information computed during parsing. |
| 481 // | 488 // |
| 482 // This scope is inside a 'with' of some outer scope. | 489 // This scope is inside a 'with' of some outer scope. |
| 483 bool scope_inside_with_; | 490 bool scope_inside_with_; |
| 484 // This scope contains a 'with' statement. | 491 // This scope contains a 'with' statement. |
| 485 bool scope_contains_with_; | 492 bool scope_contains_with_; |
| 486 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 493 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 487 // the 'eval' call site this scope is the declaration scope. | 494 // the 'eval' call site this scope is the declaration scope. |
| 488 bool scope_calls_eval_; | 495 bool scope_calls_eval_; |
| 496 // This scope uses "arguments". |
| 497 bool scope_uses_arguments_; |
| 498 // This scope uses "super". |
| 499 bool scope_uses_super_; |
| 489 // This scope uses "this". | 500 // This scope uses "this". |
| 490 bool scope_uses_this_; | 501 bool scope_uses_this_; |
| 491 // This scope uses "arguments". | |
| 492 bool scope_uses_arguments_; | |
| 493 // This scope contains an "use asm" annotation. | 502 // This scope contains an "use asm" annotation. |
| 494 bool asm_module_; | 503 bool asm_module_; |
| 495 // This scope's outer context is an asm module. | 504 // This scope's outer context is an asm module. |
| 496 bool asm_function_; | 505 bool asm_function_; |
| 497 // The strict mode of this scope. | 506 // The strict mode of this scope. |
| 498 StrictMode strict_mode_; | 507 StrictMode strict_mode_; |
| 499 // Source positions. | 508 // Source positions. |
| 500 int start_position_; | 509 int start_position_; |
| 501 int end_position_; | 510 int end_position_; |
| 502 | 511 |
| 503 // Computed via PropagateScopeInfo. | 512 // Computed via PropagateScopeInfo. |
| 504 bool outer_scope_calls_sloppy_eval_; | 513 bool outer_scope_calls_sloppy_eval_; |
| 505 bool inner_scope_calls_eval_; | 514 bool inner_scope_calls_eval_; |
| 515 bool inner_scope_uses_arguments_; |
| 516 bool inner_scope_uses_super_; |
| 506 bool inner_scope_uses_this_; | 517 bool inner_scope_uses_this_; |
| 507 bool inner_scope_uses_arguments_; | |
| 508 bool force_eager_compilation_; | 518 bool force_eager_compilation_; |
| 509 bool force_context_allocation_; | 519 bool force_context_allocation_; |
| 510 | 520 |
| 511 // True if it doesn't need scope resolution (e.g., if the scope was | 521 // True if it doesn't need scope resolution (e.g., if the scope was |
| 512 // constructed based on a serialized scope info or a catch context). | 522 // constructed based on a serialized scope info or a catch context). |
| 513 bool already_resolved_; | 523 bool already_resolved_; |
| 514 | 524 |
| 515 // Computed as variables are declared. | 525 // Computed as variables are declared. |
| 516 int num_var_or_const_; | 526 int num_var_or_const_; |
| 517 | 527 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 Scope* outer_scope, | 654 Scope* outer_scope, |
| 645 Handle<ScopeInfo> scope_info); | 655 Handle<ScopeInfo> scope_info); |
| 646 | 656 |
| 647 AstValueFactory* ast_value_factory_; | 657 AstValueFactory* ast_value_factory_; |
| 648 Zone* zone_; | 658 Zone* zone_; |
| 649 }; | 659 }; |
| 650 | 660 |
| 651 } } // namespace v8::internal | 661 } } // namespace v8::internal |
| 652 | 662 |
| 653 #endif // V8_SCOPES_H_ | 663 #endif // V8_SCOPES_H_ |
| OLD | NEW |