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

Side by Side Diff: src/scopes.cc

Issue 291153005: Consistently say 'own' property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add new files Created 6 years, 7 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.h ('k') | src/stub-cache.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 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "scopes.h" 7 #include "scopes.h"
8 8
9 #include "accessors.h" 9 #include "accessors.h"
10 #include "bootstrapper.h" 10 #include "bootstrapper.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 // Move unresolved variables 360 // Move unresolved variables
361 for (int i = 0; i < unresolved_.length(); i++) { 361 for (int i = 0; i < unresolved_.length(); i++) {
362 outer_scope()->unresolved_.Add(unresolved_[i], zone()); 362 outer_scope()->unresolved_.Add(unresolved_[i], zone());
363 } 363 }
364 364
365 return NULL; 365 return NULL;
366 } 366 }
367 367
368 368
369 Variable* Scope::LocalLookup(Handle<String> name) { 369 Variable* Scope::LookupLocal(Handle<String> name) {
370 Variable* result = variables_.Lookup(name); 370 Variable* result = variables_.Lookup(name);
371 if (result != NULL || scope_info_.is_null()) { 371 if (result != NULL || scope_info_.is_null()) {
372 return result; 372 return result;
373 } 373 }
374 // If we have a serialized scope info, we might find the variable there. 374 // If we have a serialized scope info, we might find the variable there.
375 // There should be no local slot with the given name. 375 // There should be no local slot with the given name.
376 ASSERT(scope_info_->StackSlotIndex(*name) < 0); 376 ASSERT(scope_info_->StackSlotIndex(*name) < 0);
377 377
378 // Check context slot lookup. 378 // Check context slot lookup.
379 VariableMode mode; 379 VariableMode mode;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } else { 418 } else {
419 return NULL; 419 return NULL;
420 } 420 }
421 } 421 }
422 422
423 423
424 Variable* Scope::Lookup(Handle<String> name) { 424 Variable* Scope::Lookup(Handle<String> name) {
425 for (Scope* scope = this; 425 for (Scope* scope = this;
426 scope != NULL; 426 scope != NULL;
427 scope = scope->outer_scope()) { 427 scope = scope->outer_scope()) {
428 Variable* var = scope->LocalLookup(name); 428 Variable* var = scope->LookupLocal(name);
429 if (var != NULL) return var; 429 if (var != NULL) return var;
430 } 430 }
431 return NULL; 431 return NULL;
432 } 432 }
433 433
434 434
435 void Scope::DeclareParameter(Handle<String> name, VariableMode mode) { 435 void Scope::DeclareParameter(Handle<String> name, VariableMode mode) {
436 ASSERT(!already_resolved()); 436 ASSERT(!already_resolved());
437 ASSERT(is_function_scope()); 437 ASSERT(is_function_scope());
438 Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL, 438 Variable* var = variables_.Declare(this, name, mode, true, Variable::NORMAL,
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 AstNodeFactory<AstNullVisitor>* factory) { 943 AstNodeFactory<AstNullVisitor>* factory) {
944 ASSERT(binding_kind != NULL); 944 ASSERT(binding_kind != NULL);
945 if (already_resolved() && is_with_scope()) { 945 if (already_resolved() && is_with_scope()) {
946 // Short-cut: if the scope is deserialized from a scope info, variable 946 // Short-cut: if the scope is deserialized from a scope info, variable
947 // allocation is already fixed. We can simply return with dynamic lookup. 947 // allocation is already fixed. We can simply return with dynamic lookup.
948 *binding_kind = DYNAMIC_LOOKUP; 948 *binding_kind = DYNAMIC_LOOKUP;
949 return NULL; 949 return NULL;
950 } 950 }
951 951
952 // Try to find the variable in this scope. 952 // Try to find the variable in this scope.
953 Variable* var = LocalLookup(name); 953 Variable* var = LookupLocal(name);
954 954
955 // We found a variable and we are done. (Even if there is an 'eval' in 955 // We found a variable and we are done. (Even if there is an 'eval' in
956 // this scope which introduces the same variable again, the resulting 956 // this scope which introduces the same variable again, the resulting
957 // variable remains the same.) 957 // variable remains the same.)
958 if (var != NULL) { 958 if (var != NULL) {
959 *binding_kind = BOUND; 959 *binding_kind = BOUND;
960 return var; 960 return var;
961 } 961 }
962 962
963 // We did not find a variable locally. Check against the function variable, 963 // We did not find a variable locally. Check against the function variable,
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 } 1204 }
1205 1205
1206 1206
1207 void Scope::AllocateHeapSlot(Variable* var) { 1207 void Scope::AllocateHeapSlot(Variable* var) {
1208 var->AllocateTo(Variable::CONTEXT, num_heap_slots_++); 1208 var->AllocateTo(Variable::CONTEXT, num_heap_slots_++);
1209 } 1209 }
1210 1210
1211 1211
1212 void Scope::AllocateParameterLocals() { 1212 void Scope::AllocateParameterLocals() {
1213 ASSERT(is_function_scope()); 1213 ASSERT(is_function_scope());
1214 Variable* arguments = LocalLookup(isolate_->factory()->arguments_string()); 1214 Variable* arguments = LookupLocal(isolate_->factory()->arguments_string());
1215 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly 1215 ASSERT(arguments != NULL); // functions have 'arguments' declared implicitly
1216 1216
1217 bool uses_sloppy_arguments = false; 1217 bool uses_sloppy_arguments = false;
1218 1218
1219 if (MustAllocate(arguments) && !HasArgumentsParameter()) { 1219 if (MustAllocate(arguments) && !HasArgumentsParameter()) {
1220 // 'arguments' is used. Unless there is also a parameter called 1220 // 'arguments' is used. Unless there is also a parameter called
1221 // 'arguments', we must be conservative and allocate all parameters to 1221 // 'arguments', we must be conservative and allocate all parameters to
1222 // the context assuming they will be captured by the arguments object. 1222 // the context assuming they will be captured by the arguments object.
1223 // If we have a parameter named 'arguments', a (new) value is always 1223 // If we have a parameter named 'arguments', a (new) value is always
1224 // assigned to it via the function invocation. Then 'arguments' denotes 1224 // assigned to it via the function invocation. Then 'arguments' denotes
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 } 1372 }
1373 1373
1374 1374
1375 int Scope::ContextLocalCount() const { 1375 int Scope::ContextLocalCount() const {
1376 if (num_heap_slots() == 0) return 0; 1376 if (num_heap_slots() == 0) return 0;
1377 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1377 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1378 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1378 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1379 } 1379 }
1380 1380
1381 } } // namespace v8::internal 1381 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698