Reviewers: Michael Starzinger,

Message:
Committed patchset #1 manually as r19763 (presubmit successful).

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

[email protected]
BUG=

Committed: https://code.google.com/p/v8/source/detail?r=19763

Please review this at https://codereview.chromium.org/190853011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -5 lines):
  M src/parser.cc
  M src/preparser.h
  M src/preparser.cc


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 9b8223c7558e5b9217ece0ab67c331e6d717206b..a6abdde498607aab33b4e22053b3dffd4be3350d 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -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,
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index caa00d9bb2449c6b6b40bb51f307fcf5c2e5aefb..dfda9802c281aed5bfda8abdeb56ec0343770e6a 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -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 '}'
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 6d89713c24ff91ba3ed8d962ee96aac207565503..8a5517e1984552719a790666e87f7c706e91e3c6 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -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);



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to