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

Side by Side Diff: src/scopes.h

Issue 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues Created 5 years, 11 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 | « src/scopeinfo.cc ('k') | src/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_SCOPES_H_ 5 #ifndef V8_SCOPES_H_
6 #define V8_SCOPES_H_ 6 #define V8_SCOPES_H_
7 7
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // corresponding variable (though some are bound during parse time). Variable 65 // corresponding variable (though some are bound during parse time). Variable
66 // allocation binds each unresolved VariableProxy to one Variable and assigns 66 // allocation binds each unresolved VariableProxy to one Variable and assigns
67 // a location. Note that many VariableProxy nodes may refer to the same Java- 67 // a location. Note that many VariableProxy nodes may refer to the same Java-
68 // Script variable. 68 // Script variable.
69 69
70 class Scope: public ZoneObject { 70 class Scope: public ZoneObject {
71 public: 71 public:
72 // --------------------------------------------------------------------------- 72 // ---------------------------------------------------------------------------
73 // Construction 73 // Construction
74 74
75 Scope(Scope* outer_scope, ScopeType scope_type, 75 Scope(Isolate* isolate, Zone* zone, Scope* outer_scope, ScopeType scope_type,
76 AstValueFactory* value_factory, Zone* zone); 76 AstValueFactory* value_factory);
77 77
78 // Compute top scope and allocate variables. For lazy compilation the top 78 // Compute top scope and allocate variables. For lazy compilation the top
79 // scope only contains the single lazily compiled function, so this 79 // scope only contains the single lazily compiled function, so this
80 // doesn't re-allocate variables repeatedly. 80 // doesn't re-allocate variables repeatedly.
81 static bool Analyze(CompilationInfo* info); 81 static bool Analyze(CompilationInfo* info);
82 82
83 static Scope* DeserializeScopeChain(Context* context, Scope* script_scope, 83 static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
84 Zone* zone); 84 Context* context, Scope* script_scope);
85 85
86 // The scope name is only used for printing/debugging. 86 // The scope name is only used for printing/debugging.
87 void SetScopeName(const AstRawString* scope_name) { 87 void SetScopeName(const AstRawString* scope_name) {
88 scope_name_ = scope_name; 88 scope_name_ = scope_name;
89 } 89 }
90 90
91 void Initialize(); 91 void Initialize();
92 92
93 // Checks if the block scope is redundant, i.e. it does not contain any 93 // Checks if the block scope is redundant, i.e. it does not contain any
94 // block scoped declarations. In that case it is removed from the scope 94 // block scoped declarations. In that case it is removed from the scope
95 // tree and its children are reparented. 95 // tree and its children are reparented.
96 Scope* FinalizeBlockScope(); 96 Scope* FinalizeBlockScope();
97 97
98 Isolate* isolate() const { return isolate_; }
98 Zone* zone() const { return zone_; } 99 Zone* zone() const { return zone_; }
99 100
100 // --------------------------------------------------------------------------- 101 // ---------------------------------------------------------------------------
101 // Declarations 102 // Declarations
102 103
103 // Lookup a variable in this scope. Returns the variable or NULL if not found. 104 // Lookup a variable in this scope. Returns the variable or NULL if not found.
104 Variable* LookupLocal(const AstRawString* name); 105 Variable* LookupLocal(const AstRawString* name);
105 106
106 // This lookup corresponds to a lookup in the "intermediate" scope sitting 107 // This lookup corresponds to a lookup in the "intermediate" scope sitting
107 // between this scope and the outer scope. (ECMA-262, 3rd., requires that 108 // between this scope and the outer scope. (ECMA-262, 3rd., requires that
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // resolved properly. 645 // resolved properly.
645 // 646 //
646 // In the case of code compiled and run using 'eval', the context 647 // In the case of code compiled and run using 'eval', the context
647 // parameter is the context in which eval was called. In all other 648 // parameter is the context in which eval was called. In all other
648 // cases the context parameter is an empty handle. 649 // cases the context parameter is an empty handle.
649 MUST_USE_RESULT 650 MUST_USE_RESULT
650 bool AllocateVariables(CompilationInfo* info, AstNodeFactory* factory); 651 bool AllocateVariables(CompilationInfo* info, AstNodeFactory* factory);
651 652
652 private: 653 private:
653 // Construct a scope based on the scope info. 654 // Construct a scope based on the scope info.
654 Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info, 655 Scope(Isolate* isolate, Zone* zone, Scope* inner_scope, ScopeType type,
655 AstValueFactory* value_factory, Zone* zone); 656 Handle<ScopeInfo> scope_info, AstValueFactory* value_factory);
656 657
657 // Construct a catch scope with a binding for the name. 658 // Construct a catch scope with a binding for the name.
658 Scope(Scope* inner_scope, 659 Scope(Isolate* isolate, Zone* zone, Scope* inner_scope,
659 const AstRawString* catch_variable_name, 660 const AstRawString* catch_variable_name,
660 AstValueFactory* value_factory, Zone* zone); 661 AstValueFactory* value_factory);
661 662
662 void AddInnerScope(Scope* inner_scope) { 663 void AddInnerScope(Scope* inner_scope) {
663 if (inner_scope != NULL) { 664 if (inner_scope != NULL) {
664 inner_scopes_.Add(inner_scope, zone_); 665 inner_scopes_.Add(inner_scope, zone_);
665 inner_scope->outer_scope_ = this; 666 inner_scope->outer_scope_ = this;
666 } 667 }
667 } 668 }
668 669
669 void SetDefaults(ScopeType type, 670 void SetDefaults(ScopeType type,
670 Scope* outer_scope, 671 Scope* outer_scope,
671 Handle<ScopeInfo> scope_info); 672 Handle<ScopeInfo> scope_info);
672 673
673 AstValueFactory* ast_value_factory_; 674 AstValueFactory* ast_value_factory_;
674 Zone* zone_; 675 Zone* zone_;
675 }; 676 };
676 677
677 } } // namespace v8::internal 678 } } // namespace v8::internal
678 679
679 #endif // V8_SCOPES_H_ 680 #endif // V8_SCOPES_H_
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698