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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/parser.cc ('K') | « src/scopes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 3565e11b58f710e280f1080c0fb479e5e01376f9..d359ccd27cbdc055d329e622e5fa8c865c61e4a5 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -412,6 +412,31 @@ int Scope::ContextChainLength(Scope* scope) {
return n;
}
+bool Scope::HasDuplicateParameterName() {
+ int length = params_.length();
+ 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.
+ for (int i = 0; i < length; i ++) {
+ Handle<String> name = params_[i]->name();
+ HashMap::Entry* p = map.Lookup(name.location(), name->Hash(), true);
+ if (p->value == NULL) {
+ p->value = name.location();
+ } else {
+ // Duplicate found!
+ return true;
+ }
+ }
+ return false;
+}
+
+bool Scope::HasEvalOrArgumentsParameter() {
+ for (int i = 0, length = params_.length(); i < length; i++) {
+ Handle<String> name = params_[i]->name();
+ if (name.is_identical_to(Factory::arguments_symbol()) ||
+ name.is_identical_to(Factory::eval_symbol()))
+ return true;
+ }
+ return false;
+}
#ifdef DEBUG
static const char* Header(Scope::Type type) {
« 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