| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 } | 318 } |
| 319 | 319 |
| 320 | 320 |
| 321 // Executes a string within the current v8 context. | 321 // Executes a string within the current v8 context. |
| 322 bool ExecuteString(v8::Isolate* isolate, | 322 bool ExecuteString(v8::Isolate* isolate, |
| 323 v8::Handle<v8::String> source, | 323 v8::Handle<v8::String> source, |
| 324 v8::Handle<v8::Value> name, | 324 v8::Handle<v8::Value> name, |
| 325 bool print_result, | 325 bool print_result, |
| 326 bool report_exceptions) { | 326 bool report_exceptions) { |
| 327 v8::HandleScope handle_scope(isolate); | 327 v8::HandleScope handle_scope(isolate); |
| 328 v8::TryCatch try_catch; | 328 v8::TryCatch try_catch(isolate); |
| 329 v8::ScriptOrigin origin(name); | 329 v8::ScriptOrigin origin(name); |
| 330 v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin); | 330 v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin); |
| 331 if (script.IsEmpty()) { | 331 if (script.IsEmpty()) { |
| 332 // Print errors that happened during compilation. | 332 // Print errors that happened during compilation. |
| 333 if (report_exceptions) | 333 if (report_exceptions) |
| 334 ReportException(isolate, &try_catch); | 334 ReportException(isolate, &try_catch); |
| 335 return false; | 335 return false; |
| 336 } else { | 336 } else { |
| 337 v8::Handle<v8::Value> result = script->Run(); | 337 v8::Handle<v8::Value> result = script->Run(); |
| 338 if (result.IsEmpty()) { | 338 if (result.IsEmpty()) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 fprintf(stderr, "^"); | 385 fprintf(stderr, "^"); |
| 386 } | 386 } |
| 387 fprintf(stderr, "\n"); | 387 fprintf(stderr, "\n"); |
| 388 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 388 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
| 389 if (stack_trace.length() > 0) { | 389 if (stack_trace.length() > 0) { |
| 390 const char* stack_trace_string = ToCString(stack_trace); | 390 const char* stack_trace_string = ToCString(stack_trace); |
| 391 fprintf(stderr, "%s\n", stack_trace_string); | 391 fprintf(stderr, "%s\n", stack_trace_string); |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 } | 394 } |
| OLD | NEW |