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

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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 // Enter 'scope' with the given parsing mode. 687 // Enter 'scope' with the given parsing mode.
688 ParsingModeScope parsing_mode_scope(this, parsing_mode); 688 ParsingModeScope parsing_mode_scope(this, parsing_mode);
689 FunctionState function_state(&function_state_, &scope_state_, scope, 689 FunctionState function_state(&function_state_, &scope_state_, scope,
690 kNormalFunction); 690 kNormalFunction);
691 691
692 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 692 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
693 bool ok = true; 693 bool ok = true;
694 int beg_pos = scanner()->location().beg_pos; 694 int beg_pos = scanner()->location().beg_pos;
695 parsing_module_ = info->is_module(); 695 parsing_module_ = info->is_module();
696 if (parsing_module_) { 696 if (parsing_module_) {
697 // Declare the special module parameter.
698 auto name = ast_value_factory()->empty_string();
699 bool is_duplicate;
700 bool is_rest = false;
701 bool is_optional = false;
702 auto var = scope->DeclareParameter(name, VAR, is_optional, is_rest,
703 &is_duplicate, ast_value_factory());
704 DCHECK(!is_duplicate);
705 var->AllocateTo(VariableLocation::PARAMETER, 0);
706
neis 2016/09/02 12:06:07 Here we awkwardly declare the module parameter, wh
adamk 2016/09/14 17:32:22 I feel like this might be a good question for some
697 ParseModuleItemList(body, &ok); 707 ParseModuleItemList(body, &ok);
698 ok = ok && 708 ok = ok &&
699 module()->Validate(this->scope()->AsModuleScope(), 709 module()->Validate(this->scope()->AsModuleScope(),
700 &pending_error_handler_, zone()); 710 &pending_error_handler_, zone());
701 } else { 711 } else {
702 // Don't count the mode in the use counters--give the program a chance 712 // Don't count the mode in the use counters--give the program a chance
703 // to enable script-wide strict mode below. 713 // to enable script-wide strict mode below.
704 this->scope()->SetLanguageMode(info->language_mode()); 714 this->scope()->SetLanguageMode(info->language_mode());
705 ParseStatementList(body, Token::EOS, &ok); 715 ParseStatementList(body, Token::EOS, &ok);
706 } 716 }
(...skipping 23 matching lines...) Expand all
730 !body->at(0)->IsExpressionStatement() || 740 !body->at(0)->IsExpressionStatement() ||
731 !body->at(0)->AsExpressionStatement()-> 741 !body->at(0)->AsExpressionStatement()->
732 expression()->IsFunctionLiteral()) { 742 expression()->IsFunctionLiteral()) {
733 ReportMessage(MessageTemplate::kSingleFunctionLiteral); 743 ReportMessage(MessageTemplate::kSingleFunctionLiteral);
734 ok = false; 744 ok = false;
735 } 745 }
736 } 746 }
737 747
738 if (ok) { 748 if (ok) {
739 RewriteDestructuringAssignments(); 749 RewriteDestructuringAssignments();
750 int parameter_count = parsing_module_ ? 1 : 0;
740 result = factory()->NewScriptOrEvalFunctionLiteral( 751 result = factory()->NewScriptOrEvalFunctionLiteral(
741 scope, body, function_state.materialized_literal_count(), 752 scope, body, function_state.materialized_literal_count(),
742 function_state.expected_property_count()); 753 function_state.expected_property_count(), parameter_count);
743 } 754 }
744 } 755 }
745 756
746 // Make sure the target stack is empty. 757 // Make sure the target stack is empty.
747 DCHECK(target_stack_ == NULL); 758 DCHECK(target_stack_ == NULL);
748 759
749 return result; 760 return result;
750 } 761 }
751 762
752 763
(...skipping 5737 matching lines...) Expand 10 before | Expand all | Expand 10 after
6490 node->Print(Isolate::Current()); 6501 node->Print(Isolate::Current());
6491 } 6502 }
6492 #endif // DEBUG 6503 #endif // DEBUG
6493 6504
6494 #undef CHECK_OK 6505 #undef CHECK_OK
6495 #undef CHECK_OK_VOID 6506 #undef CHECK_OK_VOID
6496 #undef CHECK_FAILED 6507 #undef CHECK_FAILED
6497 6508
6498 } // namespace internal 6509 } // namespace internal
6499 } // namespace v8 6510 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698