#include "InterpreterV8.h" InterpreterV8 *InterpreterV8::This = 0; #ifdef HAVE_V8 #include #include #include #include using namespace std; using namespace v8; bool InterpreterV8::ReportException(TryCatch* try_catch) { const HandleScope handle_scope; const String::Utf8Value exception(try_catch->Exception()); if (*exception && string(*exception)=="exit") return true; const Handle message = try_catch->Message(); // Print (filename):(line number): (message). const String::Utf8Value filename(message->GetScriptResourceName()); ostringstream out; if (*filename) out << *filename; if (!message.IsEmpty()) out << ": l." << message->GetLineNumber(); if (*exception) out << ": " << *exception; JsException(out.str()); if (message.IsEmpty()) return false; // Print line of source code. const String::Utf8Value sourceline(message->GetSourceLine()); if (*sourceline) JsException(*sourceline); // Print wavy underline (GetUnderline is deprecated). const int start = message->GetStartColumn(); const int end = message->GetEndColumn(); out.str(""); if (start>0) out << setfill(' ') << setw(start) << ' '; out << setfill('^') << setw(end-start) << '^'; JsException(out.str()); String::Utf8Value stack_trace(try_catch->StackTrace()); if (stack_trace.length()<=0) return false; //if (*stack_trace) // JsException(string("\n")+*stack_trace); return false; } // Executes a string within the current v8 context. bool InterpreterV8::ExecuteStringNT(const Handle &code, const Handle &file) { if (code.IsEmpty()) return true; const HandleScope handle_scope; const Handle