| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } | 776 } |
| 777 | 777 |
| 778 | 778 |
| 779 FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { | 779 FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { |
| 780 // Note that this function can be called from the main thread or from a | 780 // Note that this function can be called from the main thread or from a |
| 781 // background thread. We should not access anything Isolate / heap dependent | 781 // background thread. We should not access anything Isolate / heap dependent |
| 782 // via ParseInfo, and also not pass it forward. | 782 // via ParseInfo, and also not pass it forward. |
| 783 DCHECK_NULL(scope_state_); | 783 DCHECK_NULL(scope_state_); |
| 784 DCHECK_NULL(target_stack_); | 784 DCHECK_NULL(target_stack_); |
| 785 | 785 |
| 786 Mode parsing_mode = allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY; | 786 ParsingModeScope mode(this, allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY); |
| 787 | 787 |
| 788 FunctionLiteral* result = NULL; | 788 FunctionLiteral* result = NULL; |
| 789 { | 789 { |
| 790 Scope* outer = original_scope_; | 790 Scope* outer = original_scope_; |
| 791 DCHECK_NOT_NULL(outer); | 791 DCHECK_NOT_NULL(outer); |
| 792 parsing_module_ = info->is_module(); | 792 parsing_module_ = info->is_module(); |
| 793 if (info->is_eval()) { | 793 if (info->is_eval()) { |
| 794 outer = NewEvalScope(outer); | 794 outer = NewEvalScope(outer); |
| 795 } else if (parsing_module_) { | 795 } else if (parsing_module_) { |
| 796 DCHECK_EQ(outer, info->script_scope()); | 796 DCHECK_EQ(outer, info->script_scope()); |
| 797 outer = NewModuleScope(info->script_scope()); | 797 outer = NewModuleScope(info->script_scope()); |
| 798 } | 798 } |
| 799 | 799 |
| 800 DeclarationScope* scope = outer->AsDeclarationScope(); | 800 DeclarationScope* scope = outer->AsDeclarationScope(); |
| 801 | 801 |
| 802 scope->set_start_position(0); | 802 scope->set_start_position(0); |
| 803 | 803 |
| 804 // Enter 'scope' with the given parsing mode. | |
| 805 ParsingModeScope parsing_mode_scope(this, parsing_mode); | |
| 806 FunctionState function_state(&function_state_, &scope_state_, scope); | 804 FunctionState function_state(&function_state_, &scope_state_, scope); |
| 807 | 805 |
| 808 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 806 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 809 bool ok = true; | 807 bool ok = true; |
| 810 int beg_pos = scanner()->location().beg_pos; | 808 int beg_pos = scanner()->location().beg_pos; |
| 811 if (parsing_module_) { | 809 if (parsing_module_) { |
| 812 // Declare the special module parameter. | 810 // Declare the special module parameter. |
| 813 auto name = ast_value_factory()->empty_string(); | 811 auto name = ast_value_factory()->empty_string(); |
| 814 bool is_duplicate; | 812 bool is_duplicate; |
| 815 bool is_rest = false; | 813 bool is_rest = false; |
| (...skipping 4632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5448 | 5446 |
| 5449 return final_loop; | 5447 return final_loop; |
| 5450 } | 5448 } |
| 5451 | 5449 |
| 5452 #undef CHECK_OK | 5450 #undef CHECK_OK |
| 5453 #undef CHECK_OK_VOID | 5451 #undef CHECK_OK_VOID |
| 5454 #undef CHECK_FAILED | 5452 #undef CHECK_FAILED |
| 5455 | 5453 |
| 5456 } // namespace internal | 5454 } // namespace internal |
| 5457 } // namespace v8 | 5455 } // namespace v8 |
| OLD | NEW |