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

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

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: . 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
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // Enter 'scope' with the given parsing mode. 689 // Enter 'scope' with the given parsing mode.
690 ParsingModeScope parsing_mode_scope(this, parsing_mode); 690 ParsingModeScope parsing_mode_scope(this, parsing_mode);
691 FunctionState function_state(&function_state_, &scope_state_, scope, 691 FunctionState function_state(&function_state_, &scope_state_, scope,
692 kNormalFunction); 692 kNormalFunction);
693 693
694 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 694 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
695 bool ok = true; 695 bool ok = true;
696 int beg_pos = scanner()->location().beg_pos; 696 int beg_pos = scanner()->location().beg_pos;
697 parsing_module_ = info->is_module(); 697 parsing_module_ = info->is_module();
698 if (parsing_module_) { 698 if (parsing_module_) {
699 // Declare the special module parameter.
700 auto name = ast_value_factory()->empty_string();
701 bool is_duplicate;
702 bool is_rest = false;
703 bool is_optional = false;
704 auto var = scope->DeclareParameter(name, VAR, is_optional, is_rest,
705 &is_duplicate, ast_value_factory());
706 DCHECK(!is_duplicate);
707 var->AllocateTo(VariableLocation::PARAMETER, 0);
708
699 ParseModuleItemList(body, &ok); 709 ParseModuleItemList(body, &ok);
700 ok = ok && 710 ok = ok &&
701 module()->Validate(this->scope()->AsModuleScope(), 711 module()->Validate(this->scope()->AsModuleScope(),
702 &pending_error_handler_, zone()); 712 &pending_error_handler_, zone());
703 } else { 713 } else {
704 // Don't count the mode in the use counters--give the program a chance 714 // Don't count the mode in the use counters--give the program a chance
705 // to enable script-wide strict mode below. 715 // to enable script-wide strict mode below.
706 this->scope()->SetLanguageMode(info->language_mode()); 716 this->scope()->SetLanguageMode(info->language_mode());
707 ParseStatementList(body, Token::EOS, &ok); 717 ParseStatementList(body, Token::EOS, &ok);
708 } 718 }
(...skipping 23 matching lines...) Expand all
732 !body->at(0)->IsExpressionStatement() || 742 !body->at(0)->IsExpressionStatement() ||
733 !body->at(0)->AsExpressionStatement()-> 743 !body->at(0)->AsExpressionStatement()->
734 expression()->IsFunctionLiteral()) { 744 expression()->IsFunctionLiteral()) {
735 ReportMessage(MessageTemplate::kSingleFunctionLiteral); 745 ReportMessage(MessageTemplate::kSingleFunctionLiteral);
736 ok = false; 746 ok = false;
737 } 747 }
738 } 748 }
739 749
740 if (ok) { 750 if (ok) {
741 RewriteDestructuringAssignments(); 751 RewriteDestructuringAssignments();
752 int parameter_count = parsing_module_ ? 1 : 0;
742 result = factory()->NewScriptOrEvalFunctionLiteral( 753 result = factory()->NewScriptOrEvalFunctionLiteral(
743 scope, body, function_state.materialized_literal_count(), 754 scope, body, function_state.materialized_literal_count(),
744 function_state.expected_property_count()); 755 function_state.expected_property_count(), parameter_count);
745 } 756 }
746 } 757 }
747 758
748 // Make sure the target stack is empty. 759 // Make sure the target stack is empty.
749 DCHECK(target_stack_ == NULL); 760 DCHECK(target_stack_ == NULL);
750 761
751 return result; 762 return result;
752 } 763 }
753 764
754 765
(...skipping 5893 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 node->Print(Isolate::Current()); 6659 node->Print(Isolate::Current());
6649 } 6660 }
6650 #endif // DEBUG 6661 #endif // DEBUG
6651 6662
6652 #undef CHECK_OK 6663 #undef CHECK_OK
6653 #undef CHECK_OK_VOID 6664 #undef CHECK_OK_VOID
6654 #undef CHECK_FAILED 6665 #undef CHECK_FAILED
6655 6666
6656 } // namespace internal 6667 } // namespace internal
6657 } // namespace v8 6668 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698