aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-12 16:55:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-23 21:16:46 +0200
commita885d10a0289da85b8c966d2fa40fb10edae4fd7 (patch)
tree7c16b5abd88d436f6596d6a424126c1b1dd2aba8 /src/qml/jsruntime/qv4runtime.cpp
parent937fdde5d3b26291d417f856ee05ba479a6ba730 (diff)
Extend the QML bootstrap library by the IR builders
This is among other things needed to fix the qml import scanner to detect dependencies from .js files correctly. The patch also fixes the use of Q_QML_EXPORT towards Q_QML_PRIVATE_EXPORT where appropriate and corrects the wrong include path for the double conversion code to actually be relative to the file it is included from. This worked by accident because of other include paths present in the build. Change-Id: I338583dad2f76300819af8ab0dae8e5724c84430 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp94
1 files changed, 76 insertions, 18 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 4923c217b6..e44d1a07a6 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -41,6 +41,7 @@
#include "qv4global_p.h"
#include "qv4runtime_p.h"
+#ifndef V4_BOOTSTRAP
#include "qv4object_p.h"
#include "qv4jsir_p.h"
#include "qv4objectproto_p.h"
@@ -54,6 +55,7 @@
#include <private/qqmlcontextwrapper_p.h>
#include "qv4qobjectwrapper_p.h"
#include <private/qv8engine_p.h>
+#endif
#include <QtCore/qmath.h>
#include <QtCore/qnumeric.h>
@@ -63,7 +65,7 @@
#include <typeinfo>
#include <stdlib.h>
-#include "../../../3rdparty/double-conversion/double-conversion.h"
+#include "../../3rdparty/double-conversion/double-conversion.h"
QT_BEGIN_NAMESPACE
@@ -207,6 +209,7 @@ void RuntimeCounters::count(const char *func, uint tag1, uint tag2)
#endif // QV4_COUNT_RUNTIME_FUNCTIONS
+#ifndef V4_BOOTSTRAP
void RuntimeHelpers::numberToString(QString *result, double num, int radix)
{
Q_ASSERT(result);
@@ -414,10 +417,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(Object *object, int typeHint)
return ctx->throwTypeError();
}
-Bool Runtime::toBoolean(const ValueRef value)
-{
- return value->toBoolean();
-}
+
Returned<Object> *RuntimeHelpers::convertToObject(ExecutionContext *ctx, const ValueRef value)
{
@@ -677,6 +677,8 @@ ReturnedValue Runtime::getActivationProperty(ExecutionContext *ctx, const String
return ctx->getProperty(name);
}
+#endif // V4_BOOTSTRAP
+
uint RuntimeHelpers::equalHelper(const ValueRef x, const ValueRef y)
{
Q_ASSERT(x->type() != y->type() || (x->isManaged() && (x->isString() != y->isString())));
@@ -697,14 +699,20 @@ uint RuntimeHelpers::equalHelper(const ValueRef x, const ValueRef y)
return Runtime::compareEqual(Primitive::fromDouble((double) x->booleanValue()), y);
} else if (y->isBoolean()) {
return Runtime::compareEqual(x, Primitive::fromDouble((double) y->booleanValue()));
- } else 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);
- } 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);
+ } else {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+#else
+ 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);
+ } 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);
+ }
+#endif
}
return false;
@@ -732,15 +740,25 @@ QV4::Bool Runtime::compareGreaterThan(const QV4::ValueRef l, const QV4::ValueRef
return l->integerValue() > r->integerValue();
if (l->isNumber() && r->isNumber())
return l->asDouble() > r->asDouble();
- if (l->isString() && r->isString())
+ if (l->isString() && r->isString()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+ return false;
+#else
return r->stringValue()->compare(l->stringValue());
+#endif
+ }
if (l->isObject() || r->isObject()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+#else
QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine();
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);
+#endif
}
double dl = RuntimeHelpers::toNumber(l);
@@ -755,15 +773,25 @@ QV4::Bool Runtime::compareLessThan(const QV4::ValueRef l, const QV4::ValueRef r)
return l->integerValue() < r->integerValue();
if (l->isNumber() && r->isNumber())
return l->asDouble() < r->asDouble();
- if (l->isString() && r->isString())
+ if (l->isString() && r->isString()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+ return false;
+#else
return l->stringValue()->compare(r->stringValue());
+#endif
+ }
if (l->isObject() || r->isObject()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+#else
QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine();
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);
+#endif
}
double dl = RuntimeHelpers::toNumber(l);
@@ -778,15 +806,25 @@ QV4::Bool Runtime::compareGreaterEqual(const QV4::ValueRef l, const QV4::ValueRe
return l->integerValue() >= r->integerValue();
if (l->isNumber() && r->isNumber())
return l->asDouble() >= r->asDouble();
- if (l->isString() && r->isString())
+ if (l->isString() && r->isString()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+ return false;
+#else
return !l->stringValue()->compare(r->stringValue());
+#endif
+ }
if (l->isObject() || r->isObject()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+#else
QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine();
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);
+#endif
}
double dl = RuntimeHelpers::toNumber(l);
@@ -801,15 +839,25 @@ QV4::Bool Runtime::compareLessEqual(const QV4::ValueRef l, const QV4::ValueRef r
return l->integerValue() <= r->integerValue();
if (l->isNumber() && r->isNumber())
return l->asDouble() <= r->asDouble();
- if (l->isString() && r->isString())
+ if (l->isString() && r->isString()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+ return false;
+#else
return !r->stringValue()->compare(l->stringValue());
+#endif
+ }
if (l->isObject() || r->isObject()) {
+#ifdef V4_BOOTSTRAP
+ Q_UNIMPLEMENTED();
+#else
QV4::ExecutionEngine *e = (l->isObject() ? l->objectValue() : r->objectValue())->engine();
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);
+#endif
}
double dl = RuntimeHelpers::toNumber(l);
@@ -817,7 +865,7 @@ QV4::Bool Runtime::compareLessEqual(const QV4::ValueRef l, const QV4::ValueRef r
return dl <= dr;
}
-
+#ifndef V4_BOOTSTRAP
ReturnedValue Runtime::callGlobalLookup(ExecutionContext *context, uint index, CallDataRef callData)
{
Scope scope(context);
@@ -1144,6 +1192,8 @@ QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionContext *ctx)
return (new (c->engine->memoryManager) ArgumentsObject(c))->asReturnedValue();
}
+#endif // V4_BOOTSTRAP
+
QV4::ReturnedValue Runtime::increment(const QV4::ValueRef value)
{
TRACE1(value);
@@ -1168,6 +1218,8 @@ QV4::ReturnedValue Runtime::decrement(const QV4::ValueRef value)
}
}
+#ifndef V4_BOOTSTRAP
+
QV4::ReturnedValue RuntimeHelpers::toString(QV4::ExecutionContext *ctx, const QV4::ValueRef value)
{
if (value->isString())
@@ -1187,6 +1239,8 @@ QV4::ReturnedValue RuntimeHelpers::toObject(QV4::ExecutionContext *ctx, const QV
return Encode(o);
}
+#endif // V4_BOOTSTRAP
+
ReturnedValue Runtime::toDouble(const ValueRef value)
{
TRACE1(value);
@@ -1217,6 +1271,8 @@ unsigned Runtime::doubleToUInt(const double &d)
return Primitive::toUInt32(d);
}
+#ifndef V4_BOOTSTRAP
+
ReturnedValue Runtime::regexpLiteral(ExecutionContext *ctx, int id)
{
return ctx->compilationUnit->runtimeRegularExpressions[id].asReturnedValue();
@@ -1301,6 +1357,8 @@ void Runtime::convertThisToObject(ExecutionContext *ctx)
}
}
+#endif // V4_BOOTSTRAP
+
} // namespace QV4
QT_END_NAMESPACE