| 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-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 DCHECK_NULL(scope_state_); | 664 DCHECK_NULL(scope_state_); |
| 665 DCHECK_NULL(target_stack_); | 665 DCHECK_NULL(target_stack_); |
| 666 | 666 |
| 667 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; | 667 Mode parsing_mode = FLAG_lazy && allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; |
| 668 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; | 668 if (allow_natives() || extension_ != NULL) parsing_mode = PARSE_EAGERLY; |
| 669 | 669 |
| 670 FunctionLiteral* result = NULL; | 670 FunctionLiteral* result = NULL; |
| 671 { | 671 { |
| 672 Scope* outer = original_scope_; | 672 Scope* outer = original_scope_; |
| 673 DCHECK_NOT_NULL(outer); | 673 DCHECK_NOT_NULL(outer); |
| 674 // If there's a chance that there's a reference to global 'this', predeclare | |
| 675 // it as a dynamic global on the script scope. | |
| 676 if (outer->GetReceiverScope()->is_script_scope()) { | |
| 677 info->script_scope()->DeclareDynamicGlobal( | |
| 678 ast_value_factory()->this_string(), Variable::THIS); | |
| 679 } | |
| 680 if (info->is_eval()) { | 674 if (info->is_eval()) { |
| 681 if (!outer->is_script_scope() || is_strict(info->language_mode())) { | 675 if (!outer->is_script_scope() || is_strict(info->language_mode())) { |
| 682 parsing_mode = PARSE_EAGERLY; | 676 parsing_mode = PARSE_EAGERLY; |
| 683 } | 677 } |
| 684 outer = NewEvalScope(outer); | 678 outer = NewEvalScope(outer); |
| 685 } else if (info->is_module()) { | 679 } else if (info->is_module()) { |
| 686 DCHECK_EQ(outer, info->script_scope()); | 680 DCHECK_EQ(outer, info->script_scope()); |
| 687 outer = NewModuleScope(info->script_scope()); | 681 outer = NewModuleScope(info->script_scope()); |
| 688 } | 682 } |
| 689 | 683 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 828 |
| 835 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 829 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| 836 | 830 |
| 837 // Place holder for the result. | 831 // Place holder for the result. |
| 838 FunctionLiteral* result = nullptr; | 832 FunctionLiteral* result = nullptr; |
| 839 | 833 |
| 840 { | 834 { |
| 841 // Parse the function literal. | 835 // Parse the function literal. |
| 842 Scope* outer = original_scope_; | 836 Scope* outer = original_scope_; |
| 843 DCHECK(outer); | 837 DCHECK(outer); |
| 844 // If there's a chance that there's a reference to global 'this', predeclare | |
| 845 // it as a dynamic global on the script scope. | |
| 846 if (info->is_arrow() && outer->GetReceiverScope()->is_script_scope()) { | |
| 847 info->script_scope()->DeclareDynamicGlobal( | |
| 848 ast_value_factory()->this_string(), Variable::THIS); | |
| 849 } | |
| 850 FunctionState function_state(&function_state_, &scope_state_, outer, | 838 FunctionState function_state(&function_state_, &scope_state_, outer, |
| 851 info->function_kind()); | 839 info->function_kind()); |
| 852 DCHECK(is_sloppy(outer->language_mode()) || | 840 DCHECK(is_sloppy(outer->language_mode()) || |
| 853 is_strict(info->language_mode())); | 841 is_strict(info->language_mode())); |
| 854 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); | 842 FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); |
| 855 bool ok = true; | 843 bool ok = true; |
| 856 | 844 |
| 857 if (info->is_arrow()) { | 845 if (info->is_arrow()) { |
| 858 bool is_async = allow_harmony_async_await() && info->is_async(); | 846 bool is_async = allow_harmony_async_await() && info->is_async(); |
| 859 if (is_async) { | 847 if (is_async) { |
| (...skipping 5798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6658 node->Print(Isolate::Current()); | 6646 node->Print(Isolate::Current()); |
| 6659 } | 6647 } |
| 6660 #endif // DEBUG | 6648 #endif // DEBUG |
| 6661 | 6649 |
| 6662 #undef CHECK_OK | 6650 #undef CHECK_OK |
| 6663 #undef CHECK_OK_VOID | 6651 #undef CHECK_OK_VOID |
| 6664 #undef CHECK_FAILED | 6652 #undef CHECK_FAILED |
| 6665 | 6653 |
| 6666 } // namespace internal | 6654 } // namespace internal |
| 6667 } // namespace v8 | 6655 } // namespace v8 |
| OLD | NEW |