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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 297 |
298 | 298 |
299 // Executes a string within the current v8 context. | 299 // Executes a string within the current v8 context. |
300 bool ExecuteString(v8::Isolate* isolate, | 300 bool ExecuteString(v8::Isolate* isolate, |
301 v8::Handle<v8::String> source, | 301 v8::Handle<v8::String> source, |
302 v8::Handle<v8::Value> name, | 302 v8::Handle<v8::Value> name, |
303 bool print_result, | 303 bool print_result, |
304 bool report_exceptions) { | 304 bool report_exceptions) { |
305 v8::HandleScope handle_scope(isolate); | 305 v8::HandleScope handle_scope(isolate); |
306 v8::TryCatch try_catch; | 306 v8::TryCatch try_catch; |
307 v8::Handle<v8::Script> script = v8::Script::Compile(source, name); | 307 v8::ScriptOrigin origin(name); |
| 308 v8::Handle<v8::Script> script = v8::Script::Compile(source, &origin); |
308 if (script.IsEmpty()) { | 309 if (script.IsEmpty()) { |
309 // Print errors that happened during compilation. | 310 // Print errors that happened during compilation. |
310 if (report_exceptions) | 311 if (report_exceptions) |
311 ReportException(isolate, &try_catch); | 312 ReportException(isolate, &try_catch); |
312 return false; | 313 return false; |
313 } else { | 314 } else { |
314 v8::Handle<v8::Value> result = script->Run(); | 315 v8::Handle<v8::Value> result = script->Run(); |
315 if (result.IsEmpty()) { | 316 if (result.IsEmpty()) { |
316 assert(try_catch.HasCaught()); | 317 assert(try_catch.HasCaught()); |
317 // Print errors that happened during execution. | 318 // Print errors that happened during execution. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 fprintf(stderr, "^"); | 363 fprintf(stderr, "^"); |
363 } | 364 } |
364 fprintf(stderr, "\n"); | 365 fprintf(stderr, "\n"); |
365 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 366 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
366 if (stack_trace.length() > 0) { | 367 if (stack_trace.length() > 0) { |
367 const char* stack_trace_string = ToCString(stack_trace); | 368 const char* stack_trace_string = ToCString(stack_trace); |
368 fprintf(stderr, "%s\n", stack_trace_string); | 369 fprintf(stderr, "%s\n", stack_trace_string); |
369 } | 370 } |
370 } | 371 } |
371 } | 372 } |
OLD | NEW |