diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-04-24 18:05:46 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-30 11:23:08 +0200 |
commit | 8635e5b300298c01ada7dc51bfca76c3f02bfc14 (patch) | |
tree | f7e797d9ab242c82659258ff4829a7e2a65ee1ed | |
parent | 88e2b6316effd0a570b49e7e9f6f6378078c12a4 (diff) |
Use QV4::Scope::hasException() where applicable
It is shorter and encapsulates the exception handling a bit.
Change-Id: I8e2dc0eb3b930e222b8cb4852b73d99ca18a0379
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
26 files changed, 107 insertions, 108 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 7e05769941..0fce7426ec 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -112,7 +112,7 @@ void JavaScriptJob::run() script.inheritContext = true; script.parse(); QV4::ScopedValue result(scope); - if (!scope.engine->hasException) { + if (!scope.hasException()) { if (frame) { QV4::ScopedValue thisObject(scope, frame->thisObject()); result = script.run(thisObject); @@ -120,7 +120,7 @@ void JavaScriptJob::run() result = script.run(); } } - if (scope.engine->hasException) { + if (scope.hasException()) { result = scope.engine->catchException(); resultIsException = true; } diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 03c5ba8679..e7d784ef29 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -554,11 +554,11 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in script.strictMode = v4->globalCode->isStrict(); script.inheritContext = true; script.parse(); - if (!scope.engine->hasException) + if (!scope.hasException()) result = script.run(); if (exceptionStackTrace) exceptionStackTrace->clear(); - if (scope.engine->hasException) { + if (scope.hasException()) { QV4::StackTrace trace; result = v4->catchException(&trace); if (exceptionStackTrace) { diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 3b361bcaf5..b32ff6a0dd 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -67,13 +67,13 @@ ReturnedValue SharedArrayBufferCtor::virtualCallAsConstructor(const FunctionObje return scope.engine->throwTypeError(); qint64 len = argc ? argv[0].toIndex() : 0; - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); if (len < 0 || len >= INT_MAX) return scope.engine->throwRangeError(QStringLiteral("SharedArrayBuffer: Invalid length.")); Scoped<SharedArrayBuffer> a(scope, scope.engine->memoryManager->allocate<SharedArrayBuffer>(len)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); return a->asReturnedValue(); @@ -105,7 +105,7 @@ ReturnedValue ArrayBufferCtor::virtualCallAsConstructor(const FunctionObject *f, if (o) a->setPrototypeOf(o); } - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); return a->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 03e5c29973..3ecc56dbf5 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -258,7 +258,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V mapArguments[0] = *nextValue; mapArguments[1] = Value::fromDouble(k); mappedValue = mapfn->call(thisArg, mapArguments, 2); - if (scope.engine->hasException) + if (scope.hasException()) return Runtime::IteratorClose::call(scope.engine, iterator, Value::fromBoolean(false)); } else { mappedValue = *nextValue; @@ -271,7 +271,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k)); } - if (scope.engine->hasException) { + if (scope.hasException()) { ScopedValue falsey(scope, Encode(false)); return Runtime::IteratorClose::call(scope.engine, iterator, falsey); } @@ -423,7 +423,7 @@ ReturnedValue ArrayPrototype::method_concat(const FunctionObject *b, const Value } else if (eltAsObj && eltAsObj->isConcatSpreadable()) { const uint startIndex = result->getLength(); const uint len = eltAsObj->getLength(); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); for (uint i = 0; i < len; ++i) { diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 3e6417af57..2eb773bd75 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -173,9 +173,9 @@ void QV4Include::finished() QV4::Script script(v4, qml, /*parse as QML binding*/false, code, m_url.toString()); script.parse(); - if (!scope.engine->hasException) + if (!scope.hasException()) script.run(); - if (scope.engine->hasException) { + if (scope.hasException()) { QV4::ScopedValue ex(scope, scope.engine->catchException()); resultObj->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Exception))); QV4::ScopedString exception(scope, v4->newString(QStringLiteral("exception"))); @@ -245,9 +245,9 @@ QJSValue QV4Include::method_include(QV4::ExecutionEngine *engine, const QUrl &ur if (!script.isNull()) { script->parse(); - if (!scope.engine->hasException) + if (!scope.hasException()) script->run(); - if (scope.engine->hasException) { + if (scope.hasException()) { QV4::ScopedValue ex(scope, scope.engine->catchException()); result = resultValue(scope.engine, Exception); QV4::ScopedString exception(scope, scope.engine->newString(QStringLiteral("exception"))); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index a3ffdb5431..18f9e17f11 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -957,7 +957,7 @@ ReturnedValue JsonObject::method_stringify(const FunctionObject *b, const Value ScopedValue arg0(scope, argc ? argv[0] : Value::undefinedValue()); QString result = stringify.Str(QString(), arg0); - if (result.isEmpty() || scope.engine->hasException) + if (result.isEmpty() || scope.hasException()) RETURN_UNDEFINED(); return Encode(scope.engine->newString(result)); } diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 0044e0bc68..e758384a84 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -306,7 +306,7 @@ ReturnedValue NumberPrototype::method_toPrecision(const FunctionObject *b, const { Scope scope(b); ScopedValue v(scope, thisNumberValue(scope.engine, thisObject)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); double d = v->asDouble(); @@ -314,7 +314,7 @@ ReturnedValue NumberPrototype::method_toPrecision(const FunctionObject *b, const return Encode(v->toString(scope.engine)); int precision = argv[0].toInt32(); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); if (std::isnan(d)) diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 2ad1ecb6e3..bc7e15d315 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -460,7 +460,7 @@ ReturnedValue Object::internalGet(PropertyKey id, const Value *receiver, bool *h bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver) { Scope scope(this); - if (scope.engine->hasException) + if (scope.hasException()) return false; Object *r = receiver->objectValue(); @@ -523,7 +523,7 @@ bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver) jsCallData.args[0] = value; *jsCallData.thisObject = *receiver; setter->call(jsCallData); - return !scope.engine->hasException; + return !scope.hasException(); } // Data property @@ -566,7 +566,7 @@ bool Object::internalDeleteProperty(PropertyKey id) if (id.isArrayIndex()) { uint index = id.asArrayIndex(); Scope scope(engine()); - if (scope.engine->hasException) + if (scope.hasException()) return false; Scoped<ArrayData> ad(scope, arrayData()); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 0c8cc192fc..584f78727f 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -137,7 +137,7 @@ ReturnedValue ObjectPrototype::method_getPrototypeOf(const FunctionObject *b, co return scope.engine->throwTypeError(); ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject p(scope, o->getPrototypeOf()); @@ -160,7 +160,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj return scope.engine->throwTypeError(); ScopedObject O(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); if (ArgumentsObject::isNonStrictArgumentsObject(O)) @@ -168,7 +168,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj ScopedValue v(scope, argc > 1 ? argv[1] : Value::undefinedValue()); ScopedPropertyKey name(scope, v->toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedProperty desc(scope); @@ -183,7 +183,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptors(const FunctionOb return scope.engine->throwTypeError(); ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); ScopedObject descriptors(scope, scope.engine->newObject()); @@ -212,7 +212,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(const FunctionObject * return scope.engine->throwTypeError(); ScopedObject O(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); return Encode(getOwnPropertyNames(scope.engine, argv[0])); @@ -252,7 +252,7 @@ ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Valu return scope.engine->throwTypeError(); ScopedObject to(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); if (argc == 1) @@ -263,7 +263,7 @@ ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Valu continue; ScopedObject from(scope, argv[i].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); QV4::ScopedArrayObject keys(scope, QV4::ObjectPrototype::getOwnPropertyNames(scope.engine, from)); quint32 length = keys->getLength(); @@ -284,7 +284,7 @@ ReturnedValue ObjectPrototype::method_assign(const FunctionObject *b, const Valu propValue = from->get(nextKey); to->set(nextKey, propValue, Object::DoThrowOnRejection); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); } } @@ -322,14 +322,14 @@ ReturnedValue ObjectPrototype::method_defineProperty(const FunctionObject *b, co ScopedObject O(scope, argv[0]); ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue()); ScopedProperty pd(scope); PropertyAttributes attrs; toPropertyDescriptor(scope.engine, attributes, pd, &attrs); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); if (!O->defineOwnProperty(name, pd, attrs)) @@ -347,7 +347,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b, ScopedObject O(scope, argv[0]); ScopedObject o(scope, argv[1].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedValue val(scope); @@ -364,7 +364,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b, PropertyAttributes nattrs; val = o->getValue(pd->value, attrs); toPropertyDescriptor(scope.engine, val, n, &nattrs); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); bool ok = O->defineOwnProperty(key, n, nattrs); if (!ok) @@ -381,7 +381,7 @@ ReturnedValue ObjectPrototype::method_entries(const FunctionObject *f, const Val return scope.engine->throwTypeError(); ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); ScopedArrayObject a(scope, scope.engine->newArrayObject()); @@ -405,7 +405,7 @@ ReturnedValue ObjectPrototype::method_entries(const FunctionObject *f, const Val entry = a->get(PropertyKey::fromArrayIndex(i)); name = entry->get(PropertyKey::fromArrayIndex(0)); value = o->get(name->toPropertyKey()); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); entry->push_back(value); } @@ -560,7 +560,7 @@ ReturnedValue ObjectPrototype::method_keys(const FunctionObject *b, const Value return scope.engine->throwTypeError(); ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedArrayObject a(scope, scope.engine->newArrayObject()); @@ -602,7 +602,7 @@ ReturnedValue ObjectPrototype::method_values(const FunctionObject *f, const Valu return scope.engine->throwTypeError(); ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedArrayObject a(scope, scope.engine->newArrayObject()); @@ -679,10 +679,10 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(const FunctionObject *b, co { Scope scope(b); ScopedPropertyKey P(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject O(scope, thisObject->toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); bool r = O->getOwnProperty(P) != Attr_Invalid; return Encode(r); @@ -696,7 +696,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(const FunctionObject *b, con ScopedObject V(scope, argv[0]); ScopedObject O(scope, thisObject->toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject proto(scope, V->getPrototypeOf()); while (proto) { @@ -711,11 +711,11 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(const FunctionObject { Scope scope(b); ScopedPropertyKey p(scope, (argc ? argv[0] : Value::undefinedValue()).toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject o(scope, thisObject->toObject(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); PropertyAttributes attrs = o->getOwnProperty(p); return Encode(attrs.isEnumerable()); @@ -732,7 +732,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(const FunctionObject *b, cons THROW_TYPE_ERROR(); ScopedString prop(scope, argv[0], ScopedString::Convert); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject o(scope, thisObject); @@ -762,7 +762,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(const FunctionObject *b, cons THROW_TYPE_ERROR(); ScopedString prop(scope, argv[0], ScopedString::Convert); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedObject o(scope, thisObject); diff --git a/src/qml/jsruntime/qv4promiseobject.cpp b/src/qml/jsruntime/qv4promiseobject.cpp index 83bfba9b11..b6dba47897 100644 --- a/src/qml/jsruntime/qv4promiseobject.cpp +++ b/src/qml/jsruntime/qv4promiseobject.cpp @@ -235,7 +235,7 @@ void ReactionHandler::executeResolveThenable(ResolveThenableEvent *event) jsCallData.args[1] = reject; jsCallData.thisObject = event->thenable.as<QV4::Object>(); event->then.as<const FunctionObject>()->call(jsCallData); - if (scope.engine->hasException) { + if (scope.hasException()) { JSCallArguments rejectCallData(scope, 1); rejectCallData.args[0] = scope.engine->catchException(); Scoped<RejectWrapper> reject {scope, scope.engine->memoryManager->allocate<QV4::RejectWrapper>()}; @@ -428,7 +428,7 @@ ReturnedValue PromiseCtor::virtualCallAsConstructor(const FunctionObject *f, con THROW_TYPE_ERROR(); // throw a TypeError exception Scoped<PromiseObject> a(scope, scope.engine->newPromiseObject()); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); a->d()->state = Heap::PromiseObject::Pending; //4. Set promise.[[PromiseState]] to "pending" @@ -447,7 +447,7 @@ ReturnedValue PromiseCtor::virtualCallAsConstructor(const FunctionObject *f, con executor->call(jsCallData); // 9. Let completion be Call(executor, undefined, « resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]] »). - if (scope.engine->hasException) { + if (scope.hasException()) { ScopedValue exception {scope, scope.engine->catchException()}; JSCallArguments callData {scope, 1}; callData.args[0] = exception; @@ -1032,7 +1032,7 @@ ReturnedValue ResolveWrapper::virtualCall(const FunctionObject *f, const Value * // 8. Let then be Get(resolution, then) ScopedFunctionObject thenAction { scope, resolutionObject->get(thenName)}; // 9. If then is an abrupt completion, then - if (scope.engine->hasException) { + if (scope.hasException()) { // Return RecjectPromise(promise, then.[[Value]] ScopedValue thenValue {scope, scope.engine->catchException()}; promise->d()->setState(Heap::PromiseObject::Rejected); diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp index b223e73f0f..48bd3c78c2 100644 --- a/src/qml/jsruntime/qv4proxy.cpp +++ b/src/qml/jsruntime/qv4proxy.cpp @@ -97,7 +97,7 @@ ReturnedValue ProxyObject::virtualGet(const Managed *m, PropertyKey id, const Va JSCallData cdata(handler, args, 3); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); ScopedProperty targetDesc(scope); PropertyAttributes attributes = target->getOwnProperty(id, targetDesc); @@ -140,7 +140,7 @@ bool ProxyObject::virtualPut(Managed *m, PropertyKey id, const Value &value, Val JSCallData cdata(handler, args, 4); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException || !trapResult->toBoolean()) + if (scope.hasException() || !trapResult->toBoolean()) return false; ScopedProperty targetDesc(scope); PropertyAttributes attributes = target->getOwnProperty(id, targetDesc); @@ -181,7 +181,7 @@ bool ProxyObject::virtualDeleteProperty(Managed *m, PropertyKey id) JSCallData cdata(handler, args, 3); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException || !trapResult->toBoolean()) + if (scope.hasException() || !trapResult->toBoolean()) return false; ScopedProperty targetDesc(scope); PropertyAttributes attributes = target->getOwnProperty(id, targetDesc); @@ -217,7 +217,7 @@ bool ProxyObject::virtualHasProperty(const Managed *m, PropertyKey id) JSCallData cdata(handler, args, 2); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return false; bool result = trapResult->toBoolean(); if (!result) { @@ -260,7 +260,7 @@ PropertyAttributes ProxyObject::virtualGetOwnProperty(const Managed *m, Property JSCallData cdata(handler, args, 2); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return Attr_Invalid; if (!trapResult->isObject() && !trapResult->isUndefined()) { scope.engine->throwTypeError(); @@ -337,7 +337,7 @@ bool ProxyObject::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Pro JSCallData cdata(handler, args, 3); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - bool result = !scope.engine->hasException && trapResult->toBoolean(); + bool result = !scope.hasException() && trapResult->toBoolean(); if (!result) return false; @@ -388,7 +388,7 @@ bool ProxyObject::virtualIsExtensible(const Managed *m) JSCallData cdata(handler, args, 1); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return false; bool result = trapResult->toBoolean(); if (result != target->isExtensible()) { @@ -422,7 +422,7 @@ bool ProxyObject::virtualPreventExtensions(Managed *m) JSCallData cdata(handler, args, 1); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return false; bool result = trapResult->toBoolean(); if (result && target->isExtensible()) { @@ -460,7 +460,7 @@ Heap::Object *ProxyObject::virtualGetPrototypeOf(const Managed *m) JSCallData cdata(handler, args, 1); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return nullptr; if (!trapResult->isNull() && !trapResult->isObject()) { scope.engine->throwTypeError(); @@ -506,7 +506,7 @@ bool ProxyObject::virtualSetPrototypeOf(Managed *m, const Object *p) JSCallData cdata(handler, args, 2); ScopedValue trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - bool result = !scope.engine->hasException && trapResult->toBoolean(); + bool result = !scope.hasException() && trapResult->toBoolean(); if (!result) return false; if (!target->isExtensible()) { @@ -598,7 +598,7 @@ OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Val args[0] = target; JSCallData cdata(handler, args, 1); ScopedObject trapResult(scope, static_cast<const FunctionObject *>(trap.ptr)->call(cdata)); - if (scope.engine->hasException) + if (scope.hasException()) return nullptr; if (!trapResult) { scope.engine->throwTypeError(); @@ -610,7 +610,7 @@ OwnPropertyKeyIterator *ProxyObject::virtualOwnPropertyKeys(const Object *m, Val ScopedStringOrSymbol key(scope); for (uint i = 0; i < len; ++i) { key = trapResult->get(i); - if (scope.engine->hasException) + if (scope.hasException()) return nullptr; if (!key) { scope.engine->throwTypeError(); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 0a4f4658ed..49a43860df 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -797,8 +797,7 @@ bool QObjectWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, return false; } - - if (scope.engine->hasException || QQmlData::wasDeleted(that->d()->object())) + if (scope.hasException() || QQmlData::wasDeleted(that->d()->object())) return false; QQmlRefPointer<QQmlContextData> qmlContext = scope.engine->callingQmlContext(); diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp index 2a6c61f044..dbef5699d5 100644 --- a/src/qml/jsruntime/qv4reflect.cpp +++ b/src/qml/jsruntime/qv4reflect.cpp @@ -128,14 +128,14 @@ ReturnedValue Reflect::method_defineProperty(const FunctionObject *f, const Valu ScopedObject O(scope, argv[0]); ScopedPropertyKey name(scope, (argc > 1 ? argv[1] : Value::undefinedValue()).toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); ScopedValue attributes(scope, argc > 2 ? argv[2] : Value::undefinedValue()); ScopedProperty pd(scope); PropertyAttributes attrs; ObjectPrototype::toPropertyDescriptor(scope.engine, attributes, pd, &attrs); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); bool result = O->defineOwnProperty(name, pd, attrs); @@ -199,7 +199,7 @@ ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const const Value *index = argc > 1 ? &argv[1] : &undef; ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return false; return Encode(o->hasProperty(name)); @@ -268,7 +268,7 @@ ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const ScopedValue receiver(scope, argc >3 ? argv[3] : argv[0]); ScopedPropertyKey propertyKey(scope, index->toPropertyKey(scope.engine)); - if (scope.engine->hasException) + if (scope.hasException()) return false; bool result = o->put(propertyKey, val, receiver); return Encode(result); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 0ae7fbb180..354ff8e41b 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -330,7 +330,7 @@ Bool Runtime::DeleteProperty_NoThrow::call(ExecutionEngine *engine, const Value { Scope scope(engine); ScopedObject o(scope, base.toObject(engine)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); Q_ASSERT(o); @@ -1587,11 +1587,11 @@ static CallArgs createSpreadArguments(Scope &scope, Value *argv, int argc) // spread element ++i; it = Runtime::GetIterator::call(scope.engine, argv[i], /* ForInIterator */ 1); - if (scope.engine->hasException) + if (scope.hasException()) return { nullptr, 0 }; while (1) { done = Runtime::IteratorNext::call(scope.engine, it, v); - if (scope.engine->hasException) + if (scope.hasException()) return { nullptr, 0 }; Q_ASSERT(done->isBoolean()); if (done->booleanValue()) diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index e7063b05a4..cfac1f9569 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -385,7 +385,7 @@ public: argv[0] = m_v4->fromVariant(lhs); argv[1] = m_v4->fromVariant(rhs); QV4::ScopedValue result(scope, compare->call(m_v4->globalObject, argv, 2)); - if (scope.engine->hasException) + if (scope.hasException()) return false; return result->toNumber() < 0; } diff --git a/src/qml/jsruntime/qv4setobject.cpp b/src/qml/jsruntime/qv4setobject.cpp index 1664d1bd71..bbc2f5c391 100644 --- a/src/qml/jsruntime/qv4setobject.cpp +++ b/src/qml/jsruntime/qv4setobject.cpp @@ -90,7 +90,7 @@ ReturnedValue WeakSetCtor::construct(const FunctionObject *f, const Value *argv, return a.asReturnedValue(); adder->call(a, nextValue, 1); - if (scope.engine->hasException) { + if (scope.hasException()) { ScopedValue falsey(scope, Encode(false)); return Runtime::IteratorClose::call(scope.engine, iter, falsey); } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 14c1e3ed54..1d1a5b5814 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -266,14 +266,14 @@ ReturnedValue StringCtor::method_raw(const FunctionObject *f, const Value *, con while (1) { val = raw->get(nextIndex); result += val->toQString(); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); if (nextIndex + 1 == literalSegments) return scope.engine->newString(result)->asReturnedValue(); if (nextIndex < static_cast<uint>(argc)) result += argv[nextIndex].toQString(); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); ++nextIndex; } @@ -895,13 +895,13 @@ ReturnedValue StringPrototype::method_search(const FunctionObject *b, const Valu { Scope scope(b); QString string = getThisString(scope.engine, thisObject); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); Scoped<RegExpObject> regExp(scope, argc ? argv[0] : Value::undefinedValue()); if (!regExp) { regExp = scope.engine->regExpCtor()->callAsConstructor(argv, 1); - if (scope.engine->hasException) + if (scope.hasException()) return QV4::Encode::undefined(); Q_ASSERT(regExp); diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index c816465d76..319bde7033 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -297,7 +297,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, if (!argc || !argv[0].isObject()) { // ECMA 6 22.2.1.1 qint64 l = argc ? argv[0].toIndex() : 0; - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); // ### lift UINT_MAX restriction if (l < 0 || l > UINT_MAX) @@ -307,7 +307,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, scope.engine->throwRangeError(QStringLiteral("Non integer length for typed array.")); uint byteLength = len * operations[that->d()->type].bytesPerElement; Scoped<ArrayBuffer> buffer(scope, scope.engine->newArrayBuffer(byteLength)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); @@ -330,7 +330,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, uint destByteLength = byteLength*destElementSize/srcElementSize; Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(destByteLength)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); @@ -380,7 +380,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, return scope.engine->throwRangeError(QStringLiteral("new TypedArray: invalid length")); } else { double l = qBound(0., argv[2].toInteger(), (double)UINT_MAX); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); if (buffer->isDetachedBuffer()) return scope.engine->throwTypeError(); @@ -403,7 +403,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, ScopedObject o(scope, argc ? argv[0] : Value::undefinedValue()); uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length()))->toInteger(), (double)UINT_MAX); - if (scope.engine->hasException) + if (scope.hasException()) return scope.engine->throwTypeError(); uint elementSize = operations[that->d()->type].bytesPerElement; @@ -411,7 +411,7 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, if (mul_overflow(size_t(l), size_t(elementSize), &bufferSize)) return scope.engine->throwRangeError(QLatin1String("new TypedArray: invalid length")); Scoped<ArrayBuffer> newBuffer(scope, scope.engine->newArrayBuffer(bufferSize)); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); Scoped<TypedArray> array(scope, TypedArray::create(scope.engine, that->d()->type)); @@ -425,10 +425,10 @@ ReturnedValue TypedArrayCtor::virtualCallAsConstructor(const FunctionObject *f, while (idx < l) { val = o->get(idx); val = val->convertedToNumber(); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); array->d()->type->write(b, val); - if (scope.engine->hasException) + if (scope.hasException()) return Encode::undefined(); ++idx; b += elementSize; @@ -1393,7 +1393,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b, Scoped<ArrayBuffer> buffer(scope, a->d()->buffer); double doffset = argc >= 2 ? argv[1].toInteger() : 0; - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); if (!buffer || buffer->isDetachedBuffer()) return scope.engine->throwTypeError(); @@ -1407,12 +1407,12 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b, if (!srcTypedArray) { // src is a regular object ScopedObject o(scope, argv[0].toObject(scope.engine)); - if (scope.engine->hasException || !o) + if (scope.hasException() || !o) return scope.engine->throwTypeError(); double len = ScopedValue(scope, o->get(scope.engine->id_length()))->toNumber(); uint l = (uint)len; - if (scope.engine->hasException || l != len) + if (scope.hasException() || l != len) return scope.engine->throwTypeError(); const uint aLength = a->length(); @@ -1432,7 +1432,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_set(const FunctionObject *b, if (scope.hasException() || buffer->isDetachedBuffer()) return scope.engine->throwTypeError(); a->d()->type->write(b, val); - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); ++idx; b += elementSize; @@ -1554,7 +1554,7 @@ ReturnedValue IntrinsicTypedArrayPrototype::method_subarray(const FunctionObject if (end < begin) end = begin; - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); int newLen = end - begin; @@ -1707,7 +1707,7 @@ ReturnedValue IntrinsicTypedArrayCtor::method_from(const FunctionObject *f, cons } // Retrieve the next value. If the iteration ends, we're done here. done = Value::fromReturnedValue(Runtime::IteratorNext::call(scope.engine, lengthIterator, nextValue)); - if (scope.engine->hasException) + if (scope.hasException()) return Runtime::IteratorClose::call(scope.engine, lengthIterator, Value::fromBoolean(false)); if (done->toBoolean()) { break; @@ -1740,21 +1740,21 @@ ReturnedValue IntrinsicTypedArrayCtor::method_from(const FunctionObject *f, cons ScopedValue mappedValue(scope, Value::undefinedValue()); for (qint64 k = 0; k < iterableLength; ++k) { done = Value::fromReturnedValue(Runtime::IteratorNext::call(scope.engine, iterator, nextValue)); - if (scope.engine->hasException) + if (scope.hasException()) return Runtime::IteratorClose::call(scope.engine, iterator, Value::fromBoolean(false)); if (mapfn) { mapArguments[0] = *nextValue; mapArguments[1] = Value::fromDouble(k); mappedValue = mapfn->call(thisArg, mapArguments, 2); - if (scope.engine->hasException) + if (scope.hasException()) return Runtime::IteratorClose::call(scope.engine, iterator, Value::fromBoolean(false)); } else { mappedValue = *nextValue; } a->put(k, mappedValue); - if (scope.engine->hasException) + if (scope.hasException()) return Runtime::IteratorClose::call(scope.engine, iterator, Value::fromBoolean(false)); } return a.asReturnedValue(); diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index 6913a49f9c..f6d07d17d5 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -109,7 +109,7 @@ double Value::toNumberImpl(Value val) Scope scope(val.objectValue()->engine()); ScopedValue protectThis(scope, val); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(val, NUMBER_HINT)); - if (scope.engine->hasException) + if (scope.hasException()) return 0; return prim->toNumber(); } diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 3b0000ab02..474b99b728 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -974,7 +974,7 @@ bool AOTCompiledContext::callQmlContextPropertyLookup( } function->call(nullptr, args, types, argc); - return !scope.engine->hasException; + return !scope.hasException(); } void AOTCompiledContext::initCallQmlContextPropertyLookup(uint index) const @@ -1056,7 +1056,7 @@ bool AOTCompiledContext::callObjectPropertyLookup( } function->call(object, args, types, argc); - return !scope.engine->hasException; + return !scope.hasException(); } void AOTCompiledContext::initCallObjectPropertyLookup(uint index) const diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 598de8d3a0..5291d46adc 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -76,7 +76,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en callback->call(jsCallData); - if (scope.engine->hasException) { + if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); error.setDescription(error.description() + QLatin1String(" (exception occurred during delayed function evaluation)")); QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 1930c15e0d..870d983c02 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -317,7 +317,7 @@ bool QQmlTypeWrapper::virtualPut(Managed *m, PropertyKey id, const Value &value, Q_ASSERT(m->as<QQmlTypeWrapper>()); QQmlTypeWrapper *w = static_cast<QQmlTypeWrapper *>(m); QV4::Scope scope(w); - if (scope.engine->hasException) + if (scope.hasException()) return false; ScopedString name(scope, id.asStringOrSymbol()); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 67a26e4806..afa98fbd4f 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1594,7 +1594,7 @@ void QQmlXMLHttpRequest::dispatchCallbackNow(Object *thisObj, bool done, bool er QV4::JSCallArguments jsCallData(scope); callback->call(jsCallData); - if (scope.engine->hasException) { + if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); QQmlEnginePrivate *qmlEnginePrivate = scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : nullptr; QQmlEnginePrivate::warning(qmlEnginePrivate, error); diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 64b8b80f8b..0e978b3be0 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -2815,7 +2815,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_font(const QV4::FunctionObject CHECK_CONTEXT_SETTER(r) QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert); - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); QFont font = qt_font_from_string(s->toQString(), r->d()->context()->state.font); if (font != r->d()->context()->state.font) { @@ -2867,7 +2867,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(const QV4::FunctionOb CHECK_CONTEXT_SETTER(r) QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert); - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); QString textAlign = s->toQString(); @@ -2934,7 +2934,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(const QV4::Functio QV4::Scoped<QQuickJSContext2D> r(scope, *thisObject); CHECK_CONTEXT_SETTER(r) QV4::ScopedString s(scope, argc ? argv[0] : QV4::Value::undefinedValue(), QV4::ScopedString::Convert); - if (scope.engine->hasException) + if (scope.hasException()) RETURN_UNDEFINED(); QString textBaseline = s->toQString(); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d8d90b1aff..997f04d72e 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2641,7 +2641,7 @@ static inline bool evaluate_error(QV4::ExecutionEngine *v4, const QV4::Value &o, program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return true; } @@ -2649,7 +2649,7 @@ static inline bool evaluate_error(QV4::ExecutionEngine *v4, const QV4::Value &o, jsCallData.args[0] = o; *jsCallData.thisObject = v4->global(); function->call(jsCallData); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return true; } @@ -2667,7 +2667,7 @@ static inline bool evaluate_value(QV4::ExecutionEngine *v4, const QV4::Value &o, program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return false; } @@ -2679,7 +2679,7 @@ static inline bool evaluate_value(QV4::ExecutionEngine *v4, const QV4::Value &o, jsCallData.args[0] = o; *jsCallData.thisObject = v4->global(); value = function->call(jsCallData); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return false; } @@ -2698,7 +2698,7 @@ static inline QV4::ReturnedValue evaluate(QV4::ExecutionEngine *v4, const QV4::V program.inheritContext = true; QV4::ScopedFunctionObject function(scope, program.run()); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return QV4::Encode::undefined(); } @@ -2708,7 +2708,7 @@ static inline QV4::ReturnedValue evaluate(QV4::ExecutionEngine *v4, const QV4::V jsCallData.args[0] = o; *jsCallData.thisObject = v4->global(); QV4::ScopedValue result(scope, function->call(jsCallData)); - if (scope.engine->hasException) { + if (scope.hasException()) { scope.engine->catchException(); return QV4::Encode::undefined(); } diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index ba5e5f553c..28f3934253 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) script->parseAsBinding = runAsQml; script->parse(); } - if (!scope.engine->hasException) { + if (!scope.hasException()) { const auto unit = script->compilationUnit; if (cache && unit && !(unit->unitData()->flags & QV4::CompiledData::Unit::StaticData)) { if (unit->unitData()->sourceTimeStamp == 0) { @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) // std::cout << t.elapsed() << " ms. elapsed" << std::endl; } } - if (scope.engine->hasException) { + if (scope.hasException()) { QV4::StackTrace trace; QV4::ScopedValue ex(scope, scope.engine->catchException(&trace)); showException(ctx, ex, trace); |