| 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 || |
| 750 info->function_literal_id() == FunctionLiteral::kIdTypeInvalid); | 751 info->function_literal_id() == FunctionLiteral::kIdTypeInvalid); |
| 751 | 752 |
| 752 FunctionLiteral* result = NULL; | 753 FunctionLiteral* result = NULL; |
| 753 { | 754 { |
| 754 Scope* outer = original_scope_; | 755 Scope* outer = original_scope_; |
| 755 DCHECK_NOT_NULL(outer); | 756 DCHECK_NOT_NULL(outer); |
| 756 parsing_module_ = info->is_module(); | 757 parsing_module_ = info->is_module(); |
| 757 if (info->is_eval()) { | 758 if (info->is_eval()) { |
| 758 outer = NewEvalScope(outer); | 759 outer = NewEvalScope(outer); |
| 759 } else if (parsing_module_) { | 760 } else if (parsing_module_) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 ReportMessage(MessageTemplate::kSingleFunctionLiteral); | 828 ReportMessage(MessageTemplate::kSingleFunctionLiteral); |
| 828 ok = false; | 829 ok = false; |
| 829 } | 830 } |
| 830 } | 831 } |
| 831 | 832 |
| 832 if (ok) { | 833 if (ok) { |
| 833 RewriteDestructuringAssignments(); | 834 RewriteDestructuringAssignments(); |
| 834 int parameter_count = parsing_module_ ? 1 : 0; | 835 int parameter_count = parsing_module_ ? 1 : 0; |
| 835 result = factory()->NewScriptOrEvalFunctionLiteral( | 836 result = factory()->NewScriptOrEvalFunctionLiteral( |
| 836 scope, body, function_state.materialized_literal_count(), | 837 scope, body, function_state.materialized_literal_count(), |
| 837 function_state.expected_property_count(), parameter_count); | 838 function_state.expected_property_count(), parameter_count, |
| 839 info->is_eval() ? FunctionLiteral::kIdTypeEval |
| 840 : FunctionLiteral::kIdTypeTopLevel); |
| 838 } | 841 } |
| 839 } | 842 } |
| 840 | 843 |
| 841 // Make sure the target stack is empty. | 844 // Make sure the target stack is empty. |
| 842 DCHECK(target_stack_ == NULL); | 845 DCHECK(target_stack_ == NULL); |
| 843 | 846 |
| 844 return result; | 847 return result; |
| 845 } | 848 } |
| 846 | 849 |
| 847 FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info) { | 850 FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info) { |
| (...skipping 4617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5465 | 5468 |
| 5466 return final_loop; | 5469 return final_loop; |
| 5467 } | 5470 } |
| 5468 | 5471 |
| 5469 #undef CHECK_OK | 5472 #undef CHECK_OK |
| 5470 #undef CHECK_OK_VOID | 5473 #undef CHECK_OK_VOID |
| 5471 #undef CHECK_FAILED | 5474 #undef CHECK_FAILED |
| 5472 | 5475 |
| 5473 } // namespace internal | 5476 } // namespace internal |
| 5474 } // namespace v8 | 5477 } // namespace v8 |
| OLD | NEW |