diff options
Diffstat (limited to 'src/qml/jsruntime/qv4math_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4math_p.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h index 90246c4229..a60a49a811 100644 --- a/src/qml/jsruntime/qv4math_p.h +++ b/src/qml/jsruntime/qv4math_p.h @@ -66,27 +66,42 @@ QT_BEGIN_NAMESPACE namespace QV4 { -static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b) +static inline QMLJS_READONLY ReturnedValue add_int32(int a, int b, quint8 *traceInfo = nullptr) { int result; - if (Q_UNLIKELY(add_overflow(a, b, &result))) + if (Q_UNLIKELY(add_overflow(a, b, &result))) { + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Double); return Value::fromDouble(static_cast<double>(a) + b).asReturnedValue(); + } + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Integer); return Value::fromInt32(result).asReturnedValue(); } -static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b) +static inline QMLJS_READONLY ReturnedValue sub_int32(int a, int b, quint8 *traceInfo = nullptr) { int result; - if (Q_UNLIKELY(sub_overflow(a, b, &result))) + if (Q_UNLIKELY(sub_overflow(a, b, &result))) { + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Double); return Value::fromDouble(static_cast<double>(a) - b).asReturnedValue(); + } + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Integer); return Value::fromInt32(result).asReturnedValue(); } -static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b) +static inline QMLJS_READONLY ReturnedValue mul_int32(int a, int b, quint8 *traceInfo = nullptr) { int result; - if (Q_UNLIKELY(mul_overflow(a, b, &result))) + if (Q_UNLIKELY(mul_overflow(a, b, &result))) { + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Double); return Value::fromDouble(static_cast<double>(a) * b).asReturnedValue(); + } + if (traceInfo) + *traceInfo |= quint8(QV4::ObservedTraceValues::Integer); return Value::fromInt32(result).asReturnedValue(); } |