| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 bool report_exceptions) { | 99 bool report_exceptions) { |
| 100 HandleScope handle_scope; | 100 HandleScope handle_scope; |
| 101 TryCatch try_catch; | 101 TryCatch try_catch; |
| 102 if (i::FLAG_debugger) { | 102 if (i::FLAG_debugger) { |
| 103 // When debugging make exceptions appear to be uncaught. | 103 // When debugging make exceptions appear to be uncaught. |
| 104 try_catch.SetVerbose(true); | 104 try_catch.SetVerbose(true); |
| 105 } | 105 } |
| 106 Handle<Script> script = Script::Compile(source, name); | 106 Handle<Script> script = Script::Compile(source, name); |
| 107 if (script.IsEmpty()) { | 107 if (script.IsEmpty()) { |
| 108 // Print errors that happened during compilation. | 108 // Print errors that happened during compilation. |
| 109 if (report_exceptions) | 109 if (report_exceptions && !i::FLAG_debugger) |
| 110 ReportException(&try_catch); | 110 ReportException(&try_catch); |
| 111 return false; | 111 return false; |
| 112 } else { | 112 } else { |
| 113 Handle<Value> result = script->Run(); | 113 Handle<Value> result = script->Run(); |
| 114 if (result.IsEmpty()) { | 114 if (result.IsEmpty()) { |
| 115 // Print errors that happened during execution. | 115 // Print errors that happened during execution. |
| 116 if (report_exceptions) | 116 if (report_exceptions && !i::FLAG_debugger) |
| 117 ReportException(&try_catch); | 117 ReportException(&try_catch); |
| 118 return false; | 118 return false; |
| 119 } else { | 119 } else { |
| 120 if (print_result && !result->IsUndefined()) { | 120 if (print_result && !result->IsUndefined()) { |
| 121 // If all went well and the result wasn't undefined then print | 121 // If all went well and the result wasn't undefined then print |
| 122 // the returned value. | 122 // the returned value. |
| 123 String::Utf8Value str(result); | 123 String::Utf8Value str(result); |
| 124 printf("%s\n", *str); | 124 printf("%s\n", *str); |
| 125 } | 125 } |
| 126 return true; | 126 return true; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 evaluation_context_ = Context::New(NULL, global_template); | 360 evaluation_context_ = Context::New(NULL, global_template); |
| 361 evaluation_context_->SetSecurityToken(Undefined()); | 361 evaluation_context_->SetSecurityToken(Undefined()); |
| 362 | 362 |
| 363 // Set the security token of the debug context to allow access. | 363 // Set the security token of the debug context to allow access. |
| 364 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); | 364 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 | 367 |
| 368 void Shell::OnExit() { | 368 void Shell::OnExit() { |
| 369 if (i::FLAG_dump_counters) { | 369 if (i::FLAG_dump_counters) { |
| 370 ::printf("+----------------------------------------+----------+\n"); | 370 ::printf("+----------------------------------------+-------------+\n"); |
| 371 ::printf("| Name | Value |\n"); | 371 ::printf("| Name | Value |\n"); |
| 372 ::printf("+----------------------------------------+----------+\n"); | 372 ::printf("+----------------------------------------+-------------+\n"); |
| 373 for (CounterMap::iterator i = counter_map_.begin(); | 373 for (CounterMap::iterator i = counter_map_.begin(); |
| 374 i != counter_map_.end(); | 374 i != counter_map_.end(); |
| 375 i++) { | 375 i++) { |
| 376 Counter* counter = (*i).second; | 376 Counter* counter = (*i).second; |
| 377 ::printf("| %-38s | %8i |\n", (*i).first, counter->value()); | 377 ::printf("| %-38s | %11i |\n", (*i).first, counter->value()); |
| 378 } | 378 } |
| 379 ::printf("+----------------------------------------+----------+\n"); | 379 ::printf("+----------------------------------------+-------------+\n"); |
| 380 } | 380 } |
| 381 if (counters_file_ != NULL) | 381 if (counters_file_ != NULL) |
| 382 delete counters_file_; | 382 delete counters_file_; |
| 383 } | 383 } |
| 384 | 384 |
| 385 | 385 |
| 386 // Reads a file into a v8 string. | 386 // Reads a file into a v8 string. |
| 387 Handle<String> Shell::ReadFile(const char* name) { | 387 Handle<String> Shell::ReadFile(const char* name) { |
| 388 FILE* file = i::OS::FOpen(name, "rb"); | 388 FILE* file = i::OS::FOpen(name, "rb"); |
| 389 if (file == NULL) return Handle<String>(); | 389 if (file == NULL) return Handle<String>(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return 0; | 470 return 0; |
| 471 } | 471 } |
| 472 | 472 |
| 473 | 473 |
| 474 } // namespace v8 | 474 } // namespace v8 |
| 475 | 475 |
| 476 | 476 |
| 477 int main(int argc, char* argv[]) { | 477 int main(int argc, char* argv[]) { |
| 478 return v8::Shell::Main(argc, argv); | 478 return v8::Shell::Main(argc, argv); |
| 479 } | 479 } |
| OLD | NEW |