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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 void ResolveVariable(ParseInfo* info, VariableProxy* proxy); | 524 void ResolveVariable(ParseInfo* info, VariableProxy* proxy); |
525 void ResolveVariablesRecursively(ParseInfo* info); | 525 void ResolveVariablesRecursively(ParseInfo* info); |
526 | 526 |
527 // Finds free variables of this scope. This mutates the unresolved variables | 527 // Finds free variables of this scope. This mutates the unresolved variables |
528 // list along the way, so full resolution cannot be done afterwards. | 528 // list along the way, so full resolution cannot be done afterwards. |
529 // If a ParseInfo* is passed, non-free variables will be resolved. | 529 // If a ParseInfo* is passed, non-free variables will be resolved. |
530 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, | 530 VariableProxy* FetchFreeVariables(DeclarationScope* max_outer_scope, |
531 ParseInfo* info = nullptr, | 531 ParseInfo* info = nullptr, |
532 VariableProxy* stack = nullptr); | 532 VariableProxy* stack = nullptr); |
533 | 533 |
534 // Scope analysis. | |
535 void PropagateScopeInfo(); | |
536 | |
537 // Predicates. | 534 // Predicates. |
538 bool MustAllocate(Variable* var); | 535 bool MustAllocate(Variable* var); |
539 bool MustAllocateInContext(Variable* var); | 536 bool MustAllocateInContext(Variable* var); |
540 | 537 |
541 // Variable allocation. | 538 // Variable allocation. |
542 void AllocateStackSlot(Variable* var); | 539 void AllocateStackSlot(Variable* var); |
543 void AllocateHeapSlot(Variable* var); | 540 void AllocateHeapSlot(Variable* var); |
544 void AllocateNonParameterLocal(Variable* var); | 541 void AllocateNonParameterLocal(Variable* var); |
545 void AllocateDeclaredGlobal(Variable* var); | 542 void AllocateDeclaredGlobal(Variable* var); |
546 void AllocateNonParameterLocalsAndDeclaredGlobals(); | 543 void AllocateNonParameterLocalsAndDeclaredGlobals(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 IsClassConstructor(function_kind()))); | 614 IsClassConstructor(function_kind()))); |
618 } | 615 } |
619 | 616 |
620 void SetScriptScopeInfo(Handle<ScopeInfo> scope_info) { | 617 void SetScriptScopeInfo(Handle<ScopeInfo> scope_info) { |
621 DCHECK(is_script_scope()); | 618 DCHECK(is_script_scope()); |
622 DCHECK(scope_info_.is_null()); | 619 DCHECK(scope_info_.is_null()); |
623 scope_info_ = scope_info; | 620 scope_info_ = scope_info; |
624 } | 621 } |
625 | 622 |
626 bool asm_module() const { return asm_module_; } | 623 bool asm_module() const { return asm_module_; } |
627 void set_asm_module() { asm_module_ = true; } | 624 void set_asm_module(); |
628 bool asm_function() const { return asm_function_; } | 625 bool asm_function() const { return asm_function_; } |
629 void set_asm_function() { asm_module_ = true; } | 626 void set_asm_function() { asm_module_ = true; } |
630 | 627 |
631 void DeclareThis(AstValueFactory* ast_value_factory); | 628 void DeclareThis(AstValueFactory* ast_value_factory); |
632 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); | 629 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory); |
633 | 630 |
634 // This lookup corresponds to a lookup in the "intermediate" scope sitting | 631 // This lookup corresponds to a lookup in the "intermediate" scope sitting |
635 // between this scope and the outer scope. (ECMA-262, 3rd., requires that | 632 // between this scope and the outer scope. (ECMA-262, 3rd., requires that |
636 // the name of named function literal is kept in an intermediate scope | 633 // the name of named function literal is kept in an intermediate scope |
637 // in between this scope and the next outer scope.) | 634 // in between this scope and the next outer scope.) |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 void AllocateModuleVariables(); | 850 void AllocateModuleVariables(); |
854 | 851 |
855 private: | 852 private: |
856 ModuleDescriptor* module_descriptor_; | 853 ModuleDescriptor* module_descriptor_; |
857 }; | 854 }; |
858 | 855 |
859 } // namespace internal | 856 } // namespace internal |
860 } // namespace v8 | 857 } // namespace v8 |
861 | 858 |
862 #endif // V8_AST_SCOPES_H_ | 859 #endif // V8_AST_SCOPES_H_ |
OLD | NEW |