本文整理汇总了C++中JSValue::toThis方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toThis方法的具体用法?C++ JSValue::toThis怎么用?C++ JSValue::toThis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::toThis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate
JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, NakedPtr<Exception>& returnedException)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
RELEASE_ASSERT(!exec->vm().isCollectorBusy());
CodeProfiling profile(source);
ProgramExecutable* program = ProgramExecutable::create(exec, source);
if (!program) {
returnedException = exec->vm().exception();
exec->vm().clearException();
return jsUndefined();
}
if (!thisValue || thisValue.isUndefinedOrNull())
thisValue = exec->vmEntryGlobalObject();
JSObject* thisObj = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
JSValue result = exec->interpreter()->execute(program, exec, thisObj);
if (exec->hadException()) {
returnedException = exec->exception();
exec->clearException();
return jsUndefined();
}
RELEASE_ASSERT(result);
return result;
}
示例2: evaluate
JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, NakedPtr<Exception>& returnedException)
{
VM& vm = exec->vm();
JSLockHolder lock(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
RELEASE_ASSERT(!vm.isCollectorBusyOnCurrentThread());
CodeProfiling profile(source);
ProgramExecutable* program = ProgramExecutable::create(exec, source);
ASSERT(scope.exception() || program);
if (!program) {
returnedException = scope.exception();
scope.clearException();
return jsUndefined();
}
if (!thisValue || thisValue.isUndefinedOrNull())
thisValue = exec->vmEntryGlobalObject();
JSObject* thisObj = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
JSValue result = exec->interpreter()->execute(program, exec, thisObj);
if (scope.exception()) {
returnedException = scope.exception();
scope.clearException();
return jsUndefined();
}
RELEASE_ASSERT(result);
return result;
}
示例3: dateProtoFuncToJSON
EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
{
JSValue thisValue = exec->thisValue();
JSObject* object = jsCast<JSObject*>(thisValue.toThis(exec, NotStrictMode));
if (exec->hadException())
return JSValue::encode(jsNull());
JSValue toISOValue = object->get(exec, exec->vm().propertyNames->toISOString);
if (exec->hadException())
return JSValue::encode(jsNull());
CallData callData;
CallType callType = getCallData(toISOValue, callData);
if (callType == CallTypeNone)
return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString is not a function")));
JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
if (exec->hadException())
return JSValue::encode(jsNull());
if (result.isObject())
return throwVMError(exec, createTypeError(exec, ASCIILiteral("toISOString did not return a primitive value")));
return JSValue::encode(result);
}
示例4: thisValue
JSValue DebuggerCallFrame::thisValue() const
{
ASSERT(isValid());
if (!isValid())
return jsUndefined();
CodeBlock* codeBlock = nullptr;
JSValue thisValue;
if (isTailDeleted()) {
thisValue = m_shadowChickenFrame.thisValue;
codeBlock = m_shadowChickenFrame.codeBlock;
} else {
thisValue = m_validMachineFrame->thisValue();
codeBlock = m_validMachineFrame->codeBlock();
}
if (!thisValue)
return jsUndefined();
ECMAMode ecmaMode = NotStrictMode;
if (codeBlock && codeBlock->isStrictMode())
ecmaMode = StrictMode;
return thisValue.toThis(m_validMachineFrame, ecmaMode);
}