| 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_AST_SCOPES_H_ | 5 #ifndef V8_AST_SCOPES_H_ |
| 6 #define V8_AST_SCOPES_H_ | 6 #define V8_AST_SCOPES_H_ |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
| 10 #include "src/globals.h" | 10 #include "src/globals.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // scopes. | 246 // scopes. |
| 247 Declaration* CheckLexDeclarationsConflictingWith( | 247 Declaration* CheckLexDeclarationsConflictingWith( |
| 248 const ZoneList<const AstRawString*>& names); | 248 const ZoneList<const AstRawString*>& names); |
| 249 | 249 |
| 250 // --------------------------------------------------------------------------- | 250 // --------------------------------------------------------------------------- |
| 251 // Scope-specific info. | 251 // Scope-specific info. |
| 252 | 252 |
| 253 // Inform the scope that the corresponding code contains an eval call. | 253 // Inform the scope that the corresponding code contains an eval call. |
| 254 void RecordEvalCall() { scope_calls_eval_ = true; } | 254 void RecordEvalCall() { scope_calls_eval_ = true; } |
| 255 | 255 |
| 256 // Inform the scope that the corresponding code uses "arguments". | |
| 257 void RecordArgumentsUsage() { scope_uses_arguments_ = true; } | |
| 258 | |
| 259 // Inform the scope that the corresponding code uses "super". | 256 // Inform the scope that the corresponding code uses "super". |
| 260 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } | 257 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } |
| 261 | 258 |
| 262 // Set the language mode flag (unless disabled by a global flag). | 259 // Set the language mode flag (unless disabled by a global flag). |
| 263 void SetLanguageMode(LanguageMode language_mode) { | 260 void SetLanguageMode(LanguageMode language_mode) { |
| 264 DCHECK(!is_module_scope() || is_strict(language_mode)); | 261 DCHECK(!is_module_scope() || is_strict(language_mode)); |
| 265 language_mode_ = language_mode; | 262 language_mode_ = language_mode; |
| 266 } | 263 } |
| 267 | 264 |
| 268 // Set the ASM module flag. | 265 // Set the ASM module flag. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 349 } |
| 353 bool outer_scope_calls_sloppy_eval() const { | 350 bool outer_scope_calls_sloppy_eval() const { |
| 354 return outer_scope_calls_sloppy_eval_; | 351 return outer_scope_calls_sloppy_eval_; |
| 355 } | 352 } |
| 356 bool asm_module() const { return asm_module_; } | 353 bool asm_module() const { return asm_module_; } |
| 357 bool asm_function() const { return asm_function_; } | 354 bool asm_function() const { return asm_function_; } |
| 358 | 355 |
| 359 // Is this scope inside a with statement. | 356 // Is this scope inside a with statement. |
| 360 bool inside_with() const { return scope_inside_with_; } | 357 bool inside_with() const { return scope_inside_with_; } |
| 361 | 358 |
| 362 // Does this scope access "arguments". | |
| 363 bool uses_arguments() const { return scope_uses_arguments_; } | |
| 364 // Does this scope access "super" property (super.foo). | 359 // Does this scope access "super" property (super.foo). |
| 365 bool uses_super_property() const { return scope_uses_super_property_; } | 360 bool uses_super_property() const { return scope_uses_super_property_; } |
| 366 // Does this scope have the potential to execute declarations non-linearly? | 361 // Does this scope have the potential to execute declarations non-linearly? |
| 367 bool is_nonlinear() const { return scope_nonlinear_; } | 362 bool is_nonlinear() const { return scope_nonlinear_; } |
| 368 | 363 |
| 369 // Whether this needs to be represented by a runtime context. | 364 // Whether this needs to be represented by a runtime context. |
| 370 bool NeedsContext() const { | 365 bool NeedsContext() const { |
| 371 // Catch and module scopes always have heap slots. | 366 // Catch and module scopes always have heap slots. |
| 372 DCHECK(!is_catch_scope() || num_heap_slots() > 0); | 367 DCHECK(!is_catch_scope() || num_heap_slots() > 0); |
| 373 DCHECK(!is_module_scope() || num_heap_slots() > 0); | 368 DCHECK(!is_module_scope() || num_heap_slots() > 0); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 // Map of function names to lists of functions defined in sloppy blocks | 652 // Map of function names to lists of functions defined in sloppy blocks |
| 658 SloppyBlockFunctionMap sloppy_block_function_map_; | 653 SloppyBlockFunctionMap sloppy_block_function_map_; |
| 659 | 654 |
| 660 // Scope-specific information computed during parsing. | 655 // Scope-specific information computed during parsing. |
| 661 // | 656 // |
| 662 // This scope is inside a 'with' of some outer scope. | 657 // This scope is inside a 'with' of some outer scope. |
| 663 bool scope_inside_with_; | 658 bool scope_inside_with_; |
| 664 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 659 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 665 // the 'eval' call site this scope is the declaration scope. | 660 // the 'eval' call site this scope is the declaration scope. |
| 666 bool scope_calls_eval_; | 661 bool scope_calls_eval_; |
| 667 // This scope uses "arguments". | |
| 668 bool scope_uses_arguments_; | |
| 669 // This scope uses "super" property ('super.foo'). | 662 // This scope uses "super" property ('super.foo'). |
| 670 bool scope_uses_super_property_; | 663 bool scope_uses_super_property_; |
| 671 // This scope has a parameter called "arguments". | 664 // This scope has a parameter called "arguments". |
| 672 bool has_arguments_parameter_; | 665 bool has_arguments_parameter_; |
| 673 // This scope contains an "use asm" annotation. | 666 // This scope contains an "use asm" annotation. |
| 674 bool asm_module_; | 667 bool asm_module_; |
| 675 // This scope's outer context is an asm module. | 668 // This scope's outer context is an asm module. |
| 676 bool asm_function_; | 669 bool asm_function_; |
| 677 // This scope's declarations might not be executed in order (e.g., switch). | 670 // This scope's declarations might not be executed in order (e.g., switch). |
| 678 bool scope_nonlinear_; | 671 bool scope_nonlinear_; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 834 |
| 842 void SetDefaults(); | 835 void SetDefaults(); |
| 843 | 836 |
| 844 PendingCompilationErrorHandler pending_error_handler_; | 837 PendingCompilationErrorHandler pending_error_handler_; |
| 845 }; | 838 }; |
| 846 | 839 |
| 847 } // namespace internal | 840 } // namespace internal |
| 848 } // namespace v8 | 841 } // namespace v8 |
| 849 | 842 |
| 850 #endif // V8_AST_SCOPES_H_ | 843 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |