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

Side by Side Diff: src/scopes.cc

Issue 6144005: Early draft of strict mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« src/parser.cc ('K') | « src/scopes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 int Scope::ContextChainLength(Scope* scope) { 406 int Scope::ContextChainLength(Scope* scope) {
407 int n = 0; 407 int n = 0;
408 for (Scope* s = this; s != scope; s = s->outer_scope_) { 408 for (Scope* s = this; s != scope; s = s->outer_scope_) {
409 ASSERT(s != NULL); // scope must be in the scope chain 409 ASSERT(s != NULL); // scope must be in the scope chain
410 if (s->num_heap_slots() > 0) n++; 410 if (s->num_heap_slots() > 0) n++;
411 } 411 }
412 return n; 412 return n;
413 } 413 }
414 414
415 bool Scope::HasDuplicateParameterName() {
416 int length = params_.length();
417 HashMap map(Match, &HashMap::DefaultAllocator, length * 2);
Lasse Reichstein 2011/01/13 07:18:40 If the length is short (e.g., five or less), just
Martin Maly 2011/01/14 00:06:28 Done.
Lasse Reichstein 2011/01/14 11:42:05 And thinking more about it, just do the simple thi
Martin Maly 2011/01/14 16:30:43 Done.
418 for (int i = 0; i < length; i ++) {
419 Handle<String> name = params_[i]->name();
420 HashMap::Entry* p = map.Lookup(name.location(), name->Hash(), true);
421 if (p->value == NULL) {
422 p->value = name.location();
423 } else {
424 // Duplicate found!
425 return true;
426 }
427 }
428 return false;
429 }
430
431 bool Scope::HasEvalOrArgumentsParameter() {
432 for (int i = 0, length = params_.length(); i < length; i++) {
433 Handle<String> name = params_[i]->name();
434 if (name.is_identical_to(Factory::arguments_symbol()) ||
435 name.is_identical_to(Factory::eval_symbol()))
436 return true;
437 }
438 return false;
439 }
415 440
416 #ifdef DEBUG 441 #ifdef DEBUG
417 static const char* Header(Scope::Type type) { 442 static const char* Header(Scope::Type type) {
418 switch (type) { 443 switch (type) {
419 case Scope::EVAL_SCOPE: return "eval"; 444 case Scope::EVAL_SCOPE: return "eval";
420 case Scope::FUNCTION_SCOPE: return "function"; 445 case Scope::FUNCTION_SCOPE: return "function";
421 case Scope::GLOBAL_SCOPE: return "global"; 446 case Scope::GLOBAL_SCOPE: return "global";
422 } 447 }
423 UNREACHABLE(); 448 UNREACHABLE();
424 return NULL; 449 return NULL;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS && 998 if (num_heap_slots_ == Context::MIN_CONTEXT_SLOTS &&
974 !must_have_local_context) { 999 !must_have_local_context) {
975 num_heap_slots_ = 0; 1000 num_heap_slots_ = 0;
976 } 1001 }
977 1002
978 // Allocation done. 1003 // Allocation done.
979 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS); 1004 ASSERT(num_heap_slots_ == 0 || num_heap_slots_ >= Context::MIN_CONTEXT_SLOTS);
980 } 1005 }
981 1006
982 } } // namespace v8::internal 1007 } } // namespace v8::internal
OLDNEW
« src/parser.cc ('K') | « src/scopes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698