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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index aeef16bb6a34c7b0ad671fd5355d2bcc0c62dfff..597521e5051f694fece51e0379625471d2ee6082 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -696,6 +696,16 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
int beg_pos = scanner()->location().beg_pos;
parsing_module_ = info->is_module();
if (parsing_module_) {
+ // Declare the special module parameter.
+ auto name = ast_value_factory()->empty_string();
+ bool is_duplicate;
+ bool is_rest = false;
+ bool is_optional = false;
+ auto var = scope->DeclareParameter(name, VAR, is_optional, is_rest,
+ &is_duplicate, ast_value_factory());
+ DCHECK(!is_duplicate);
+ var->AllocateTo(VariableLocation::PARAMETER, 0);
+
ParseModuleItemList(body, &ok);
ok = ok &&
module()->Validate(this->scope()->AsModuleScope(),
@@ -739,9 +749,10 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
if (ok) {
RewriteDestructuringAssignments();
+ int parameter_count = parsing_module_ ? 1 : 0;
result = factory()->NewScriptOrEvalFunctionLiteral(
scope, body, function_state.materialized_literal_count(),
- function_state.expected_property_count());
+ function_state.expected_property_count(), parameter_count);
}
}

Powered by Google App Engine
This is Rietveld 408576698