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

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: mjsunit/debug-scopes: Skip "this" the same as "arguments" 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
« src/parser.cc ('K') | « src/preparser.h ('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 2e418be219b08844bd94f3f7cc9643aea23ec606..66dfeb46a4d7af23f5289842a95f7bca83557bd9 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -22,7 +22,7 @@ class VariableMap: public ZoneHashMap {
virtual ~VariableMap();
Variable* Declare(Scope* scope, const AstRawString* name, VariableMode mode,
- bool is_valid_lhs, Variable::Kind kind,
+ Variable::Kind kind,
InitializationFlag initialization_flag,
MaybeAssignedFlag maybe_assigned_flag = kNotAssigned,
Interface* interface = Interface::NewValue());
@@ -152,7 +152,7 @@ class Scope: public ZoneObject {
// RemoveUnresolved().
DCHECK(!already_resolved());
VariableProxy* proxy =
- factory->NewVariableProxy(name, false, interface, position);
+ factory->NewVariableProxy(name, interface, position);
wingo 2015/02/06 17:31:19 Please make this function take an additional Varia
unresolved_.Add(proxy, zone_);
return proxy;
}
@@ -223,9 +223,6 @@ class Scope: public ZoneObject {
scope_uses_super_constructor_call_ = true;
}
- // Inform the scope that the corresponding code uses "this".
- void RecordThisUsage() { scope_uses_this_ = true; }
-
// Set the strict mode flag (unless disabled by a global flag).
void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
@@ -328,10 +325,6 @@ class Scope: public ZoneObject {
bool inner_uses_super_constructor_call() const {
return inner_scope_uses_super_constructor_call_;
}
- // Does this scope access "this".
- bool uses_this() const { return scope_uses_this_; }
- // Does any inner scope access "this".
- bool inner_uses_this() const { return inner_scope_uses_this_; }
// ---------------------------------------------------------------------------
// Accessors.
@@ -343,7 +336,15 @@ class Scope: public ZoneObject {
StrictMode strict_mode() const { return strict_mode_; }
// The variable corresponding 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 holding the function literal for named function
// literals, or NULL. Only valid for function scopes.
@@ -541,8 +542,6 @@ class Scope: public ZoneObject {
bool scope_uses_super_property_;
// This scope uses "super" constructor ('super(..)').
bool scope_uses_super_constructor_call_;
- // This scope uses "this".
- bool scope_uses_this_;
// This scope contains an "use asm" annotation.
bool asm_module_;
// This scope's outer context is an asm module.
@@ -559,7 +558,6 @@ class Scope: public ZoneObject {
bool inner_scope_uses_arguments_;
bool inner_scope_uses_super_property_;
bool inner_scope_uses_super_constructor_call_;
- bool inner_scope_uses_this_;
bool force_eager_compilation_;
bool force_context_allocation_;
@@ -663,6 +661,8 @@ class Scope: public ZoneObject {
void AllocateStackSlot(Variable* var);
void AllocateHeapSlot(Variable* var);
void AllocateParameterLocals();
+ void AllocateParameter(Variable* var, int index);
+ void AllocateReceiver();
void AllocateNonParameterLocal(Variable* var);
void AllocateNonParameterLocals();
void AllocateVariablesRecursively();
« src/parser.cc ('K') | « src/preparser.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698