Reviewers: ulan,

Description:
Limit entry points into the parser API.

[email protected]

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

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

Affected files (+9, -9 lines):
  M src/parser.h
  M src/parser.cc
  M test/cctest/test-parsing.cc


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 05ae11e4291ae8c169d962dad7531b05cc0fc1bd..c77c17126fa442ef420eb2720b510a497a153ced 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3170,8 +3170,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
       if (op == Token::NOT) {
         // Convert the literal to a boolean condition and negate it.
         bool condition = literal->BooleanValue();
-        Handle<Object> result(isolate()->heap()->ToBoolean(!condition),
-                              isolate());
+ Handle<Object> result = isolate()->factory()->ToBoolean(!condition);
         return factory()->NewLiteral(result);
       } else if (literal->IsNumber()) {
         // Compute some expressions involving only number literals.
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 783626ad190f28bd030caeab3d635a72d7df7202..efb7706086d20d3c59ecd8ac6303ea6dc70b0a37 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -461,9 +461,6 @@ class Parser BASE_EMBEDDED {
   static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
   bool Parse();

-  // Returns NULL if parsing failed.
-  FunctionLiteral* ParseProgram();
-
   void ReportMessageAt(Scanner::Location loc,
                        const char* message,
                        Vector<const char*> args);
@@ -568,6 +565,9 @@ class Parser BASE_EMBEDDED {
     Mode old_mode_;
   };

+  // Returns NULL if parsing failed.
+  FunctionLiteral* ParseProgram();
+
   FunctionLiteral* ParseLazy();
   FunctionLiteral* ParseLazy(Utf16CharacterStream* source);

Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index e6b536771a14ba453d9058e10ea94c8ba6bce8b6..8d52fe5999dab1258e88565cfe3fd3715b2c3d53 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1027,11 +1027,11 @@ TEST(ScopePositions) {
     parser.set_allow_harmony_scoping(true);
     info.MarkAsGlobal();
     info.SetLanguageMode(source_data[i].language_mode);
-    i::FunctionLiteral* function = parser.ParseProgram();
-    CHECK(function != NULL);
+    parser.Parse();
+    CHECK(info.function() != NULL);

     // Check scope types and positions.
-    i::Scope* scope = function->scope();
+    i::Scope* scope = info.function()->scope();
     CHECK(scope->is_global_scope());
     CHECK_EQ(scope->start_position(), 0);
     CHECK_EQ(scope->end_position(), kProgramSize);
@@ -1137,7 +1137,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) {
     i::Parser parser(&info);
     SET_PARSER_FLAGS(parser, flags);
     info.MarkAsGlobal();
-    function = parser.ParseProgram();
+    parser.Parse();
+    function = info.function();
   }

   // Check that preparsing fails iff parsing fails.


--
--
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/groups/opt_out.

Reply via email to