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) { |