OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 // via ParseInfo, and also not pass it forward. | 991 // via ParseInfo, and also not pass it forward. |
992 DCHECK_NULL(scope_state_); | 992 DCHECK_NULL(scope_state_); |
993 DCHECK_NULL(target_stack_); | 993 DCHECK_NULL(target_stack_); |
994 | 994 |
995 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; | 995 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; |
996 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; | 996 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; |
997 | 997 |
998 FunctionLiteral* result = NULL; | 998 FunctionLiteral* result = NULL; |
999 { | 999 { |
1000 Scope* outer = original_scope_; | 1000 Scope* outer = original_scope_; |
| 1001 // If there's a chance that there's a reference to global 'this', predeclare |
| 1002 // it as a dynamic global on the script scope. |
| 1003 if (outer->GetDeclarationScope()->is_script_scope()) { |
| 1004 info->script_scope()->DeclareDynamicGlobal( |
| 1005 ast_value_factory()->this_string(), Variable::THIS); |
| 1006 } |
1001 DCHECK(outer); | 1007 DCHECK(outer); |
1002 if (info->is_eval()) { | 1008 if (info->is_eval()) { |
1003 if (!outer->is_script_scope() || is_strict(info->language_mode())) { | 1009 if (!outer->is_script_scope() || is_strict(info->language_mode())) { |
1004 parsing_mode = PARSE_EAGERLY; | 1010 parsing_mode = PARSE_EAGERLY; |
1005 } | 1011 } |
1006 outer = NewEvalScope(outer); | 1012 outer = NewEvalScope(outer); |
1007 } else if (info->is_module()) { | 1013 } else if (info->is_module()) { |
1008 outer = NewModuleScope(outer); | 1014 outer = NewModuleScope(outer); |
1009 } | 1015 } |
1010 | 1016 |
(...skipping 6083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7094 node->Print(Isolate::Current()); | 7100 node->Print(Isolate::Current()); |
7095 } | 7101 } |
7096 #endif // DEBUG | 7102 #endif // DEBUG |
7097 | 7103 |
7098 #undef CHECK_OK | 7104 #undef CHECK_OK |
7099 #undef CHECK_OK_VOID | 7105 #undef CHECK_OK_VOID |
7100 #undef CHECK_FAILED | 7106 #undef CHECK_FAILED |
7101 | 7107 |
7102 } // namespace internal | 7108 } // namespace internal |
7103 } // namespace v8 | 7109 } // namespace v8 |
OLD | NEW |