diff options
author | Simon Hausmann <[email protected]> | 2014-03-12 16:55:06 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-04-23 21:16:46 +0200 |
commit | a885d10a0289da85b8c966d2fa40fb10edae4fd7 (patch) | |
tree | 7c16b5abd88d436f6596d6a424126c1b1dd2aba8 /src/qml/jsruntime | |
parent | 937fdde5d3b26291d417f856ee05ba479a6ba730 (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 <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/jsruntime.pri | 22 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 94 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_inl_p.h | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 4 |
12 files changed, 154 insertions, 39 deletions
diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri index 9d5757b5a0..72010d3fa8 100644 --- a/src/qml/jsruntime/jsruntime.pri +++ b/src/qml/jsruntime/jsruntime.pri @@ -1,11 +1,10 @@ INCLUDEPATH += $$PWD INCLUDEPATH += $$OUT_PWD +!qmldevtools_build { SOURCES += \ $$PWD/qv4engine.cpp \ $$PWD/qv4context.cpp \ - $$PWD/qv4runtime.cpp \ - $$PWD/qv4value.cpp \ $$PWD/qv4persistent.cpp \ $$PWD/qv4debugging.cpp \ $$PWD/qv4lookup.cpp \ @@ -33,7 +32,6 @@ SOURCES += \ $$PWD/qv4regexpobject.cpp \ $$PWD/qv4stringobject.cpp \ $$PWD/qv4variantobject.cpp \ - $$PWD/qv4string.cpp \ $$PWD/qv4objectiterator.cpp \ $$PWD/qv4regexp.cpp \ $$PWD/qv4serialize.cpp \ @@ -50,10 +48,7 @@ HEADERS += \ $$PWD/qv4global_p.h \ $$PWD/qv4engine_p.h \ $$PWD/qv4context_p.h \ - $$PWD/qv4runtime_p.h \ $$PWD/qv4math_p.h \ - $$PWD/qv4value_inl_p.h \ - $$PWD/qv4value_p.h \ $$PWD/qv4persistent_p.h \ $$PWD/qv4debugging_p.h \ $$PWD/qv4lookup_p.h \ @@ -81,7 +76,6 @@ HEADERS += \ $$PWD/qv4regexpobject_p.h \ $$PWD/qv4stringobject_p.h \ $$PWD/qv4variantobject_p.h \ - $$PWD/qv4string_p.h \ $$PWD/qv4property_p.h \ $$PWD/qv4objectiterator_p.h \ $$PWD/qv4regexp_p.h \ @@ -97,6 +91,20 @@ HEADERS += \ $$PWD/qv4vme_moth_p.h \ $$PWD/qv4profiling_p.h +} + + +HEADERS += \ + $$PWD/qv4runtime_p.h \ + $$PWD/qv4value_inl_p.h \ + $$PWD/qv4string_p.h \ + $$PWD/qv4value_p.h + +SOURCES += \ + $$PWD/qv4runtime.cpp \ + $$PWD/qv4string.cpp \ + $$PWD/qv4value.cpp + # Use SSE2 floating point math on 32 bit instead of the default # 387 to make test results pass on 32 and on 64 bit builds. linux-g++*:isEqual(QT_ARCH,i386) { diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 4e05bb81ab..b5dc6742f9 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -45,6 +45,7 @@ #include <QtCore/qglobal.h> #include <QString> #include <qtqmlglobal.h> +#include <private/qtqmlglobal_p.h> #if defined(Q_CC_MSVC) #include <float.h> @@ -66,6 +67,10 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } #define qOffsetOf(s, m) ((size_t)((((char *)&(((s *)64)->m)) - 64))) +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +#define V4_BOOTSTRAP +#endif + // Decide whether to enable or disable the JIT // White list architectures diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 5ad4c28970..06d3e4884b 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -187,7 +187,7 @@ const QV4::ObjectVTable classname::static_vtbl = \ } -struct Q_QML_EXPORT Managed +struct Q_QML_PRIVATE_EXPORT Managed { V4_MANAGED enum { diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 0dfaffc132..40f38ee347 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -410,11 +410,13 @@ inline ArrayObject *value_cast(const Value &v) { return v.asArrayObject(); } +#ifndef V4_BOOTSTRAP template<> inline ReturnedValue value_convert<Object>(ExecutionEngine *e, const Value &v) { return v.toObject(e->currentContext())->asReturnedValue(); } +#endif struct ObjectRef : public ManagedRef { 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 diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index d00c579283..0979105680 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -103,7 +103,7 @@ struct NoThrowContext : public ExecutionContext { }; -struct Q_QML_EXPORT Runtime { +struct Q_QML_PRIVATE_EXPORT Runtime { // call static ReturnedValue callGlobalLookup(ExecutionContext *context, uint index, CallDataRef callData); static ReturnedValue callActivationProperty(ExecutionContext *, const StringRef name, CallDataRef callData); @@ -232,7 +232,7 @@ struct Q_QML_EXPORT Runtime { static void setQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object, int propertyIndex, const ValueRef value); }; -struct Q_QML_EXPORT RuntimeHelpers { +struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static ReturnedValue objectDefaultValue(Object *object, int typeHint); static ReturnedValue toPrimitive(const ValueRef value, int typeHint); @@ -255,6 +255,7 @@ struct Q_QML_EXPORT RuntimeHelpers { // type conversion and testing +#ifndef V4_BOOTSTRAP inline ReturnedValue RuntimeHelpers::toPrimitive(const ValueRef value, int typeHint) { Object *o = value->asObject(); @@ -262,6 +263,7 @@ inline ReturnedValue RuntimeHelpers::toPrimitive(const ValueRef value, int typeH return value.asReturnedValue(); return RuntimeHelpers::objectDefaultValue(o, typeHint); } +#endif inline double RuntimeHelpers::toNumber(const ValueRef value) { @@ -338,6 +340,7 @@ inline ReturnedValue Runtime::bitAnd(const ValueRef left, const ValueRef right) return Encode(lval & rval); } +#ifndef V4_BOOTSTRAP inline ReturnedValue Runtime::add(ExecutionContext *ctx, const ValueRef left, const ValueRef right) { TRACE2(left, right); @@ -349,6 +352,7 @@ inline ReturnedValue Runtime::add(ExecutionContext *ctx, const ValueRef left, co return RuntimeHelpers::addHelper(ctx, left, right); } +#endif // V4_BOOTSTRAP inline ReturnedValue Runtime::sub(const ValueRef left, const ValueRef right) { @@ -532,6 +536,7 @@ inline Bool Runtime::compareStrictNotEqual(const ValueRef left, const ValueRef r return ! RuntimeHelpers::strictEqual(left, right); } +#ifndef V4_BOOTSTRAP inline Bool Runtime::compareInstanceof(ExecutionContext *ctx, const ValueRef left, const ValueRef right) { TRACE2(left, right); @@ -550,6 +555,13 @@ inline uint Runtime::compareIn(ExecutionContext *ctx, const ValueRef left, const return v->booleanValue(); } +#endif // V4_BOOTSTRAP + +inline Bool Runtime::toBoolean(const ValueRef value) +{ + return value->toBoolean(); +} + } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 33922684da..36f61a1df5 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -385,10 +385,10 @@ QV4::CompiledData::CompilationUnit *Script::precompile(IR::Module *module, Compi QQmlJS::Codegen cg(/*strict mode*/false); cg.generateFromProgram(url.toString(), source, program, module, QQmlJS::Codegen::EvalCode); - errors = cg.errors(); + errors = cg.qmlErrors(); if (!errors.isEmpty()) { if (reportedErrors) - *reportedErrors << cg.errors(); + *reportedErrors << errors; return 0; } diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 575f605e45..d9aa881f21 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -40,10 +40,13 @@ ****************************************************************************/ #include "qv4string_p.h" +#include "qv4value_inl_p.h" +#ifndef V4_BOOTSTRAP #include "qv4identifiertable_p.h" #include "qv4runtime_p.h" #include "qv4objectproto_p.h" #include "qv4stringobject_p.h" +#endif #include <QtCore/QHash> using namespace QV4; @@ -74,6 +77,8 @@ static uint toArrayIndex(const QChar *ch, const QChar *end, bool *ok) return i; } +#ifndef V4_BOOTSTRAP + static uint toArrayIndex(const char *ch, const char *end, bool *ok) { *ok = false; @@ -407,13 +412,16 @@ uint String::createHashValue(const char *ch, int length) return h; } +uint String::getLength(const Managed *m) +{ + return static_cast<const String *>(m)->length(); +} + +#endif // V4_BOOTSTRAP + uint String::toArrayIndex(const QString &str) { bool ok; return ::toArrayIndex(str.constData(), str.constData() + str.length(), &ok); } -uint String::getLength(const Managed *m) -{ - return static_cast<const String *>(m)->length(); -} diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index ade64d1352..ed2a4e3646 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -51,7 +51,8 @@ namespace QV4 { struct ExecutionEngine; struct Identifier; -struct Q_QML_EXPORT String : public Managed { +struct Q_QML_PRIVATE_EXPORT String : public Managed { +#ifndef V4_BOOTSTRAP // ### FIXME: Should this be a V4_OBJECT V4_OBJECT Q_MANAGED_TYPE(String) @@ -143,8 +144,6 @@ struct Q_QML_EXPORT String : public Managed { return len; } - static uint toArrayIndex(const QString &str); - union { mutable QStringData *_text; mutable String *left; @@ -174,8 +173,13 @@ protected: private: QChar *recursiveAppend(QChar *ch) const; +#endif + +public: + static uint toArrayIndex(const QString &str); }; +#ifndef V4_BOOTSTRAP template<> inline String *value_cast(const Value &v) { return v.asString(); @@ -188,6 +192,7 @@ inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v) } DEFINE_REF(String, Managed); +#endif } diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index fa16662b46..e9246f7a14 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -39,9 +39,11 @@ ** ****************************************************************************/ #include <qv4engine_p.h> +#ifndef V4_BOOTSTRAP #include <qv4object_p.h> #include <qv4objectproto_p.h> #include "qv4mm_p.h" +#endif #include <wtf/MathExtras.h> @@ -87,6 +89,9 @@ double Value::toNumberImpl() const case QV4::Value::Undefined_Type: return std::numeric_limits<double>::quiet_NaN(); case QV4::Value::Managed_Type: +#ifdef V4_BOOTSTRAP + Q_UNIMPLEMENTED(); +#else if (isString()) return RuntimeHelpers::stringToNumber(stringValue()->toQString()); { @@ -95,6 +100,7 @@ double Value::toNumberImpl() const ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), NUMBER_HINT)); return prim->toNumber(); } +#endif case QV4::Value::Null_Type: case QV4::Value::Boolean_Type: case QV4::Value::Integer_Type: @@ -104,6 +110,7 @@ double Value::toNumberImpl() const } } +#ifndef V4_BOOTSTRAP QString Value::toQStringNoThrow() const { switch (type()) { @@ -192,6 +199,7 @@ QString Value::toQString() const } } // switch } +#endif // V4_BOOTSTRAP bool Value::sameValue(Value other) const { if (val == other.val) @@ -263,6 +271,7 @@ double Primitive::toInteger(double number) return std::signbit(number) ? -v : v; } +#ifndef V4_BOOTSTRAP String *Value::toString(ExecutionEngine *e) const { return toString(e->currentContext()); @@ -282,3 +291,4 @@ Object *Value::toObject(ExecutionContext *ctx) const return RuntimeHelpers::convertToObject(ctx, ValueRef::fromRawValue(this))->getPointer(); } +#endif // V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4value_inl_p.h b/src/qml/jsruntime/qv4value_inl_p.h index 35508f442a..1fe9e1c165 100644 --- a/src/qml/jsruntime/qv4value_inl_p.h +++ b/src/qml/jsruntime/qv4value_inl_p.h @@ -180,14 +180,19 @@ inline bool Value::toBoolean() const case Value::Integer_Type: return (bool)int_32; case Value::Managed_Type: +#ifdef V4_BOOTSTRAP + Q_UNIMPLEMENTED(); +#else if (isString()) return stringValue()->toQString().length() > 0; +#endif return true; default: // double return doubleValue() && !std::isnan(doubleValue()); } } +#ifndef V4_BOOTSTRAP inline uint Value::asArrayIndex() const { #if QT_POINTER_SIZE == 8 @@ -278,6 +283,8 @@ inline ErrorObject *Value::asErrorObject() const template<typename T> inline T *Value::as() const { Managed *m = isObject() ? managed() : 0; return m ? m->as<T>() : 0; } +#endif + } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 27c81d59a5..2c780622dc 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -64,7 +64,7 @@ struct Returned : private T using T::asReturnedValue; }; -struct Q_QML_EXPORT Value +struct Q_QML_PRIVATE_EXPORT Value { /* We use two different ways of encoding JS values. One for 32bit and one for 64bit systems. @@ -372,7 +372,7 @@ inline String *Value::asString() const return 0; } -struct Q_QML_EXPORT Primitive : public Value +struct Q_QML_PRIVATE_EXPORT Primitive : public Value { inline static Primitive emptyValue(); static inline Primitive fromBoolean(bool b); |