OLD | NEW |
---|---|
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 0, 1); | 284 0, 1); |
285 if (result == BZ_OK) { | 285 if (result == BZ_OK) { |
286 *raw_data_size = decompressed_size; | 286 *raw_data_size = decompressed_size; |
287 } | 287 } |
288 return result; | 288 return result; |
289 } | 289 } |
290 }; | 290 }; |
291 #endif | 291 #endif |
292 | 292 |
293 | 293 |
294 void DumpException(Handle<Message> message) { | |
295 Local<String> message_string = message->Get(); | |
Sven Panne
2013/04/29 11:23:36
Simpler:
-----------------------------------------
jochen (gone - plz use gerrit)
2013/04/29 11:38:28
Done.
| |
296 Local<String> message_line = message->GetSourceLine(); | |
297 int len = 2 + message_string->Utf8Length() + message_line->Utf8Length(); | |
298 char* buf = new char(len); | |
299 message_string->WriteUtf8(buf); | |
300 fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber()); | |
301 message_line->WriteUtf8(buf); | |
302 fprintf(stderr, "%s\n", buf); | |
303 int from = message->GetStartColumn(); | |
304 int to = message->GetEndColumn(); | |
305 int i; | |
306 for (i = 0; i < from; i++) fprintf(stderr, " "); | |
307 for ( ; i <= to; i++) fprintf(stderr, "^"); | |
308 fprintf(stderr, "\n"); | |
309 } | |
310 | |
311 | |
294 int main(int argc, char** argv) { | 312 int main(int argc, char** argv) { |
295 // By default, log code create information in the snapshot. | 313 // By default, log code create information in the snapshot. |
296 i::FLAG_log_code = true; | 314 i::FLAG_log_code = true; |
297 | 315 |
298 // Print the usage if an error occurs when parsing the command line | 316 // Print the usage if an error occurs when parsing the command line |
299 // flags or if the help flag is set. | 317 // flags or if the help flag is set. |
300 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); | 318 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
301 if (result > 0 || argc != 2 || i::FLAG_help) { | 319 if (result > 0 || argc != 2 || i::FLAG_help) { |
302 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); | 320 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); |
303 i::FlagList::PrintHelp(); | 321 i::FlagList::PrintHelp(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno); | 361 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno); |
344 exit(1); | 362 exit(1); |
345 } | 363 } |
346 i += read; | 364 i += read; |
347 } | 365 } |
348 fclose(file); | 366 fclose(file); |
349 Local<String> source = String::New(chars); | 367 Local<String> source = String::New(chars); |
350 TryCatch try_catch; | 368 TryCatch try_catch; |
351 Local<Script> script = Script::Compile(source); | 369 Local<Script> script = Script::Compile(source); |
352 if (try_catch.HasCaught()) { | 370 if (try_catch.HasCaught()) { |
353 fprintf(stderr, "Failure compiling '%s' (see above)\n", name); | 371 fprintf(stderr, "Failure compiling '%s'\n", name); |
372 DumpException(try_catch.Message()); | |
354 exit(1); | 373 exit(1); |
355 } | 374 } |
356 script->Run(); | 375 script->Run(); |
357 if (try_catch.HasCaught()) { | 376 if (try_catch.HasCaught()) { |
358 fprintf(stderr, "Failure running '%s'\n", name); | 377 fprintf(stderr, "Failure running '%s'\n", name); |
359 Local<Message> message = try_catch.Message(); | 378 DumpException(try_catch.Message()); |
360 Local<String> message_string = message->Get(); | |
361 Local<String> message_line = message->GetSourceLine(); | |
362 int len = 2 + message_string->Utf8Length() + message_line->Utf8Length(); | |
363 char* buf = new char(len); | |
364 message_string->WriteUtf8(buf); | |
365 fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber()); | |
366 message_line->WriteUtf8(buf); | |
367 fprintf(stderr, "%s\n", buf); | |
368 int from = message->GetStartColumn(); | |
369 int to = message->GetEndColumn(); | |
370 int i; | |
371 for (i = 0; i < from; i++) fprintf(stderr, " "); | |
372 for ( ; i <= to; i++) fprintf(stderr, "^"); | |
373 fprintf(stderr, "\n"); | |
374 exit(1); | 379 exit(1); |
375 } | 380 } |
376 context->Exit(); | 381 context->Exit(); |
377 } | 382 } |
378 // Make sure all builtin scripts are cached. | 383 // Make sure all builtin scripts are cached. |
379 { HandleScope scope(isolate); | 384 { HandleScope scope(isolate); |
380 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { | 385 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { |
381 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); | 386 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); |
382 } | 387 } |
383 } | 388 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 sink.WriteSpaceUsed( | 423 sink.WriteSpaceUsed( |
419 "", | 424 "", |
420 ser.CurrentAllocationAddress(i::NEW_SPACE), | 425 ser.CurrentAllocationAddress(i::NEW_SPACE), |
421 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 426 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
422 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 427 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
423 ser.CurrentAllocationAddress(i::CODE_SPACE), | 428 ser.CurrentAllocationAddress(i::CODE_SPACE), |
424 ser.CurrentAllocationAddress(i::MAP_SPACE), | 429 ser.CurrentAllocationAddress(i::MAP_SPACE), |
425 ser.CurrentAllocationAddress(i::CELL_SPACE)); | 430 ser.CurrentAllocationAddress(i::CELL_SPACE)); |
426 return 0; | 431 return 0; |
427 } | 432 } |
OLD | NEW |