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

Unified Diff: src/ast/scopes.cc

Issue 2298673002: Move pre-declaring the this variable to Scope::Analyze (Closed)
Patch Set: updates 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..368d3eff6a2e17570e5ac3727e689609e71560ec 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -411,6 +411,13 @@ 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->GetReceiverScope()->is_script_scope()) {
+ 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