Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: src/ast/scopes.h

Issue 2160943004: Remove ast_value_factory_ and usages from scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename NewScope(...FunctionKind) to NewFunctionScope Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // allocation binds each unresolved VariableProxy to one Variable and assigns 83 // allocation binds each unresolved VariableProxy to one Variable and assigns
84 // a location. Note that many VariableProxy nodes may refer to the same Java- 84 // a location. Note that many VariableProxy nodes may refer to the same Java-
85 // Script variable. 85 // Script variable.
86 86
87 class Scope: public ZoneObject { 87 class Scope: public ZoneObject {
88 public: 88 public:
89 // --------------------------------------------------------------------------- 89 // ---------------------------------------------------------------------------
90 // Construction 90 // Construction
91 91
92 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type, 92 Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
93 AstValueFactory* value_factory,
94 FunctionKind function_kind = kNormalFunction); 93 FunctionKind function_kind = kNormalFunction);
95 94
96 // Compute top scope and allocate variables. For lazy compilation the top 95 // Compute top scope and allocate variables. For lazy compilation the top
97 // scope only contains the single lazily compiled function, so this 96 // scope only contains the single lazily compiled function, so this
98 // doesn't re-allocate variables repeatedly. 97 // doesn't re-allocate variables repeatedly.
99 static bool Analyze(ParseInfo* info); 98 static bool Analyze(ParseInfo* info);
100 99
101 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone, 100 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
102 Context* context, Scope* script_scope); 101 Context* context, Scope* script_scope,
102 AstValueFactory* ast_value_factory);
103 103
104 // The scope name is only used for printing/debugging. 104 // The scope name is only used for printing/debugging.
105 void SetScopeName(const AstRawString* scope_name) { 105 void SetScopeName(const AstRawString* scope_name) {
106 scope_name_ = scope_name; 106 scope_name_ = scope_name;
107 } 107 }
108 108
109 void Initialize(); 109 void Initialize();
110 void DeclareThis(AstValueFactory* ast_value_factory);
111 void DeclareDefaultFunctionVariables(AstValueFactory* ast_value_factory);
110 112
111 // Checks if the block scope is redundant, i.e. it does not contain any 113 // Checks if the block scope is redundant, i.e. it does not contain any
112 // block scoped declarations. In that case it is removed from the scope 114 // block scoped declarations. In that case it is removed from the scope
113 // tree and its children are reparented. 115 // tree and its children are reparented.
114 Scope* FinalizeBlockScope(); 116 Scope* FinalizeBlockScope();
115 117
116 // Inserts outer_scope into this scope's scope chain (and removes this 118 // Inserts outer_scope into this scope's scope chain (and removes this
117 // from the current outer_scope_'s inner_scopes_). 119 // from the current outer_scope_'s inner_scopes_).
118 // Assumes outer_scope_ is non-null. 120 // Assumes outer_scope_ is non-null.
119 void ReplaceOuterScope(Scope* outer_scope); 121 void ReplaceOuterScope(Scope* outer_scope);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 // resolved properly. 796 // resolved properly.
795 // 797 //
796 // In the case of code compiled and run using 'eval', the context 798 // In the case of code compiled and run using 'eval', the context
797 // parameter is the context in which eval was called. In all other 799 // parameter is the context in which eval was called. In all other
798 // cases the context parameter is an empty handle. 800 // cases the context parameter is an empty handle.
799 MUST_USE_RESULT 801 MUST_USE_RESULT
800 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory); 802 bool AllocateVariables(ParseInfo* info, AstNodeFactory* factory);
801 803
802 // Construct a scope based on the scope info. 804 // Construct a scope based on the scope info.
803 Scope(Zone* zone, Scope* inner_scope, ScopeType type, 805 Scope(Zone* zone, Scope* inner_scope, ScopeType type,
804 Handle<ScopeInfo> scope_info, AstValueFactory* value_factory); 806 Handle<ScopeInfo> scope_info);
805 807
806 // Construct a catch scope with a binding for the name. 808 // Construct a catch scope with a binding for the name.
807 Scope(Zone* zone, Scope* inner_scope, const AstRawString* catch_variable_name, 809 Scope(Zone* zone, Scope* inner_scope,
808 AstValueFactory* value_factory); 810 const AstRawString* catch_variable_name);
809 811
810 void AddInnerScope(Scope* inner_scope) { 812 void AddInnerScope(Scope* inner_scope) {
811 if (inner_scope != NULL) { 813 if (inner_scope != NULL) {
812 inner_scopes_.Add(inner_scope, zone_); 814 inner_scopes_.Add(inner_scope, zone_);
813 inner_scope->outer_scope_ = this; 815 inner_scope->outer_scope_ = this;
814 } 816 }
815 } 817 }
816 818
817 void RemoveInnerScope(Scope* inner_scope) { 819 void RemoveInnerScope(Scope* inner_scope) {
818 DCHECK_NOT_NULL(inner_scope); 820 DCHECK_NOT_NULL(inner_scope);
819 for (int i = 0; i < inner_scopes_.length(); i++) { 821 for (int i = 0; i < inner_scopes_.length(); i++) {
820 if (inner_scopes_[i] == inner_scope) { 822 if (inner_scopes_[i] == inner_scope) {
821 inner_scopes_.Remove(i); 823 inner_scopes_.Remove(i);
822 break; 824 break;
823 } 825 }
824 } 826 }
825 } 827 }
826 828
827 void SetDefaults(ScopeType type, Scope* outer_scope, 829 void SetDefaults(ScopeType type, Scope* outer_scope,
828 Handle<ScopeInfo> scope_info, 830 Handle<ScopeInfo> scope_info,
829 FunctionKind function_kind = kNormalFunction); 831 FunctionKind function_kind = kNormalFunction);
830 832
831 AstValueFactory* ast_value_factory_;
832 Zone* zone_; 833 Zone* zone_;
833 834
834 PendingCompilationErrorHandler pending_error_handler_; 835 PendingCompilationErrorHandler pending_error_handler_;
835 }; 836 };
836 837
837 } // namespace internal 838 } // namespace internal
838 } // namespace v8 839 } // namespace v8
839 840
840 #endif // V8_AST_SCOPES_H_ 841 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698