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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/parser.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5326 matching lines...) Expand 10 before | Expand all | Expand 10 after
5337 result->tree = tree; 5337 result->tree = tree;
5338 int capture_count = parser.captures_started(); 5338 int capture_count = parser.captures_started();
5339 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; 5339 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
5340 result->contains_anchor = parser.contains_anchor(); 5340 result->contains_anchor = parser.contains_anchor();
5341 result->capture_count = capture_count; 5341 result->capture_count = capture_count;
5342 } 5342 }
5343 return !parser.failed(); 5343 return !parser.failed();
5344 } 5344 }
5345 5345
5346 5346
5347 FunctionLiteral* Parser::MakeAST(bool compile_in_global_context, 5347 bool Parser::Parse(CompilationInfo* info) {
5348 Handle<Script> script, 5348 ASSERT(info->function() == NULL);
5349 v8::Extension* extension, 5349 FunctionLiteral* result = NULL;
5350 ScriptDataImpl* pre_data, 5350 Handle<Script> script = info->script();
5351 bool is_json) { 5351 if (info->is_lazy()) {
5352 bool allow_natives_syntax = 5352 AstBuildingParser parser(script, true, NULL, NULL);
5353 FLAG_allow_natives_syntax || Bootstrapper::IsActive(); 5353 result = parser.ParseLazy(info->shared_info());
5354 AstBuildingParser parser(script, allow_natives_syntax, extension, pre_data); 5354 } else {
5355 if (pre_data != NULL && pre_data->has_error()) { 5355 bool allow_natives_syntax =
5356 Scanner::Location loc = pre_data->MessageLocation(); 5356 FLAG_allow_natives_syntax || Bootstrapper::IsActive();
5357 const char* message = pre_data->BuildMessage(); 5357 ScriptDataImpl* pre_data = info->pre_parse_data();
5358 Vector<const char*> args = pre_data->BuildArgs(); 5358 AstBuildingParser parser(script, allow_natives_syntax, info->extension(),
5359 parser.ReportMessageAt(loc, message, args); 5359 pre_data);
5360 DeleteArray(message); 5360 if (pre_data != NULL && pre_data->has_error()) {
5361 for (int i = 0; i < args.length(); i++) { 5361 Scanner::Location loc = pre_data->MessageLocation();
5362 DeleteArray(args[i]); 5362 const char* message = pre_data->BuildMessage();
5363 Vector<const char*> args = pre_data->BuildArgs();
5364 parser.ReportMessageAt(loc, message, args);
5365 DeleteArray(message);
5366 for (int i = 0; i < args.length(); i++) {
5367 DeleteArray(args[i]);
5368 }
5369 DeleteArray(args.start());
5370 ASSERT(Top::has_pending_exception());
5371 } else {
5372 Handle<String> source = Handle<String>(String::cast(script->source()));
5373 // JSON is always global.
5374 ASSERT(!info->is_json() || info->is_global());
5375 result = info->is_json()
5376 ? parser.ParseJson(source)
5377 : parser.ParseProgram(source, info->is_global());
5363 } 5378 }
5364 DeleteArray(args.start());
5365 return NULL;
5366 } 5379 }
5367 Handle<String> source = Handle<String>(String::cast(script->source()));
5368 FunctionLiteral* result;
5369 if (is_json) {
5370 ASSERT(compile_in_global_context);
5371 result = parser.ParseJson(source);
5372 } else {
5373 result = parser.ParseProgram(source, compile_in_global_context);
5374 }
5375 return result;
5376 }
5377 5380
5378 5381 info->SetFunction(result);
5379 FunctionLiteral* Parser::MakeLazyAST(Handle<SharedFunctionInfo> info) { 5382 return (result != NULL);
5380 Handle<Script> script(Script::cast(info->script()));
5381 AstBuildingParser parser(script, true, NULL, NULL);
5382 FunctionLiteral* result = parser.ParseLazy(info);
5383 return result;
5384 } 5383 }
5385 5384
5386 #undef NEW 5385 #undef NEW
5387 5386
5388 } } // namespace v8::internal 5387 } } // namespace v8::internal
OLDNEW
« 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