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

Unified Diff: src/preparser.cc

Issue 477263002: ES6: Add support for method shorthand in object literals (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add strict formal param checking Created 6 years, 4 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/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 04907d3c1cab9f3d378b347e47992a0717300a70..12cacd8d3124fa8e963fc97d2a139837ab94f319 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -97,17 +97,16 @@ PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
PreParserExpression PreParserTraits::ParseFunctionLiteral(
- PreParserIdentifier name,
- Scanner::Location function_name_location,
- bool name_is_strict_reserved,
- bool is_generator,
- int function_token_position,
- FunctionLiteral::FunctionType type,
- FunctionLiteral::ArityRestriction arity_restriction,
- bool* ok) {
+ PreParserIdentifier name, Scanner::Location function_name_location,
+ bool name_is_strict_reserved, FunctionLiteral::IsGeneratorFlag is_generator,
+ FunctionLiteral::IsArrowFlag is_arrow,
+ FunctionLiteral::IsConciseMethodFlag is_concise_method,
+ int function_token_position, FunctionLiteral::FunctionType type,
+ FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
return pre_parser_->ParseFunctionLiteral(
name, function_name_location, name_is_strict_reserved, is_generator,
- function_token_position, type, arity_restriction, ok);
+ is_arrow, is_concise_method, function_token_position, type,
+ arity_restriction, ok);
}
@@ -335,14 +334,12 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
bool is_strict_reserved = false;
Identifier name = ParseIdentifierOrStrictReservedWord(
&is_strict_reserved, CHECK_OK);
- ParseFunctionLiteral(name,
- scanner()->location(),
- is_strict_reserved,
- is_generator,
- pos,
- FunctionLiteral::DECLARATION,
- FunctionLiteral::NORMAL_ARITY,
- CHECK_OK);
+ ParseFunctionLiteral(
+ name, scanner()->location(), is_strict_reserved,
+ is_generator ? FunctionLiteral::kIsGenerator
+ : FunctionLiteral::kNotGenerator,
+ FunctionLiteral::kNotArrow, FunctionLiteral::kNotConciseMethod, pos,
+ FunctionLiteral::DECLARATION, FunctionLiteral::NORMAL_ARITY, CHECK_OK);
return Statement::FunctionDeclaration();
}
@@ -800,14 +797,12 @@ PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) {
PreParser::Expression PreParser::ParseFunctionLiteral(
- Identifier function_name,
- Scanner::Location function_name_location,
- bool name_is_strict_reserved,
- bool is_generator,
- int function_token_pos,
- FunctionLiteral::FunctionType function_type,
- FunctionLiteral::ArityRestriction arity_restriction,
- bool* ok) {
+ Identifier function_name, Scanner::Location function_name_location,
+ bool name_is_strict_reserved, FunctionLiteral::IsGeneratorFlag is_generator,
+ FunctionLiteral::IsArrowFlag is_arrow,
+ FunctionLiteral::IsConciseMethodFlag is_concise_method,
+ int function_token_pos, FunctionLiteral::FunctionType function_type,
+ FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
@@ -871,7 +866,8 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
// Validate strict mode. We can do this only after parsing the function,
// since the function can declare itself strict.
- if (strict_mode() == STRICT) {
+ // Concise methods use StrictFormalParameters.
+ if (strict_mode() == STRICT || is_concise_method) {
if (function_name.IsEvalOrArguments()) {
ReportMessageAt(function_name_location, "strict_eval_arguments");
*ok = false;

Powered by Google App Engine
This is Rietveld 408576698