1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 // #define REGISTER_CLEANUP_DEBUG
44 #include "qv4bindings_p.h"
45 #include "qv4program_p.h"
46 #include "qv4compiler_p.h"
47 #include "qv4compiler_p_p.h"
49 #include <private/qdeclarativeaccessors_p.h>
50 #include <private/qdeclarativedebugtrace_p.h>
51 #include <private/qdeclarativemetatype_p.h>
52 #include <private/qdeclarativetrace_p.h>
54 #include <QtDeclarative/qdeclarativeinfo.h>
55 #include <QtCore/qnumeric.h>
56 #include <QtCore/qmath.h>
57 #include <math.h> // ::fmod
61 using namespace QDeclarativeJS;
65 typedef QDeclarativeRegisterType Type;
67 void setUndefined() { dataType = UndefinedType; }
68 void setNaN() { setqreal(qSNaN()); }
69 bool isUndefined() const { return dataType == UndefinedType; }
71 void setQObject(QObject *o) { qobjectValue = o; dataType = QObjectStarType; }
72 QObject *getQObject() const { return qobjectValue; }
74 void setqreal(qreal v) { qrealValue = v; dataType = QRealType; }
75 qreal getqreal() const { return qrealValue; }
76 qreal &getqrealref() { return qrealValue; }
78 void setint(int v) { intValue = v; dataType = IntType; }
79 int getint() const { return intValue; }
80 int &getintref() { return intValue; }
82 void setbool(bool v) { boolValue = v; dataType = BoolType; }
83 bool getbool() const { return boolValue; }
84 bool &getboolref() { return boolValue; }
86 QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
87 QString *getstringptr() { return (QString *)typeDataPtr(); }
88 QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
89 const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
90 const QString *getstringptr() const { return (QString *)typeDataPtr(); }
91 const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
93 void *typeDataPtr() { return (void *)&data; }
94 void *typeMemory() { return (void *)data; }
95 const void *typeDataPtr() const { return (void *)&data; }
96 const void *typeMemory() const { return (void *)data; }
98 Type gettype() const { return dataType; }
99 void settype(Type t) { dataType = t; }
101 Type dataType; // Type of data
103 QObject *qobjectValue;
107 void *data[sizeof(QVariant)];
108 qint64 q_for_alignment_1;
109 double q_for_alignment_2;
112 inline void cleanup();
113 inline void cleanupString();
114 inline void cleanupUrl();
115 inline void cleanupVariant();
117 inline void copy(const Register &other);
118 inline void init(Type type);
119 #ifdef REGISTER_CLEANUP_DEBUG
125 if (dataType >= FirstCleanupType)
126 qWarning("Register leaked of type %d", dataType);
131 void Register::cleanup()
133 if (dataType >= FirstCleanupType) {
134 if (dataType == QStringType) {
135 getstringptr()->~QString();
136 } else if (dataType == QUrlType) {
137 geturlptr()->~QUrl();
138 } else if (dataType == QVariantType) {
139 getvariantptr()->~QVariant();
145 void Register::cleanupString()
147 getstringptr()->~QString();
151 void Register::cleanupUrl()
153 geturlptr()->~QUrl();
157 void Register::cleanupVariant()
159 getvariantptr()->~QVariant();
163 void Register::copy(const Register &other)
166 if (other.dataType >= FirstCleanupType) {
167 if (other.dataType == QStringType)
168 new (getstringptr()) QString(*other.getstringptr());
169 else if (other.dataType == QUrlType)
170 new (geturlptr()) QUrl(*other.geturlptr());
171 else if (other.dataType == QVariantType)
172 new (getvariantptr()) QVariant(*other.getvariantptr());
176 void Register::init(Type type)
179 if (dataType >= FirstCleanupType) {
180 if (dataType == QStringType)
181 new (getstringptr()) QString();
182 else if (dataType == QUrlType)
183 new (geturlptr()) QUrl();
184 else if (dataType == QVariantType)
185 new (getvariantptr()) QVariant();
189 } // end of anonymous namespace
191 QV4Bindings::QV4Bindings(const char *programData,
192 QDeclarativeContextData *context,
193 QDeclarativeRefCount *ref)
194 : subscriptions(0), program(0), dataRef(0), bindings(0)
196 program = (QV4Program *)programData;
198 if (dataRef) dataRef->addref();
201 subscriptions = new Subscription[program->subscriptions];
202 bindings = new Binding[program->bindings];
204 QDeclarativeAbstractExpression::setContext(context);
208 QV4Bindings::~QV4Bindings()
211 delete [] subscriptions; subscriptions = 0;
212 if (dataRef) dataRef->release();
215 QDeclarativeAbstractBinding *QV4Bindings::configBinding(int index, QObject *target,
216 QObject *scope, int property,
217 int line, int column)
219 Binding *rv = bindings + index;
222 rv->property = property;
229 addref(); // This is decremented in Binding::destroy()
234 void QV4Bindings::Binding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
239 if (e) update(flags);
243 void QV4Bindings::Binding::update(QDeclarativePropertyPrivate::WriteFlags flags)
245 QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Binding);
246 if (parent->context())
247 QDeclarativeDebugTrace::rangeLocation(QDeclarativeDebugTrace::Binding,
248 parent->context()->url, line, column);
249 parent->run(this, flags);
250 QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Binding);
253 void QV4Bindings::Binding::destroy()
262 void QV4Bindings::Subscription::subscriptionCallback(QDeclarativeNotifierEndpoint *e)
264 Subscription *s = static_cast<Subscription *>(e);
265 s->bindings->subscriptionNotify(s->method);
268 void QV4Bindings::subscriptionNotify(int id)
270 QV4Program::BindingReferenceList *list = program->signalTable(id);
272 for (quint32 ii = 0; ii < list->count; ++ii) {
273 QV4Program::BindingReference *bindingRef = list->bindings + ii;
275 Binding *binding = bindings + bindingRef->binding;
277 if (binding->executedBlocks & bindingRef->blockMask) {
278 run(binding, QDeclarativePropertyPrivate::DontRemoveBinding);
283 void QV4Bindings::run(Binding *binding, QDeclarativePropertyPrivate::WriteFlags flags)
285 if (!binding->enabled)
288 QDeclarativeContextData *context = QDeclarativeAbstractExpression::context();
289 if (!context || !context->isValid())
292 QDeclarativeTrace trace("V4 Binding Update");
293 trace.addDetail("URL", context->url);
294 trace.addDetail("Line", binding->line);
295 trace.addDetail("Column", binding->column);
297 if (binding->updating) {
299 if (binding->property & 0xFFFF0000) {
300 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
302 QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
305 name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name());
306 name.append(QLatin1String("."));
307 name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name()));
309 name = QLatin1String(binding->target->metaObject()->property(binding->property).name());
311 qmlInfo(binding->target) << tr("Binding loop detected for property \"%1\"").arg(name);
315 binding->updating = true;
316 if (binding->property & 0xFFFF0000) {
317 QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context->engine);
319 QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
321 vt->read(binding->target, binding->property & 0xFFFF);
323 QObject *target = vt;
324 run(binding->index, binding->executedBlocks, context, binding, binding->scope, target, flags);
326 vt->write(binding->target, binding->property & 0xFFFF, flags);
328 run(binding->index, binding->executedBlocks, context, binding, binding->scope, binding->target, flags);
330 binding->updating = false;
334 void QV4Bindings::unsubscribe(int subIndex)
336 Subscription *sub = (subscriptions + subIndex);
340 void QV4Bindings::subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex)
342 unsubscribe(subIndex);
344 if (p->idValues[idIndex]) {
345 Subscription *sub = (subscriptions + subIndex);
346 sub->bindings = this;
347 sub->method = subIndex;
348 sub->connect(&p->idValues[idIndex].bindings);
352 void QV4Bindings::subscribe(QObject *o, int notifyIndex, int subIndex)
354 Subscription *sub = (subscriptions + subIndex);
355 if (sub->isConnected(o, notifyIndex))
357 sub->bindings = this;
358 sub->method = subIndex;
360 sub->connect(o, notifyIndex);
365 // Conversion functions - these MUST match the QtScript expression path
366 inline static qreal toReal(Register *reg, int type, bool *ok = 0)
370 if (type == QMetaType::QReal) {
371 return reg->getqreal();
372 } else if (type == qMetaTypeId<QVariant>()) {
373 return reg->getvariantptr()->toReal();
380 inline static QString toString(Register *reg, int type, bool *ok = 0)
384 if (type == QMetaType::QReal) {
385 return QString::number(reg->getqreal());
386 } else if (type == QMetaType::Int) {
387 return QString::number(reg->getint());
388 } else if (type == qMetaTypeId<QVariant>()) {
389 return reg->getvariantptr()->toString();
390 } else if (type == QMetaType::QString) {
391 return *reg->getstringptr();
398 inline static bool toBool(Register *reg, int type, bool *ok = 0)
402 if (type == QMetaType::Bool) {
403 return reg->getbool();
404 } else if (type == qMetaTypeId<QVariant>()) {
405 return reg->getvariantptr()->toBool();
412 inline static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok = 0)
417 if (type == qMetaTypeId<QVariant>()) {
418 QVariant *var = reg->getvariantptr();
419 int vt = var->type();
420 if (vt == QVariant::Url) {
422 } else if (vt == QVariant::ByteArray) {
423 base = QUrl(QString::fromUtf8(var->toByteArray()));
424 } else if (vt == QVariant::String) {
425 base = QUrl(var->toString());
430 } else if (type == QMetaType::QString) {
431 base = QUrl(*reg->getstringptr());
437 if (!base.isEmpty() && base.isRelative())
438 return context->url.resolved(base);
443 static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4)
445 QVariant qtscript = qtscriptRaw;
447 if (qtscript.userType() == v4.userType()) {
448 } else if (qtscript.canConvert((QVariant::Type)v4.userType())) {
449 qtscript.convert((QVariant::Type)v4.userType());
450 } else if (qtscript.userType() == QVariant::Invalid && v4.userType() == QMetaType::QObjectStar) {
451 qtscript = qVariantFromValue<QObject *>(0);
456 int type = qtscript.userType();
458 if (type == qMetaTypeId<QDeclarative1AnchorLine>()) {
459 QDeclarative1AnchorLine la = qvariant_cast<QDeclarative1AnchorLine>(qtscript);
460 QDeclarative1AnchorLine ra = qvariant_cast<QDeclarative1AnchorLine>(v4);
463 } else if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
464 return QDeclarativeMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData());
465 } else if (type == QMetaType::Double) {
467 double la = qvariant_cast<double>(qtscript);
468 double lr = qvariant_cast<double>(v4);
470 return la == lr || (qIsNaN(la) && qIsNaN(lr));
472 } else if (type == QMetaType::Float) {
474 float la = qvariant_cast<float>(qtscript);
475 float lr = qvariant_cast<float>(v4);
477 return la == lr || (qIsNaN(la) && qIsNaN(lr));
480 return qtscript == v4;
484 QByteArray testResultToString(const QVariant &result, bool undefined)
496 static void testBindingResult(const QString &binding, int line, int column,
497 QDeclarativeContextData *context, QObject *scope,
498 const Register &result, int resultType)
500 QDeclarativeExpression expression(context->asQDeclarativeContext(), scope, binding);
501 bool isUndefined = false;
502 QVariant value = expression.evaluate(&isUndefined);
504 bool iserror = false;
505 QByteArray qtscriptResult;
508 if (expression.hasError()) {
510 qtscriptResult = "exception";
512 qtscriptResult = testResultToString(value, isUndefined);
515 if (isUndefined && result.isUndefined()) {
517 } else if(isUndefined != result.isUndefined()) {
522 if (!result.isUndefined()) {
523 switch (resultType) {
524 case QMetaType::QString:
525 v4value = *result.getstringptr();
527 case QMetaType::QUrl:
528 v4value = *result.geturlptr();
530 case QMetaType::QObjectStar:
531 v4value = qVariantFromValue<QObject *>(result.getQObject());
533 case QMetaType::Bool:
534 v4value = result.getbool();
537 v4value = result.getint();
539 case QMetaType::QReal:
540 v4value = result.getqreal();
543 if (resultType == qMetaTypeId<QDeclarative1AnchorLine>()) {
544 v4value = qVariantFromValue<QDeclarative1AnchorLine>(*(QDeclarative1AnchorLine *)result.typeDataPtr());
545 } else if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) {
546 v4value = QVariant(QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr());
549 v4Result = "Unknown V4 type";
553 if (v4Result.isEmpty())
554 v4Result = testResultToString(v4value, result.isUndefined());
556 if (!testCompareVariants(value, v4value))
560 qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
562 qWarning().nospace() << " Binding: " << binding;
563 qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
564 qWarning().nospace() << " V4: " << v4Result.constData();
568 static void testBindingException(const QString &binding, int line, int column,
569 QDeclarativeContextData *context, QObject *scope)
571 QDeclarativeExpression expression(context->asQDeclarativeContext(), scope, binding);
572 bool isUndefined = false;
573 QVariant value = expression.evaluate(&isUndefined);
575 if (!expression.hasError()) {
576 QByteArray qtscriptResult = testResultToString(value, isUndefined);
577 qWarning().nospace() << "QV4: Optimization error @" << context->url.toString().toUtf8().constData() << ":" << line << ":" << column;
578 qWarning().nospace() << " Binding: " << binding;
579 qWarning().nospace() << " QtScript: " << qtscriptResult.constData();
580 qWarning().nospace() << " V4: exception";
584 static void throwException(int id, QDeclarativeDelayedError *error,
585 QV4Program *program, QDeclarativeContextData *context,
586 const QString &description = QString())
588 error->error.setUrl(context->url);
589 if (description.isEmpty())
590 error->error.setDescription(QLatin1String("TypeError: Result of expression is not an object"));
592 error->error.setDescription(description);
594 quint64 e = *((quint64 *)(program->data() + program->exceptionDataOffset) + id);
595 error->error.setLine((e >> 32) & 0xFFFFFFFF);
596 error->error.setColumn(e & 0xFFFFFFFF);
598 error->error.setLine(-1);
599 error->error.setColumn(-1);
601 if (!context->engine || !error->addError(QDeclarativeEnginePrivate::get(context->engine)))
602 QDeclarativeEnginePrivate::warning(context->engine, error->error);
605 const qreal QV4Bindings::D32 = 4294967296.0;
607 qint32 QV4Bindings::toInt32(qreal n)
609 if (qIsNaN(n) || qIsInf(n) || (n == 0))
612 double sign = (n < 0) ? -1.0 : 1.0;
613 qreal abs_n = fabs(n);
615 n = ::fmod(sign * ::floor(abs_n), D32);
616 const double D31 = D32 / 2.0;
618 if (sign == -1 && n < -D31)
621 else if (sign != -1 && n >= D31)
627 inline quint32 QV4Bindings::toUint32(qreal n)
629 if (qIsNaN(n) || qIsInf(n) || (n == 0))
632 double sign = (n < 0) ? -1.0 : 1.0;
633 qreal abs_n = fabs(n);
635 n = ::fmod(sign * ::floor(abs_n), D32);
643 #define THROW_EXCEPTION_STR(id, str) { \
644 if (testBinding) testBindingException(*testBindingSource, bindingLine, bindingColumn, context, scope); \
645 throwException((id), error, program, context, (str)); \
646 goto exceptionExit; \
649 #define THROW_EXCEPTION(id) THROW_EXCEPTION_STR(id, QString())
651 #define MARK_REGISTER(reg) cleanupRegisterMask |= (1 << (reg))
652 #define MARK_CLEAN_REGISTER(reg) cleanupRegisterMask &= ~(1 << (reg))
654 #define STRING_REGISTER(reg) { \
655 registers[(reg)].settype(QStringType); \
656 MARK_REGISTER(reg); \
659 #define URL_REGISTER(reg) { \
660 registers[(reg)].settype(QUrlType); \
661 MARK_REGISTER(reg); \
664 #define VARIANT_REGISTER(reg) { \
665 registers[(reg)].settype(QVariantType); \
666 MARK_REGISTER(reg); \
669 #ifdef QML_THREADED_INTERPRETER
670 void **QV4Bindings::getDecodeInstrTable()
672 static void **decode_instr;
674 QV4Bindings *dummy = new QV4Bindings(0, 0, 0);
675 quint32 executedBlocks = 0;
676 dummy->run(0, executedBlocks, 0, 0, 0, 0,
677 QDeclarativePropertyPrivate::BypassInterceptor,
685 void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
686 QDeclarativeContextData *context, QDeclarativeDelayedError *error,
687 QObject *scope, QObject *output,
688 QDeclarativePropertyPrivate::WriteFlags storeFlags
689 #ifdef QML_THREADED_INTERPRETER
694 #ifdef QML_THREADED_INTERPRETER
696 static void *decode_instr[] = {
697 FOR_EACH_V4_INSTR(QML_V4_INSTR_ADDR)
700 *table = decode_instr;
706 error->removeError();
708 Register registers[32];
709 quint32 cleanupRegisterMask = 0;
713 const char *code = program->instructions();
714 code += instrIndex * QML_V4_INSTR_SIZE(Jump, jump);
715 const V4Instr *instr = reinterpret_cast<const V4Instr *>(code);
717 const char *data = program->data();
719 QString *testBindingSource = 0;
720 bool testBinding = false;
722 int bindingColumn = 0;
724 #ifdef QML_THREADED_INTERPRETER
725 goto *instr->common.code;
728 switch (instr->common.type) {
731 QML_V4_BEGIN_INSTR(Noop, common)
732 QML_V4_END_INSTR(Noop, common)
734 QML_V4_BEGIN_INSTR(BindingId, id)
735 bindingLine = instr->id.line;
736 bindingColumn = instr->id.column;
737 QML_V4_END_INSTR(BindingId, id)
739 QML_V4_BEGIN_INSTR(SubscribeId, subscribeop)
740 subscribeId(context, instr->subscribeop.index, instr->subscribeop.offset);
741 QML_V4_END_INSTR(SubscribeId, subscribeop)
743 QML_V4_BEGIN_INSTR(Subscribe, subscribeop)
746 const Register &object = registers[instr->subscribeop.reg];
747 if (!object.isUndefined()) o = object.getQObject();
748 subscribe(o, instr->subscribeop.index, instr->subscribeop.offset);
750 QML_V4_END_INSTR(Subscribe, subscribeop)
752 QML_V4_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
754 Register ® = registers[instr->fetchAndSubscribe.reg];
756 if (reg.isUndefined())
757 THROW_EXCEPTION(instr->fetchAndSubscribe.exceptionId);
759 QObject *object = reg.getQObject();
763 int subIdx = instr->fetchAndSubscribe.subscription;
764 Subscription *sub = 0;
766 sub = (subscriptions + subIdx);
767 sub->bindings = this;
768 sub->method = subIdx;
770 reg.init((Register::Type)instr->fetchAndSubscribe.valueType);
771 if (instr->fetchAndSubscribe.valueType >= FirstCleanupType)
772 MARK_REGISTER(instr->fetchAndSubscribe.reg);
773 QDeclarativeAccessors *accessors = instr->fetchAndSubscribe.property.accessors;
774 accessors->read(object, instr->fetchAndSubscribe.property.accessorData,
777 if (accessors->notifier) {
778 QDeclarativeNotifier *notifier = 0;
779 accessors->notifier(object, instr->fetchAndSubscribe.property.accessorData, ¬ifier);
780 if (notifier) sub->connect(notifier);
781 } else if (instr->fetchAndSubscribe.property.notifyIndex != -1) {
782 sub->connect(object, instr->fetchAndSubscribe.property.notifyIndex);
786 QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
788 QML_V4_BEGIN_INSTR(LoadId, load)
789 registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
790 QML_V4_END_INSTR(LoadId, load)
792 QML_V4_BEGIN_INSTR(LoadScope, load)
793 registers[instr->load.reg].setQObject(scope);
794 QML_V4_END_INSTR(LoadScope, load)
796 QML_V4_BEGIN_INSTR(LoadRoot, load)
797 registers[instr->load.reg].setQObject(context->contextObject);
798 QML_V4_END_INSTR(LoadRoot, load)
800 QML_V4_BEGIN_INSTR(LoadAttached, attached)
802 const Register &input = registers[instr->attached.reg];
803 Register &output = registers[instr->attached.output];
804 if (input.isUndefined())
805 THROW_EXCEPTION(instr->attached.exceptionId);
807 QObject *object = registers[instr->attached.reg].getQObject();
809 output.setUndefined();
811 QObject *attached = qmlAttachedPropertiesObjectById(instr->attached.id, input.getQObject(), true);
813 output.setQObject(attached);
816 QML_V4_END_INSTR(LoadAttached, attached)
818 QML_V4_BEGIN_INSTR(UnaryNot, unaryop)
820 registers[instr->unaryop.output].setbool(!registers[instr->unaryop.src].getbool());
822 QML_V4_END_INSTR(UnaryNot, unaryop)
824 QML_V4_BEGIN_INSTR(UnaryMinusReal, unaryop)
826 registers[instr->unaryop.output].setqreal(-registers[instr->unaryop.src].getqreal());
828 QML_V4_END_INSTR(UnaryMinusReal, unaryop)
830 QML_V4_BEGIN_INSTR(UnaryMinusInt, unaryop)
832 registers[instr->unaryop.output].setint(-registers[instr->unaryop.src].getint());
834 QML_V4_END_INSTR(UnaryMinusInt, unaryop)
836 QML_V4_BEGIN_INSTR(UnaryPlusReal, unaryop)
838 registers[instr->unaryop.output].setqreal(+registers[instr->unaryop.src].getqreal());
840 QML_V4_END_INSTR(UnaryPlusReal, unaryop)
842 QML_V4_BEGIN_INSTR(UnaryPlusInt, unaryop)
844 registers[instr->unaryop.output].setint(+registers[instr->unaryop.src].getint());
846 QML_V4_END_INSTR(UnaryPlusInt, unaryop)
848 QML_V4_BEGIN_INSTR(ConvertBoolToInt, unaryop)
850 const Register &src = registers[instr->unaryop.src];
851 Register &output = registers[instr->unaryop.output];
852 if (src.isUndefined()) output.setUndefined();
853 else output.setint(src.getbool());
855 QML_V4_END_INSTR(ConvertBoolToInt, unaryop)
857 QML_V4_BEGIN_INSTR(ConvertBoolToReal, unaryop)
859 const Register &src = registers[instr->unaryop.src];
860 Register &output = registers[instr->unaryop.output];
861 if (src.isUndefined()) output.setUndefined();
862 else output.setqreal(src.getbool());
864 QML_V4_END_INSTR(ConvertBoolToReal, unaryop)
866 QML_V4_BEGIN_INSTR(ConvertBoolToString, unaryop)
868 const Register &src = registers[instr->unaryop.src];
869 Register &output = registers[instr->unaryop.output];
870 if (src.isUndefined()) {
871 output.setUndefined();
873 new (output.getstringptr()) QString(QLatin1String(src.getbool() ? "true" : "false"));
874 STRING_REGISTER(instr->unaryop.output);
877 QML_V4_END_INSTR(ConvertBoolToString, unaryop)
879 QML_V4_BEGIN_INSTR(ConvertIntToBool, unaryop)
881 const Register &src = registers[instr->unaryop.src];
882 Register &output = registers[instr->unaryop.output];
883 if (src.isUndefined()) output.setUndefined();
884 else output.setbool(src.getint());
886 QML_V4_END_INSTR(ConvertIntToBool, unaryop)
888 QML_V4_BEGIN_INSTR(ConvertIntToReal, unaryop)
890 const Register &src = registers[instr->unaryop.src];
891 Register &output = registers[instr->unaryop.output];
892 if (src.isUndefined()) output.setUndefined();
893 else output.setqreal(qreal(src.getint()));
895 QML_V4_END_INSTR(ConvertIntToReal, unaryop)
897 QML_V4_BEGIN_INSTR(ConvertIntToString, unaryop)
899 const Register &src = registers[instr->unaryop.src];
900 Register &output = registers[instr->unaryop.output];
901 if (src.isUndefined()) {
902 output.setUndefined();
904 new (output.getstringptr()) QString(QString::number(src.getint()));
905 STRING_REGISTER(instr->unaryop.output);
908 QML_V4_END_INSTR(ConvertIntToString, unaryop)
910 QML_V4_BEGIN_INSTR(ConvertRealToBool, unaryop)
912 const Register &src = registers[instr->unaryop.src];
913 Register &output = registers[instr->unaryop.output];
914 if (src.isUndefined()) output.setUndefined();
915 else output.setbool(src.getqreal() != 0);
917 QML_V4_END_INSTR(ConvertRealToBool, unaryop)
919 QML_V4_BEGIN_INSTR(ConvertRealToInt, unaryop)
921 const Register &src = registers[instr->unaryop.src];
922 Register &output = registers[instr->unaryop.output];
923 if (src.isUndefined()) output.setUndefined();
924 else output.setint(toInt32(src.getqreal()));
926 QML_V4_END_INSTR(ConvertRealToInt, unaryop)
928 QML_V4_BEGIN_INSTR(ConvertRealToString, unaryop)
930 const Register &src = registers[instr->unaryop.src];
931 Register &output = registers[instr->unaryop.output];
933 if (src.isUndefined()) {
934 output.setUndefined();
936 new (output.getstringptr()) QString(QString::number(src.getqreal()));
937 STRING_REGISTER(instr->unaryop.output);
940 QML_V4_END_INSTR(ConvertRealToString, unaryop)
942 QML_V4_BEGIN_INSTR(ConvertStringToBool, unaryop)
944 const Register &src = registers[instr->unaryop.src];
945 Register &output = registers[instr->unaryop.output];
947 if (src.isUndefined()) {
948 output.setUndefined();
950 // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
951 // Ideally we should just call the methods in the QScript namespace directly.
952 QJSValue tmp(*src.getstringptr());
953 if (instr->unaryop.src == instr->unaryop.output) {
954 output.cleanupString();
955 MARK_CLEAN_REGISTER(instr->unaryop.output);
957 output.setbool(tmp.toBool());
960 QML_V4_END_INSTR(ConvertStringToBool, unaryop)
962 QML_V4_BEGIN_INSTR(ConvertStringToInt, unaryop)
964 const Register &src = registers[instr->unaryop.src];
965 Register &output = registers[instr->unaryop.output];
967 if (src.isUndefined()) {
968 output.setUndefined();
970 // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
971 // Ideally we should just call the methods in the QScript namespace directly.
972 QJSValue tmp(*src.getstringptr());
973 if (instr->unaryop.src == instr->unaryop.output) {
974 output.cleanupString();
975 MARK_CLEAN_REGISTER(instr->unaryop.output);
977 output.setint(tmp.toInt32());
980 QML_V4_END_INSTR(ConvertStringToInt, unaryop)
982 QML_V4_BEGIN_INSTR(ConvertStringToReal, unaryop)
984 const Register &src = registers[instr->unaryop.src];
985 Register &output = registers[instr->unaryop.output];
987 if (src.isUndefined()) {
988 output.setUndefined();
990 // Delegate the conversion. This is pretty fast and it doesn't require a QScriptEngine.
991 // Ideally we should just call the methods in the QScript namespace directly.
992 QJSValue tmp(*src.getstringptr());
993 if (instr->unaryop.src == instr->unaryop.output) {
994 output.cleanupString();
995 MARK_CLEAN_REGISTER(instr->unaryop.output);
997 output.setqreal(tmp.toNumber());
1000 QML_V4_END_INSTR(ConvertStringToReal, unaryop)
1002 QML_V4_BEGIN_INSTR(ConvertStringToUrl, unaryop)
1004 const Register &src = registers[instr->unaryop.src];
1005 Register &output = registers[instr->unaryop.output];
1007 if (src.isUndefined()) {
1008 output.setUndefined();
1010 const QString tmp(*src.getstringptr());
1011 if (instr->unaryop.src == instr->unaryop.output) {
1012 output.cleanupString();
1013 MARK_CLEAN_REGISTER(instr->unaryop.output);
1015 new (output.geturlptr()) QUrl(tmp);
1016 URL_REGISTER(instr->unaryop.output);
1019 QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
1021 QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
1023 const Register &src = registers[instr->unaryop.src];
1024 Register &output = registers[instr->unaryop.output];
1026 if (src.isUndefined()) {
1027 output.setUndefined();
1029 const QUrl tmp(*src.geturlptr());
1030 if (instr->unaryop.src == instr->unaryop.output) {
1031 output.cleanupUrl();
1032 MARK_CLEAN_REGISTER(instr->unaryop.output);
1034 output.setbool(!tmp.isEmpty());
1037 QML_V4_END_INSTR(ConvertUrlToBool, unaryop)
1039 QML_V4_BEGIN_INSTR(ConvertUrlToString, unaryop)
1041 const Register &src = registers[instr->unaryop.src];
1042 Register &output = registers[instr->unaryop.output];
1044 if (src.isUndefined()) {
1045 output.setUndefined();
1047 const QUrl tmp(*src.geturlptr());
1048 if (instr->unaryop.src == instr->unaryop.output) {
1049 output.cleanupUrl();
1050 MARK_CLEAN_REGISTER(instr->unaryop.output);
1052 new (output.getstringptr()) QString(tmp.toString());
1053 STRING_REGISTER(instr->unaryop.output);
1056 QML_V4_END_INSTR(ConvertUrlToString, unaryop)
1058 QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
1060 const Register &src = registers[instr->unaryop.src];
1061 Register &output = registers[instr->unaryop.output];
1062 if (src.isUndefined()) {
1063 output.setUndefined();
1065 const QUrl tmp(*src.geturlptr());
1066 if (instr->unaryop.src == instr->unaryop.output) {
1067 *output.geturlptr() = context->resolvedUrl(tmp);
1069 new (output.geturlptr()) QUrl(context->resolvedUrl(tmp));
1070 URL_REGISTER(instr->unaryop.output);
1074 QML_V4_END_INSTR(ResolveUrl, unaryop)
1076 QML_V4_BEGIN_INSTR(MathSinReal, unaryop)
1078 const Register &src = registers[instr->unaryop.src];
1079 Register &output = registers[instr->unaryop.output];
1080 if (src.isUndefined()) output.setUndefined();
1081 else output.setqreal(qSin(src.getqreal()));
1083 QML_V4_END_INSTR(MathSinReal, unaryop)
1085 QML_V4_BEGIN_INSTR(MathCosReal, unaryop)
1087 const Register &src = registers[instr->unaryop.src];
1088 Register &output = registers[instr->unaryop.output];
1089 if (src.isUndefined()) output.setUndefined();
1090 else output.setqreal(qCos(src.getqreal()));
1092 QML_V4_END_INSTR(MathCosReal, unaryop)
1094 QML_V4_BEGIN_INSTR(MathRoundReal, unaryop)
1096 const Register &src = registers[instr->unaryop.src];
1097 Register &output = registers[instr->unaryop.output];
1098 if (src.isUndefined()) output.setUndefined();
1099 else output.setint(qRound(src.getqreal()));
1101 QML_V4_END_INSTR(MathRoundReal, unaryop)
1103 QML_V4_BEGIN_INSTR(MathFloorReal, unaryop)
1105 const Register &src = registers[instr->unaryop.src];
1106 Register &output = registers[instr->unaryop.output];
1107 if (src.isUndefined()) output.setUndefined();
1108 else output.setint(qFloor(src.getqreal()));
1110 QML_V4_END_INSTR(MathFloorReal, unaryop)
1112 QML_V4_BEGIN_INSTR(MathPIReal, unaryop)
1114 static const qreal qmlPI = 2.0 * qAsin(1.0);
1115 Register &output = registers[instr->unaryop.output];
1116 output.setqreal(qmlPI);
1118 QML_V4_END_INSTR(MathPIReal, unaryop)
1120 QML_V4_BEGIN_INSTR(LoadReal, real_value)
1121 registers[instr->real_value.reg].setqreal(instr->real_value.value);
1122 QML_V4_END_INSTR(LoadReal, real_value)
1124 QML_V4_BEGIN_INSTR(LoadInt, int_value)
1125 registers[instr->int_value.reg].setint(instr->int_value.value);
1126 QML_V4_END_INSTR(LoadInt, int_value)
1128 QML_V4_BEGIN_INSTR(LoadBool, bool_value)
1129 registers[instr->bool_value.reg].setbool(instr->bool_value.value);
1130 QML_V4_END_INSTR(LoadBool, bool_value)
1132 QML_V4_BEGIN_INSTR(LoadString, string_value)
1134 Register &output = registers[instr->string_value.reg];
1135 QChar *string = (QChar *)(data + instr->string_value.offset);
1136 new (output.getstringptr()) QString(string, instr->string_value.length);
1137 STRING_REGISTER(instr->string_value.reg);
1139 QML_V4_END_INSTR(LoadString, string_value)
1141 QML_V4_BEGIN_INSTR(EnableV4Test, string_value)
1143 testBindingSource = new QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
1146 QML_V4_END_INSTR(String, string_value)
1148 QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
1150 registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() &
1151 registers[instr->binaryop.right].getint());
1153 QML_V4_END_INSTR(BitAndInt, binaryop)
1155 QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
1157 registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() |
1158 registers[instr->binaryop.right].getint());
1160 QML_V4_END_INSTR(BitAndInt, binaryop)
1162 QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
1164 registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^
1165 registers[instr->binaryop.right].getint());
1167 QML_V4_END_INSTR(BitXorInt, binaryop)
1169 QML_V4_BEGIN_INSTR(AddReal, binaryop)
1171 registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() +
1172 registers[instr->binaryop.right].getqreal());
1174 QML_V4_END_INSTR(AddReal, binaryop)
1176 QML_V4_BEGIN_INSTR(AddString, binaryop)
1178 QString &string = *registers[instr->binaryop.output].getstringptr();
1179 if (instr->binaryop.output == instr->binaryop.left) {
1180 string += registers[instr->binaryop.right].getstringptr();
1182 string = *registers[instr->binaryop.left].getstringptr() +
1183 *registers[instr->binaryop.right].getstringptr();
1186 QML_V4_END_INSTR(AddString, binaryop)
1188 QML_V4_BEGIN_INSTR(SubReal, binaryop)
1190 registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() -
1191 registers[instr->binaryop.right].getqreal());
1193 QML_V4_END_INSTR(SubReal, binaryop)
1195 QML_V4_BEGIN_INSTR(MulReal, binaryop)
1197 registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() *
1198 registers[instr->binaryop.right].getqreal());
1200 QML_V4_END_INSTR(MulReal, binaryop)
1202 QML_V4_BEGIN_INSTR(DivReal, binaryop)
1204 registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() /
1205 registers[instr->binaryop.right].getqreal());
1207 QML_V4_END_INSTR(DivReal, binaryop)
1209 QML_V4_BEGIN_INSTR(ModReal, binaryop)
1211 Register &target = registers[instr->binaryop.output];
1212 const Register &left = registers[instr->binaryop.left];
1213 const Register &right = registers[instr->binaryop.right];
1214 if (QMetaType::QReal == QMetaType::Float)
1215 target.setqreal(::fmodf(left.getqreal(), right.getqreal()));
1217 target.setqreal(::fmod(left.getqreal(), right.getqreal()));
1219 QML_V4_END_INSTR(ModInt, binaryop)
1221 QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
1223 registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() <<
1224 registers[instr->binaryop.right].getint());
1226 QML_V4_END_INSTR(LShiftInt, binaryop)
1228 QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
1230 registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >>
1231 registers[instr->binaryop.right].getint());
1233 QML_V4_END_INSTR(RShiftInt, binaryop)
1235 QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
1237 registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >>
1238 registers[instr->binaryop.right].getint());
1240 QML_V4_END_INSTR(URShiftInt, binaryop)
1242 QML_V4_BEGIN_INSTR(GtReal, binaryop)
1244 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >
1245 registers[instr->binaryop.right].getqreal());
1247 QML_V4_END_INSTR(GtReal, binaryop)
1249 QML_V4_BEGIN_INSTR(LtReal, binaryop)
1251 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <
1252 registers[instr->binaryop.right].getqreal());
1254 QML_V4_END_INSTR(LtReal, binaryop)
1256 QML_V4_BEGIN_INSTR(GeReal, binaryop)
1258 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >=
1259 registers[instr->binaryop.right].getqreal());
1261 QML_V4_END_INSTR(GeReal, binaryop)
1263 QML_V4_BEGIN_INSTR(LeReal, binaryop)
1265 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <=
1266 registers[instr->binaryop.right].getqreal());
1268 QML_V4_END_INSTR(LeReal, binaryop)
1270 QML_V4_BEGIN_INSTR(EqualReal, binaryop)
1272 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
1273 registers[instr->binaryop.right].getqreal());
1275 QML_V4_END_INSTR(EqualReal, binaryop)
1277 QML_V4_BEGIN_INSTR(NotEqualReal, binaryop)
1279 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
1280 registers[instr->binaryop.right].getqreal());
1282 QML_V4_END_INSTR(NotEqualReal, binaryop)
1284 QML_V4_BEGIN_INSTR(StrictEqualReal, binaryop)
1286 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() ==
1287 registers[instr->binaryop.right].getqreal());
1289 QML_V4_END_INSTR(StrictEqualReal, binaryop)
1291 QML_V4_BEGIN_INSTR(StrictNotEqualReal, binaryop)
1293 registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() !=
1294 registers[instr->binaryop.right].getqreal());
1296 QML_V4_END_INSTR(StrictNotEqualReal, binaryop)
1298 QML_V4_BEGIN_INSTR(GtString, binaryop)
1300 const QString &a = *registers[instr->binaryop.left].getstringptr();
1301 const QString &b = *registers[instr->binaryop.right].getstringptr();
1302 bool result = a > b;
1303 if (instr->binaryop.left == instr->binaryop.output) {
1304 registers[instr->binaryop.output].cleanupString();
1305 MARK_CLEAN_REGISTER(instr->binaryop.output);
1307 registers[instr->binaryop.output].setbool(result);
1309 QML_V4_END_INSTR(GtString, binaryop)
1311 QML_V4_BEGIN_INSTR(LtString, binaryop)
1313 const QString &a = *registers[instr->binaryop.left].getstringptr();
1314 const QString &b = *registers[instr->binaryop.right].getstringptr();
1315 bool result = a < b;
1316 if (instr->binaryop.left == instr->binaryop.output) {
1317 registers[instr->binaryop.output].cleanupString();
1318 MARK_CLEAN_REGISTER(instr->binaryop.output);
1320 registers[instr->binaryop.output].setbool(result);
1322 QML_V4_END_INSTR(LtString, binaryop)
1324 QML_V4_BEGIN_INSTR(GeString, binaryop)
1326 const QString &a = *registers[instr->binaryop.left].getstringptr();
1327 const QString &b = *registers[instr->binaryop.right].getstringptr();
1328 bool result = a >= b;
1329 if (instr->binaryop.left == instr->binaryop.output) {
1330 registers[instr->binaryop.output].cleanupString();
1331 MARK_CLEAN_REGISTER(instr->binaryop.output);
1333 registers[instr->binaryop.output].setbool(result);
1335 QML_V4_END_INSTR(GeString, binaryop)
1337 QML_V4_BEGIN_INSTR(LeString, binaryop)
1339 const QString &a = *registers[instr->binaryop.left].getstringptr();
1340 const QString &b = *registers[instr->binaryop.right].getstringptr();
1341 bool result = a <= b;
1342 if (instr->binaryop.left == instr->binaryop.output) {
1343 registers[instr->binaryop.output].cleanupString();
1344 MARK_CLEAN_REGISTER(instr->binaryop.output);
1346 registers[instr->binaryop.output].setbool(result);
1348 QML_V4_END_INSTR(LeString, binaryop)
1350 QML_V4_BEGIN_INSTR(EqualString, binaryop)
1352 const QString &a = *registers[instr->binaryop.left].getstringptr();
1353 const QString &b = *registers[instr->binaryop.right].getstringptr();
1354 bool result = a == b;
1355 if (instr->binaryop.left == instr->binaryop.output) {
1356 registers[instr->binaryop.output].cleanupString();
1357 MARK_CLEAN_REGISTER(instr->binaryop.output);
1359 registers[instr->binaryop.output].setbool(result);
1361 QML_V4_END_INSTR(EqualString, binaryop)
1363 QML_V4_BEGIN_INSTR(NotEqualString, binaryop)
1365 const QString &a = *registers[instr->binaryop.left].getstringptr();
1366 const QString &b = *registers[instr->binaryop.right].getstringptr();
1367 bool result = a != b;
1368 if (instr->binaryop.left == instr->binaryop.output) {
1369 registers[instr->binaryop.output].cleanupString();
1370 MARK_CLEAN_REGISTER(instr->binaryop.output);
1372 registers[instr->binaryop.output].setbool(result);
1374 QML_V4_END_INSTR(NotEqualString, binaryop)
1376 QML_V4_BEGIN_INSTR(StrictEqualString, binaryop)
1378 const QString &a = *registers[instr->binaryop.left].getstringptr();
1379 const QString &b = *registers[instr->binaryop.right].getstringptr();
1380 bool result = a == b;
1381 if (instr->binaryop.left == instr->binaryop.output) {
1382 registers[instr->binaryop.output].cleanupString();
1383 MARK_CLEAN_REGISTER(instr->binaryop.output);
1385 registers[instr->binaryop.output].setbool(result);
1387 QML_V4_END_INSTR(StrictEqualString, binaryop)
1389 QML_V4_BEGIN_INSTR(StrictNotEqualString, binaryop)
1391 const QString &a = *registers[instr->binaryop.left].getstringptr();
1392 const QString &b = *registers[instr->binaryop.right].getstringptr();
1393 bool result = a != b;
1394 if (instr->binaryop.left == instr->binaryop.output) {
1395 registers[instr->binaryop.output].cleanupString();
1396 MARK_CLEAN_REGISTER(instr->binaryop.output);
1398 registers[instr->binaryop.output].setbool(result);
1400 QML_V4_END_INSTR(StrictNotEqualString, binaryop)
1402 QML_V4_BEGIN_INSTR(NewString, construct)
1404 Register &output = registers[instr->construct.reg];
1405 new (output.getstringptr()) QString;
1406 STRING_REGISTER(instr->construct.reg);
1408 QML_V4_END_INSTR(NewString, construct)
1410 QML_V4_BEGIN_INSTR(NewUrl, construct)
1412 Register &output = registers[instr->construct.reg];
1413 new (output.geturlptr()) QUrl;
1414 URL_REGISTER(instr->construct.reg);
1416 QML_V4_END_INSTR(NewUrl, construct)
1418 QML_V4_BEGIN_INSTR(Fetch, fetch)
1420 Register ® = registers[instr->fetch.reg];
1422 if (reg.isUndefined())
1423 THROW_EXCEPTION(instr->fetch.exceptionId);
1425 QObject *object = reg.getQObject();
1427 THROW_EXCEPTION(instr->fetch.exceptionId);
1429 reg.init((Register::Type)instr->fetch.valueType);
1430 if (instr->fetch.valueType >= FirstCleanupType)
1431 MARK_REGISTER(instr->fetch.reg);
1432 void *argv[] = { reg.typeDataPtr(), 0 };
1433 QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
1436 QML_V4_END_INSTR(Fetch, fetch)
1438 QML_V4_BEGIN_INSTR(TestV4Store, storetest)
1440 Register &data = registers[instr->storetest.reg];
1441 testBindingResult(*testBindingSource, bindingLine, bindingColumn, context,
1442 scope, data, instr->storetest.regType);
1444 QML_V4_END_INSTR(TestV4Store, storetest)
1446 QML_V4_BEGIN_INSTR(Store, store)
1448 Register &data = registers[instr->store.reg];
1450 if (data.isUndefined())
1451 THROW_EXCEPTION_STR(instr->store.exceptionId, QLatin1String("Unable to assign undefined value"));
1454 void *argv[] = { data.typeDataPtr(), 0, &status, &storeFlags };
1455 QMetaObject::metacall(output, QMetaObject::WriteProperty,
1456 instr->store.index, argv);
1460 QML_V4_END_INSTR(Store, store)
1462 QML_V4_BEGIN_INSTR(Copy, copy)
1463 registers[instr->copy.reg].copy(registers[instr->copy.src]);
1464 if (registers[instr->copy.reg].gettype() >= FirstCleanupType)
1465 MARK_REGISTER(instr->copy.reg);
1466 QML_V4_END_INSTR(Copy, copy)
1468 QML_V4_BEGIN_INSTR(Jump, jump)
1469 if (instr->jump.reg == -1 || !registers[instr->jump.reg].getbool())
1470 code += instr->jump.count;
1471 QML_V4_END_INSTR(Jump, jump)
1473 QML_V4_BEGIN_INSTR(BranchTrue, branchop)
1474 if (registers[instr->branchop.reg].getbool())
1475 code += instr->branchop.offset;
1476 QML_V4_END_INSTR(BranchTrue, branchop)
1478 QML_V4_BEGIN_INSTR(BranchFalse, branchop)
1479 if (! registers[instr->branchop.reg].getbool())
1480 code += instr->branchop.offset;
1481 QML_V4_END_INSTR(BranchFalse, branchop)
1483 QML_V4_BEGIN_INSTR(Branch, branchop)
1484 code += instr->branchop.offset;
1485 QML_V4_END_INSTR(Branch, branchop)
1487 QML_V4_BEGIN_INSTR(Block, blockop)
1488 executedBlocks |= instr->blockop.block;
1489 QML_V4_END_INSTR(Block, blockop)
1491 // XXX not applicable in v8
1492 QML_V4_BEGIN_INSTR(InitString, initstring)
1493 // if (!identifiers[instr->initstring.offset].identifier) {
1494 // quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
1495 // QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
1497 // QString str = QString::fromRawData(strdata, len);
1499 // // identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
1501 QML_V4_END_INSTR(InitString, initstring)
1503 QML_V4_BEGIN_INSTR(CleanupRegister, cleanup)
1504 registers[instr->cleanup.reg].cleanup();
1505 QML_V4_END_INSTR(CleanupRegister, cleanup)
1507 #ifdef QML_THREADED_INTERPRETER
1511 qFatal("QV4: Unknown instruction %d encountered.", instr->common.type);
1518 Q_ASSERT(!"Unreachable code reached");
1522 delete testBindingSource;
1525 while (cleanupRegisterMask) {
1526 if (cleanupRegisterMask & 0x1)
1527 registers[reg].cleanup();
1530 cleanupRegisterMask >>= 1;