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

Unified Diff: src/parsing/parser.cc

Issue 1518873004: [es6] Support Function name inference in variable declarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 65b835367f558d3c9c60cfcd6b44402993621faf..ce81c053f30a831c8676652c90f3f1721b9c92aa 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -934,6 +934,7 @@ Parser::Parser(ParseInfo* info)
set_allow_strong_mode(FLAG_strong_mode);
set_allow_legacy_const(FLAG_legacy_const);
set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
+ set_allow_harmony_function_name(FLAG_harmony_function_name);
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
++feature) {
use_counts_[feature] = 0;
@@ -2566,6 +2567,21 @@ void Parser::ParseVariableDeclarations(VariableDeclarationContext var_context,
fni_->RemoveLastFunction();
}
}
+
+ if (allow_harmony_function_name() && single_name) {
+ if (value->IsFunctionLiteral()) {
+ auto function_literal = value->AsFunctionLiteral();
+ if (function_literal->is_anonymous()) {
+ function_literal->set_raw_name(single_name);
+ }
+ } else if (value->IsClassLiteral()) {
+ auto class_literal = value->AsClassLiteral();
+ if (class_literal->raw_name() == nullptr) {
+ class_literal->set_raw_name(single_name);
+ }
+ }
+ }
+
// End position of the initializer is after the assignment expression.
initializer_position = scanner()->location().end_pos;
} else {
@@ -4910,6 +4926,7 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
SET_ALLOW(harmony_destructuring_bind);
SET_ALLOW(strong_mode);
SET_ALLOW(harmony_do_expressions);
+ SET_ALLOW(harmony_function_name);
#undef SET_ALLOW
}
PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
« no previous file with comments | « src/flag-definitions.h ('k') | src/parsing/parser-base.h » ('j') | test/test262/test262.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698