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

Unified Diff: src/parsing/parser.cc

Issue 2237873002: Declare 'this' as DYNAMIC_GLOBAL on the script_scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: typo 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
« src/ast/scopes.cc ('K') | « src/ast/scopes.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 59d31f5a73514fd5c8a7f98d8e4be9146f8f433f..b294e98a4799e70c3c6220a89f87bc90e53e9600 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -998,6 +998,12 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
FunctionLiteral* result = NULL;
{
Scope* outer = original_scope_;
+ // If there's a chance that there's a reference to global 'this', predeclare
+ // it as a dynamic global on the script scope.
+ if (outer->GetDeclarationScope()->is_script_scope()) {
+ info->script_scope()->DeclareDynamicGlobal(
+ ast_value_factory()->this_string(), Variable::THIS);
+ }
DCHECK(outer);
if (info->is_eval()) {
if (!outer->is_script_scope() || is_strict(info->language_mode())) {
« src/ast/scopes.cc ('K') | « src/ast/scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698