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

Unified Diff: src/scopes.h

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased against master, plus fixes. Only 4 tests failing (+2 in TurboFan) Created 5 years, 10 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/scopeinfo.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 c58d124939676e876a848d5741c94552bab76fa8..15ee267a8771fd84a471ddecefa42c410177d668 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -22,8 +22,7 @@ class VariableMap: public ZoneHashMap {
virtual ~VariableMap();
Variable* Declare(Scope* scope, const AstRawString* name, VariableMode mode,
- bool is_valid_lhs, Variable::Kind kind,
- InitializationFlag initialization_flag,
+ Variable::Kind kind, InitializationFlag initialization_flag,
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned);
Variable* Lookup(const AstRawString* name);
@@ -142,12 +141,14 @@ class Scope: public ZoneObject {
// Create a new unresolved variable.
VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name,
+ Variable::Kind variable_kind,
int position = RelocInfo::kNoPosition) {
// Note that we must not share the unresolved variables with
// the same name because they may be removed selectively via
// RemoveUnresolved().
DCHECK(!already_resolved());
- VariableProxy* proxy = factory->NewVariableProxy(name, false, position);
+ VariableProxy* proxy =
+ factory->NewVariableProxy(name, variable_kind, position);
unresolved_.Add(proxy, zone_);
return proxy;
}
@@ -327,7 +328,15 @@ class Scope: public ZoneObject {
LanguageMode language_mode() const { return language_mode_; }
// The variable corresponding to the 'this' value.
- Variable* receiver() { return receiver_; }
+ Variable* receiver() {
+ DCHECK(has_this_declaration());
+ DCHECK_NOT_NULL(receiver_);
+ return receiver_;
+ }
+
+ bool has_this_declaration() const {
+ return !is_arrow_scope() && is_declaration_scope();
+ }
// The variable corresponding to the 'new.target' value.
Variable* new_target_var() { return new_target_; }
@@ -662,6 +671,8 @@ class Scope: public ZoneObject {
void AllocateNonParameterLocals(Isolate* isolate);
void AllocateVariablesRecursively(Isolate* isolate);
void AllocateModulesRecursively(Scope* host_scope);
+ void AllocateParameter(Variable* var, int index);
+ void AllocateReceiver();
// Resolve and fill in the allocation information for all variables
// in this scopes. Must be called *after* all scopes have been
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698