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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { | 740 FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { |
741 // Note that this function can be called from the main thread or from a | 741 // Note that this function can be called from the main thread or from a |
742 // background thread. We should not access anything Isolate / heap dependent | 742 // background thread. We should not access anything Isolate / heap dependent |
743 // via ParseInfo, and also not pass it forward. | 743 // via ParseInfo, and also not pass it forward. |
744 DCHECK_NULL(scope_state_); | 744 DCHECK_NULL(scope_state_); |
745 DCHECK_NULL(target_stack_); | 745 DCHECK_NULL(target_stack_); |
746 | 746 |
747 ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY); | 747 ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY); |
748 ResetFunctionLiteralId(); | 748 ResetFunctionLiteralId(); |
749 DCHECK(info->function_literal_id() == FunctionLiteral::kIdTypeTopLevel || | 749 DCHECK(info->function_literal_id() == FunctionLiteral::kIdTypeTopLevel || |
750 info->function_literal_id() == FunctionLiteral::kIdTypeEval || | |
751 info->function_literal_id() == FunctionLiteral::kIdTypeInvalid); | 750 info->function_literal_id() == FunctionLiteral::kIdTypeInvalid); |
752 | 751 |
753 FunctionLiteral* result = NULL; | 752 FunctionLiteral* result = NULL; |
754 { | 753 { |
755 Scope* outer = original_scope_; | 754 Scope* outer = original_scope_; |
756 DCHECK_NOT_NULL(outer); | 755 DCHECK_NOT_NULL(outer); |
757 parsing_module_ = info->is_module(); | 756 parsing_module_ = info->is_module(); |
758 if (info->is_eval()) { | 757 if (info->is_eval()) { |
759 outer = NewEvalScope(outer); | 758 outer = NewEvalScope(outer); |
760 } else if (parsing_module_) { | 759 } else if (parsing_module_) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 ReportMessage(MessageTemplate::kSingleFunctionLiteral); | 827 ReportMessage(MessageTemplate::kSingleFunctionLiteral); |
829 ok = false; | 828 ok = false; |
830 } | 829 } |
831 } | 830 } |
832 | 831 |
833 if (ok) { | 832 if (ok) { |
834 RewriteDestructuringAssignments(); | 833 RewriteDestructuringAssignments(); |
835 int parameter_count = parsing_module_ ? 1 : 0; | 834 int parameter_count = parsing_module_ ? 1 : 0; |
836 result = factory()->NewScriptOrEvalFunctionLiteral( | 835 result = factory()->NewScriptOrEvalFunctionLiteral( |
837 scope, body, function_state.materialized_literal_count(), | 836 scope, body, function_state.materialized_literal_count(), |
838 function_state.expected_property_count(), parameter_count, | 837 function_state.expected_property_count(), parameter_count); |
839 info->is_eval() ? FunctionLiteral::kIdTypeEval | |
840 : FunctionLiteral::kIdTypeTopLevel); | |
841 } | 838 } |
842 } | 839 } |
843 | 840 |
844 // Make sure the target stack is empty. | 841 // Make sure the target stack is empty. |
845 DCHECK(target_stack_ == NULL); | 842 DCHECK(target_stack_ == NULL); |
846 | 843 |
847 return result; | 844 return result; |
848 } | 845 } |
849 | 846 |
850 FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info) { | 847 FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info) { |
(...skipping 4617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5468 | 5465 |
5469 return final_loop; | 5466 return final_loop; |
5470 } | 5467 } |
5471 | 5468 |
5472 #undef CHECK_OK | 5469 #undef CHECK_OK |
5473 #undef CHECK_OK_VOID | 5470 #undef CHECK_OK_VOID |
5474 #undef CHECK_FAILED | 5471 #undef CHECK_FAILED |
5475 | 5472 |
5476 } // namespace internal | 5473 } // namespace internal |
5477 } // namespace v8 | 5474 } // namespace v8 |
OLD | NEW |