Revision: 19763
Author:   [email protected]
Date:     Mon Mar 10 15:19:20 2014 UTC
Log: Parser & preparser unification: make the ParseFunctionLiteral APIs the same.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/190853011
http://code.google.com/p/v8/source/detail?r=19763

Modified:
 /branches/bleeding_edge/src/parser.cc
 /branches/bleeding_edge/src/preparser.cc
 /branches/bleeding_edge/src/preparser.h

=======================================
--- /branches/bleeding_edge/src/parser.cc       Mon Mar 10 11:42:17 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc       Mon Mar 10 15:19:20 2014 UTC
@@ -3360,14 +3360,14 @@
     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,
=======================================
--- /branches/bleeding_edge/src/preparser.cc    Mon Mar 10 11:42:17 2014 UTC
+++ /branches/bleeding_edge/src/preparser.cc    Mon Mar 10 15:19:20 2014 UTC
@@ -347,7 +347,7 @@
   //   '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 @@
                        scanner()->location(),
                        is_strict_reserved,
                        is_generator,
+                       pos,
+                       FunctionLiteral::DECLARATION,
                        CHECK_OK);
   return Statement::FunctionDeclaration();
 }
@@ -1063,20 +1065,25 @@
   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 @@
                                  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 @@
     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 '}'
=======================================
--- /branches/bleeding_edge/src/preparser.h     Fri Feb 28 12:08:17 2014 UTC
+++ /branches/bleeding_edge/src/preparser.h     Mon Mar 10 15:19:20 2014 UTC
@@ -903,6 +903,8 @@
       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