Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Unified Diff: src/parser.cc

Issue 3586006: Begin a more aggressive refactoring of the Compiler interface. (Closed)
Patch Set: Always return false on a parse failure. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 3d48c9c58551d5dd61a44ce7785bc8c6fae80388..7690e92d520988de3fbae454f38049341ac6b20d 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5344,43 +5344,42 @@ bool Parser::ParseRegExp(FlatStringReader* input,
}
-FunctionLiteral* Parser::MakeAST(bool compile_in_global_context,
- Handle<Script> script,
- v8::Extension* extension,
- ScriptDataImpl* pre_data,
- bool is_json) {
- bool allow_natives_syntax =
- FLAG_allow_natives_syntax || Bootstrapper::IsActive();
- AstBuildingParser parser(script, allow_natives_syntax, extension, pre_data);
- if (pre_data != NULL && pre_data->has_error()) {
- Scanner::Location loc = pre_data->MessageLocation();
- const char* message = pre_data->BuildMessage();
- Vector<const char*> args = pre_data->BuildArgs();
- parser.ReportMessageAt(loc, message, args);
- DeleteArray(message);
- for (int i = 0; i < args.length(); i++) {
- DeleteArray(args[i]);
- }
- DeleteArray(args.start());
- return NULL;
- }
- Handle<String> source = Handle<String>(String::cast(script->source()));
- FunctionLiteral* result;
- if (is_json) {
- ASSERT(compile_in_global_context);
- result = parser.ParseJson(source);
+bool Parser::Parse(CompilationInfo* info) {
+ ASSERT(info->function() == NULL);
+ FunctionLiteral* result = NULL;
+ Handle<Script> script = info->script();
+ if (info->is_lazy()) {
+ AstBuildingParser parser(script, true, NULL, NULL);
+ result = parser.ParseLazy(info->shared_info());
} else {
- result = parser.ParseProgram(source, compile_in_global_context);
+ bool allow_natives_syntax =
+ FLAG_allow_natives_syntax || Bootstrapper::IsActive();
+ ScriptDataImpl* pre_data = info->pre_parse_data();
+ AstBuildingParser parser(script, allow_natives_syntax, info->extension(),
+ pre_data);
+ if (pre_data != NULL && pre_data->has_error()) {
+ Scanner::Location loc = pre_data->MessageLocation();
+ const char* message = pre_data->BuildMessage();
+ Vector<const char*> args = pre_data->BuildArgs();
+ parser.ReportMessageAt(loc, message, args);
+ DeleteArray(message);
+ for (int i = 0; i < args.length(); i++) {
+ DeleteArray(args[i]);
+ }
+ DeleteArray(args.start());
+ ASSERT(Top::has_pending_exception());
+ } else {
+ Handle<String> source = Handle<String>(String::cast(script->source()));
+ // JSON is always global.
+ ASSERT(!info->is_json() || info->is_global());
+ result = info->is_json()
+ ? parser.ParseJson(source)
+ : parser.ParseProgram(source, info->is_global());
+ }
}
- return result;
-}
-
-FunctionLiteral* Parser::MakeLazyAST(Handle<SharedFunctionInfo> info) {
- Handle<Script> script(Script::cast(info->script()));
- AstBuildingParser parser(script, true, NULL, NULL);
- FunctionLiteral* result = parser.ParseLazy(info);
- return result;
+ info->SetFunction(result);
+ return (result != NULL);
}
#undef NEW
« no previous file with comments | « src/parser.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698