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

Unified Diff: src/scopes.cc

Issue 1189743003: [destructuring] Implement parameter pattern matching. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix magic number issue Created 5 years, 6 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
« no previous file with comments | « src/preparser.cc ('k') | src/snapshot/serialize.cc » ('j') | 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 039bea0987a4261432cab324cdd464e0e87939a6..61a75ab16fcf408a0ba79355f4e43d59979564c8 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -466,15 +466,22 @@ Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
bool is_rest, bool* is_duplicate) {
DCHECK(!already_resolved());
DCHECK(is_function_scope());
- Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL,
- kCreatedInitialized);
+
+ Variable* var;
+ if (!name->IsEmpty()) {
+ var = variables_.Declare(this, name, mode, Variable::NORMAL,
+ kCreatedInitialized);
+ // TODO(wingo): Avoid O(n^2) check.
+ *is_duplicate = IsDeclaredParameter(name);
+ } else {
+ var = new (zone())
+ Variable(this, name, TEMPORARY, Variable::NORMAL, kCreatedInitialized);
+ }
if (is_rest) {
DCHECK_NULL(rest_parameter_);
rest_parameter_ = var;
rest_index_ = num_parameters();
}
- // TODO(wingo): Avoid O(n^2) check.
- *is_duplicate = IsDeclaredParameter(name);
params_.Add(var, zone());
return var;
}
« no previous file with comments | « src/preparser.cc ('k') | src/snapshot/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698