Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/parsing/parser.cc

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: Disable module tests for deopt fuzzer. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // Enter 'scope' with the given parsing mode. 735 // Enter 'scope' with the given parsing mode.
736 ParsingModeScope parsing_mode_scope(this, parsing_mode); 736 ParsingModeScope parsing_mode_scope(this, parsing_mode);
737 FunctionState function_state(&function_state_, &scope_state_, scope, 737 FunctionState function_state(&function_state_, &scope_state_, scope,
738 kNormalFunction); 738 kNormalFunction);
739 739
740 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 740 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
741 bool ok = true; 741 bool ok = true;
742 int beg_pos = scanner()->location().beg_pos; 742 int beg_pos = scanner()->location().beg_pos;
743 parsing_module_ = info->is_module(); 743 parsing_module_ = info->is_module();
744 if (parsing_module_) { 744 if (parsing_module_) {
745 // Declare the special module parameter.
746 auto name = ast_value_factory()->empty_string();
747 bool is_duplicate;
748 bool is_rest = false;
749 bool is_optional = false;
750 auto var = scope->DeclareParameter(name, VAR, is_optional, is_rest,
751 &is_duplicate, ast_value_factory());
752 DCHECK(!is_duplicate);
753 var->AllocateTo(VariableLocation::PARAMETER, 0);
754
745 ParseModuleItemList(body, &ok); 755 ParseModuleItemList(body, &ok);
746 ok = ok && 756 ok = ok &&
747 module()->Validate(this->scope()->AsModuleScope(), 757 module()->Validate(this->scope()->AsModuleScope(),
748 &pending_error_handler_, zone()); 758 &pending_error_handler_, zone());
749 } else { 759 } else {
750 // Don't count the mode in the use counters--give the program a chance 760 // Don't count the mode in the use counters--give the program a chance
751 // to enable script-wide strict mode below. 761 // to enable script-wide strict mode below.
752 this->scope()->SetLanguageMode(info->language_mode()); 762 this->scope()->SetLanguageMode(info->language_mode());
753 ParseStatementList(body, Token::EOS, &ok); 763 ParseStatementList(body, Token::EOS, &ok);
754 } 764 }
(...skipping 23 matching lines...) Expand all
778 !body->at(0)->IsExpressionStatement() || 788 !body->at(0)->IsExpressionStatement() ||
779 !body->at(0)->AsExpressionStatement()-> 789 !body->at(0)->AsExpressionStatement()->
780 expression()->IsFunctionLiteral()) { 790 expression()->IsFunctionLiteral()) {
781 ReportMessage(MessageTemplate::kSingleFunctionLiteral); 791 ReportMessage(MessageTemplate::kSingleFunctionLiteral);
782 ok = false; 792 ok = false;
783 } 793 }
784 } 794 }
785 795
786 if (ok) { 796 if (ok) {
787 RewriteDestructuringAssignments(); 797 RewriteDestructuringAssignments();
798 int parameter_count = parsing_module_ ? 1 : 0;
788 result = factory()->NewScriptOrEvalFunctionLiteral( 799 result = factory()->NewScriptOrEvalFunctionLiteral(
789 scope, body, function_state.materialized_literal_count(), 800 scope, body, function_state.materialized_literal_count(),
790 function_state.expected_property_count()); 801 function_state.expected_property_count(), parameter_count);
791 } 802 }
792 } 803 }
793 804
794 // Make sure the target stack is empty. 805 // Make sure the target stack is empty.
795 DCHECK(target_stack_ == NULL); 806 DCHECK(target_stack_ == NULL);
796 807
797 return result; 808 return result;
798 } 809 }
799 810
800 811
(...skipping 4875 matching lines...) Expand 10 before | Expand all | Expand 10 after
5676 node->Print(Isolate::Current()); 5687 node->Print(Isolate::Current());
5677 } 5688 }
5678 #endif // DEBUG 5689 #endif // DEBUG
5679 5690
5680 #undef CHECK_OK 5691 #undef CHECK_OK
5681 #undef CHECK_OK_VOID 5692 #undef CHECK_OK_VOID
5682 #undef CHECK_FAILED 5693 #undef CHECK_FAILED
5683 5694
5684 } // namespace internal 5695 } // namespace internal
5685 } // namespace v8 5696 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698