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

Unified Diff: src/scopes.h

Issue 1127063003: [es6] implement default parameters via desugaring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add more context-allocation tests 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
« src/parser.cc ('K') | « src/preparser.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index 01df8f9d77e2d355a3ab8b17a8f7b85d5cd31990..5d473a20204ffcdc2133c51e45127b9694e2f5f6 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -126,7 +126,7 @@ class Scope: public ZoneObject {
// 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);
+ bool is_rest, bool* is_duplicate, int pos);
// Declare a local variable in this scope. If the variable has been
// declared before, the previously declared variable is returned.
@@ -182,6 +182,10 @@ class Scope: public ZoneObject {
// the scope; see codegen.cc:ProcessDeclarations.
void AddDeclaration(Declaration* declaration);
+ // Formal parameters may be re-declared as lexical declarations in order to
+ // support TDZ semantics specified in ECMAScript 6.
+ void UndeclareParametersForExpressions();
+
// ---------------------------------------------------------------------------
// Illegal redeclaration support.
@@ -373,6 +377,13 @@ class Scope: public ZoneObject {
return params_[index];
}
+ // TODO(caitp): This probably won't work when BindingPatterns are supported
+ // in function parameters. Need a better way.
+ int parameter_position(int index) const {
+ DCHECK(is_function_scope());
+ return param_positions_[index];
+ }
+
// Returns the default function arity --- does not include rest parameters.
int default_function_length() const {
int count = params_.length();
@@ -553,6 +564,7 @@ class Scope: public ZoneObject {
ZoneList<Variable*> temps_;
// Parameter list in source order.
ZoneList<Variable*> params_;
+ ZoneList<int> param_positions_;
// Variables that must be looked up dynamically.
DynamicScopePart* dynamics_;
// Unresolved variables referred to from this scope.
@@ -625,6 +637,8 @@ class Scope: public ZoneObject {
Variable* rest_parameter_;
int rest_index_;
+ bool has_parameter_expressions_;
+
// Serialized scope info support.
Handle<ScopeInfo> scope_info_;
bool already_resolved() { return already_resolved_; }
« src/parser.cc ('K') | « src/preparser.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698