本文整理汇总了C++中v8::Handle::Run方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::Run方法的具体用法?C++ Handle::Run怎么用?C++ Handle::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::Run方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMaxRecursionDepthExceeded
v8::Local<v8::Value> ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ScriptExecutionContext* context)
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
V8GCController::checkMemoryUsage();
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded();
if (handleOutOfMemory())
return v8::Local<v8::Value>();
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8RecursionScope recursionScope(context);
result = script->Run();
}
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
if (result.IsEmpty())
return v8::Local<v8::Value>();
crashIfV8IsDead();
return result;
}
示例2: RangeError
v8::Local<v8::Value> WorkerContextExecutionProxy::runScript(v8::Handle<v8::Script> script)
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
// Compute the source string and prevent against infinite recursion.
if (m_recursion >= kMaxRecursionDepth) {
v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
script = V8Proxy::compileScript(code, "", 0);
}
if (V8Proxy::handleOutOfMemory())
ASSERT(script.IsEmpty());
if (script.IsEmpty())
return v8::Local<v8::Value>();
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
m_recursion++;
result = script->Run();
m_recursion--;
}
// Handle V8 internal error situation (Out-of-memory).
if (result.IsEmpty())
return v8::Local<v8::Value>();
return result;
}
示例3: handleMaxRecursionDepthExceeded
v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> script, ExecutionContext* context, v8::Isolate* isolate)
{
TRACE_EVENT0("v8", "v8.run");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
if (script.IsEmpty())
return v8::Local<v8::Value>();
if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
RELEASE_ASSERT(!context->isIteratingOverObservers());
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8RecursionScope recursionScope(isolate, context);
result = script->Run();
}
if (result.IsEmpty())
return v8::Local<v8::Value>();
crashIfV8IsDead();
return result;
}
示例4: notHandledByInterceptor
v8::Local<v8::Value> V8Proxy::runScriptInternal(v8::Handle<v8::Script> script, bool isInlineCode)
#endif
{
if (script.IsEmpty())
return notHandledByInterceptor();
V8GCController::checkMemoryUsage();
// Compute the source string and prevent against infinite recursion.
if (m_recursion >= kMaxRecursionDepth) {
v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
// FIXME: Ideally, we should be able to re-use the origin of the
// script passed to us as the argument instead of using an empty string
// and 0 baseLine.
script = compileScript(code, "", 0);
}
if (handleOutOfMemory())
ASSERT(script.IsEmpty());
if (script.IsEmpty())
return notHandledByInterceptor();
// Save the previous value of the inlineCode flag and update the flag for
// the duration of the script invocation.
bool previousInlineCode = inlineCode();
setInlineCode(isInlineCode);
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
V8ConsoleMessage::Scope scope;
// See comment in V8Proxy::callFunction.
m_frame->keepAlive();
m_recursion++;
result = script->Run();
m_recursion--;
}
// Release the storage mutex if applicable.
releaseStorageMutex();
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
// Handle V8 internal error situation (Out-of-memory).
if (result.IsEmpty())
return notHandledByInterceptor();
// Restore inlineCode flag.
setInlineCode(previousInlineCode);
if (v8::V8::IsDead())
handleFatalErrorInV8();
return result;
}
示例5: context
AdblockPlus::JsValuePtr AdblockPlus::JsEngine::Evaluate(const std::string& source,
const std::string& filename)
{
const JsContext context(shared_from_this());
const v8::TryCatch tryCatch;
const v8::Handle<v8::Script> script = CompileScript(isolate, source,
filename);
CheckTryCatch(tryCatch);
v8::Local<v8::Value> result = script->Run();
CheckTryCatch(tryCatch);
return JsValuePtr(new JsValue(shared_from_this(), result));
}
示例6: assert
v8::Handle<v8::Value>
run(v8::Handle<v8::Script> script, HandleTryCatch handleTryCatch)
{
assert(!script.IsEmpty());
assert(v8::Context::InContext());
v8::HandleScope handle_scope;
v8::TryCatch try_catch;
v8::Handle<v8::Value> result = script->Run();
if (try_catch.HasCaught()) {
handleTryCatch(try_catch);
}
return handle_scope.Close(result);
}
示例7: handleMaxRecursionDepthExceeded
v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script)
{
if (script.IsEmpty())
return v8::Local<v8::Value>();
V8GCController::checkMemoryUsage();
if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded();
if (handleOutOfMemory())
ASSERT(script.IsEmpty());
// Keep Frame (and therefore ScriptController and V8Proxy) alive.
RefPtr<Frame> protect(frame());
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
{
V8RecursionScope recursionScope(frame()->document());
result = script->Run();
}
if (handleOutOfMemory())
ASSERT(result.IsEmpty());
// Handle V8 internal error situation (Out-of-memory).
if (tryCatch.HasCaught()) {
ASSERT(result.IsEmpty());
return v8::Local<v8::Value>();
}
if (result.IsEmpty())
return v8::Local<v8::Value>();
if (v8::V8::IsDead())
handleFatalErrorInV8();
return result;
}