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

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

Issue 2158393002: Make the Scope constructors less reliant on SetDefaults to magically set flags (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reupload 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // 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
119 // from the current outer_scope_'s inner_scopes_). 119 // from the current outer_scope_'s inner_scopes_).
120 // Assumes outer_scope_ is non-null. 120 // Assumes outer_scope_ is non-null.
121 void ReplaceOuterScope(Scope* outer_scope); 121 void ReplaceOuterScope(Scope* outer_scope);
122 122
123 // Propagates any eagerly-gathered scope usage flags (such as calls_eval()) 123 // Propagates any eagerly-gathered scope usage flags (such as calls_eval())
124 // to the passed-in scope. 124 // to the passed-in scope.
125 void PropagateUsageFlagsToScope(Scope* other); 125 void PropagateUsageFlagsToScope(Scope* other);
126 126
127 Zone* zone() const { return zone_; } 127 Zone* zone() const { return variables_.zone(); }
128 128
129 // --------------------------------------------------------------------------- 129 // ---------------------------------------------------------------------------
130 // Declarations 130 // Declarations
131 131
132 // Lookup a variable in this scope. Returns the variable or NULL if not found. 132 // Lookup a variable in this scope. Returns the variable or NULL if not found.
133 Variable* LookupLocal(const AstRawString* name); 133 Variable* LookupLocal(const AstRawString* name);
134 134
135 // This lookup corresponds to a lookup in the "intermediate" scope sitting 135 // This lookup corresponds to a lookup in the "intermediate" scope sitting
136 // between this scope and the outer scope. (ECMA-262, 3rd., requires that 136 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
137 // the name of named function literal is kept in an intermediate scope 137 // the name of named function literal is kept in an intermediate scope
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 #endif 605 #endif
606 606
607 // --------------------------------------------------------------------------- 607 // ---------------------------------------------------------------------------
608 // Implementation. 608 // Implementation.
609 private: 609 private:
610 // Scope tree. 610 // Scope tree.
611 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL 611 Scope* outer_scope_; // the immediately enclosing outer scope, or NULL
612 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes 612 ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
613 613
614 // The scope type. 614 // The scope type.
615 ScopeType scope_type_; 615 const ScopeType scope_type_;
616 // If the scope is a function scope, this is the function kind. 616 // If the scope is a function scope, this is the function kind.
617 FunctionKind function_kind_; 617 const FunctionKind function_kind_;
618 618
619 // Debugging support. 619 // Debugging support.
620 const AstRawString* scope_name_; 620 const AstRawString* scope_name_;
621 621
622 // The variables declared in this scope: 622 // The variables declared in this scope:
623 // 623 //
624 // All user-declared variables (incl. parameters). For script scopes 624 // All user-declared variables (incl. parameters). For script scopes
625 // variables may be implicitly 'declared' by being used (possibly in 625 // variables may be implicitly 'declared' by being used (possibly in
626 // an inner scope) with no intervening with statements or eval calls. 626 // an inner scope) with no intervening with statements or eval calls.
627 VariableMap variables_; 627 VariableMap variables_;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // Construct a scope based on the scope info. 804 // Construct a scope based on the scope info.
805 Scope(Zone* zone, Scope* inner_scope, ScopeType type, 805 Scope(Zone* zone, Scope* inner_scope, ScopeType type,
806 Handle<ScopeInfo> scope_info); 806 Handle<ScopeInfo> scope_info);
807 807
808 // Construct a catch scope with a binding for the name. 808 // Construct a catch scope with a binding for the name.
809 Scope(Zone* zone, Scope* inner_scope, 809 Scope(Zone* zone, Scope* inner_scope,
810 const AstRawString* catch_variable_name); 810 const AstRawString* catch_variable_name);
811 811
812 void AddInnerScope(Scope* inner_scope) { 812 void AddInnerScope(Scope* inner_scope) {
813 if (inner_scope != NULL) { 813 if (inner_scope != NULL) {
814 inner_scopes_.Add(inner_scope, zone_); 814 inner_scopes_.Add(inner_scope, zone());
815 inner_scope->outer_scope_ = this; 815 inner_scope->outer_scope_ = this;
816 } 816 }
817 } 817 }
818 818
819 void RemoveInnerScope(Scope* inner_scope) { 819 void RemoveInnerScope(Scope* inner_scope) {
820 DCHECK_NOT_NULL(inner_scope); 820 DCHECK_NOT_NULL(inner_scope);
821 for (int i = 0; i < inner_scopes_.length(); i++) { 821 for (int i = 0; i < inner_scopes_.length(); i++) {
822 if (inner_scopes_[i] == inner_scope) { 822 if (inner_scopes_[i] == inner_scope) {
823 inner_scopes_.Remove(i); 823 inner_scopes_.Remove(i);
824 break; 824 break;
825 } 825 }
826 } 826 }
827 } 827 }
828 828
829 void SetDefaults(ScopeType type, Scope* outer_scope, 829 void SetDefaults();
830 Handle<ScopeInfo> scope_info,
831 FunctionKind function_kind = kNormalFunction);
832
833 Zone* zone_;
834 830
835 PendingCompilationErrorHandler pending_error_handler_; 831 PendingCompilationErrorHandler pending_error_handler_;
836 }; 832 };
837 833
838 } // namespace internal 834 } // namespace internal
839 } // namespace v8 835 } // namespace v8
840 836
841 #endif // V8_AST_SCOPES_H_ 837 #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