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

Unified Diff: src/variables.h

Issue 1178903003: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Add test Created 5 years, 6 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/snapshot/snapshot-common.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/variables.h
diff --git a/src/variables.h b/src/variables.h
index 0cb50c87e985580c1fd1c7fc5ea9b3fde63f4206..218eefae08e08a0cd937a14e1d158c5b878d1a0c 100644
--- a/src/variables.h
+++ b/src/variables.h
@@ -105,6 +105,16 @@ class Variable: public ZoneObject {
bool is_this() const { return kind_ == THIS; }
bool is_arguments() const { return kind_ == ARGUMENTS; }
+ // For script scopes, the "this" binding is provided by a ScriptContext added
+ // to the global's ScriptContextTable. This binding might not statically
+ // resolve to a Variable::THIS binding, instead being DYNAMIC_LOCAL. However
+ // any variable named "this" does indeed refer to a Variable::THIS binding;
+ // the grammar ensures this to be the case. So wherever a "this" binding
+ // might be provided by the global, use HasThisName instead of is_this().
+ bool HasThisName(Isolate* isolate) const {
+ return is_this() || *name() == *isolate->factory()->this_string();
+ }
+
ClassVariable* AsClassVariable() {
DCHECK(is_class());
return reinterpret_cast<ClassVariable*>(this);
« no previous file with comments | « src/snapshot/snapshot-common.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698