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

Unified Diff: src/scopes.cc

Issue 1127063003: [es6] implement default parameters via desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index 8b623f90ce908ac548bfd8ea46bdcf088121bbcf..94d4df66926b47dd1fca117c3220d3e11e6f5aca 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -77,6 +77,7 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type,
internals_(4, zone),
temps_(4, zone),
params_(4, zone),
+ param_positions_(4, zone),
unresolved_(16, zone),
decls_(4, zone),
module_descriptor_(
@@ -100,6 +101,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
internals_(4, zone),
temps_(4, zone),
params_(4, zone),
+ param_positions_(4, zone),
unresolved_(16, zone),
decls_(4, zone),
module_descriptor_(NULL),
@@ -126,6 +128,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope,
internals_(0, zone),
temps_(0, zone),
params_(0, zone),
+ param_positions_(0, zone),
unresolved_(0, zone),
decls_(0, zone),
module_descriptor_(NULL),
@@ -464,7 +467,7 @@ Variable* Scope::Lookup(const AstRawString* name) {
Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
- bool is_rest, bool* is_duplicate) {
+ int pos, bool is_rest, bool* is_duplicate) {
DCHECK(!already_resolved());
DCHECK(is_function_scope());
Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL,
@@ -477,6 +480,7 @@ Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
// TODO(wingo): Avoid O(n^2) check.
*is_duplicate = IsDeclaredParameter(name);
params_.Add(var, zone());
+ param_positions_.Add(pos, zone());
return var;
}
@@ -506,6 +510,16 @@ Variable* Scope::DeclareDynamicGlobal(const AstRawString* name) {
}
+void Scope::ShadowParametersForExpressions() {
arv (Not doing code reviews) 2015/05/06 20:32:38 This could use a comment
caitp (gmail) 2015/05/06 20:42:55 I believe there's a comment in parser.h for the fu
+ DCHECK(is_function_scope());
+ for (int i = 0; i < num_parameters(); ++i) {
+ Variable* p = parameter(i);
+ const AstRawString* name = p->raw_name();
+ variables_.Remove(const_cast<AstRawString*>(name), name->hash());
+ }
+}
+
+
void Scope::RemoveUnresolved(VariableProxy* var) {
// Most likely (always?) any variable we want to remove
// was just added before, so we search backwards.

Powered by Google App Engine
This is Rietveld 408576698