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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 int num_global_slots_; | 494 int num_global_slots_; |
495 | 495 |
496 // The scope type. | 496 // The scope type. |
497 const ScopeType scope_type_; | 497 const ScopeType scope_type_; |
498 | 498 |
499 // Scope-specific information computed during parsing. | 499 // Scope-specific information computed during parsing. |
500 // | 500 // |
501 // The language mode of this scope. | 501 // The language mode of this scope. |
502 STATIC_ASSERT(LANGUAGE_END == 2); | 502 STATIC_ASSERT(LANGUAGE_END == 2); |
503 bool is_strict_ : 1; | 503 bool is_strict_ : 1; |
504 // This scope is inside a 'with' of some outer scope. | |
505 bool scope_inside_with_ : 1; | |
506 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 504 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
507 // the 'eval' call site this scope is the declaration scope. | 505 // the 'eval' call site this scope is the declaration scope. |
508 bool scope_calls_eval_ : 1; | 506 bool scope_calls_eval_ : 1; |
509 // This scope uses "super" property ('super.foo'). | 507 // This scope uses "super" property ('super.foo'). |
510 bool scope_uses_super_property_ : 1; | 508 bool scope_uses_super_property_ : 1; |
511 // This scope has a parameter called "arguments". | 509 // This scope has a parameter called "arguments". |
512 bool has_arguments_parameter_ : 1; | 510 bool has_arguments_parameter_ : 1; |
513 // This scope's declarations might not be executed in order (e.g., switch). | 511 // This scope's declarations might not be executed in order (e.g., switch). |
514 bool scope_nonlinear_ : 1; | 512 bool scope_nonlinear_ : 1; |
515 bool is_hidden_ : 1; | 513 bool is_hidden_ : 1; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
588 AstNodeFactory* factory); | 586 AstNodeFactory* factory); |
589 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); | 587 void ResolveVariablesRecursively(ParseInfo* info, AstNodeFactory* factory); |
590 | 588 |
591 // Finds free variables of this scope. This mutates the unresolved variables | 589 // Finds free variables of this scope. This mutates the unresolved variables |
592 // list along the way, so full resolution cannot be done afterwards. | 590 // list along the way, so full resolution cannot be done afterwards. |
593 // If a ParseInfo* is passed, non-free variables will be resolved. | 591 // If a ParseInfo* is passed, non-free variables will be resolved. |
594 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, | 592 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, |
595 ParseInfo* info = nullptr, | 593 ParseInfo* info = nullptr, |
596 VariableProxy* stack = nullptr); | 594 VariableProxy* stack = nullptr); |
597 | 595 |
596 bool InsideWithScope() const { | |
597 for (const Scope* scope = this; scope != nullptr; | |
598 scope = scope->outer_scope()) { | |
599 if (scope->is_with_scope()) return true; | |
600 } | |
601 return false; | |
602 } | |
603 | |
neis
2016/08/19 14:25:24
This will return true for any with scope. Is that
Toon Verwaest
2016/08/19 15:58:23
Yes? That's what the flag used to do
| |
598 // Scope analysis. | 604 // Scope analysis. |
599 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); | 605 void PropagateScopeInfo(bool outer_scope_calls_sloppy_eval); |
600 bool HasTrivialContext() const; | 606 bool HasTrivialContext() const; |
601 | 607 |
602 // Predicates. | 608 // Predicates. |
603 bool MustAllocate(Variable* var); | 609 bool MustAllocate(Variable* var); |
604 bool MustAllocateInContext(Variable* var); | 610 bool MustAllocateInContext(Variable* var); |
605 | 611 |
606 // Variable allocation. | 612 // Variable allocation. |
607 void AllocateStackSlot(Variable* var); | 613 void AllocateStackSlot(Variable* var); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 void AllocateModuleVariables(); | 905 void AllocateModuleVariables(); |
900 | 906 |
901 private: | 907 private: |
902 ModuleDescriptor* module_descriptor_; | 908 ModuleDescriptor* module_descriptor_; |
903 }; | 909 }; |
904 | 910 |
905 } // namespace internal | 911 } // namespace internal |
906 } // namespace v8 | 912 } // namespace v8 |
907 | 913 |
908 #endif // V8_AST_SCOPES_H_ | 914 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |