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

Side by Side Diff: src/variables.h

Issue 345513003: Revert "Parser: Delay internalizing strings and values." (r21841) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/utils.cc ('k') | src/variables.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_VARIABLES_H_ 5 #ifndef V8_VARIABLES_H_
6 #define V8_VARIABLES_H_ 6 #define V8_VARIABLES_H_
7 7
8 #include "src/ast-value-factory.h"
9 #include "src/zone.h" 8 #include "src/zone.h"
10 #include "src/interface.h" 9 #include "src/interface.h"
11 10
12 namespace v8 { 11 namespace v8 {
13 namespace internal { 12 namespace internal {
14 13
15 // The AST refers to variables via VariableProxies - placeholders for the actual 14 // The AST refers to variables via VariableProxies - placeholders for the actual
16 // variables. Variables themselves are never directly referred to from the AST, 15 // variables. Variables themselves are never directly referred to from the AST,
17 // they are maintained by scopes, and referred to from VariableProxies and Slots 16 // they are maintained by scopes, and referred to from VariableProxies and Slots
18 // after binding and variable allocation. 17 // after binding and variable allocation.
(...skipping 27 matching lines...) Expand all
46 // corresponding scope. 45 // corresponding scope.
47 CONTEXT, 46 CONTEXT,
48 47
49 // A named slot in a heap context. name() is the variable name in the 48 // A named slot in a heap context. name() is the variable name in the
50 // context object on the heap, with lookup starting at the current 49 // context object on the heap, with lookup starting at the current
51 // context. index() is invalid. 50 // context. index() is invalid.
52 LOOKUP 51 LOOKUP
53 }; 52 };
54 53
55 Variable(Scope* scope, 54 Variable(Scope* scope,
56 const AstString* name, 55 Handle<String> name,
57 VariableMode mode, 56 VariableMode mode,
58 bool is_valid_ref, 57 bool is_valid_ref,
59 Kind kind, 58 Kind kind,
60 InitializationFlag initialization_flag, 59 InitializationFlag initialization_flag,
61 Interface* interface = Interface::NewValue()); 60 Interface* interface = Interface::NewValue());
62 61
63 // Printing support 62 // Printing support
64 static const char* Mode2String(VariableMode mode); 63 static const char* Mode2String(VariableMode mode);
65 64
66 bool IsValidReference() { return is_valid_ref_; } 65 bool IsValidReference() { return is_valid_ref_; }
67 66
68 // The source code for an eval() call may refer to a variable that is 67 // The source code for an eval() call may refer to a variable that is
69 // in an outer scope about which we don't know anything (it may not 68 // in an outer scope about which we don't know anything (it may not
70 // be the global scope). scope() is NULL in that case. Currently the 69 // be the global scope). scope() is NULL in that case. Currently the
71 // scope is only used to follow the context chain length. 70 // scope is only used to follow the context chain length.
72 Scope* scope() const { return scope_; } 71 Scope* scope() const { return scope_; }
73 72
74 Handle<String> name() const { return name_->string(); } 73 Handle<String> name() const { return name_; }
75 const AstString* raw_name() const { return name_; }
76 VariableMode mode() const { return mode_; } 74 VariableMode mode() const { return mode_; }
77 bool has_forced_context_allocation() const { 75 bool has_forced_context_allocation() const {
78 return force_context_allocation_; 76 return force_context_allocation_;
79 } 77 }
80 void ForceContextAllocation() { 78 void ForceContextAllocation() {
81 ASSERT(mode_ != TEMPORARY); 79 ASSERT(mode_ != TEMPORARY);
82 force_context_allocation_ = true; 80 force_context_allocation_ = true;
83 } 81 }
84 bool is_used() { return is_used_; } 82 bool is_used() { return is_used_; }
85 void set_is_used(bool flag) { is_used_ = flag; } 83 void set_is_used(bool flag) { is_used_ = flag; }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 129
132 void AllocateTo(Location location, int index) { 130 void AllocateTo(Location location, int index) {
133 location_ = location; 131 location_ = location;
134 index_ = index; 132 index_ = index;
135 } 133 }
136 134
137 static int CompareIndex(Variable* const* v, Variable* const* w); 135 static int CompareIndex(Variable* const* v, Variable* const* w);
138 136
139 private: 137 private:
140 Scope* scope_; 138 Scope* scope_;
141 const AstString* name_; 139 Handle<String> name_;
142 VariableMode mode_; 140 VariableMode mode_;
143 Kind kind_; 141 Kind kind_;
144 Location location_; 142 Location location_;
145 int index_; 143 int index_;
146 int initializer_position_; 144 int initializer_position_;
147 145
148 // If this field is set, this variable references the stored locally bound 146 // If this field is set, this variable references the stored locally bound
149 // variable, but it might be shadowed by variable bindings introduced by 147 // variable, but it might be shadowed by variable bindings introduced by
150 // sloppy 'eval' calls between the reference scope (inclusive) and the 148 // sloppy 'eval' calls between the reference scope (inclusive) and the
151 // binding scope (exclusive). 149 // binding scope (exclusive).
152 Variable* local_if_not_shadowed_; 150 Variable* local_if_not_shadowed_;
153 151
154 // Valid as a reference? (const and this are not valid, for example) 152 // Valid as a reference? (const and this are not valid, for example)
155 bool is_valid_ref_; 153 bool is_valid_ref_;
156 154
157 // Usage info. 155 // Usage info.
158 bool force_context_allocation_; // set by variable resolver 156 bool force_context_allocation_; // set by variable resolver
159 bool is_used_; 157 bool is_used_;
160 InitializationFlag initialization_flag_; 158 InitializationFlag initialization_flag_;
161 159
162 // Module type info. 160 // Module type info.
163 Interface* interface_; 161 Interface* interface_;
164 }; 162 };
165 163
166 164
167 } } // namespace v8::internal 165 } } // namespace v8::internal
168 166
169 #endif // V8_VARIABLES_H_ 167 #endif // V8_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/utils.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698