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

Unified Diff: src/ast/scopes.cc

Issue 2298673002: Move pre-declaring the this variable to Scope::Analyze (Closed)
Patch Set: Created 4 years, 4 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 | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index bbc8155e9bd3f5f54070d480170f6ed4faef91cc..a981a5dc9a4280fe1f7f7ed7243ea88b0d9d17fa 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -411,6 +411,14 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) {
scope->outer_scope()->scope_type() == SCRIPT_SCOPE ||
scope->outer_scope()->already_resolved_);
+ // If there's a chance that there's a reference to global 'this', predeclare
+ // it as a dynamic global on the script scope.
+ if (scope->scope_type() != SCRIPT_SCOPE &&
+ scope->outer_scope()->GetReceiverScope()->is_script_scope()) {
Toon Verwaest 2016/08/31 08:56:55 Shouldn't this just be scope->GetReceiverScope()?
+ info->script_scope()->DeclareDynamicGlobal(
+ info->ast_value_factory()->this_string(), Variable::THIS);
+ }
+
scope->AllocateVariables(info, mode);
#ifdef DEBUG
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698