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

Unified Diff: src/scopes.h

Issue 1097283003: Resolve references to "this" the same way as normal variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Add tests for "this" scoping in arrow functions Created 5 years, 8 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') | src/x64/full-codegen-x64.cc » ('J')
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 7b372d9643fe4c1c07892139c6ecf1937ed1257e..c869e8010148298dfe3b83f5325fb49d8e209321 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -143,13 +143,14 @@ class Scope: public ZoneObject {
VariableProxy* NewUnresolved(AstNodeFactory* factory,
const AstRawString* name,
int start_position = RelocInfo::kNoPosition,
- int end_position = RelocInfo::kNoPosition) {
+ int end_position = RelocInfo::kNoPosition,
+ Variable::Kind kind = Variable::NORMAL) {
// 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, Variable::NORMAL, start_position, end_position);
+ VariableProxy* proxy =
+ factory->NewVariableProxy(name, kind, start_position, end_position);
unresolved_.Add(proxy, zone_);
return proxy;
}
@@ -344,7 +345,18 @@ class Scope: public ZoneObject {
LanguageMode language_mode() const { return language_mode_; }
// The variable corresponding to the 'this' value.
- Variable* receiver() { return receiver_; }
+ Variable* receiver() {
+ CHECK(has_this_declaration());
+ CHECK_NOT_NULL(receiver_);
adamk 2015/04/22 15:50:54 These should probably be DCHECKs.
wingo 2015/04/23 14:16:02 Done.
+ return receiver_;
+ }
+
+ Variable* LookupThis() { return Lookup(ast_value_factory_->this_string()); }
+
+ bool has_this_declaration() const {
+ return (is_function_scope() && !is_arrow_scope()) || is_module_scope() ||
+ is_script_scope();
+ }
// The variable corresponding to the 'new.target' value.
Variable* new_target_var() { return new_target_; }
@@ -695,6 +707,8 @@ class Scope: public ZoneObject {
void AllocateNonParameterLocal(Isolate* isolate, Variable* var);
void AllocateNonParameterLocals(Isolate* isolate);
void AllocateVariablesRecursively(Isolate* isolate);
+ void AllocateParameter(Variable* var, int index);
+ void AllocateReceiver();
void AllocateModules();
// Resolve and fill in the allocation information for all variables
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | src/x64/full-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698