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

Unified Diff: src/parser.cc

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 TODO to fix fat-fingered "this" scoping in script context 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
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 87d347d4c56491499b05c55bdf05fac38c3b8435..a63ad15ff77d69ebe7235d38005804074565682b 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -740,7 +740,9 @@ const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
int pos) {
- return factory->NewVariableProxy(scope->receiver(), pos);
+ return scope->NewUnresolved(factory,
+ parser_->ast_value_factory()->this_string(), pos,
+ pos + 4, Variable::THIS);
arv (Not doing code reviews) 2015/05/05 14:59:10 I still want you to change the order of these para
wingo 2015/05/05 15:49:29 Sorry I forgot about this! Done. Had to add Vari
}
Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory,
@@ -966,6 +968,8 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
FunctionLiteral* result = NULL;
{
+ // TODO(wingo): Add an outer GLOBAL_SCOPE corresponding to the native
+ // context, which will have the "this" binding for script scopes.
arv (Not doing code reviews) 2015/05/05 14:59:10 Might make sense. Also for module scopes there is
Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
info->set_script_scope(scope);
if (!info->context().is_null() && !info->context()->IsNativeContext()) {

Powered by Google App Engine
This is Rietveld 408576698