Limit entry points into the parser API.

R=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b267a955
...@@ -3170,8 +3170,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) { ...@@ -3170,8 +3170,7 @@ Expression* Parser::ParseUnaryExpression(bool* ok) {
if (op == Token::NOT) { if (op == Token::NOT) {
// Convert the literal to a boolean condition and negate it. // Convert the literal to a boolean condition and negate it.
bool condition = literal->BooleanValue(); bool condition = literal->BooleanValue();
Handle<Object> result(isolate()->heap()->ToBoolean(!condition), Handle<Object> result = isolate()->factory()->ToBoolean(!condition);
isolate());
return factory()->NewLiteral(result); return factory()->NewLiteral(result);
} else if (literal->IsNumber()) { } else if (literal->IsNumber()) {
// Compute some expressions involving only number literals. // Compute some expressions involving only number literals.
......
...@@ -461,9 +461,6 @@ class Parser BASE_EMBEDDED { ...@@ -461,9 +461,6 @@ class Parser BASE_EMBEDDED {
static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); } static bool Parse(CompilationInfo* info) { return Parser(info).Parse(); }
bool Parse(); bool Parse();
// Returns NULL if parsing failed.
FunctionLiteral* ParseProgram();
void ReportMessageAt(Scanner::Location loc, void ReportMessageAt(Scanner::Location loc,
const char* message, const char* message,
Vector<const char*> args); Vector<const char*> args);
...@@ -568,6 +565,9 @@ class Parser BASE_EMBEDDED { ...@@ -568,6 +565,9 @@ class Parser BASE_EMBEDDED {
Mode old_mode_; Mode old_mode_;
}; };
// Returns NULL if parsing failed.
FunctionLiteral* ParseProgram();
FunctionLiteral* ParseLazy(); FunctionLiteral* ParseLazy();
FunctionLiteral* ParseLazy(Utf16CharacterStream* source); FunctionLiteral* ParseLazy(Utf16CharacterStream* source);
......
...@@ -1027,11 +1027,11 @@ TEST(ScopePositions) { ...@@ -1027,11 +1027,11 @@ TEST(ScopePositions) {
parser.set_allow_harmony_scoping(true); parser.set_allow_harmony_scoping(true);
info.MarkAsGlobal(); info.MarkAsGlobal();
info.SetLanguageMode(source_data[i].language_mode); info.SetLanguageMode(source_data[i].language_mode);
i::FunctionLiteral* function = parser.ParseProgram(); parser.Parse();
CHECK(function != NULL); CHECK(info.function() != NULL);
// Check scope types and positions. // Check scope types and positions.
i::Scope* scope = function->scope(); i::Scope* scope = info.function()->scope();
CHECK(scope->is_global_scope()); CHECK(scope->is_global_scope());
CHECK_EQ(scope->start_position(), 0); CHECK_EQ(scope->start_position(), 0);
CHECK_EQ(scope->end_position(), kProgramSize); CHECK_EQ(scope->end_position(), kProgramSize);
...@@ -1137,7 +1137,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) { ...@@ -1137,7 +1137,8 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, unsigned flags) {
i::Parser parser(&info); i::Parser parser(&info);
SET_PARSER_FLAGS(parser, flags); SET_PARSER_FLAGS(parser, flags);
info.MarkAsGlobal(); info.MarkAsGlobal();
function = parser.ParseProgram(); parser.Parse();
function = info.function();
} }
// Check that preparsing fails iff parsing fails. // Check that preparsing fails iff parsing fails.
......
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