diff options
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/jsruntime.pri | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arraydata.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 19 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p_p.h | 83 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dataview.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 50 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4dateobject_p.h | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mathobject.cpp | 64 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4numberobject.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 188 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 216 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 304 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 136 |
16 files changed, 664 insertions, 431 deletions
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri index c61e848bd7..6ef92511e2 100644 --- a/src/qml/jsruntime/jsruntime.pri +++ b/src/qml/jsruntime/jsruntime.pri @@ -49,6 +49,7 @@ HEADERS += \ $$PWD/qv4global_p.h \ $$PWD/qv4engine_p.h \ $$PWD/qv4context_p.h \ + $$PWD/qv4context_p_p.h \ $$PWD/qv4math_p.h \ $$PWD/qv4persistent_p.h \ $$PWD/qv4debugging_p.h \ @@ -98,6 +99,7 @@ HEADERS += \ HEADERS += \ $$PWD/qv4runtime_p.h \ + $$PWD/qv4runtimeapi_p.h \ $$PWD/qv4value_p.h \ $$PWD/qv4string_p.h \ $$PWD/qv4value_p.h diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 728ee38e76..73aa7047b8 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -676,7 +676,7 @@ bool ArrayElementLessThan::operator()(Value v1, Value v2) const callData->thisObject = Primitive::undefinedValue(); callData->args[0] = v1; callData->args[1] = v2; - result = Runtime::callValue(scope.engine, m_comparefn, callData); + result = scope.engine->runtime.callValue(scope.engine, m_comparefn, callData); return result->toNumber() < 0; } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 18983eb832..97b3e26a26 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -39,7 +39,7 @@ #include <QString> #include "qv4debugging_p.h" -#include <qv4context_p.h> +#include <qv4context_p_p.h> #include <qv4object_p.h> #include <qv4objectproto_p.h> #include <private/qv4mm_p.h> @@ -47,7 +47,6 @@ #include "qv4function_p.h" #include "qv4errorobject_p.h" #include "qv4string_p.h" -#include "private/qqmlcontextwrapper_p.h" using namespace QV4; @@ -574,19 +573,3 @@ Heap::FunctionObject *ExecutionContext::getFunctionObject() const return 0; } - - -QObject *QmlContext::qmlScope() const -{ - return d()->qml->scopeObject; -} - -QQmlContextData *QmlContext::qmlContext() const -{ - return d()->qml->context; -} - -void QmlContext::takeContextOwnership() { - d()->qml->ownsContext = true; -} - diff --git a/src/qml/jsruntime/qv4context_p_p.h b/src/qml/jsruntime/qv4context_p_p.h new file mode 100644 index 0000000000..0da9f678ed --- /dev/null +++ b/src/qml/jsruntime/qv4context_p_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QV4CONTEXT_P_P_H +#define QV4CONTEXT_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// This header defines a couple of inlinable methods. +// These implementation cannot be put in qv4context_p.h, because they rely on the +// QQmlContextWrapper, which in turn is a QV4::Object subclass (so it includes qv4object_p.h), +// which includes qv4engine_p.h, that needs to include qv4context_p.h + +#include "qv4context_p.h" +#include "private/qqmlcontextwrapper_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +QObject *QmlContext::qmlScope() const +{ + return d()->qml->scopeObject; +} + +QQmlContextData *QmlContext::qmlContext() const +{ + return d()->qml->context; +} + +void QmlContext::takeContextOwnership() { + d()->qml->ownsContext = true; +} + +} // QV4 namespace + +QT_END_NAMESPACE + +#endif // QV4CONTEXT_P_P_H diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index b4422bcdc6..f296ffd71e 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -41,6 +41,7 @@ #include "qv4arraybuffer_p.h" #include "qv4string_p.h" +#include <QtCore/private/qnumeric_p.h> #include "qendian.h" using namespace QV4; @@ -291,7 +292,7 @@ ReturnedValue DataViewPrototype::method_setFloat(CallContext *ctx) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qQNaN(); + double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qt_qnan(); bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean(); if (sizeof(T) == 4) { diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 7051d5c3a5..5783e8fa2b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -204,7 +204,7 @@ static inline double MonthFromTime(double t) else if (d < 365.0 + l) return 11; - return qQNaN(); // ### assert? + return qt_qnan(); // ### assert? } static inline double DateFromTime(double t) @@ -228,7 +228,7 @@ static inline double DateFromTime(double t) case 11: return d - 333.0 - l; } - return qQNaN(); // ### assert + return qt_qnan(); // ### assert } static inline double WeekDay(double t) @@ -260,7 +260,7 @@ static inline double DayFromMonth(double month, double leap) case 11: return 334.0 + leap; } - return qQNaN(); // ### assert? + return qt_qnan(); // ### assert? } static double MakeDay(double year, double month, double day) @@ -339,7 +339,7 @@ static inline double currentTime() static inline double TimeClip(double t) { if (! qIsFinite(t) || fabs(t) > 8.64e15) - return qQNaN(); + return qt_qnan(); return Primitive::toInteger(t); } @@ -466,7 +466,7 @@ static inline double ParseString(const QString &s) if (format < Minute || format >= TimezoneHour) error = true; format = TimezoneHour; - } else if (*ch == 'Z' || *ch == 0) { + } else if (*ch == 'Z' || ch->unicode() == 0) { format = Done; } current = 0; @@ -544,7 +544,7 @@ static inline double ParseString(const QString &s) } } if (!dt.isValid()) - return qQNaN(); + return qt_qnan(); return dt.toMSecsSinceEpoch(); } @@ -636,7 +636,7 @@ DEFINE_OBJECT_VTABLE(DateObject); Heap::DateObject::DateObject(const QDateTime &date) { - this->date = date.isValid() ? date.toMSecsSinceEpoch() : qQNaN(); + this->date = date.isValid() ? date.toMSecsSinceEpoch() : qt_qnan(); } QDateTime DateObject::toQDateTime() const @@ -770,7 +770,7 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(CallContext *ctx) { if (!ctx->argc()) - return Encode(qQNaN()); + return Encode(qt_qnan()); return Encode(ParseString(ctx->args()[0].toQString())); } @@ -1000,7 +1000,7 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx) if (!self) return ctx->engine()->throwTypeError(); - double t = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double t = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(t)); return Encode(self->date()); } @@ -1013,7 +1013,7 @@ ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return Encode(self->date()); } @@ -1025,7 +1025,7 @@ ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double ms = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); self->setDate(TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))); return Encode(self->date()); } @@ -1037,7 +1037,7 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->setDate(t); @@ -1051,7 +1051,7 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double sec = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))); self->setDate(t); @@ -1065,7 +1065,7 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); @@ -1080,7 +1080,7 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double min = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))); @@ -1095,7 +1095,7 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1111,7 +1111,7 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double hour = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); @@ -1127,7 +1127,7 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->setDate(t); return Encode(self->date()); @@ -1140,7 +1140,7 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double date = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))); self->setDate(t); return Encode(self->date()); @@ -1153,7 +1153,7 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date()); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->setDate(t); @@ -1167,7 +1167,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double month = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))); self->setDate(t); @@ -1185,10 +1185,10 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double r; if (std::isnan(year)) { - r = qQNaN(); + r = qt_qnan(); } else { if ((Primitive::toInteger(year) >= 0) && (Primitive::toInteger(year) <= 99)) year += 1900; @@ -1207,7 +1207,7 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) return ctx->engine()->throwTypeError(); double t = self->date(); - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))); @@ -1224,7 +1224,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) double t = LocalTime(self->date()); if (std::isnan(t)) t = 0; - double year = ctx->argc() ? ctx->args()[0].toNumber() : qQNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan(); double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index edf5d625fd..e3615d76a7 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -52,7 +52,7 @@ #include "qv4object_p.h" #include "qv4functionobject_p.h" -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> QT_BEGIN_NAMESPACE @@ -65,7 +65,7 @@ namespace Heap { struct DateObject : Object { DateObject() { - date = qQNaN(); + date = qt_qnan(); } DateObject(const Value &date) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 7da4a1c3c1..57a5952a6d 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -55,6 +55,7 @@ #include "qv4managed_p.h" #include "qv4context_p.h" #include "qv4internalclass_p.h" +#include "qv4runtimeapi_p.h" #include <private/qintrusivelist_p.h> namespace WTF { @@ -109,6 +110,8 @@ public: Value *jsStackLimit; quintptr cStackLimit; + Runtime runtime; + WTF::BumpPointerAllocator *bumperPointerAllocator; // Used by Yarr Regex engine. enum { JSStackLimit = 4*1024*1024 }; @@ -473,6 +476,13 @@ public: void assertObjectBelongsToEngine(const Heap::Base &baseObject); }; +// This is a trick to tell the code generators that functions taking a NoThrowContext won't +// throw exceptions and therefore don't need a check after the call. +struct NoThrowEngine : public ExecutionEngine +{ +}; + + inline void ExecutionEngine::pushContext(Heap::ExecutionContext *context) { Q_ASSERT(currentContext && context); diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 8c5e7d8be1..4a304b6138 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -42,7 +42,7 @@ #include <QtCore/qdatetime.h> #include <QtCore/qmath.h> -#include <QtCore/qnumeric.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/qthreadstorage.h> #include <cmath> @@ -100,7 +100,7 @@ static double copySign(double x, double y) ReturnedValue MathObject::method_abs(CallContext *context) { if (!context->argc()) - return Encode(qQNaN()); + return Encode(qt_qnan()); if (context->args()[0].isInteger()) { int i = context->args()[0].integerValue(); @@ -118,7 +118,7 @@ ReturnedValue MathObject::method_acos(CallContext *context) { double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) - return Encode(qQNaN()); + return Encode(qt_qnan()); return Encode(std::acos(v)); } @@ -127,14 +127,14 @@ ReturnedValue MathObject::method_asin(CallContext *context) { double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) - return Encode(qQNaN()); + return Encode(qt_qnan()); else return Encode(std::asin(v)); } ReturnedValue MathObject::method_atan(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v == 0.0) return Encode(v); else @@ -143,10 +143,10 @@ ReturnedValue MathObject::method_atan(CallContext *context) ReturnedValue MathObject::method_atan2(CallContext *context) { - double v1 = context->argc() ? context->args()[0].toNumber() : qQNaN(); - double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qQNaN(); + double v1 = context->argc() ? context->args()[0].toNumber() : qt_qnan(); + double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qt_qnan(); - if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0)) + if ((v1 < 0) && qt_is_finite(v1) && qt_is_inf(v2) && (copySign(1.0, v2) == 1.0)) return Encode(copySign(0, -1.0)); if ((v1 == 0.0) && (v2 == 0.0)) { @@ -161,7 +161,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context) ReturnedValue MathObject::method_ceil(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v < 0.0 && v > -1.0) return Encode(copySign(0, -1.0)); else @@ -170,18 +170,18 @@ ReturnedValue MathObject::method_ceil(CallContext *context) ReturnedValue MathObject::method_cos(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::cos(v)); } ReturnedValue MathObject::method_exp(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); - if (qIsInf(v)) { + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); + if (qt_is_inf(v)) { if (copySign(1.0, v) == -1.0) return Encode(0); else - return Encode(qInf()); + return Encode(qt_inf()); } else { return Encode(std::exp(v)); } @@ -189,22 +189,22 @@ ReturnedValue MathObject::method_exp(CallContext *context) ReturnedValue MathObject::method_floor(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::floor(v)); } ReturnedValue MathObject::method_log(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v < 0) - return Encode(qQNaN()); + return Encode(qt_qnan()); else return Encode(std::log(v)); } ReturnedValue MathObject::method_max(CallContext *context) { - double mx = -qInf(); + double mx = -qt_inf(); for (int i = 0; i < context->argc(); ++i) { double x = context->args()[i].toNumber(); if (x > mx || std::isnan(x)) @@ -215,7 +215,7 @@ ReturnedValue MathObject::method_max(CallContext *context) ReturnedValue MathObject::method_min(CallContext *context) { - double mx = qInf(); + double mx = qt_inf(); for (int i = 0; i < context->argc(); ++i) { double x = context->args()[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) @@ -228,24 +228,24 @@ ReturnedValue MathObject::method_min(CallContext *context) ReturnedValue MathObject::method_pow(CallContext *context) { - double x = context->argc() > 0 ? context->args()[0].toNumber() : qQNaN(); - double y = context->argc() > 1 ? context->args()[1].toNumber() : qQNaN(); + double x = context->argc() > 0 ? context->args()[0].toNumber() : qt_qnan(); + double y = context->argc() > 1 ? context->args()[1].toNumber() : qt_qnan(); if (std::isnan(y)) - return Encode(qQNaN()); + return Encode(qt_qnan()); if (y == 0) { return Encode(1); } else if (((x == 1) || (x == -1)) && std::isinf(y)) { - return Encode(qQNaN()); + return Encode(qt_qnan()); } else if (((x == 0) && copySign(1.0, x) == 1.0) && (y < 0)) { return Encode(qInf()); } else if ((x == 0) && copySign(1.0, x) == -1.0) { if (y < 0) { if (std::fmod(-y, 2.0) == 1.0) - return Encode(-qInf()); + return Encode(-qt_inf()); else - return Encode(qInf()); + return Encode(qt_inf()); } else if (y > 0) { if (std::fmod(y, 2.0) == 1.0) return Encode(copySign(0, -1.0)); @@ -255,12 +255,12 @@ ReturnedValue MathObject::method_pow(CallContext *context) } #ifdef Q_OS_AIX - else if (qIsInf(x) && copySign(1.0, x) == -1.0) { + else if (qt_is_inf(x) && copySign(1.0, x) == -1.0) { if (y > 0) { if (std::fmod(y, 2.0) == 1.0) - return Encode(-qInf()); + return Encode(-qt_inf()); else - return Encode(qInf()); + return Encode(qt_inf()); } else if (y < 0) { if (std::fmod(-y, 2.0) == 1.0) return Encode(copySign(0, -1.0)); @@ -273,7 +273,7 @@ ReturnedValue MathObject::method_pow(CallContext *context) return Encode(std::pow(x, y)); } // ### - return Encode(qQNaN()); + return Encode(qt_qnan()); } Q_GLOBAL_STATIC(QThreadStorage<bool *>, seedCreatedStorage); @@ -294,26 +294,26 @@ ReturnedValue MathObject::method_random(CallContext *context) ReturnedValue MathObject::method_round(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); v = copySign(std::floor(v + 0.5), v); return Encode(v); } ReturnedValue MathObject::method_sin(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::sin(v)); } ReturnedValue MathObject::method_sqrt(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); return Encode(std::sqrt(v)); } ReturnedValue MathObject::method_tan(CallContext *context) { - double v = context->argc() ? context->args()[0].toNumber() : qQNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qt_qnan(); if (v == 0.0) return Encode(v); else diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 5cf7dbebd8..ab3e03b183 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -95,7 +95,7 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor) ctor->defineReadonlyProperty(engine->id_prototype(), (o = this)); ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1)); - ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qQNaN())); + ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qt_qnan())); ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf())); ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf())); ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308)); @@ -149,7 +149,7 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx) if (std::isnan(num)) { return scope.engine->newString(QStringLiteral("NaN"))->asReturnedValue(); - } else if (qIsInf(num)) { + } else if (qt_is_inf(num)) { return scope.engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue(); } @@ -223,7 +223,7 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) QString str; if (std::isnan(v)) str = QStringLiteral("NaN"); - else if (qIsInf(v)) + else if (qt_is_inf(v)) str = QString::fromLatin1(v < 0 ? "-Infinity" : "Infinity"); else if (v < 1.e21) str = NumberLocale::instance()->toString(v, 'f', int(fdigits)); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 470791fb00..fca218d9d0 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1591,12 +1591,6 @@ void CallArgument::fromValue(int callType, QV4::ExecutionEngine *engine, const Q else qstringPtr = new (&allocData) QString(value.toQStringNoThrow()); type = callType; - } else if (callType == QMetaType::QByteArray) { - if (const ArrayBuffer *ab = value.as<ArrayBuffer>()) - qbyteArrayPtr = new (&allocData) QByteArray(ab->asByteArray()); - else - qbyteArrayPtr = new (&allocData) QByteArray(); - type = callType; } else if (callType == QMetaType::QObjectStar) { qobjectPtr = 0; if (const QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>()) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 373e7fc8de..2abe6eeb06 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -225,7 +225,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) if (std::isnan(num)) { *result = QStringLiteral("NaN"); return; - } else if (qIsInf(num)) { + } else if (qt_is_inf(num)) { *result = num < 0 ? QStringLiteral("-Infinity") : QStringLiteral("Infinity"); return; } @@ -297,14 +297,14 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) result->prepend(QLatin1Char('-')); } -ReturnedValue Runtime::closure(ExecutionEngine *engine, int functionId) +ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId) { QV4::Function *clos = engine->current->compilationUnit->runtimeFunctions[functionId]; Q_ASSERT(clos); return FunctionObject::createScriptFunction(engine->currentContext, clos)->asReturnedValue(); } -ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const Value &base, const Value &index) +ReturnedValue Runtime::method_deleteElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); ScopedObject o(scope, base); @@ -316,17 +316,17 @@ ReturnedValue Runtime::deleteElement(ExecutionEngine *engine, const Value &base, } ScopedString name(scope, index.toString(engine)); - return Runtime::deleteMemberString(engine, base, name); + return method_deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex) +ReturnedValue Runtime::method_deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); - return deleteMemberString(engine, base, name); + return method_deleteMemberString(engine, base, name); } -ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const Value &base, String *name) +ReturnedValue Runtime::method_deleteMemberString(ExecutionEngine *engine, const Value &base, String *name) { Scope scope(engine); ScopedObject obj(scope, base.toObject(engine)); @@ -335,14 +335,14 @@ ReturnedValue Runtime::deleteMemberString(ExecutionEngine *engine, const Value & return Encode(obj->deleteProperty(name)); } -ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex) +ReturnedValue Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); return Encode(engine->currentContext->deleteProperty(name)); } -QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Value &left, const Value &right) { Scope scope(engine); ScopedFunctionObject f(scope, right.as<FunctionObject>()); @@ -372,7 +372,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &lef return Encode(false); } -QV4::ReturnedValue Runtime::in(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right) { if (!right.isObject()) return engine->throwTypeError(); @@ -561,7 +561,7 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu return Encode(x + y); } -QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left, const Value &right) +QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Value &left, const Value &right) { Q_ASSERT(left.isString() || right.isString()); @@ -592,7 +592,7 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); } -void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) +void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -602,7 +602,7 @@ void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int name o->put(name, value); } -ReturnedValue Runtime::getElement(ExecutionEngine *engine, const Value &object, const Value &index) +ReturnedValue Runtime::method_getElement(ExecutionEngine *engine, const Value &object, const Value &index) { Scope scope(engine); uint idx = index.asArrayIndex(); @@ -645,7 +645,7 @@ ReturnedValue Runtime::getElement(ExecutionEngine *engine, const Value &object, return o->get(name); } -void Runtime::setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) +void Runtime::method_setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { Scope scope(engine); ScopedObject o(scope, object.toObject(engine)); @@ -669,7 +669,7 @@ void Runtime::setElement(ExecutionEngine *engine, const Value &object, const Val o->put(name, value); } -ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const Value &in) +ReturnedValue Runtime::method_foreachIterator(ExecutionEngine *engine, const Value &in) { Scope scope(engine); ScopedObject o(scope, (Object *)0); @@ -678,7 +678,7 @@ ReturnedValue Runtime::foreachIterator(ExecutionEngine *engine, const Value &in) return engine->newForEachIteratorObject(o)->asReturnedValue(); } -ReturnedValue Runtime::foreachNextPropertyName(const Value &foreach_iterator) +ReturnedValue Runtime::method_foreachNextPropertyName(const Value &foreach_iterator) { Q_ASSERT(foreach_iterator.isObject()); @@ -689,14 +689,14 @@ ReturnedValue Runtime::foreachNextPropertyName(const Value &foreach_iterator) } -void Runtime::setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value) +void Runtime::method_setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); engine->currentContext->setProperty(name, value); } -ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const Value &object, int nameIndex) +ReturnedValue Runtime::method_getProperty(ExecutionEngine *engine, const Value &object, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -716,7 +716,7 @@ ReturnedValue Runtime::getProperty(ExecutionEngine *engine, const Value &object, return o->get(name); } -ReturnedValue Runtime::getActivationProperty(ExecutionEngine *engine, int nameIndex) +ReturnedValue Runtime::method_getActivationProperty(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -742,9 +742,9 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) double dx = RuntimeHelpers::toNumber(x); return dx == y.asDouble(); } else if (x.isBoolean()) { - return Runtime::compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); + return Runtime::method_compareEqual(Primitive::fromDouble((double) x.booleanValue()), y); } else if (y.isBoolean()) { - return Runtime::compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); + return Runtime::method_compareEqual(x, Primitive::fromDouble((double) y.booleanValue())); } else { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); @@ -752,11 +752,11 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) if ((x.isNumber() || x.isString()) && y.isObject()) { Scope scope(y.objectValue()->engine()); ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(x, py); + return Runtime::method_compareEqual(x, py); } else if (x.isObject() && (y.isNumber() || y.isString())) { Scope scope(x.objectValue()->engine()); ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT)); - return Runtime::compareEqual(px, y); + return Runtime::method_compareEqual(px, y); } #endif } @@ -779,7 +779,7 @@ Bool RuntimeHelpers::strictEqual(const Value &x, const Value &y) return false; } -QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -803,7 +803,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterThan(pl, pr); + return Runtime::method_compareGreaterThan(pl, pr); #endif } @@ -812,7 +812,7 @@ QV4::Bool Runtime::compareGreaterThan(const Value &l, const Value &r) return dl > dr; } -QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -836,7 +836,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessThan(pl, pr); + return Runtime::method_compareLessThan(pl, pr); #endif } @@ -845,7 +845,7 @@ QV4::Bool Runtime::compareLessThan(const Value &l, const Value &r) return dl < dr; } -QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -869,7 +869,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareGreaterEqual(pl, pr); + return Runtime::method_compareGreaterEqual(pl, pr); #endif } @@ -878,7 +878,7 @@ QV4::Bool Runtime::compareGreaterEqual(const Value &l, const Value &r) return dl >= dr; } -QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) +QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) { TRACE2(l, r); if (l.isInteger() && r.isInteger()) @@ -902,7 +902,7 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) QV4::Scope scope(e); QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); - return Runtime::compareLessEqual(pl, pr); + return Runtime::method_compareLessEqual(pl, pr); #endif } @@ -912,26 +912,26 @@ QV4::Bool Runtime::compareLessEqual(const Value &l, const Value &r) } #ifndef V4_BOOTSTRAP -Bool Runtime::compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) +Bool Runtime::method_compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); Scope scope(engine); - ScopedValue v(scope, Runtime::instanceof(engine, left, right)); + ScopedValue v(scope, method_instanceof(engine, left, right)); return v->booleanValue(); } -uint Runtime::compareIn(ExecutionEngine *engine, const Value &left, const Value &right) +uint Runtime::method_compareIn(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); Scope scope(engine); - ScopedValue v(scope, Runtime::in(engine, left, right)); + ScopedValue v(scope, method_in(engine, left, right)); return v->booleanValue(); } -ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) { Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); @@ -949,7 +949,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, Cal } -ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Q_ASSERT(callData->thisObject.isUndefined()); Scope scope(engine); @@ -979,10 +979,10 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI return o->call(callData); } -ReturnedValue Runtime::callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) +ReturnedValue Runtime::method_callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) { Scope scope(engine); - ScopedFunctionObject o(scope, getQmlScopeObjectProperty(engine, callData->thisObject, propertyIndex)); + ScopedFunctionObject o(scope, method_getQmlScopeObjectProperty(engine, callData->thisObject, propertyIndex)); if (!o) { QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(propertyIndex).arg(callData->thisObject.toQStringNoThrow()); return engine->throwTypeError(error); @@ -991,10 +991,10 @@ ReturnedValue Runtime::callQmlScopeObjectProperty(ExecutionEngine *engine, int p return o->call(callData); } -ReturnedValue Runtime::callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) +ReturnedValue Runtime::method_callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData) { Scope scope(engine); - ScopedFunctionObject o(scope, getQmlContextObjectProperty(engine, callData->thisObject, propertyIndex)); + ScopedFunctionObject o(scope, method_getQmlContextObjectProperty(engine, callData->thisObject, propertyIndex)); if (!o) { QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(propertyIndex).arg(callData->thisObject.toQStringNoThrow()); return engine->throwTypeError(error); @@ -1003,7 +1003,7 @@ ReturnedValue Runtime::callQmlContextObjectProperty(ExecutionEngine *engine, int return o->call(callData); } -ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1030,7 +1030,7 @@ ReturnedValue Runtime::callProperty(ExecutionEngine *engine, int nameIndex, Call return o->call(callData); } -ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { Lookup *l = engine->current->lookups + index; Value v; @@ -1041,7 +1041,7 @@ ReturnedValue Runtime::callPropertyLookup(ExecutionEngine *engine, uint index, C return v.objectValue()->call(callData); } -ReturnedValue Runtime::callElement(ExecutionEngine *engine, const Value &index, CallData *callData) +ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value &index, CallData *callData) { Scope scope(engine); ScopedObject baseObject(scope, callData->thisObject.toObject(engine)); @@ -1058,7 +1058,7 @@ ReturnedValue Runtime::callElement(ExecutionEngine *engine, const Value &index, return o->call(callData); } -ReturnedValue Runtime::callValue(ExecutionEngine *engine, const Value &func, CallData *callData) +ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &func, CallData *callData) { if (!func.isObject()) return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); @@ -1067,7 +1067,7 @@ ReturnedValue Runtime::callValue(ExecutionEngine *engine, const Value &func, Cal } -ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData) { Scope scope(engine); Q_ASSERT(callData->thisObject.isUndefined()); @@ -1081,7 +1081,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionEngine *engine, uint index } -ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1096,7 +1096,7 @@ ReturnedValue Runtime::constructActivationProperty(ExecutionEngine *engine, int return f->construct(callData); } -ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const Value &func, CallData *callData) +ReturnedValue Runtime::method_constructValue(ExecutionEngine *engine, const Value &func, CallData *callData) { const Object *f = func.as<Object>(); if (!f) @@ -1105,7 +1105,7 @@ ReturnedValue Runtime::constructValue(ExecutionEngine *engine, const Value &func return f->construct(callData); } -ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) +ReturnedValue Runtime::method_constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData) { Scope scope(engine); ScopedObject thisObject(scope, callData->thisObject.toObject(engine)); @@ -1120,7 +1120,7 @@ ReturnedValue Runtime::constructProperty(ExecutionEngine *engine, int nameIndex, return f->construct(callData); } -ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) +ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData) { Lookup *l = engine->current->lookups + index; Value v; @@ -1132,13 +1132,13 @@ ReturnedValue Runtime::constructPropertyLookup(ExecutionEngine *engine, uint ind } -void Runtime::throwException(ExecutionEngine *engine, const Value &value) +void Runtime::method_throwException(ExecutionEngine *engine, const Value &value) { if (!value.isEmpty()) engine->throwError(value); } -ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) +ReturnedValue Runtime::method_typeofValue(ExecutionEngine *engine, const Value &value) { Scope scope(engine); ScopedString res(scope); @@ -1167,39 +1167,37 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) return res.asReturnedValue(); } -QV4::ReturnedValue Runtime::typeofName(ExecutionEngine *engine, int nameIndex) +QV4::ReturnedValue Runtime::method_typeofName(ExecutionEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); ScopedValue prop(scope, engine->currentContext->getProperty(name)); // typeof doesn't throw. clear any possible exception scope.engine->hasException = false; - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } #ifndef V4_BOOTSTRAP -ReturnedValue Runtime::typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, - int propertyIndex) +ReturnedValue Runtime::method_typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { Scope scope(engine); - ScopedValue prop(scope, getQmlScopeObjectProperty(engine, context, propertyIndex)); + ScopedValue prop(scope, method_getQmlScopeObjectProperty(engine, context, propertyIndex)); if (scope.engine->hasException) return Encode::undefined(); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -ReturnedValue Runtime::typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, - int propertyIndex) +ReturnedValue Runtime::method_typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { Scope scope(engine); - ScopedValue prop(scope, getQmlContextObjectProperty(engine, context, propertyIndex)); + ScopedValue prop(scope, method_getQmlContextObjectProperty(engine, context, propertyIndex)); if (scope.engine->hasException) return Encode::undefined(); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } #endif // V4_BOOTSTRAP -QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex) +QV4::ReturnedValue Runtime::method_typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); @@ -1207,10 +1205,10 @@ QV4::ReturnedValue Runtime::typeofMember(ExecutionEngine *engine, const Value &b if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const Value &base, const Value &index) +QV4::ReturnedValue Runtime::method_typeofElement(ExecutionEngine *engine, const Value &base, const Value &index) { Scope scope(engine); ScopedString name(scope, index.toString(engine)); @@ -1218,10 +1216,10 @@ QV4::ReturnedValue Runtime::typeofElement(ExecutionEngine *engine, const Value & if (scope.engine->hasException) return Encode::undefined(); ScopedValue prop(scope, obj->get(name)); - return Runtime::typeofValue(engine, prop); + return method_typeofValue(engine, prop); } -ReturnedValue Runtime::unwindException(ExecutionEngine *engine) +ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine) { if (!engine->hasException) return Primitive::emptyValue().asReturnedValue(); @@ -1233,39 +1231,39 @@ ReturnedValue Runtime::unwindException(ExecutionEngine *engine) * * Instead the push/pop pair acts as a non local scope. */ -void Runtime::pushWithScope(const Value &o, ExecutionEngine *engine) +void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine) { engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine))); Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); } -void Runtime::pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex) +void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex) { ExecutionContext *c = engine->currentContext; engine->pushContext(c->newCatchContext(c->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0))); Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); } -void Runtime::popScope(ExecutionEngine *engine) +void Runtime::method_popScope(ExecutionEngine *engine) { Q_ASSERT(engine->jsStackTop = engine->currentContext + 2); engine->popContext(); engine->jsStackTop -= 2; } -void Runtime::declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) +void Runtime::method_declareVar(ExecutionEngine *engine, bool deletable, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); engine->currentContext->createMutableBinding(name, deletable); } -ReturnedValue Runtime::arrayLiteral(ExecutionEngine *engine, Value *values, uint length) +ReturnedValue Runtime::method_arrayLiteral(ExecutionEngine *engine, Value *values, uint length) { return engine->newArrayObject(values, length)->asReturnedValue(); } -ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) +ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) { Scope scope(engine); QV4::InternalClass *klass = engine->current->compilationUnit->runtimeClasses[classId]; @@ -1307,7 +1305,7 @@ ReturnedValue Runtime::objectLiteral(ExecutionEngine *engine, const QV4::Value * return o.asReturnedValue(); } -QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) +QV4::ReturnedValue Runtime::method_setupArgumentsObject(ExecutionEngine *engine) { Q_ASSERT(engine->current->type == Heap::ExecutionContext::Type_CallContext); QV4::CallContext *c = static_cast<QV4::CallContext *>(engine->currentContext); @@ -1317,7 +1315,7 @@ QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionEngine *engine) #endif // V4_BOOTSTRAP -QV4::ReturnedValue Runtime::increment(const Value &value) +QV4::ReturnedValue Runtime::method_increment(const Value &value) { TRACE1(value); @@ -1329,7 +1327,7 @@ QV4::ReturnedValue Runtime::increment(const Value &value) } } -QV4::ReturnedValue Runtime::decrement(const Value &value) +QV4::ReturnedValue Runtime::method_decrement(const Value &value) { TRACE1(value); @@ -1364,31 +1362,31 @@ QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const Value #endif // V4_BOOTSTRAP -ReturnedValue Runtime::toDouble(const Value &value) +ReturnedValue Runtime::method_toDouble(const Value &value) { TRACE1(value); return Encode(value.toNumber()); } -int Runtime::toInt(const Value &value) +int Runtime::method_toInt(const Value &value) { TRACE1(value); return value.toInt32(); } -int Runtime::doubleToInt(const double &d) +int Runtime::method_doubleToInt(const double &d) { TRACE0(); return Primitive::toInt32(d); } -unsigned Runtime::toUInt(const Value &value) +unsigned Runtime::method_toUInt(const Value &value) { TRACE1(value); return value.toUInt32(); } -unsigned Runtime::doubleToUInt(const double &d) +unsigned Runtime::method_doubleToUInt(const double &d) { TRACE0(); return Primitive::toUInt32(d); @@ -1396,17 +1394,17 @@ unsigned Runtime::doubleToUInt(const double &d) #ifndef V4_BOOTSTRAP -ReturnedValue Runtime::getQmlContext(NoThrowEngine *engine) +ReturnedValue Runtime::method_getQmlContext(NoThrowEngine *engine) { return engine->qmlContext()->asReturnedValue(); } -ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id) +ReturnedValue Runtime::method_regexpLiteral(ExecutionEngine *engine, int id) { return engine->current->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); } -ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::method_getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1417,7 +1415,7 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Valu return QV4::QObjectWrapper::getProperty(scope.engine, wrapper->object(), propertyIndex, captureRequired); } -QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex) +QV4::ReturnedValue Runtime::method_getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex) { QObject *scopeObject = engine->qmlScopeObject(); QObject *attachedObject = qmlAttachedPropertiesObjectById(attachedPropertiesId, scopeObject); @@ -1427,19 +1425,19 @@ QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionEngine *engine, int return QV4::QObjectWrapper::getProperty(engine, attachedObject, propertyIndex, /*captureRequired*/true); } -ReturnedValue Runtime::getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) +ReturnedValue Runtime::method_getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::getProperty(engine, c.d()->qml->scopeObject, propertyIndex, false); } -ReturnedValue Runtime::getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) +ReturnedValue Runtime::method_getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::getProperty(engine, c.d()->qml->context->contextObject, propertyIndex, false); } -ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) +ReturnedValue Runtime::method_getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); QV4::Scoped<QmlTypeWrapper> wrapper(scope, object); @@ -1450,7 +1448,7 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, c return QV4::QObjectWrapper::getProperty(scope.engine, wrapper->singletonObject(), propertyIndex, captureRequired); } -ReturnedValue Runtime::getQmlIdObject(ExecutionEngine *engine, const Value &c, uint index) +ReturnedValue Runtime::method_getQmlIdObject(ExecutionEngine *engine, const Value &c, uint index) { Scope scope(engine); const QmlContext &qmlContext = static_cast<const QmlContext &>(c); @@ -1465,19 +1463,19 @@ ReturnedValue Runtime::getQmlIdObject(ExecutionEngine *engine, const Value &c, u return QObjectWrapper::wrap(engine, context->idValues[index].data()); } -void Runtime::setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) +void Runtime::method_setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::setProperty(engine, c.d()->qml->scopeObject, propertyIndex, value); } -void Runtime::setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) +void Runtime::method_setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) { const QmlContext &c = static_cast<const QmlContext &>(context); return QV4::QObjectWrapper::setProperty(engine, c.d()->qml->context->contextObject, propertyIndex, value); } -void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value) +void Runtime::method_setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value) { Scope scope(engine); QV4::Scoped<QObjectWrapper> wrapper(scope, object); @@ -1488,7 +1486,7 @@ void Runtime::setQmlQObjectProperty(ExecutionEngine *engine, const Value &object wrapper->setProperty(engine, propertyIndex, value); } -ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) +ReturnedValue Runtime::method_getQmlImportedScripts(NoThrowEngine *engine) { QQmlContextData *context = engine->callingQmlContext(); if (!context) @@ -1496,14 +1494,14 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowEngine *engine) return context->importedScripts.value(); } -QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex) +QV4::ReturnedValue Runtime::method_getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex) { Scope scope(engine); ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]); return engine->qmlSingletonWrapper(name); } -void Runtime::convertThisToObject(ExecutionEngine *engine) +void Runtime::method_convertThisToObject(ExecutionEngine *engine) { Value *t = &engine->current->callData->thisObject; if (t->isObject()) diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index 51cc4f50b0..d9b46606c9 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -55,7 +55,7 @@ #include "qv4context_p.h" #include "qv4engine_p.h" #include "qv4math_p.h" - +#include "qv4runtimeapi_p.h" #include <QtCore/qnumeric.h> @@ -98,150 +98,6 @@ enum TypeHint { STRING_HINT }; -// This is a trick to tell the code generators that functions taking a NoThrowContext won't -// throw exceptions and therefore don't need a check after the call. -struct NoThrowEngine : public ExecutionEngine -{ -}; - -struct Q_QML_PRIVATE_EXPORT Runtime { - // call - static ReturnedValue callGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue callActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue callQmlScopeObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData); - static ReturnedValue callQmlContextObjectProperty(ExecutionEngine *engine, int propertyIndex, CallData *callData); - static ReturnedValue callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue callElement(ExecutionEngine *engine, const Value &index, CallData *callData); - static ReturnedValue callValue(ExecutionEngine *engine, const Value &func, CallData *callData); - - // construct - static ReturnedValue constructGlobalLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue constructProperty(ExecutionEngine *engine, int nameIndex, CallData *callData); - static ReturnedValue constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData); - static ReturnedValue constructValue(ExecutionEngine *engine, const Value &func, CallData *callData); - - // set & get - static void setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value); - static void setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value); - static void setElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value); - static ReturnedValue getProperty(ExecutionEngine *engine, const Value &object, int nameIndex); - static ReturnedValue getActivationProperty(ExecutionEngine *engine, int nameIndex); - static ReturnedValue getElement(ExecutionEngine *engine, const Value &object, const Value &index); - - // typeof - static ReturnedValue typeofValue(ExecutionEngine *engine, const Value &val); - static ReturnedValue typeofName(ExecutionEngine *engine, int nameIndex); - static ReturnedValue typeofScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue typeofContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue typeofMember(ExecutionEngine *engine, const Value &base, int nameIndex); - static ReturnedValue typeofElement(ExecutionEngine *engine, const Value &base, const Value &index); - - // delete - static ReturnedValue deleteElement(ExecutionEngine *engine, const Value &base, const Value &index); - static ReturnedValue deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex); - static ReturnedValue deleteMemberString(ExecutionEngine *engine, const Value &base, String *name); - static ReturnedValue deleteName(ExecutionEngine *engine, int nameIndex); - - // exceptions & scopes - static void throwException(ExecutionEngine *engine, const Value &value); - static ReturnedValue unwindException(ExecutionEngine *engine); - static void pushWithScope(const Value &o, ExecutionEngine *engine); - static void pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex); - static void popScope(ExecutionEngine *engine); - - // closures - static ReturnedValue closure(ExecutionEngine *engine, int functionId); - - // function header - static void declareVar(ExecutionEngine *engine, bool deletable, int nameIndex); - static ReturnedValue setupArgumentsObject(ExecutionEngine *engine); - static void convertThisToObject(ExecutionEngine *engine); - - // literals - static ReturnedValue arrayLiteral(ExecutionEngine *engine, Value *values, uint length); - static ReturnedValue objectLiteral(ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags); - static ReturnedValue regexpLiteral(ExecutionEngine *engine, int id); - - // foreach - static ReturnedValue foreachIterator(ExecutionEngine *engine, const Value &in); - static ReturnedValue foreachNextPropertyName(const Value &foreach_iterator); - - // unary operators - typedef ReturnedValue (*UnaryOperation)(const Value &value); - static ReturnedValue uPlus(const Value &value); - static ReturnedValue uMinus(const Value &value); - static ReturnedValue uNot(const Value &value); - static ReturnedValue complement(const Value &value); - static ReturnedValue increment(const Value &value); - static ReturnedValue decrement(const Value &value); - - // binary operators - typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); - typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); - - static ReturnedValue instanceof(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue in(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue add(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue addString(ExecutionEngine *engine, const Value &left, const Value &right); - static ReturnedValue bitOr(const Value &left, const Value &right); - static ReturnedValue bitXor(const Value &left, const Value &right); - static ReturnedValue bitAnd(const Value &left, const Value &right); - static ReturnedValue sub(const Value &left, const Value &right); - static ReturnedValue mul(const Value &left, const Value &right); - static ReturnedValue div(const Value &left, const Value &right); - static ReturnedValue mod(const Value &left, const Value &right); - static ReturnedValue shl(const Value &left, const Value &right); - static ReturnedValue shr(const Value &left, const Value &right); - static ReturnedValue ushr(const Value &left, const Value &right); - static ReturnedValue greaterThan(const Value &left, const Value &right); - static ReturnedValue lessThan(const Value &left, const Value &right); - static ReturnedValue greaterEqual(const Value &left, const Value &right); - static ReturnedValue lessEqual(const Value &left, const Value &right); - static ReturnedValue equal(const Value &left, const Value &right); - static ReturnedValue notEqual(const Value &left, const Value &right); - static ReturnedValue strictEqual(const Value &left, const Value &right); - static ReturnedValue strictNotEqual(const Value &left, const Value &right); - - // comparisons - typedef Bool (*CompareOperation)(const Value &left, const Value &right); - static Bool compareGreaterThan(const Value &l, const Value &r); - static Bool compareLessThan(const Value &l, const Value &r); - static Bool compareGreaterEqual(const Value &l, const Value &r); - static Bool compareLessEqual(const Value &l, const Value &r); - static Bool compareEqual(const Value &left, const Value &right); - static Bool compareNotEqual(const Value &left, const Value &right); - static Bool compareStrictEqual(const Value &left, const Value &right); - static Bool compareStrictNotEqual(const Value &left, const Value &right); - - typedef Bool (*CompareOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareInstanceof(ExecutionEngine *engine, const Value &left, const Value &right); - static Bool compareIn(ExecutionEngine *engine, const Value &left, const Value &right); - - // conversions - static Bool toBoolean(const Value &value); - static ReturnedValue toDouble(const Value &value); - static int toInt(const Value &value); - static int doubleToInt(const double &d); - static unsigned toUInt(const Value &value); - static unsigned doubleToUInt(const double &d); - - // qml - static ReturnedValue getQmlContext(NoThrowEngine *engine); - static ReturnedValue getQmlImportedScripts(NoThrowEngine *engine); - static ReturnedValue getQmlSingleton(NoThrowEngine *engine, int nameIndex); - static ReturnedValue getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex); - static ReturnedValue getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); - static ReturnedValue getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); - static ReturnedValue getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); - static ReturnedValue getQmlIdObject(ExecutionEngine *engine, const Value &context, uint index); - - static void setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); - static void setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); - static void setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value); -}; struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static ReturnedValue objectDefaultValue(const Object *object, int typeHint); @@ -281,7 +137,7 @@ inline double RuntimeHelpers::toNumber(const Value &value) return value.toNumber(); } -inline ReturnedValue Runtime::uPlus(const Value &value) +inline ReturnedValue Runtime::method_uPlus(const Value &value) { TRACE1(value); @@ -294,7 +150,7 @@ inline ReturnedValue Runtime::uPlus(const Value &value) return Encode(n); } -inline ReturnedValue Runtime::uMinus(const Value &value) +inline ReturnedValue Runtime::method_uMinus(const Value &value) { TRACE1(value); @@ -307,7 +163,7 @@ inline ReturnedValue Runtime::uMinus(const Value &value) } } -inline ReturnedValue Runtime::complement(const Value &value) +inline ReturnedValue Runtime::method_complement(const Value &value) { TRACE1(value); @@ -315,7 +171,7 @@ inline ReturnedValue Runtime::complement(const Value &value) return Encode((int)~n); } -inline ReturnedValue Runtime::uNot(const Value &value) +inline ReturnedValue Runtime::method_uNot(const Value &value) { TRACE1(value); @@ -324,7 +180,7 @@ inline ReturnedValue Runtime::uNot(const Value &value) } // binary operators -inline ReturnedValue Runtime::bitOr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitOr(const Value &left, const Value &right) { TRACE2(left, right); @@ -333,7 +189,7 @@ inline ReturnedValue Runtime::bitOr(const Value &left, const Value &right) return Encode(lval | rval); } -inline ReturnedValue Runtime::bitXor(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitXor(const Value &left, const Value &right) { TRACE2(left, right); @@ -342,7 +198,7 @@ inline ReturnedValue Runtime::bitXor(const Value &left, const Value &right) return Encode(lval ^ rval); } -inline ReturnedValue Runtime::bitAnd(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_bitAnd(const Value &left, const Value &right) { TRACE2(left, right); @@ -352,7 +208,7 @@ inline ReturnedValue Runtime::bitAnd(const Value &left, const Value &right) } #ifndef V4_BOOTSTRAP -inline ReturnedValue Runtime::add(ExecutionEngine *engine, const Value &left, const Value &right) +inline ReturnedValue Runtime::method_add(ExecutionEngine *engine, const Value &left, const Value &right) { TRACE2(left, right); @@ -365,7 +221,7 @@ inline ReturnedValue Runtime::add(ExecutionEngine *engine, const Value &left, co } #endif // V4_BOOTSTRAP -inline ReturnedValue Runtime::sub(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_sub(const Value &left, const Value &right) { TRACE2(left, right); @@ -378,7 +234,7 @@ inline ReturnedValue Runtime::sub(const Value &left, const Value &right) return Primitive::fromDouble(lval - rval).asReturnedValue(); } -inline ReturnedValue Runtime::mul(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_mul(const Value &left, const Value &right) { TRACE2(left, right); @@ -391,7 +247,7 @@ inline ReturnedValue Runtime::mul(const Value &left, const Value &right) return Primitive::fromDouble(lval * rval).asReturnedValue(); } -inline ReturnedValue Runtime::div(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_div(const Value &left, const Value &right) { TRACE2(left, right); @@ -409,7 +265,7 @@ inline ReturnedValue Runtime::div(const Value &left, const Value &right) return Primitive::fromDouble(lval / rval).asReturnedValue(); } -inline ReturnedValue Runtime::mod(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_mod(const Value &left, const Value &right) { TRACE2(left, right); @@ -424,7 +280,7 @@ inline ReturnedValue Runtime::mod(const Value &left, const Value &right) return Primitive::fromDouble(std::fmod(lval, rval)).asReturnedValue(); } -inline ReturnedValue Runtime::shl(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_shl(const Value &left, const Value &right) { TRACE2(left, right); @@ -433,7 +289,7 @@ inline ReturnedValue Runtime::shl(const Value &left, const Value &right) return Encode((int)(lval << rval)); } -inline ReturnedValue Runtime::shr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_shr(const Value &left, const Value &right) { TRACE2(left, right); @@ -442,7 +298,7 @@ inline ReturnedValue Runtime::shr(const Value &left, const Value &right) return Encode((int)(lval >> rval)); } -inline ReturnedValue Runtime::ushr(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_ushr(const Value &left, const Value &right) { TRACE2(left, right); @@ -453,39 +309,39 @@ inline ReturnedValue Runtime::ushr(const Value &left, const Value &right) return Encode(res); } -inline ReturnedValue Runtime::greaterThan(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_greaterThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareGreaterThan(left, right); + bool r = method_compareGreaterThan(left, right); return Encode(r); } -inline ReturnedValue Runtime::lessThan(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_lessThan(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessThan(left, right); + bool r = method_compareLessThan(left, right); return Encode(r); } -inline ReturnedValue Runtime::greaterEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_greaterEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareGreaterEqual(left, right); + bool r = method_compareGreaterEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::lessEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_lessEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareLessEqual(left, right); + bool r = method_compareLessEqual(left, right); return Encode(r); } -inline Bool Runtime::compareEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -503,23 +359,23 @@ inline Bool Runtime::compareEqual(const Value &left, const Value &right) return RuntimeHelpers::equalHelper(left, right); } -inline ReturnedValue Runtime::equal(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_equal(const Value &left, const Value &right) { TRACE2(left, right); - bool r = Runtime::compareEqual(left, right); + bool r = method_compareEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::notEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_notEqual(const Value &left, const Value &right) { TRACE2(left, right); - bool r = !Runtime::compareEqual(left, right); + bool r = !method_compareEqual(left, right); return Encode(r); } -inline ReturnedValue Runtime::strictEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_strictEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -527,7 +383,7 @@ inline ReturnedValue Runtime::strictEqual(const Value &left, const Value &right) return Encode(r); } -inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &right) +inline ReturnedValue Runtime::method_strictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); @@ -535,28 +391,28 @@ inline ReturnedValue Runtime::strictNotEqual(const Value &left, const Value &rig return Encode(r); } -inline Bool Runtime::compareNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareNotEqual(const Value &left, const Value &right) { TRACE2(left, right); - return !Runtime::compareEqual(left, right); + return !Runtime::method_compareEqual(left, right); } -inline Bool Runtime::compareStrictEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictEqual(const Value &left, const Value &right) { TRACE2(left, right); return RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::compareStrictNotEqual(const Value &left, const Value &right) +inline Bool Runtime::method_compareStrictNotEqual(const Value &left, const Value &right) { TRACE2(left, right); return ! RuntimeHelpers::strictEqual(left, right); } -inline Bool Runtime::toBoolean(const Value &value) +inline Bool Runtime::method_toBoolean(const Value &value) { return value.toBoolean(); } diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h new file mode 100644 index 0000000000..9eb6a124b4 --- /dev/null +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -0,0 +1,304 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QV4RUNTIMEAPI_P_H +#define QV4RUNTIMEAPI_P_H + +#include <private/qv4global_p.h> + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct NoThrowEngine; + +#define RUNTIME_METHOD(returnvalue, name, args) \ + typedef returnvalue (*Method_##name)args; \ + static returnvalue method_##name args; \ + const Method_##name name + +#define INIT_RUNTIME_METHOD(name) \ + name(method_##name) + +struct Q_QML_PRIVATE_EXPORT Runtime { + Runtime() + : INIT_RUNTIME_METHOD(callGlobalLookup) + , INIT_RUNTIME_METHOD(callActivationProperty) + , INIT_RUNTIME_METHOD(callQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(callQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(callProperty) + , INIT_RUNTIME_METHOD(callPropertyLookup) + , INIT_RUNTIME_METHOD(callElement) + , INIT_RUNTIME_METHOD(callValue) + , INIT_RUNTIME_METHOD(constructGlobalLookup) + , INIT_RUNTIME_METHOD(constructActivationProperty) + , INIT_RUNTIME_METHOD(constructProperty) + , INIT_RUNTIME_METHOD(constructPropertyLookup) + , INIT_RUNTIME_METHOD(constructValue) + , INIT_RUNTIME_METHOD(setActivationProperty) + , INIT_RUNTIME_METHOD(setProperty) + , INIT_RUNTIME_METHOD(setElement) + , INIT_RUNTIME_METHOD(getProperty) + , INIT_RUNTIME_METHOD(getActivationProperty) + , INIT_RUNTIME_METHOD(getElement) + , INIT_RUNTIME_METHOD(typeofValue) + , INIT_RUNTIME_METHOD(typeofName) + , INIT_RUNTIME_METHOD(typeofScopeObjectProperty) + , INIT_RUNTIME_METHOD(typeofContextObjectProperty) + , INIT_RUNTIME_METHOD(typeofMember) + , INIT_RUNTIME_METHOD(typeofElement) + , INIT_RUNTIME_METHOD(deleteElement) + , INIT_RUNTIME_METHOD(deleteMember) + , INIT_RUNTIME_METHOD(deleteMemberString) + , INIT_RUNTIME_METHOD(deleteName) + , INIT_RUNTIME_METHOD(throwException) + , INIT_RUNTIME_METHOD(unwindException) + , INIT_RUNTIME_METHOD(pushWithScope) + , INIT_RUNTIME_METHOD(pushCatchScope) + , INIT_RUNTIME_METHOD(popScope) + , INIT_RUNTIME_METHOD(closure) + , INIT_RUNTIME_METHOD(declareVar) + , INIT_RUNTIME_METHOD(setupArgumentsObject) + , INIT_RUNTIME_METHOD(convertThisToObject) + , INIT_RUNTIME_METHOD(arrayLiteral) + , INIT_RUNTIME_METHOD(objectLiteral) + , INIT_RUNTIME_METHOD(regexpLiteral) + , INIT_RUNTIME_METHOD(foreachIterator) + , INIT_RUNTIME_METHOD(foreachNextPropertyName) + , INIT_RUNTIME_METHOD(uPlus) + , INIT_RUNTIME_METHOD(uMinus) + , INIT_RUNTIME_METHOD(uNot) + , INIT_RUNTIME_METHOD(complement) + , INIT_RUNTIME_METHOD(increment) + , INIT_RUNTIME_METHOD(decrement) + , INIT_RUNTIME_METHOD(instanceof) + , INIT_RUNTIME_METHOD(in) + , INIT_RUNTIME_METHOD(add) + , INIT_RUNTIME_METHOD(addString) + , INIT_RUNTIME_METHOD(bitOr) + , INIT_RUNTIME_METHOD(bitXor) + , INIT_RUNTIME_METHOD(bitAnd) + , INIT_RUNTIME_METHOD(sub) + , INIT_RUNTIME_METHOD(mul) + , INIT_RUNTIME_METHOD(div) + , INIT_RUNTIME_METHOD(mod) + , INIT_RUNTIME_METHOD(shl) + , INIT_RUNTIME_METHOD(shr) + , INIT_RUNTIME_METHOD(ushr) + , INIT_RUNTIME_METHOD(greaterThan) + , INIT_RUNTIME_METHOD(lessThan) + , INIT_RUNTIME_METHOD(greaterEqual) + , INIT_RUNTIME_METHOD(lessEqual) + , INIT_RUNTIME_METHOD(equal) + , INIT_RUNTIME_METHOD(notEqual) + , INIT_RUNTIME_METHOD(strictEqual) + , INIT_RUNTIME_METHOD(strictNotEqual) + , INIT_RUNTIME_METHOD(compareGreaterThan) + , INIT_RUNTIME_METHOD(compareLessThan) + , INIT_RUNTIME_METHOD(compareGreaterEqual) + , INIT_RUNTIME_METHOD(compareLessEqual) + , INIT_RUNTIME_METHOD(compareEqual) + , INIT_RUNTIME_METHOD(compareNotEqual) + , INIT_RUNTIME_METHOD(compareStrictEqual) + , INIT_RUNTIME_METHOD(compareStrictNotEqual) + , INIT_RUNTIME_METHOD(compareInstanceof) + , INIT_RUNTIME_METHOD(compareIn) + , INIT_RUNTIME_METHOD(toBoolean) + , INIT_RUNTIME_METHOD(toDouble) + , INIT_RUNTIME_METHOD(toInt) + , INIT_RUNTIME_METHOD(doubleToInt) + , INIT_RUNTIME_METHOD(toUInt) + , INIT_RUNTIME_METHOD(doubleToUInt) + , INIT_RUNTIME_METHOD(getQmlContext) + , INIT_RUNTIME_METHOD(getQmlImportedScripts) + , INIT_RUNTIME_METHOD(getQmlSingleton) + , INIT_RUNTIME_METHOD(getQmlAttachedProperty) + , INIT_RUNTIME_METHOD(getQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(getQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(getQmlQObjectProperty) + , INIT_RUNTIME_METHOD(getQmlSingletonQObjectProperty) + , INIT_RUNTIME_METHOD(getQmlIdObject) + , INIT_RUNTIME_METHOD(setQmlScopeObjectProperty) + , INIT_RUNTIME_METHOD(setQmlContextObjectProperty) + , INIT_RUNTIME_METHOD(setQmlQObjectProperty) + { } + + // call + RUNTIME_METHOD(ReturnedValue, callGlobalLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callActivationProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callQmlScopeObjectProperty, (ExecutionEngine *engine, int propertyIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callQmlContextObjectProperty, (ExecutionEngine *engine, int propertyIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callPropertyLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callElement, (ExecutionEngine *engine, const Value &index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, callValue, (ExecutionEngine *engine, const Value &func, CallData *callData)); + + // construct + RUNTIME_METHOD(ReturnedValue, constructGlobalLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructActivationProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructProperty, (ExecutionEngine *engine, int nameIndex, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructPropertyLookup, (ExecutionEngine *engine, uint index, CallData *callData)); + RUNTIME_METHOD(ReturnedValue, constructValue, (ExecutionEngine *engine, const Value &func, CallData *callData)); + + // set & get + RUNTIME_METHOD(void, setActivationProperty, (ExecutionEngine *engine, int nameIndex, const Value &value)); + RUNTIME_METHOD(void, setProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)); + RUNTIME_METHOD(void, setElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)); + RUNTIME_METHOD(ReturnedValue, getProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getActivationProperty, (ExecutionEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getElement, (ExecutionEngine *engine, const Value &object, const Value &index)); + + // typeof + RUNTIME_METHOD(ReturnedValue, typeofValue, (ExecutionEngine *engine, const Value &val)); + RUNTIME_METHOD(ReturnedValue, typeofName, (ExecutionEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, typeofScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, typeofContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, typeofMember, (ExecutionEngine *engine, const Value &base, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, typeofElement, (ExecutionEngine *engine, const Value &base, const Value &index)); + + // delete + RUNTIME_METHOD(ReturnedValue, deleteElement, (ExecutionEngine *engine, const Value &base, const Value &index)); + RUNTIME_METHOD(ReturnedValue, deleteMember, (ExecutionEngine *engine, const Value &base, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, deleteMemberString, (ExecutionEngine *engine, const Value &base, String *name)); + RUNTIME_METHOD(ReturnedValue, deleteName, (ExecutionEngine *engine, int nameIndex)); + + // exceptions & scopes + RUNTIME_METHOD(void, throwException, (ExecutionEngine *engine, const Value &value)); + RUNTIME_METHOD(ReturnedValue, unwindException, (ExecutionEngine *engine)); + RUNTIME_METHOD(void, pushWithScope, (const Value &o, ExecutionEngine *engine)); + RUNTIME_METHOD(void, pushCatchScope, (NoThrowEngine *engine, int exceptionVarNameIndex)); + RUNTIME_METHOD(void, popScope, (ExecutionEngine *engine)); + + // closures + RUNTIME_METHOD(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)); + + // function header + RUNTIME_METHOD(void, declareVar, (ExecutionEngine *engine, bool deletable, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, setupArgumentsObject, (ExecutionEngine *engine)); + RUNTIME_METHOD(void, convertThisToObject, (ExecutionEngine *engine)); + + // literals + RUNTIME_METHOD(ReturnedValue, arrayLiteral, (ExecutionEngine *engine, Value *values, uint length)); + RUNTIME_METHOD(ReturnedValue, objectLiteral, (ExecutionEngine *engine, const Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)); + RUNTIME_METHOD(ReturnedValue, regexpLiteral, (ExecutionEngine *engine, int id)); + + // foreach + RUNTIME_METHOD(ReturnedValue, foreachIterator, (ExecutionEngine *engine, const Value &in)); + RUNTIME_METHOD(ReturnedValue, foreachNextPropertyName, (const Value &foreach_iterator)); + + // unary operators + typedef ReturnedValue (*UnaryOperation)(const Value &value); + RUNTIME_METHOD(ReturnedValue, uPlus, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, uMinus, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, uNot, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, complement, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, increment, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, decrement, (const Value &value)); + + // binary operators + typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right); + typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *engine, const Value &left, const Value &right); + + RUNTIME_METHOD(ReturnedValue, instanceof, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, in, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, add, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, addString, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitOr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitXor, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, bitAnd, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, sub, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, mul, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, div, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, mod, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, shl, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, shr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, ushr, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, greaterThan, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, lessThan, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, greaterEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, lessEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, equal, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, notEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, strictEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(ReturnedValue, strictNotEqual, (const Value &left, const Value &right)); + + // comparisons + RUNTIME_METHOD(Bool, compareGreaterThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessThan, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareGreaterEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareLessEqual, (const Value &l, const Value &r)); + RUNTIME_METHOD(Bool, compareEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareNotEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictEqual, (const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareStrictNotEqual, (const Value &left, const Value &right)); + + RUNTIME_METHOD(Bool, compareInstanceof, (ExecutionEngine *engine, const Value &left, const Value &right)); + RUNTIME_METHOD(Bool, compareIn, (ExecutionEngine *engine, const Value &left, const Value &right)); + + // conversions + RUNTIME_METHOD(Bool, toBoolean, (const Value &value)); + RUNTIME_METHOD(ReturnedValue, toDouble, (const Value &value)); + RUNTIME_METHOD(int, toInt, (const Value &value)); + RUNTIME_METHOD(int, doubleToInt, (const double &d)); + RUNTIME_METHOD(unsigned, toUInt, (const Value &value)); + RUNTIME_METHOD(unsigned, doubleToUInt, (const double &d)); + + // qml + RUNTIME_METHOD(ReturnedValue, getQmlContext, (NoThrowEngine *engine)); + RUNTIME_METHOD(ReturnedValue, getQmlImportedScripts, (NoThrowEngine *engine)); + RUNTIME_METHOD(ReturnedValue, getQmlSingleton, (NoThrowEngine *engine, int nameIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlAttachedProperty, (ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex)); + RUNTIME_METHOD(ReturnedValue, getQmlQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired)); + RUNTIME_METHOD(ReturnedValue, getQmlSingletonQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired)); + RUNTIME_METHOD(ReturnedValue, getQmlIdObject, (ExecutionEngine *engine, const Value &context, uint index)); + + RUNTIME_METHOD(void, setQmlScopeObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)); + RUNTIME_METHOD(void, setQmlContextObjectProperty, (ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value)); + RUNTIME_METHOD(void, setQmlQObjectProperty, (ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value)); +}; + +#undef RUNTIME_METHOD +#undef INIT_RUNTIME_METHOD + +} // namespace QV4 + +QT_END_NAMESPACE + +#endif // QV4RUNTIMEAPI_P_H diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 5adc5beea5..b874766655 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -270,7 +270,7 @@ ReturnedValue StringPrototype::method_charCodeAt(CallContext *context) if (pos >= 0 && pos < str.length()) return Encode(str.at(pos).unicode()); - return Encode(qQNaN()); + return Encode(qt_qnan()); } ReturnedValue StringPrototype::method_concat(CallContext *context) diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index ecbc243baa..ec4509a5cc 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -451,12 +451,12 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadRegExp) MOTH_BEGIN_INSTR(LoadClosure) - STOREVALUE(instr.result, Runtime::closure(engine, instr.value)); + STOREVALUE(instr.result, engine->runtime.closure(engine, instr.value)); MOTH_END_INSTR(LoadClosure) MOTH_BEGIN_INSTR(LoadName) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - STOREVALUE(instr.result, Runtime::getActivationProperty(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.getActivationProperty(engine, instr.name)); MOTH_END_INSTR(LoadName) MOTH_BEGIN_INSTR(GetGlobalLookup) @@ -466,12 +466,12 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_BEGIN_INSTR(StoreName) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - Runtime::setActivationProperty(engine, instr.name, VALUE(instr.source)); + engine->runtime.setActivationProperty(engine, instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreName) MOTH_BEGIN_INSTR(LoadElement) - STOREVALUE(instr.result, Runtime::getElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.getElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(LoadElement) MOTH_BEGIN_INSTR(LoadElementLookup) @@ -480,7 +480,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadElementLookup) MOTH_BEGIN_INSTR(StoreElement) - Runtime::setElement(engine, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); + engine->runtime.setElement(engine, VALUE(instr.base), VALUE(instr.index), VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElement) @@ -491,7 +491,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(StoreElementLookup) MOTH_BEGIN_INSTR(LoadProperty) - STOREVALUE(instr.result, Runtime::getProperty(engine, VALUE(instr.base), instr.name)); + STOREVALUE(instr.result, engine->runtime.getProperty(engine, VALUE(instr.base), instr.name)); MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) @@ -500,7 +500,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(GetLookup) MOTH_BEGIN_INSTR(StoreProperty) - Runtime::setProperty(engine, VALUE(instr.base), instr.name, VALUE(instr.source)); + engine->runtime.setProperty(engine, VALUE(instr.base), instr.name, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreProperty) @@ -511,42 +511,42 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(SetLookup) MOTH_BEGIN_INSTR(StoreQObjectProperty) - Runtime::setQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreQObjectProperty) MOTH_BEGIN_INSTR(LoadQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, engine->runtime.getQmlQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadQObjectProperty) MOTH_BEGIN_INSTR(StoreScopeObjectProperty) - Runtime::setQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreScopeObjectProperty) MOTH_BEGIN_INSTR(LoadScopeObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlScopeObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); MOTH_END_INSTR(LoadScopeObjectProperty) MOTH_BEGIN_INSTR(StoreContextObjectProperty) - Runtime::setQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); + engine->runtime.setQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, VALUE(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreContextObjectProperty) MOTH_BEGIN_INSTR(LoadContextObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); MOTH_END_INSTR(LoadContextObjectProperty) MOTH_BEGIN_INSTR(LoadIdObject) - STOREVALUE(instr.result, Runtime::getQmlIdObject(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.getQmlIdObject(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(LoadIdObject) MOTH_BEGIN_INSTR(LoadAttachedQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlAttachedProperty(engine, instr.attachedPropertiesId, instr.propertyIndex)); + STOREVALUE(instr.result, engine->runtime.getQmlAttachedProperty(engine, instr.attachedPropertiesId, instr.propertyIndex)); MOTH_END_INSTR(LoadAttachedQObjectProperty) MOTH_BEGIN_INSTR(LoadSingletonQObjectProperty) - STOREVALUE(instr.result, Runtime::getQmlSingletonQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); + STOREVALUE(instr.result, engine->runtime.getQmlSingletonQObjectProperty(engine, VALUE(instr.base), instr.propertyIndex, instr.captureRequired)); MOTH_END_INSTR(LoadSingletonQObjectProperty) MOTH_BEGIN_INSTR(Push) @@ -572,7 +572,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callValue(engine, VALUE(instr.dest), callData)); + STOREVALUE(instr.result, engine->runtime.callValue(engine, VALUE(instr.dest), callData)); MOTH_END_INSTR(CallValue) MOTH_BEGIN_INSTR(CallProperty) @@ -582,7 +582,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.callProperty(engine, instr.name, callData)); MOTH_END_INSTR(CallProperty) MOTH_BEGIN_INSTR(CallPropertyLookup) @@ -591,7 +591,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callPropertyLookup(engine, instr.lookupIndex, callData)); + STOREVALUE(instr.result, engine->runtime.callPropertyLookup(engine, instr.lookupIndex, callData)); MOTH_END_INSTR(CallPropertyLookup) MOTH_BEGIN_INSTR(CallScopeObjectProperty) @@ -601,7 +601,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callQmlScopeObjectProperty(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.callQmlScopeObjectProperty(engine, instr.index, callData)); MOTH_END_INSTR(CallScopeObjectProperty) MOTH_BEGIN_INSTR(CallContextObjectProperty) @@ -611,7 +611,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callQmlContextObjectProperty(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.callQmlContextObjectProperty(engine, instr.index, callData)); MOTH_END_INSTR(CallContextObjectProperty) MOTH_BEGIN_INSTR(CallElement) @@ -620,7 +620,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::callElement(engine, VALUE(instr.index), callData)); + STOREVALUE(instr.result, engine->runtime.callElement(engine, VALUE(instr.index), callData)); MOTH_END_INSTR(CallElement) MOTH_BEGIN_INSTR(CallActivationProperty) @@ -629,7 +629,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callActivationProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.callActivationProperty(engine, instr.name, callData)); MOTH_END_INSTR(CallActivationProperty) MOTH_BEGIN_INSTR(CallGlobalLookup) @@ -638,7 +638,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::callGlobalLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, Runtime::method_callGlobalLookup(engine, instr.index, callData)); MOTH_END_INSTR(CallGlobalLookup) MOTH_BEGIN_INSTR(SetExceptionHandler) @@ -646,95 +646,95 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(SetExceptionHandler) MOTH_BEGIN_INSTR(CallBuiltinThrow) - Runtime::throwException(engine, VALUE(instr.arg)); + engine->runtime.throwException(engine, VALUE(instr.arg)); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinThrow) MOTH_BEGIN_INSTR(CallBuiltinUnwindException) - STOREVALUE(instr.result, Runtime::unwindException(engine)); + STOREVALUE(instr.result, engine->runtime.unwindException(engine)); MOTH_END_INSTR(CallBuiltinUnwindException) MOTH_BEGIN_INSTR(CallBuiltinPushCatchScope) - Runtime::pushCatchScope(static_cast<QV4::NoThrowEngine*>(engine), instr.name); + engine->runtime.pushCatchScope(static_cast<QV4::NoThrowEngine*>(engine), instr.name); context = engine->currentContext; MOTH_END_INSTR(CallBuiltinPushCatchScope) MOTH_BEGIN_INSTR(CallBuiltinPushScope) - Runtime::pushWithScope(VALUE(instr.arg), engine); + engine->runtime.pushWithScope(VALUE(instr.arg), engine); context = engine->currentContext; CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinPushScope) MOTH_BEGIN_INSTR(CallBuiltinPopScope) - Runtime::popScope(engine); + engine->runtime.popScope(engine); context = engine->currentContext; MOTH_END_INSTR(CallBuiltinPopScope) MOTH_BEGIN_INSTR(CallBuiltinForeachIteratorObject) - STOREVALUE(instr.result, Runtime::foreachIterator(engine, VALUE(instr.arg))); + STOREVALUE(instr.result, engine->runtime.foreachIterator(engine, VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachIteratorObject) MOTH_BEGIN_INSTR(CallBuiltinForeachNextPropertyName) - STOREVALUE(instr.result, Runtime::foreachNextPropertyName(VALUE(instr.arg))); + STOREVALUE(instr.result, engine->runtime.foreachNextPropertyName(VALUE(instr.arg))); MOTH_END_INSTR(CallBuiltinForeachNextPropertyName) MOTH_BEGIN_INSTR(CallBuiltinDeleteMember) - STOREVALUE(instr.result, Runtime::deleteMember(engine, VALUE(instr.base), instr.member)); + STOREVALUE(instr.result, engine->runtime.deleteMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinDeleteMember) MOTH_BEGIN_INSTR(CallBuiltinDeleteSubscript) - STOREVALUE(instr.result, Runtime::deleteElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.deleteElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinDeleteSubscript) MOTH_BEGIN_INSTR(CallBuiltinDeleteName) - STOREVALUE(instr.result, Runtime::deleteName(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.deleteName(engine, instr.name)); MOTH_END_INSTR(CallBuiltinDeleteName) MOTH_BEGIN_INSTR(CallBuiltinTypeofScopeObjectProperty) - STOREVALUE(instr.result, Runtime::typeofScopeObjectProperty(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.typeofScopeObjectProperty(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofContextObjectProperty) - STOREVALUE(instr.result, Runtime::typeofContextObjectProperty(engine, VALUE(instr.base), instr.index)); + STOREVALUE(instr.result, engine->runtime.typeofContextObjectProperty(engine, VALUE(instr.base), instr.index)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofMember) - STOREVALUE(instr.result, Runtime::typeofMember(engine, VALUE(instr.base), instr.member)); + STOREVALUE(instr.result, engine->runtime.typeofMember(engine, VALUE(instr.base), instr.member)); MOTH_END_INSTR(CallBuiltinTypeofMember) MOTH_BEGIN_INSTR(CallBuiltinTypeofSubscript) - STOREVALUE(instr.result, Runtime::typeofElement(engine, VALUE(instr.base), VALUE(instr.index))); + STOREVALUE(instr.result, engine->runtime.typeofElement(engine, VALUE(instr.base), VALUE(instr.index))); MOTH_END_INSTR(CallBuiltinTypeofSubscript) MOTH_BEGIN_INSTR(CallBuiltinTypeofName) - STOREVALUE(instr.result, Runtime::typeofName(engine, instr.name)); + STOREVALUE(instr.result, engine->runtime.typeofName(engine, instr.name)); MOTH_END_INSTR(CallBuiltinTypeofName) MOTH_BEGIN_INSTR(CallBuiltinTypeofValue) - STOREVALUE(instr.result, Runtime::typeofValue(engine, VALUE(instr.value))); + STOREVALUE(instr.result, engine->runtime.typeofValue(engine, VALUE(instr.value))); MOTH_END_INSTR(CallBuiltinTypeofValue) MOTH_BEGIN_INSTR(CallBuiltinDeclareVar) - Runtime::declareVar(engine, instr.isDeletable, instr.varName); + engine->runtime.declareVar(engine, instr.isDeletable, instr.varName); MOTH_END_INSTR(CallBuiltinDeclareVar) MOTH_BEGIN_INSTR(CallBuiltinDefineArray) Q_ASSERT(instr.args + instr.argc <= stackSize); QV4::Value *args = stack + instr.args; - STOREVALUE(instr.result, Runtime::arrayLiteral(engine, args, instr.argc)); + STOREVALUE(instr.result, engine->runtime.arrayLiteral(engine, args, instr.argc)); MOTH_END_INSTR(CallBuiltinDefineArray) MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral) QV4::Value *args = stack + instr.args; - STOREVALUE(instr.result, Runtime::objectLiteral(engine, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags)); + STOREVALUE(instr.result, engine->runtime.objectLiteral(engine, args, instr.internalClassId, instr.arrayValueCount, instr.arrayGetterSetterCountAndFlags)); MOTH_END_INSTR(CallBuiltinDefineObjectLiteral) MOTH_BEGIN_INSTR(CallBuiltinSetupArgumentsObject) - STOREVALUE(instr.result, Runtime::setupArgumentsObject(engine)); + STOREVALUE(instr.result, engine->runtime.setupArgumentsObject(engine)); MOTH_END_INSTR(CallBuiltinSetupArgumentsObject) MOTH_BEGIN_INSTR(CallBuiltinConvertThisToObject) - Runtime::convertThisToObject(engine); + engine->runtime.convertThisToObject(engine); CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinConvertThisToObject) @@ -744,7 +744,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructValue(engine, VALUE(instr.func), callData)); + STOREVALUE(instr.result, engine->runtime.constructValue(engine, VALUE(instr.func), callData)); MOTH_END_INSTR(CreateValue) MOTH_BEGIN_INSTR(CreateProperty) @@ -753,7 +753,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::constructProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.constructProperty(engine, instr.name, callData)); MOTH_END_INSTR(CreateProperty) MOTH_BEGIN_INSTR(ConstructPropertyLookup) @@ -762,7 +762,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = VALUE(instr.base); - STOREVALUE(instr.result, Runtime::constructPropertyLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.constructPropertyLookup(engine, instr.index, callData)); MOTH_END_INSTR(ConstructPropertyLookup) MOTH_BEGIN_INSTR(CreateActivationProperty) @@ -771,7 +771,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructActivationProperty(engine, instr.name, callData)); + STOREVALUE(instr.result, engine->runtime.constructActivationProperty(engine, instr.name, callData)); MOTH_END_INSTR(CreateActivationProperty) MOTH_BEGIN_INSTR(ConstructGlobalLookup) @@ -780,7 +780,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code callData->tag = QV4::Value::Integer_Type; callData->argc = instr.argc; callData->thisObject = QV4::Primitive::undefinedValue(); - STOREVALUE(instr.result, Runtime::constructGlobalLookup(engine, instr.index, callData)); + STOREVALUE(instr.result, engine->runtime.constructGlobalLookup(engine, instr.index, callData)); MOTH_END_INSTR(ConstructGlobalLookup) MOTH_BEGIN_INSTR(Jump) @@ -802,7 +802,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(JumpNe) MOTH_BEGIN_INSTR(UNot) - STOREVALUE(instr.result, Runtime::uNot(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uNot(VALUE(instr.source))); MOTH_END_INSTR(UNot) MOTH_BEGIN_INSTR(UNotBool) @@ -811,15 +811,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UNotBool) MOTH_BEGIN_INSTR(UPlus) - STOREVALUE(instr.result, Runtime::uPlus(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uPlus(VALUE(instr.source))); MOTH_END_INSTR(UPlus) MOTH_BEGIN_INSTR(UMinus) - STOREVALUE(instr.result, Runtime::uMinus(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.uMinus(VALUE(instr.source))); MOTH_END_INSTR(UMinus) MOTH_BEGIN_INSTR(UCompl) - STOREVALUE(instr.result, Runtime::complement(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.complement(VALUE(instr.source))); MOTH_END_INSTR(UCompl) MOTH_BEGIN_INSTR(UComplInt) @@ -827,31 +827,32 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(UComplInt) MOTH_BEGIN_INSTR(Increment) - STOREVALUE(instr.result, Runtime::increment(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.increment(VALUE(instr.source))); MOTH_END_INSTR(Increment) MOTH_BEGIN_INSTR(Decrement) - STOREVALUE(instr.result, Runtime::decrement(VALUE(instr.source))); + STOREVALUE(instr.result, engine->runtime.decrement(VALUE(instr.source))); MOTH_END_INSTR(Decrement) MOTH_BEGIN_INSTR(Binop) - STOREVALUE(instr.result, instr.alu(VALUE(instr.lhs), VALUE(instr.rhs))); + QV4::Runtime::BinaryOperation op = *reinterpret_cast<QV4::Runtime::BinaryOperation *>(reinterpret_cast<char *>(&engine->runtime) + instr.alu); + STOREVALUE(instr.result, op(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Binop) MOTH_BEGIN_INSTR(Add) - STOREVALUE(instr.result, Runtime::add(engine, VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.add(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Add) MOTH_BEGIN_INSTR(BitAnd) - STOREVALUE(instr.result, Runtime::bitAnd(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitAnd(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitAnd) MOTH_BEGIN_INSTR(BitOr) - STOREVALUE(instr.result, Runtime::bitOr(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitOr(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitOr) MOTH_BEGIN_INSTR(BitXor) - STOREVALUE(instr.result, Runtime::bitXor(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.bitXor(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BitXor) MOTH_BEGIN_INSTR(Shr) @@ -886,15 +887,16 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(ShlConst) MOTH_BEGIN_INSTR(Mul) - STOREVALUE(instr.result, Runtime::mul(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.mul(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Mul) MOTH_BEGIN_INSTR(Sub) - STOREVALUE(instr.result, Runtime::sub(VALUE(instr.lhs), VALUE(instr.rhs))); + STOREVALUE(instr.result, engine->runtime.sub(VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(Sub) MOTH_BEGIN_INSTR(BinopContext) - STOREVALUE(instr.result, instr.alu(engine, VALUE(instr.lhs), VALUE(instr.rhs))); + QV4::Runtime::BinaryOperationContext op = *reinterpret_cast<QV4::Runtime::BinaryOperationContext *>(reinterpret_cast<char *>(&engine->runtime) + instr.alu); + STOREVALUE(instr.result, op(engine, VALUE(instr.lhs), VALUE(instr.rhs))); MOTH_END_INSTR(BinopContext) MOTH_BEGIN_INSTR(Ret) @@ -922,15 +924,15 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(LoadThis) MOTH_BEGIN_INSTR(LoadQmlContext) - VALUE(instr.result) = Runtime::getQmlContext(static_cast<QV4::NoThrowEngine*>(engine)); + VALUE(instr.result) = engine->runtime.getQmlContext(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlContext) MOTH_BEGIN_INSTR(LoadQmlImportedScripts) - VALUE(instr.result) = Runtime::getQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine)); + VALUE(instr.result) = engine->runtime.getQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlImportedScripts) MOTH_BEGIN_INSTR(LoadQmlSingleton) - VALUE(instr.result) = Runtime::getQmlSingleton(static_cast<QV4::NoThrowEngine*>(engine), instr.name); + VALUE(instr.result) = engine->runtime.getQmlSingleton(static_cast<QV4::NoThrowEngine*>(engine), instr.name); MOTH_END_INSTR(LoadQmlSingleton) #ifdef MOTH_THREADED_INTERPRETER |