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

Side by Side Diff: src/scopes.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // and setup time for scopes that don't need them. 42 // and setup time for scopes that don't need them.
43 class DynamicScopePart : public ZoneObject { 43 class DynamicScopePart : public ZoneObject {
44 public: 44 public:
45 explicit DynamicScopePart(Zone* zone) { 45 explicit DynamicScopePart(Zone* zone) {
46 for (int i = 0; i < 3; i++) 46 for (int i = 0; i < 3; i++)
47 maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone); 47 maps_[i] = new(zone->New(sizeof(VariableMap))) VariableMap(zone);
48 } 48 }
49 49
50 VariableMap* GetMap(VariableMode mode) { 50 VariableMap* GetMap(VariableMode mode) {
51 int index = mode - DYNAMIC; 51 int index = mode - DYNAMIC;
52 ASSERT(index >= 0 && index < 3); 52 DCHECK(index >= 0 && index < 3);
53 return maps_[index]; 53 return maps_[index];
54 } 54 }
55 55
56 private: 56 private:
57 VariableMap *maps_[3]; 57 VariableMap *maps_[3];
58 }; 58 };
59 59
60 60
61 // Global invariants after AST construction: Each reference (i.e. identifier) 61 // Global invariants after AST construction: Each reference (i.e. identifier)
62 // to a JavaScript variable (including global properties) is represented by a 62 // to a JavaScript variable (including global properties) is represented by a
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 AstNodeFactory<AstNullVisitor>* factory); 111 AstNodeFactory<AstNullVisitor>* factory);
112 112
113 // Lookup a variable in this scope or outer scopes. 113 // Lookup a variable in this scope or outer scopes.
114 // Returns the variable or NULL if not found. 114 // Returns the variable or NULL if not found.
115 Variable* Lookup(const AstRawString* name); 115 Variable* Lookup(const AstRawString* name);
116 116
117 // Declare the function variable for a function literal. This variable 117 // Declare the function variable for a function literal. This variable
118 // is in an intermediate scope between this function scope and the the 118 // is in an intermediate scope between this function scope and the the
119 // outer scope. Only possible for function scopes; at most one variable. 119 // outer scope. Only possible for function scopes; at most one variable.
120 void DeclareFunctionVar(VariableDeclaration* declaration) { 120 void DeclareFunctionVar(VariableDeclaration* declaration) {
121 ASSERT(is_function_scope()); 121 DCHECK(is_function_scope());
122 function_ = declaration; 122 function_ = declaration;
123 } 123 }
124 124
125 // Declare a parameter in this scope. When there are duplicated 125 // Declare a parameter in this scope. When there are duplicated
126 // parameters the rightmost one 'wins'. However, the implementation 126 // parameters the rightmost one 'wins'. However, the implementation
127 // expects all parameters to be declared and from left to right. 127 // expects all parameters to be declared and from left to right.
128 Variable* DeclareParameter(const AstRawString* name, VariableMode mode); 128 Variable* DeclareParameter(const AstRawString* name, VariableMode mode);
129 129
130 // Declare a local variable in this scope. If the variable has been 130 // Declare a local variable in this scope. If the variable has been
131 // declared before, the previously declared variable is returned. 131 // declared before, the previously declared variable is returned.
(...skipping 10 matching lines...) Expand all
142 142
143 // Create a new unresolved variable. 143 // Create a new unresolved variable.
144 template<class Visitor> 144 template<class Visitor>
145 VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory, 145 VariableProxy* NewUnresolved(AstNodeFactory<Visitor>* factory,
146 const AstRawString* name, 146 const AstRawString* name,
147 Interface* interface = Interface::NewValue(), 147 Interface* interface = Interface::NewValue(),
148 int position = RelocInfo::kNoPosition) { 148 int position = RelocInfo::kNoPosition) {
149 // Note that we must not share the unresolved variables with 149 // Note that we must not share the unresolved variables with
150 // the same name because they may be removed selectively via 150 // the same name because they may be removed selectively via
151 // RemoveUnresolved(). 151 // RemoveUnresolved().
152 ASSERT(!already_resolved()); 152 DCHECK(!already_resolved());
153 VariableProxy* proxy = 153 VariableProxy* proxy =
154 factory->NewVariableProxy(name, false, interface, position); 154 factory->NewVariableProxy(name, false, interface, position);
155 unresolved_.Add(proxy, zone_); 155 unresolved_.Add(proxy, zone_);
156 return proxy; 156 return proxy;
157 } 157 }
158 158
159 // Remove a unresolved variable. During parsing, an unresolved variable 159 // Remove a unresolved variable. During parsing, an unresolved variable
160 // may have been added optimistically, but then only the variable name 160 // may have been added optimistically, but then only the variable name
161 // was used (typically for labels). If the variable was not declared, the 161 // was used (typically for labels). If the variable was not declared, the
162 // addition introduced a new unresolved variable which may end up being 162 // addition introduced a new unresolved variable which may end up being
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void set_start_position(int statement_pos) { 240 void set_start_position(int statement_pos) {
241 start_position_ = statement_pos; 241 start_position_ = statement_pos;
242 } 242 }
243 int end_position() const { return end_position_; } 243 int end_position() const { return end_position_; }
244 void set_end_position(int statement_pos) { 244 void set_end_position(int statement_pos) {
245 end_position_ = statement_pos; 245 end_position_ = statement_pos;
246 } 246 }
247 247
248 // In some cases we want to force context allocation for a whole scope. 248 // In some cases we want to force context allocation for a whole scope.
249 void ForceContextAllocation() { 249 void ForceContextAllocation() {
250 ASSERT(!already_resolved()); 250 DCHECK(!already_resolved());
251 force_context_allocation_ = true; 251 force_context_allocation_ = true;
252 } 252 }
253 bool has_forced_context_allocation() const { 253 bool has_forced_context_allocation() const {
254 return force_context_allocation_; 254 return force_context_allocation_;
255 } 255 }
256 256
257 // --------------------------------------------------------------------------- 257 // ---------------------------------------------------------------------------
258 // Predicates. 258 // Predicates.
259 259
260 // Specific scope types. 260 // Specific scope types.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 // The language mode of this scope. 296 // The language mode of this scope.
297 StrictMode strict_mode() const { return strict_mode_; } 297 StrictMode strict_mode() const { return strict_mode_; }
298 298
299 // The variable corresponding the 'this' value. 299 // The variable corresponding the 'this' value.
300 Variable* receiver() { return receiver_; } 300 Variable* receiver() { return receiver_; }
301 301
302 // The variable holding the function literal for named function 302 // The variable holding the function literal for named function
303 // literals, or NULL. Only valid for function scopes. 303 // literals, or NULL. Only valid for function scopes.
304 VariableDeclaration* function() const { 304 VariableDeclaration* function() const {
305 ASSERT(is_function_scope()); 305 DCHECK(is_function_scope());
306 return function_; 306 return function_;
307 } 307 }
308 308
309 // Parameters. The left-most parameter has index 0. 309 // Parameters. The left-most parameter has index 0.
310 // Only valid for function scopes. 310 // Only valid for function scopes.
311 Variable* parameter(int index) const { 311 Variable* parameter(int index) const {
312 ASSERT(is_function_scope()); 312 DCHECK(is_function_scope());
313 return params_[index]; 313 return params_[index];
314 } 314 }
315 315
316 int num_parameters() const { return params_.length(); } 316 int num_parameters() const { return params_.length(); }
317 317
318 // The local variable 'arguments' if we need to allocate it; NULL otherwise. 318 // The local variable 'arguments' if we need to allocate it; NULL otherwise.
319 Variable* arguments() const { return arguments_; } 319 Variable* arguments() const { return arguments_; }
320 320
321 // Declarations list. 321 // Declarations list.
322 ZoneList<Declaration*>* declarations() { return &decls_; } 322 ZoneList<Declaration*>* declarations() { return &decls_; }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 Scope* outer_scope, 611 Scope* outer_scope,
612 Handle<ScopeInfo> scope_info); 612 Handle<ScopeInfo> scope_info);
613 613
614 AstValueFactory* ast_value_factory_; 614 AstValueFactory* ast_value_factory_;
615 Zone* zone_; 615 Zone* zone_;
616 }; 616 };
617 617
618 } } // namespace v8::internal 618 } } // namespace v8::internal
619 619
620 #endif // V8_SCOPES_H_ 620 #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