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

Side by Side Diff: src/variables.h

Issue 20458: Revert eval changes since there is a crash that I don't have the time... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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/scopes.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // The AST refers to variables via VariableProxies - placeholders for the actual 106 // The AST refers to variables via VariableProxies - placeholders for the actual
107 // variables. Variables themselves are never directly referred to from the AST, 107 // variables. Variables themselves are never directly referred to from the AST,
108 // they are maintained by scopes, and referred to from VariableProxies and Slots 108 // they are maintained by scopes, and referred to from VariableProxies and Slots
109 // after binding and variable allocation. 109 // after binding and variable allocation.
110 110
111 class Variable: public ZoneObject { 111 class Variable: public ZoneObject {
112 public: 112 public:
113 enum Mode { 113 enum Mode {
114 // User declared variables: 114 // User declared variables:
115 VAR, // declared via 'var', and 'function' declarations 115 VAR, // declared via 'var', and 'function' declarations
116
117 CONST, // declared via 'const' declarations 116 CONST, // declared via 'const' declarations
118 117
119 // Variables introduced by the compiler: 118 // Variables introduced by the compiler:
120 DYNAMIC, // always require dynamic lookup (we don't know 119 DYNAMIC, // always require dynamic lookup (we don't know the declaration)
121 // the declaration) 120 INTERNAL, // like VAR, but not user-visible (may or may not be in a
122 121 // context)
123 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the 122 TEMPORARY // temporary variables (not user-visible), never in a context
124 // variable is global unless it has been shadowed
125 // by an eval-introduced variable
126
127 DYNAMIC_LOCAL, // requires dynamic lookup, but we know that the
128 // variable is local and where it is unless it
129 // has been shadowed by an eval-introduced
130 // variable
131
132 INTERNAL, // like VAR, but not user-visible (may or may not
133 // be in a context)
134
135 TEMPORARY // temporary variables (not user-visible), never
136 // in a context
137 }; 123 };
138 124
139 // Printing support 125 // Printing support
140 static const char* Mode2String(Mode mode); 126 static const char* Mode2String(Mode mode);
141 127
142 // Type testing & conversion 128 // Type testing & conversion
143 Property* AsProperty(); 129 Property* AsProperty();
144 Variable* AsVariable(); 130 Variable* AsVariable();
145 bool IsValidLeftHandSide() { return is_valid_LHS_; } 131 bool IsValidLeftHandSide() { return is_valid_LHS_; }
146 132
(...skipping 10 matching lines...) Expand all
157 bool is_accessed_from_inner_scope() const { 143 bool is_accessed_from_inner_scope() const {
158 return is_accessed_from_inner_scope_; 144 return is_accessed_from_inner_scope_;
159 } 145 }
160 UseCount* var_uses() { return &var_uses_; } 146 UseCount* var_uses() { return &var_uses_; }
161 UseCount* obj_uses() { return &obj_uses_; } 147 UseCount* obj_uses() { return &obj_uses_; }
162 148
163 bool IsVariable(Handle<String> n) { 149 bool IsVariable(Handle<String> n) {
164 return !is_this() && name().is_identical_to(n); 150 return !is_this() && name().is_identical_to(n);
165 } 151 }
166 152
167 bool is_dynamic() const {
168 return (mode_ == DYNAMIC ||
169 mode_ == DYNAMIC_GLOBAL ||
170 mode_ == DYNAMIC_LOCAL);
171 }
172
173 bool is_global() const; 153 bool is_global() const;
174 bool is_this() const { return is_this_; } 154 bool is_this() const { return is_this_; }
175 155
176 Variable* local_if_not_shadowed() const {
177 ASSERT(mode_ == DYNAMIC_LOCAL && local_if_not_shadowed_ != NULL);
178 return local_if_not_shadowed_;
179 }
180
181 void set_local_if_not_shadowed(Variable* local) {
182 local_if_not_shadowed_ = local;
183 }
184
185 Expression* rewrite() const { return rewrite_; } 156 Expression* rewrite() const { return rewrite_; }
186 Slot* slot() const; 157 Slot* slot() const;
187 158
188 StaticType* type() { return &type_; } 159 StaticType* type() { return &type_; }
189 160
190 private: 161 private:
191 Variable(Scope* scope, Handle<String> name, Mode mode, bool is_valid_LHS, 162 Variable(Scope* scope, Handle<String> name, Mode mode, bool is_valid_LHS,
192 bool is_this); 163 bool is_this);
193 164
194 Scope* scope_; 165 Scope* scope_;
195 Handle<String> name_; 166 Handle<String> name_;
196 Mode mode_; 167 Mode mode_;
197 bool is_valid_LHS_; 168 bool is_valid_LHS_;
198 bool is_this_; 169 bool is_this_;
199 170
200 Variable* local_if_not_shadowed_;
201
202 // Usage info. 171 // Usage info.
203 bool is_accessed_from_inner_scope_; // set by variable resolver 172 bool is_accessed_from_inner_scope_; // set by variable resolver
204 UseCount var_uses_; // uses of the variable value 173 UseCount var_uses_; // uses of the variable value
205 UseCount obj_uses_; // uses of the object the variable points to 174 UseCount obj_uses_; // uses of the object the variable points to
206 175
207 // Static type information 176 // Static type information
208 StaticType type_; 177 StaticType type_;
209 178
210 // Code generation. 179 // Code generation.
211 // rewrite_ is usually a Slot or a Property, but maybe any expression. 180 // rewrite_ is usually a Slot or a Property, but maybe any expression.
212 Expression* rewrite_; 181 Expression* rewrite_;
213 182
214 friend class VariableProxy; 183 friend class VariableProxy;
215 friend class Scope; 184 friend class Scope;
216 friend class LocalsMap; 185 friend class LocalsMap;
217 friend class AstBuildingParser; 186 friend class AstBuildingParser;
218 }; 187 };
219 188
220 189
221 } } // namespace v8::internal 190 } } // namespace v8::internal
222 191
223 #endif // V8_VARIABLES_H_ 192 #endif // V8_VARIABLES_H_
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | src/variables.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698