本文整理汇总了C++中ExecState::exception方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::exception方法的具体用法?C++ ExecState::exception怎么用?C++ ExecState::exception使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
{
ASSERT(m_callback);
ASSERT(m_frame);
if (!m_frame->script()->isEnabled())
return true;
JSGlobalObject* globalObject = m_frame->script()->globalObject();
ExecState* exec = globalObject->globalExec();
KJS::JSLock lock;
JSValue* handleEventFunction = m_callback->get(exec, Identifier(exec, "handleEvent"));
CallData handleEventCallData;
CallType handleEventCallType = handleEventFunction->getCallData(handleEventCallData);
CallData callbackCallData;
CallType callbackCallType = CallTypeNone;
if (handleEventCallType == CallTypeNone) {
callbackCallType = m_callback->getCallData(callbackCallData);
if (callbackCallType == CallTypeNone) {
// FIXME: Should an exception be thrown here?
return true;
}
}
RefPtr<JSCustomSQLStatementErrorCallback> protect(this);
ArgList args;
args.append(toJS(exec, transaction));
args.append(toJS(exec, error));
JSValue* result;
globalObject->startTimeoutCheck();
if (handleEventCallType != CallTypeNone)
result = call(exec, handleEventFunction, handleEventCallType, handleEventCallData, m_callback, args);
else
result = call(exec, m_callback, callbackCallType, callbackCallData, m_callback, args);
globalObject->stopTimeoutCheck();
if (exec->hadException()) {
JSObject* exception = exec->exception()->toObject(exec);
String message = exception->get(exec, exec->propertyNames().message)->toString(exec);
int lineNumber = exception->get(exec, Identifier(exec, "line"))->toInt32(exec);
String sourceURL = exception->get(exec, Identifier(exec, "sourceURL"))->toString(exec);
m_frame->domWindow()->console()->addMessage(JSMessageSource, ErrorMessageLevel, message, lineNumber, sourceURL);
exec->clearException();
// The spec says:
// "If the error callback returns false, then move on to the next statement..."
// "Otherwise, the error callback did not return false, or there was no error callback"
// Therefore an exception and returning true are the same thing - so, return true on an exception
return true;
}
Document::updateDocumentsRendering();
return result->toBoolean(exec);
}
示例2: JSObjectCallAsFunction
JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
JSObject* jsThisObject = toJS(thisObject);
if (!jsThisObject)
jsThisObject = exec->globalThisValue();
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(exec, arguments[i]));
CallData callData;
CallType callType = jsObject->methodTable()->getCallData(jsObject, callData);
if (callType == CallTypeNone)
return 0;
JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
result = 0;
}
return result;
}
示例3: JSValueIsInstanceOfConstructor
bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return false;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue jsValue = toJS(exec, value);
JSObject* jsConstructor = toJS(constructor);
if (!jsConstructor->structure()->typeInfo().implementsHasInstance())
return false;
bool result = jsConstructor->hasInstance(exec, jsValue); // false if an exception is thrown
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
}
return result;
}
示例4: JSObjectCallAsConstructor
JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
if (!object)
return 0;
JSObject* jsObject = toJS(object);
ConstructData constructData;
ConstructType constructType = jsObject->methodTable()->getConstructData(jsObject, constructData);
if (constructType == ConstructTypeNone)
return 0;
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(exec, arguments[i]));
JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList));
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return result;
}
示例5: JSObjectMakeArray
JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap.registerThread();
JSLock lock(exec);
JSObject* result;
if (argumentCount) {
ArgList argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(arguments[i]));
result = constructArray(exec, argList);
} else
result = constructEmptyArray(exec);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
result = 0;
}
return toRef(result);
}
示例6: JSObjectMakeRegExp
JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
JSObject* result = constructRegExp(exec, exec->lexicalGlobalObject(), argList);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例7: JSObjectSetProperty
void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->vm()));
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name)) {
PropertyDescriptor desc(jsValue, attributes);
jsObject->methodTable()->defineOwnProperty(jsObject, exec, name, desc, false);
} else {
PutPropertySlot slot(jsObject);
jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
}
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
}
}
示例8: JSObjectCallAsConstructor
JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
ExecState* exec = toJS(ctx);
exec->globalData().heap->registerThread();
JSLock lock(exec);
JSObject* jsObject = toJS(object);
ConstructData constructData;
ConstructType constructType = jsObject->getConstructData(constructData);
if (constructType == ConstructTypeNone)
return 0;
ArgList argList;
for (size_t i = 0; i < argumentCount; i++)
argList.append(toJS(arguments[i]));
JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
exec->clearException();
result = 0;
}
return result;
}
示例9: JSObjectMakeError
JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
JSLockHolder locker(exec);
JSValue message = argumentCount ? toJS(exec, arguments[0]) : jsUndefined();
Structure* errorStructure = exec->lexicalGlobalObject()->errorStructure();
JSObject* result = ErrorInstance::create(exec, errorStructure, message);
if (exec->hadException()) {
JSValue exceptionValue = exec->exception();
if (exception)
*exception = toRef(exec, exceptionValue);
exec->clearException();
#if ENABLE(REMOTE_INSPECTOR)
exec->vmEntryGlobalObject()->inspectorController().reportAPIException(exec, exceptionValue);
#endif
result = 0;
}
return toRef(result);
}
示例10: JSObjectMakeFunction
JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
Identifier nameID = name ? name->identifier(&exec->vm()) : Identifier(exec, "anonymous");
MarkedArgumentBuffer args;
for (unsigned i = 0; i < parameterCount; i++)
args.append(jsString(exec, parameterNames[i]->string()));
args.append(jsString(exec, body->string()));
JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL->string(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
result = 0;
}
return toRef(result);
}
示例11: JSObjectMakeArray
JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return 0;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* result;
if (argumentCount) {
MarkedArgumentBuffer argList;
for (size_t i = 0; i < argumentCount; ++i)
argList.append(toJS(exec, arguments[i]));
result = constructArray(exec, static_cast<ArrayAllocationProfile*>(0), argList);
} else
result = constructEmptyArray(exec, 0);
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
result = 0;
}
return toRef(result);
}
示例12: JSObjectSetProperty
void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
{
if (!ctx) {
ASSERT_NOT_REACHED();
return;
}
ExecState* exec = toJS(ctx);
APIEntryShim entryShim(exec);
JSObject* jsObject = toJS(object);
Identifier name(propertyName->identifier(&exec->vm()));
JSValue jsValue = toJS(exec, value);
if (attributes && !jsObject->hasProperty(exec, name))
jsObject->methodTable()->putDirectVirtual(jsObject, exec, name, jsValue, attributes);
else {
PutPropertySlot slot;
jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot);
}
if (exec->hadException()) {
if (exception)
*exception = toRef(exec, exec->exception());
exec->clearException();
}
}
示例13: fireOnload
void NamespaceJS::fireOnload()
{
if (m_onload) {
AJOAGlobalObject* globalObject = OAGlobalObject::sharedInstance()->wrapper();
ASSERT(globalObject);
ExecState* exec = globalObject->globalExec();
AJLock lock(exec);
AJObject* callback = m_onload->optObject();
ASSERT(callback);
CallData callData;
CallType callType = callback->getCallData(callData);
if (callType != CallTypeNone) {
MarkedArgumentBuffer args;
AJ::call(exec, callback, callType, callData, globalObject, args);
if (exec->hadException())
reportAJException(exec, exec->exception());
} else
oa_error("Invalid call type for JS.onload: %d", callType);
}
}
示例14: slotEval
void KJSDebugWin::slotEval()
{
// Work out which execution state to use. If we're currently in a debugging session,
// use the current context - otherwise, use the global execution state from the interpreter
// corresponding to the currently displayed source file.
ExecState *exec;
Object thisobj;
if(m_execStates.isEmpty())
{
if(m_sourceSel->currentItem() < 0)
return;
SourceFile *sourceFile = m_sourceSelFiles.at(m_sourceSel->currentItem());
if(!sourceFile->interpreter)
return;
exec = sourceFile->interpreter->globalExec();
thisobj = exec->interpreter()->globalObject();
}
else
{
exec = m_execStates.top();
thisobj = exec->context().thisValue();
}
// Evaluate the js code from m_evalEdit
UString code(m_evalEdit->code());
QString msg;
KJSCPUGuard guard;
guard.start();
Interpreter *interp = exec->interpreter();
Object obj = Object::dynamicCast(interp->globalObject().get(exec, "eval"));
List args;
args.append(String(code));
m_evalDepth++;
Value retval = obj.call(exec, thisobj, args);
m_evalDepth--;
guard.stop();
// Print the return value or exception message to the console
if(exec->hadException())
{
Value exc = exec->exception();
exec->clearException();
msg = "Exception: " + exc.toString(interp->globalExec()).qstring();
}
else
{
msg = retval.toString(interp->globalExec()).qstring();
}
m_evalEdit->insert(msg + "\n");
updateContextList();
}
示例15: valueByEvaluatingJavaScriptFromString
JSValue* WebScriptCallFrame::valueByEvaluatingJavaScriptFromString(String script)
{
#if 0
ExecState* state = m_state;
JSGlobalObject* globObj = state->dynamicGlobalObject();
// find "eval"
JSObject* eval = 0;
if (state->scopeNode()) { // "eval" won't work without context (i.e. at global scope)
JSValue* v = globObj->get(state, "eval");
if (v->isObject() && static_cast<JSObject*>(v)->implementsCall())
eval = static_cast<JSObject*>(v);
else
// no "eval" - fallback operates on global exec state
state = globObj->globalExec();
}
JSValue* savedException = state->exception();
state->clearException();
UString code(script.utf8().data());
// evaluate
JSValue* scriptExecutionResult;
if (eval) {
List args;
args.append(jsString(code));
scriptExecutionResult = eval->call(state, 0, args);
} else
// no "eval", or no context (i.e. global scope) - use global fallback
scriptExecutionResult = Interpreter::evaluate(state, UString(), 0, code.data(), code.size(), globObj).value();
if (state->hadException())
scriptExecutionResult = state->exception(); // (may be redundant depending on which eval path was used)
state->setException(savedException);
return scriptExecutionResult;
#else
return jsNull();
#endif
}