1188 Register registers[32];
1192 const Instr *instr = program->instructions();
1193 instr += instrIndex;
1194 const char *
data = program->data();
1196 #ifdef QML_THREADED_INTERPRETER 1197 static void *decode_instr[] = {
1201 if (!program->compiled) {
1202 program->compiled =
true;
1203 const Instr *inop = program->instructions();
1204 for (
int i = 0; i < program->instructionCount; ++i) {
1205 Instr *op = (Instr *) inop++;
1206 op->common.code = decode_instr[op->common.type];
1210 goto *instr->common.code;
1214 #ifdef COMPILEDBINDINGS_DEBUG 1215 qWarning().nospace() <<
"Begin binding run";
1219 switch (instr->common.type) {
1221 #ifdef COMPILEDBINDINGS_DEBUG 1234 subscribeId(context, instr->subscribe.index, instr->subscribe.offset);
1240 const Register &
object = registers[instr->subscribe.reg];
1241 if (!
object.isUndefined()) o =
object.getQObject();
1242 subscribe(o, instr->subscribe.index, instr->subscribe.offset);
1248 const Register &input = registers[instr->fetchAndSubscribe.objectReg];
1249 Register &output = registers[instr->fetchAndSubscribe.output];
1251 if (input.isUndefined()) {
1252 throwException(instr->fetchAndSubscribe.exceptionId, error, program, context);
1256 QObject *
object = input.getQObject();
1258 output.setUndefined();
1260 int subIdx = instr->fetchAndSubscribe.subscription;
1267 fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub);
1273 registers[instr->load.reg].setQObject(context->
idValues[instr->load.index].
data());
1277 registers[instr->load.reg].setQObject(scope);
1281 registers[instr->load.reg].setQObject(context->
contextObject);
1286 const Register &input = registers[instr->attached.reg];
1287 Register &output = registers[instr->attached.output];
1288 if (input.isUndefined()) {
1289 throwException(instr->attached.exceptionId, error, program, context);
1293 QObject *
object = registers[instr->attached.reg].getQObject();
1295 output.setUndefined();
1299 registers[instr->attached.reg].getQObject(),
1302 output.setQObject(attached);
1309 const Register &input = registers[instr->unaryop.src];
1310 Register &output = registers[instr->unaryop.output];
1311 if (input.isUndefined()) output.setUndefined();
1312 else output.setqreal(
qreal(input.getint()));
1318 const Register &input = registers[instr->unaryop.src];
1319 Register &output = registers[instr->unaryop.output];
1320 if (input.isUndefined()) output.setUndefined();
1321 else output.setint(
qRound(input.getqreal()));
1326 registers[instr->real_value.reg].setqreal(instr->real_value.value);
1330 registers[instr->int_value.reg].setint(instr->int_value.value);
1334 registers[instr->bool_value.reg].setbool(instr->bool_value.value);
1339 Register &output = registers[instr->string_value.reg];
1340 new (output.getstringptr())
1341 QString((
QChar *)(data + instr->string_value.offset), instr->string_value.length);
1348 const Register &lhs = registers[instr->binaryop.src1];
1349 const Register &rhs = registers[instr->binaryop.src2];
1350 Register &output = registers[instr->binaryop.output];
1351 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1352 else output.setqreal(lhs.getqreal() + rhs.getqreal());
1358 const Register &lhs = registers[instr->binaryop.src1];
1359 const Register &rhs = registers[instr->binaryop.src2];
1360 Register &output = registers[instr->binaryop.output];
1361 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1362 else output.setint(lhs.getint() + rhs.getint());
1368 const Register &lhs = registers[instr->binaryop.src1];
1369 const Register &rhs = registers[instr->binaryop.src2];
1370 Register &output = registers[instr->binaryop.output];
1371 if (lhs.isUndefined() && rhs.isUndefined()) { output.setNaN(); }
1373 if (lhs.isUndefined())
1374 new (output.getstringptr())
1376 else if (rhs.isUndefined())
1377 new (output.getstringptr())
1380 new (output.getstringptr())
1381 QString(*registers[instr->binaryop.src1].getstringptr() +
1382 *registers[instr->binaryop.src2].getstringptr());
1390 const Register &lhs = registers[instr->binaryop.src1];
1391 const Register &rhs = registers[instr->binaryop.src2];
1392 Register &output = registers[instr->binaryop.output];
1393 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1394 else output.setqreal(lhs.getqreal() - rhs.getqreal());
1400 const Register &lhs = registers[instr->binaryop.src1];
1401 const Register &rhs = registers[instr->binaryop.src2];
1402 Register &output = registers[instr->binaryop.output];
1403 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1404 else output.setint(lhs.getint() - rhs.getint());
1410 const Register &lhs = registers[instr->binaryop.src1];
1411 const Register &rhs = registers[instr->binaryop.src2];
1412 Register &output = registers[instr->binaryop.output];
1413 if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
1414 else output.setbool(lhs.getqreal() == rhs.getqreal());
1420 const Register &lhs = registers[instr->binaryop.src1];
1421 const Register &rhs = registers[instr->binaryop.src2];
1422 Register &output = registers[instr->binaryop.output];
1423 if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined());
1424 else output.setbool(*lhs.getstringptr() == *rhs.getstringptr());
1430 const Register &lhs = registers[instr->binaryop.src1];
1431 const Register &rhs = registers[instr->binaryop.src2];
1432 Register &output = registers[instr->binaryop.output];
1433 if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
1434 else output.setbool(lhs.getqreal() != rhs.getqreal());
1440 const Register &lhs = registers[instr->binaryop.src1];
1441 const Register &rhs = registers[instr->binaryop.src2];
1442 Register &output = registers[instr->binaryop.output];
1443 if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined());
1444 else output.setbool(*lhs.getstringptr() != *rhs.getstringptr());
1450 const Register &lhs = registers[instr->binaryop.src1];
1451 const Register &rhs = registers[instr->binaryop.src2];
1452 Register &output = registers[instr->binaryop.output];
1453 if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(
false);
1454 else output.setbool(lhs.getqreal() > rhs.getqreal());
1460 const Register &lhs = registers[instr->binaryop.src1];
1461 const Register &rhs = registers[instr->binaryop.src2];
1462 Register &output = registers[instr->binaryop.output];
1463 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1464 else output.setqreal(
qMax(lhs.getqreal(), rhs.getqreal()));
1470 const Register &lhs = registers[instr->binaryop.src1];
1471 const Register &rhs = registers[instr->binaryop.src2];
1472 Register &output = registers[instr->binaryop.output];
1473 if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN();
1474 else output.setqreal(
qMin(lhs.getqreal(), rhs.getqreal()));
1480 Register &output = registers[instr->construct.reg];
1481 new (output.getstringptr())
QString;
1488 Register &output = registers[instr->construct.reg];
1489 new (output.geturlptr())
QUrl;
1495 registers[instr->cleanup.reg].getstringptr()->~QString();
1496 #ifdef REGISTER_CLEANUP_DEBUG 1497 registers[instr->cleanup.reg].setUndefined();
1502 registers[instr->cleanup.reg].geturlptr()->~QUrl();
1503 #ifdef REGISTER_CLEANUP_DEBUG 1504 registers[instr->cleanup.reg].setUndefined();
1510 const Register &input = registers[instr->fetch.objectReg];
1511 Register &output = registers[instr->fetch.output];
1513 if (input.isUndefined()) {
1514 throwException(instr->fetch.exceptionId, error, program, context);
1518 QObject *
object = input.getQObject();
1520 output.setUndefined();
1522 void *argv[] = { output.typeDataPtr(), 0 };
1530 Register &data = registers[instr->store.reg];
1531 if (data.isUndefined()) {
1532 throwException(instr->store.exceptionId, error, program, context,
1538 void *argv[] = { data.typeDataPtr(), 0, &
status, &storeFlags };
1540 instr->store.index, argv);
1545 registers[instr->copy.reg] = registers[instr->copy.src];
1549 if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool())
1550 instr += instr->skip.count;
1572 findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
1575 instr->common.type == Instr::FindGenericTerminal);
1582 findgeneric(registers + instr->find.reg, instr->find.subscribeIndex,
1585 instr->common.type == Instr::FindGenericTerminal);
1590 const Register &
object = registers[instr->find.src];
1591 if (
object.isUndefined()) {
1592 throwException(instr->find.exceptionId, error, program, context);
1596 findproperty(
object.getQObject(), registers + instr->find.reg,
1599 instr->common.type == Instr::FindPropertyTerminal);
1605 const Register &
object = registers[instr->find.src];
1606 if (
object.isUndefined()) {
1607 throwException(instr->find.exceptionId, error, program, context);
1611 findproperty(
object.getQObject(), registers + instr->find.reg,
1614 instr->common.type == Instr::FindPropertyTerminal);
1620 int type = registers[instr->cleanup.reg].gettype();
1621 if (type == qMetaTypeId<QVariant>()) {
1622 registers[instr->cleanup.reg].getvariantptr()->~QVariant();
1623 #ifdef REGISTER_CLEANUP_DEBUG 1624 registers[instr->cleanup.reg].setUndefined();
1627 registers[instr->cleanup.reg].getstringptr()->~QString();
1628 #ifdef REGISTER_CLEANUP_DEBUG 1629 registers[instr->cleanup.reg].setUndefined();
1632 registers[instr->cleanup.reg].geturlptr()->~QUrl();
1633 #ifdef REGISTER_CLEANUP_DEBUG 1634 registers[instr->cleanup.reg].setUndefined();
1642 Register &output = registers[instr->unaryop.output];
1643 Register &input = registers[instr->unaryop.src];
1645 output.setqreal(
toReal(&input, input.gettype(), &ok));
1646 if (!ok) output.setUndefined();
1652 Register &output = registers[instr->unaryop.output];
1653 Register &input = registers[instr->unaryop.src];
1655 output.setbool(
toBool(&input, input.gettype(), &ok));
1656 if (!ok) output.setUndefined();
1662 Register &output = registers[instr->unaryop.output];
1663 Register &input = registers[instr->unaryop.src];
1667 else { output.setUndefined(); }
1673 Register &output = registers[instr->unaryop.output];
1674 Register &input = registers[instr->unaryop.src];
1676 QUrl url =
toUrl(&input, input.gettype(), context, &ok);
1678 else { output.setUndefined(); }
1682 #ifdef QML_THREADED_INTERPRETER
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QDeclarativeEngine * engine
QScriptDeclarativeClass::PersistentIdentifier * identifiers
void subscribe(QObject *o, int notifyIndex, int subIndex)
void subscribeId(QDeclarativeContextData *p, int idIndex, int subIndex)
static void throwException(int id, QDeclarativeDelayedError *error, Program *program, QDeclarativeContextData *context, const QString &description=QString())
static LibLoadStatus status
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define QML_INSTR_ADDR(I)
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
QDeclarativeContextData * parent
The QObject class is the base class of all Qt objects.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
PersistentIdentifier createPersistentIdentifier(const QString &)
The QChar class provides a 16-bit Unicode character.
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Q_DECLARATIVE_EXPORT QObject * qmlAttachedPropertiesObjectById(int, const QObject *, bool create=true)
static bool toBool(Register *reg, int type, bool *ok=0)
static QString toString(Register *reg, int type, bool *ok=0)
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Subscription * subscriptions
QDeclarativePropertyCache::Data * findproperty(QObject *obj, const QScriptDeclarativeClass::Identifier &name, QDeclarativeEnginePrivate *enginePriv, QDeclarativePropertyCache::Data &local)
QDeclarativeObjectScriptClass * objectClass
Q_CORE_EXPORT void qFatal(const char *,...)
static void dumpInstruction(const Instr *instr)
#define QML_BEGIN_INSTR(I)
static QUrl toUrl(Register *reg, int type, QDeclarativeContextData *context, bool *ok=0)
#define FOR_EACH_QML_INSTR(F)
Q_DECL_CONSTEXPR int qRound(qreal d)
static qreal toReal(Register *reg, int type, bool *ok=0)
void findgeneric(Register *output, int subIdx, QDeclarativeContextData *context, const QScriptDeclarativeClass::Identifier &name, bool isTerminal)