Index: src/scopes.h |
diff --git a/src/scopes.h b/src/scopes.h |
index 83703716d24e927dfe53a4527b39dde897d3e912..fe4aa6c06c66ad9d7808b347079a7559bbb608b7 100644 |
--- a/src/scopes.h |
+++ b/src/scopes.h |
@@ -125,8 +125,9 @@ class Scope: public ZoneObject { |
// Declare a parameter in this scope. When there are duplicated |
// parameters the rightmost one 'wins'. However, the implementation |
// expects all parameters to be declared and from left to right. |
- Variable* DeclareParameter(const AstRawString* name, VariableMode mode, |
- bool is_rest, bool* is_duplicate); |
+ Variable* DeclareParameter(const AstRawString* name, Expression* pattern, |
+ VariableMode mode, bool is_rest, |
+ bool* is_duplicate); |
// Declare a local variable in this scope. If the variable has been |
// declared before, the previously declared variable is returned. |
@@ -368,9 +369,21 @@ class Scope: public ZoneObject { |
return function_; |
} |
+ struct Parameter { |
+ Parameter(Variable* var, Expression* pattern) |
+ : var(var), pattern(pattern) {} |
+ |
+ Variable* var; |
+ Expression* pattern; |
rossberg
2015/06/16 17:02:13
Can we not abuse the scope abstraction to pass aro
Dmitry Lomov (no reviews)
2015/06/17 12:28:48
Good point. Addressed.
|
+ }; |
+ |
// Parameters. The left-most parameter has index 0. |
// Only valid for function scopes. |
- Variable* parameter(int index) const { |
+ Variable* parameter_var(int index) const { return parameter(index).var; } |
+ |
+ // Parameters. The left-most parameter has index 0. |
+ // Only valid for function scopes. |
+ const Parameter& parameter(int index) const { |
DCHECK(is_function_scope()); |
return params_[index]; |
} |
@@ -518,7 +531,11 @@ class Scope: public ZoneObject { |
// If IsSimpleParameterList is false, duplicate parameters are not allowed, |
// however `arguments` may be allowed if function is not strict code. Thus, |
// the assumptions explained above do not hold. |
- return params_.Contains(variables_.Lookup(name)); |
+ auto var = variables_.Lookup(name); |
+ for (auto p : params_) { |
+ if (p.var == var) return true; |
+ } |
+ return false; |
} |
// Error handling. |
@@ -562,8 +579,10 @@ class Scope: public ZoneObject { |
ZoneList<Variable*> internals_; |
// Compiler-allocated (user-invisible) temporaries. |
ZoneList<Variable*> temps_; |
+ |
// Parameter list in source order. |
- ZoneList<Variable*> params_; |
+ ZoneList<Parameter> params_; |
+ |
// Variables that must be looked up dynamically. |
DynamicScopePart* dynamics_; |
// Unresolved variables referred to from this scope. |