Commit 988d5fe5 authored by marja@chromium.org's avatar marja@chromium.org

Parser & preparser unification: make the ParseFunctionLiteral APIs the same.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/190853011

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19763 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e25d51cc
......@@ -3360,14 +3360,14 @@ Expression* Parser::ParseMemberExpression(bool* ok) {
Handle<String> name;
bool is_strict_reserved_name = false;
Scanner::Location function_name_location = Scanner::Location::invalid();
FunctionLiteral::FunctionType function_type =
FunctionLiteral::ANONYMOUS_EXPRESSION;
if (peek_any_identifier()) {
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
CHECK_OK);
function_name_location = scanner()->location();
function_type = FunctionLiteral::NAMED_EXPRESSION;
}
FunctionLiteral::FunctionType function_type = name.is_null()
? FunctionLiteral::ANONYMOUS_EXPRESSION
: FunctionLiteral::NAMED_EXPRESSION;
result = ParseFunctionLiteral(name,
function_name_location,
is_strict_reserved_name,
......
......@@ -347,7 +347,7 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
// 'function' '*' Identifier '(' FormalParameterListopt ')'
// '{' FunctionBody '}'
Expect(Token::FUNCTION, CHECK_OK);
int pos = position();
bool is_generator = allow_generators() && Check(Token::MUL);
bool is_strict_reserved = false;
Identifier name = ParseIdentifierOrStrictReservedWord(
......@@ -356,6 +356,8 @@ PreParser::Statement PreParser::ParseFunctionDeclaration(bool* ok) {
scanner()->location(),
is_strict_reserved,
is_generator,
pos,
FunctionLiteral::DECLARATION,
CHECK_OK);
return Statement::FunctionDeclaration();
}
......@@ -1063,20 +1065,25 @@ PreParser::Expression PreParser::ParseMemberExpression(bool* ok) {
Expression result = Expression::Default();
if (peek() == Token::FUNCTION) {
Consume(Token::FUNCTION);
int function_token_position = position();
bool is_generator = allow_generators() && Check(Token::MUL);
Identifier name = Identifier::Default();
bool is_strict_reserved_name = false;
Scanner::Location function_name_location = Scanner::Location::invalid();
FunctionLiteral::FunctionType function_type =
FunctionLiteral::ANONYMOUS_EXPRESSION;
if (peek_any_identifier()) {
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
CHECK_OK);
function_name_location = scanner()->location();
function_type = FunctionLiteral::NAMED_EXPRESSION;
}
result = ParseFunctionLiteral(name,
function_name_location,
is_strict_reserved_name,
is_generator,
function_token_position,
function_type,
CHECK_OK);
} else {
result = ParsePrimaryExpression(CHECK_OK);
......@@ -1162,6 +1169,8 @@ PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) {
scanner()->location(),
false, // reserved words are allowed here
false, // not a generator
RelocInfo::kNoPosition,
FunctionLiteral::ANONYMOUS_EXPRESSION,
CHECK_OK);
if (peek() != Token::RBRACE) {
Expect(Token::COMMA, CHECK_OK);
......@@ -1232,6 +1241,8 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
Scanner::Location function_name_location,
bool name_is_strict_reserved,
bool is_generator,
int function_token_pos,
FunctionLiteral::FunctionType function_type,
bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
......
......@@ -903,6 +903,8 @@ class PreParser : public ParserBase<PreParserTraits> {
Scanner::Location function_name_location,
bool name_is_strict_reserved,
bool is_generator,
int function_token_pos,
FunctionLiteral::FunctionType function_type,
bool* ok);
void ParseLazyFunctionLiteralBody(bool* ok);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment