wvtest/javascript/v8shell.cc
bool ExecuteString(v8::Handle<v8::String> source,
                   v8::Handle<v8::Value> name,
                   bool print_result,
                   bool report_exceptions) {
  v8::HandleScope handle_scope;
  v8::TryCatch try_catch;
  v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
  if (script.IsEmpty()) {
    // Print errors that happened during compilation.
    if (report_exceptions)
      ReportException(&try_catch);
    return false;
  } else {
    v8::Handle<v8::Value> result = script->Run();
    if (result.IsEmpty()) {
      assert(try_catch.HasCaught());
      // Print errors that happened during execution.
      if (report_exceptions)
        ReportException(&try_catch);
      return false;
    } else {
      assert(!try_catch.HasCaught());
      if (print_result && !result->IsUndefined()) {
        // If all went well and the result wasn't undefined then print
        // the returned value.
        v8::String::Utf8Value str(result);
        printf("%s\n", ToCString(str));
      }
      return true;
    }
  }
}
// Executes a string within the current v8 context.
Executes a string within the current v8 context.
Executes a string within the current v8 context .
bool ExecuteString(v8::Handle<v8::String> source,
                   v8::Handle<v8::Value> name,
                   bool print_result,
                   bool report_exceptions) {
  v8::HandleScope handle_scope;
  v8::TryCatch try_catch;
  v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
  if (script.IsEmpty()) {
    if (report_exceptions)
      ReportException(&try_catch);
    return false;
  } else {
    v8::Handle<v8::Value> result = script->Run();
    if (result.IsEmpty()) {
      assert(try_catch.HasCaught());
      if (report_exceptions)
        ReportException(&try_catch);
      return false;
    } else {
      assert(!try_catch.HasCaught());
      if (print_result && !result->IsUndefined()) {
        v8::String::Utf8Value str(result);
        printf("%s\n", ToCString(str));
      }
      return true;
    }
  }
}
bool ExecuteString ( v8 :: Handle < v8 :: String > source , v8 :: Handle < v8 :: Value > name , bool print_result , bool report_exceptions ) { v8 :: HandleScope handle_scope ; v8 :: TryCatch try_catch ; v8 :: Handle < v8 :: Script > script = v8 :: Script :: Compile ( source , name ) ; if ( script . IsEmpty ( ) ) { if ( report_exceptions ) ReportException ( & try_catch ) ; return false ; } else { v8 :: Handle < v8 :: Value > result = script -> Run ( ) ; if ( result . IsEmpty ( ) ) { assert ( try_catch . HasCaught ( ) ) ; if ( report_exceptions ) ReportException ( & try_catch ) ; return false ; } else { assert ( ! try_catch . HasCaught ( ) ) ; if ( print_result && ! result -> IsUndefined ( ) ) { v8 :: String :: Utf8Value str ( result ) ; printf ( " \n " , ToCString ( str ) ) ; } return true ; } } }
Executes a string within the current v8 context.
Executes a string within the current v8 context .
// Print errors that happened during compilation. // Print errors that happened during execution. // If all went well and the result wasn't undefined then print // the returned value.