Support variable length instructions in QML bytecode
authorAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 5 May 2011 03:48:29 +0000 (13:48 +1000)
committerAaron Kennedy <aaron.kennedy@nokia.com>
Thu, 5 May 2011 05:25:43 +0000 (15:25 +1000)
Reviewed-by: Martin Jones
Change-Id: Ib04b8d46a78723d3a734e14d22a2f2256c1627c2

14 files changed:
src/declarative/qml/qdeclarativecompileddata.cpp
src/declarative/qml/qdeclarativecompiler.cpp
src/declarative/qml/qdeclarativecompiler_p.h
src/declarative/qml/qdeclarativecomponent.cpp
src/declarative/qml/qdeclarativecomponent.h
src/declarative/qml/qdeclarativecomponent_p.h
src/declarative/qml/qdeclarativeinstruction.cpp
src/declarative/qml/qdeclarativeinstruction_p.h
src/declarative/qml/qdeclarativevme.cpp
src/declarative/qml/qdeclarativevme_p.h
src/declarative/qml/v4/qdeclarativev4bindings.cpp
src/declarative/qml/v4/qdeclarativev4instruction.cpp
src/declarative/qml/v4/qdeclarativev4instruction_p.h
tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp

index ce57ccb..1f5d111 100644 (file)
@@ -248,11 +248,40 @@ void QDeclarativeCompiledData::dumpInstructions()
         qWarning() << name;
     qWarning().nospace() << "Index\tOperation\t\tData1\tData2\tData3\tComments";
     qWarning().nospace() << "-------------------------------------------------------------------------------";
-    for (int ii = 0; ii < bytecode.count(); ++ii) {
-        dump(&bytecode[ii], ii);
+
+    const char *instructionStream = bytecode.constData();
+    const char *endInstructionStream = bytecode.constData() + bytecode.size();
+
+    int instructionCount = 0;
+    while (instructionStream < endInstructionStream) {
+        QDeclarativeInstruction *instr = (QDeclarativeInstruction *)instructionStream;
+        dump(instr, instructionCount);
+        instructionStream += instr->size();
+        instructionCount++;
     }
+
     qWarning().nospace() << "-------------------------------------------------------------------------------";
 }
 
+int QDeclarativeCompiledData::addInstruction(const QDeclarativeInstruction &instr) 
+{ 
+    int ptrOffset = bytecode.size();
+    int size = instr.size();
+    bytecode.resize(bytecode.size() + size);
+    char *data = bytecode.data() + ptrOffset;
+    qMemCopy(data, &instr,  size);
+
+    return ptrOffset;
+}
+
+int QDeclarativeCompiledData::nextInstructionIndex() 
+{ 
+    return bytecode.size();
+}
+
+QDeclarativeInstruction *QDeclarativeCompiledData::instruction(int index) 
+{ 
+    return (QDeclarativeInstruction *)(bytecode.constData() + index);
+}
 
 QT_END_NAMESPACE
index 13a5d87..d8aa938 100644 (file)
@@ -336,10 +336,10 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
                 value = prop.enumerator().keyToValue(v->value.asString().toUtf8().constData());
         }
 
-        instr.type = QDeclarativeInstruction::StoreInteger;
+        instr.setType(QDeclarativeInstruction::StoreInteger);
         instr.storeInteger.propertyIndex = prop.propertyIndex();
         instr.storeInteger.value = value;
-        output->bytecode << instr;
+        output->addInstruction(instr);
         return;
     }
 
@@ -352,20 +352,20 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             if (v->value.isNumber()) {
                 double n = v->value.asNumber();
                 if (double(int(n)) == n) {
-                    instr.type = QDeclarativeInstruction::StoreVariantInteger;
+                    instr.setType(QDeclarativeInstruction::StoreVariantInteger);
                     instr.storeInteger.propertyIndex = prop.propertyIndex();
                     instr.storeInteger.value = int(n);
                 } else {
-                    instr.type = QDeclarativeInstruction::StoreVariantDouble;
+                    instr.setType(QDeclarativeInstruction::StoreVariantDouble);
                     instr.storeDouble.propertyIndex = prop.propertyIndex();
                     instr.storeDouble.value = n;
                 }
             } else if(v->value.isBoolean()) {
-                instr.type = QDeclarativeInstruction::StoreVariantBool;
+                instr.setType(QDeclarativeInstruction::StoreVariantBool);
                 instr.storeBool.propertyIndex = prop.propertyIndex();
                 instr.storeBool.value = v->value.asBoolean();
             } else {
-                instr.type = QDeclarativeInstruction::StoreVariant;
+                instr.setType(QDeclarativeInstruction::StoreVariant);
                 instr.storeString.propertyIndex = prop.propertyIndex();
                 instr.storeString.value = output->indexForString(string);
             }
@@ -373,21 +373,21 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             break;
         case QVariant::String:
             {
-            instr.type = QDeclarativeInstruction::StoreString;
+            instr.setType(QDeclarativeInstruction::StoreString);
             instr.storeString.propertyIndex = prop.propertyIndex();
             instr.storeString.value = output->indexForString(string);
             }
             break;
         case QVariant::ByteArray:
             {
-            instr.type = QDeclarativeInstruction::StoreByteArray;
+            instr.setType(QDeclarativeInstruction::StoreByteArray);
             instr.storeByteArray.propertyIndex = prop.propertyIndex();
             instr.storeByteArray.value = output->indexForByteArray(string.toLatin1());
             }
             break;
         case QVariant::Url:
             {
-            instr.type = QDeclarativeInstruction::StoreUrl;
+            instr.setType(QDeclarativeInstruction::StoreUrl);
             QUrl u = string.isEmpty() ? QUrl() : output->url.resolved(QUrl(string));
             instr.storeUrl.propertyIndex = prop.propertyIndex();
             instr.storeUrl.value = output->indexForUrl(u);
@@ -395,28 +395,28 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             break;
         case QVariant::UInt:
             {
-            instr.type = QDeclarativeInstruction::StoreInteger;
+            instr.setType(QDeclarativeInstruction::StoreInteger);
             instr.storeInteger.propertyIndex = prop.propertyIndex();
             instr.storeInteger.value = uint(v->value.asNumber());
             }
             break;
         case QVariant::Int:
             {
-            instr.type = QDeclarativeInstruction::StoreInteger;
+            instr.setType(QDeclarativeInstruction::StoreInteger);
             instr.storeInteger.propertyIndex = prop.propertyIndex();
             instr.storeInteger.value = int(v->value.asNumber());
             }
             break;
         case QMetaType::Float:
             {
-            instr.type = QDeclarativeInstruction::StoreFloat;
+            instr.setType(QDeclarativeInstruction::StoreFloat);
             instr.storeFloat.propertyIndex = prop.propertyIndex();
             instr.storeFloat.value = float(v->value.asNumber());
             }
             break;
         case QVariant::Double:
             {
-            instr.type = QDeclarativeInstruction::StoreDouble;
+            instr.setType(QDeclarativeInstruction::StoreDouble);
             instr.storeDouble.propertyIndex = prop.propertyIndex();
             instr.storeDouble.value = v->value.asNumber();
             }
@@ -424,7 +424,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
         case QVariant::Color:
             {
             QColor c = QDeclarativeStringConverters::colorFromString(string);
-            instr.type = QDeclarativeInstruction::StoreColor;
+            instr.setType(QDeclarativeInstruction::StoreColor);
             instr.storeColor.propertyIndex = prop.propertyIndex();
             instr.storeColor.value = c.rgba();
             }
@@ -433,7 +433,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
         case QVariant::Date:
             {
             QDate d = QDeclarativeStringConverters::dateFromString(string);
-            instr.type = QDeclarativeInstruction::StoreDate;
+            instr.setType(QDeclarativeInstruction::StoreDate);
             instr.storeDate.propertyIndex = prop.propertyIndex();
             instr.storeDate.value = d.toJulianDay();
             }
@@ -444,7 +444,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             int data[] = { time.hour(), time.minute(),
                            time.second(), time.msec() };
             int index = output->indexForInt(data, 4);
-            instr.type = QDeclarativeInstruction::StoreTime;
+            instr.setType(QDeclarativeInstruction::StoreTime);
             instr.storeTime.propertyIndex = prop.propertyIndex();
             instr.storeTime.valueIndex = index;
             }
@@ -458,7 +458,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
                            dateTime.time().second(),
                            dateTime.time().msec() };
             int index = output->indexForInt(data, 5);
-            instr.type = QDeclarativeInstruction::StoreDateTime;
+            instr.setType(QDeclarativeInstruction::StoreDateTime);
             instr.storeDateTime.propertyIndex = prop.propertyIndex();
             instr.storeDateTime.valueIndex = index;
             }
@@ -473,9 +473,9 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             float data[] = { float(point.x()), float(point.y()) };
             int index = output->indexForFloat(data, 2);
             if (type == QVariant::PointF)
-                instr.type = QDeclarativeInstruction::StorePointF;
+                instr.setType(QDeclarativeInstruction::StorePointF);
             else
-                instr.type = QDeclarativeInstruction::StorePoint;
+                instr.setType(QDeclarativeInstruction::StorePoint);
             instr.storeRealPair.propertyIndex = prop.propertyIndex();
             instr.storeRealPair.valueIndex = index;
             }
@@ -488,9 +488,9 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             float data[] = { float(size.width()), float(size.height()) };
             int index = output->indexForFloat(data, 2);
             if (type == QVariant::SizeF)
-                instr.type = QDeclarativeInstruction::StoreSizeF;
+                instr.setType(QDeclarativeInstruction::StoreSizeF);
             else
-                instr.type = QDeclarativeInstruction::StoreSize;
+                instr.setType(QDeclarativeInstruction::StoreSize);
             instr.storeRealPair.propertyIndex = prop.propertyIndex();
             instr.storeRealPair.valueIndex = index;
             }
@@ -504,9 +504,9 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
                              float(rect.width()), float(rect.height()) };
             int index = output->indexForFloat(data, 4);
             if (type == QVariant::RectF)
-                instr.type = QDeclarativeInstruction::StoreRectF;
+                instr.setType(QDeclarativeInstruction::StoreRectF);
             else
-                instr.type = QDeclarativeInstruction::StoreRect;
+                instr.setType(QDeclarativeInstruction::StoreRect);
             instr.storeRect.propertyIndex = prop.propertyIndex();
             instr.storeRect.valueIndex = index;
             }
@@ -514,7 +514,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
         case QVariant::Bool:
             {
             bool b = v->value.asBoolean();
-            instr.type = QDeclarativeInstruction::StoreBool;
+            instr.setType(QDeclarativeInstruction::StoreBool);
             instr.storeBool.propertyIndex = prop.propertyIndex();
             instr.storeBool.value = b;
             }
@@ -526,7 +526,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
                 QDeclarativeStringConverters::vector3DFromString(string, &ok);
             float data[] = { float(vector.x()), float(vector.y()), float(vector.z()) };
             int index = output->indexForFloat(data, 3);
-            instr.type = QDeclarativeInstruction::StoreVector3D;
+            instr.setType(QDeclarativeInstruction::StoreVector3D);
             instr.storeRealPair.propertyIndex = prop.propertyIndex();
             instr.storeRealPair.valueIndex = index;
             }
@@ -535,7 +535,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             {
             int t = prop.userType();
             int index = output->customTypeData.count();
-            instr.type = QDeclarativeInstruction::AssignCustomType;
+            instr.setType(QDeclarativeInstruction::AssignCustomType);
             instr.assignCustomType.propertyIndex = prop.propertyIndex();
             instr.assignCustomType.valueIndex = index;
             instr.assignCustomType.line = v->location.start.line;
@@ -547,7 +547,7 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
             }
             break;
     }
-    output->bytecode << instr;
+    output->addInstruction(instr);
 }
 
 /*!
@@ -664,13 +664,13 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree)
         importedScriptIndexes.append(script.qualifier);
 
         QDeclarativeInstruction import;
-        import.type = QDeclarativeInstruction::StoreImportedScript;
+        import.setType(QDeclarativeInstruction::StoreImportedScript);
         import.storeScript.value = output->scripts.count();
 
         QDeclarativeScriptData *scriptData = script.script->scriptData();
         scriptData->addref();
         output->scripts << scriptData;
-        output->bytecode << import;
+        output->addInstruction(import);
     }
 
     // We generate the importCache before we build the tree so that
@@ -685,7 +685,7 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree)
         return;
 
     QDeclarativeInstruction init;
-    init.type = QDeclarativeInstruction::Init;
+    init.setType(QDeclarativeInstruction::Init);
     init.init.bindingsSize = compileState.bindings.count();
     init.init.parserStatusSize = compileState.parserStatusCount;
     init.init.contextCache = genContextCache();
@@ -693,13 +693,17 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree)
         init.init.compiledBinding = -1;
     else
         init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
-    output->bytecode << init;
+    output->addInstruction(init);
 
     genObject(tree);
 
     QDeclarativeInstruction def;
-    def.type = QDeclarativeInstruction::SetDefault;
-    output->bytecode << def;
+    def.setType(QDeclarativeInstruction::SetDefault);
+    output->addInstruction(def);
+
+    QDeclarativeInstruction done;
+    done.setType(QDeclarativeInstruction::Done);
+    output->addInstruction(done);
 
     Q_ASSERT(tree->metatype);
 
@@ -907,18 +911,18 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
         !output->types.at(obj->type).type->isExtendedType() && obj != compileState.root) {
 
         QDeclarativeInstruction create;
-        create.type = QDeclarativeInstruction::CreateSimpleObject;
+        create.setType(QDeclarativeInstruction::CreateSimpleObject);
         create.createSimple.create = output->types.at(obj->type).type->createFunction();
         create.createSimple.typeSize = output->types.at(obj->type).type->createSize();
         create.createSimple.type = obj->type;
         create.createSimple.line = obj->location.start.line;
         create.createSimple.column = obj->location.start.column;
-        output->bytecode << create;
+        output->addInstruction(create);
 
     } else {
 
         QDeclarativeInstruction create;
-        create.type = QDeclarativeInstruction::CreateObject;
+        create.setType(QDeclarativeInstruction::CreateObject);
         create.create.line = obj->location.start.line;
         create.create.column = obj->location.start.column;
         create.create.data = -1;
@@ -933,14 +937,14 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
         } else {
             create.create.bindingBits = -1;
         }
-        output->bytecode << create;
+        output->addInstruction(create);
 
     }
 
     // Setup the synthesized meta object if necessary
     if (!obj->metadata.isEmpty()) {
         QDeclarativeInstruction meta;
-        meta.type = QDeclarativeInstruction::StoreMetaObject;
+        meta.setType(QDeclarativeInstruction::StoreMetaObject);
         meta.storeMeta.data = output->indexForByteArray(obj->metadata);
         meta.storeMeta.aliasData = output->indexForByteArray(obj->synthdata);
         meta.storeMeta.propertyCache = output->propertyCaches.count();
@@ -965,7 +969,7 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
         }
 
         output->propertyCaches << propertyCache;
-        output->bytecode << meta;
+        output->addInstruction(meta);
     } else if (obj == unitRoot) {
         output->rootPropertyCache = tr.createPropertyCache(engine);
         output->rootPropertyCache->addref();
@@ -974,18 +978,18 @@ void QDeclarativeCompiler::genObject(QDeclarativeParser::Object *obj)
     // Set the object id
     if (!obj->id.isEmpty()) {
         QDeclarativeInstruction id;
-        id.type = QDeclarativeInstruction::SetId;
+        id.setType(QDeclarativeInstruction::SetId);
         id.setId.value = output->indexForString(obj->id);
         id.setId.index = obj->idIndex;
-        output->bytecode << id;
+        output->addInstruction(id);
     }
 
     // Begin the class
     if (tr.type && obj->parserStatusCast != -1) {
         QDeclarativeInstruction begin;
-        begin.type = QDeclarativeInstruction::BeginObject;
+        begin.setType(QDeclarativeInstruction::BeginObject);
         begin.begin.castValue = obj->parserStatusCast;
-        output->bytecode << begin;
+        output->addInstruction(begin);
     }
 
     genObjectBody(obj);
@@ -996,12 +1000,12 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
     typedef QPair<Property *, int> PropPair;
     foreach(const PropPair &prop, obj->scriptStringProperties) {
         QDeclarativeInstruction ss;
-        ss.type = QDeclarativeInstruction::StoreScriptString;
+        ss.setType(QDeclarativeInstruction::StoreScriptString);
         ss.storeScriptString.propertyIndex = prop.first->index;
         ss.storeScriptString.value = 
             output->indexForString(prop.first->values.at(0)->value.asScript());
         ss.storeScriptString.scope = prop.second;
-        output->bytecode << ss;
+        output->addInstruction(ss);
     }
 
     bool seenDefer = false;
@@ -1015,18 +1019,18 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
     }
     if (seenDefer) {
         QDeclarativeInstruction defer;
-        defer.type = QDeclarativeInstruction::Defer;
+        defer.setType(QDeclarativeInstruction::Defer);
         defer.defer.deferCount = 0;
-        int deferIdx = output->bytecode.count();
-        output->bytecode << defer;
+        int deferIdx = output->addInstruction(defer);
+        int nextInstructionIndex = output->nextInstructionIndex();
 
         QDeclarativeInstruction init;
-        init.type = QDeclarativeInstruction::Init;
+        init.setType(QDeclarativeInstruction::Init);
         init.init.bindingsSize = compileState.bindings.count(); // XXX - bigger than necessary
         init.init.parserStatusSize = compileState.parserStatusCount; // XXX - bigger than necessary
         init.init.contextCache = -1;
         init.init.compiledBinding = -1;
-        output->bytecode << init;
+        output->addInstruction(init);
 
         foreach(Property *prop, obj->valueProperties) {
             if (!prop->isDeferred)
@@ -1034,8 +1038,11 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
             genValueProperty(prop, obj);
         }
 
-        output->bytecode[deferIdx].defer.deferCount =
-            output->bytecode.count() - deferIdx - 1;
+        QDeclarativeInstruction done;
+        done.setType(QDeclarativeInstruction::Done);
+        output->addInstruction(done);
+
+        output->instruction(deferIdx)->defer.deferCount = output->nextInstructionIndex() - nextInstructionIndex;
     }
 
     foreach(Property *prop, obj->signalProperties) {
@@ -1047,25 +1054,25 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
             genObject(v->object);
 
             QDeclarativeInstruction assign;
-            assign.type = QDeclarativeInstruction::AssignSignalObject;
+            assign.setType(QDeclarativeInstruction::AssignSignalObject);
             assign.assignSignalObject.line = v->location.start.line;
             assign.assignSignalObject.signal =
                 output->indexForByteArray(prop->name);
-            output->bytecode << assign;
+            output->addInstruction(assign);
 
         } else if (v->type == Value::SignalExpression) {
 
             BindingContext ctxt = compileState.signalExpressions.value(v);
 
             QDeclarativeInstruction store;
-            store.type = QDeclarativeInstruction::StoreSignal;
+            store.setType(QDeclarativeInstruction::StoreSignal);
             store.storeSignal.signalIndex = prop->index;
             store.storeSignal.value =
                 output->indexForString(v->value.asScript().trimmed());
             store.storeSignal.context = ctxt.stack;
             store.storeSignal.name = output->indexForByteArray(prop->name);
             store.storeSignal.line = v->location.start.line;
-            output->bytecode << store;
+            output->addInstruction(store);
 
         }
 
@@ -1073,39 +1080,39 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
 
     foreach(Property *prop, obj->attachedProperties) {
         QDeclarativeInstruction fetch;
-        fetch.type = QDeclarativeInstruction::FetchAttached;
+        fetch.setType(QDeclarativeInstruction::FetchAttached);
         fetch.fetchAttached.id = prop->index;
         fetch.fetchAttached.line = prop->location.start.line;
-        output->bytecode << fetch;
+        output->addInstruction(fetch);
 
         genObjectBody(prop->value);
 
         QDeclarativeInstruction pop;
-        pop.type = QDeclarativeInstruction::PopFetchedObject;
-        output->bytecode << pop;
+        pop.setType(QDeclarativeInstruction::PopFetchedObject);
+        output->addInstruction(pop);
     }
 
     foreach(Property *prop, obj->groupedProperties) {
         QDeclarativeInstruction fetch;
-        fetch.type = QDeclarativeInstruction::FetchObject;
+        fetch.setType(QDeclarativeInstruction::FetchObject);
         fetch.fetch.property = prop->index;
         fetch.fetch.line = prop->location.start.line;
-        output->bytecode << fetch;
+        output->addInstruction(fetch);
 
         if (!prop->value->metadata.isEmpty()) {
             QDeclarativeInstruction meta;
-            meta.type = QDeclarativeInstruction::StoreMetaObject;
+            meta.setType(QDeclarativeInstruction::StoreMetaObject);
             meta.storeMeta.data = output->indexForByteArray(prop->value->metadata);
             meta.storeMeta.aliasData = output->indexForByteArray(prop->value->synthdata);
             meta.storeMeta.propertyCache = -1;
-            output->bytecode << meta;
+            output->addInstruction(meta);
         }
 
         genObjectBody(prop->value);
 
         QDeclarativeInstruction pop;
-        pop.type = QDeclarativeInstruction::PopFetchedObject;
-        output->bytecode << pop;
+        pop.setType(QDeclarativeInstruction::PopFetchedObject);
+        output->addInstruction(pop);
     }
 
     foreach(Property *prop, obj->valueTypeProperties) {
@@ -1129,7 +1136,7 @@ void QDeclarativeCompiler::genObjectBody(QDeclarativeParser::Object *obj)
 void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeParser::Object *obj,QDeclarativeParser::Property *prop)
 {
     QDeclarativeInstruction fetch;
-    fetch.type = QDeclarativeInstruction::FetchValueType;
+    fetch.setType(QDeclarativeInstruction::FetchValueType);
     fetch.fetchValue.property = prop->index;
     fetch.fetchValue.type = prop->type;
     fetch.fetchValue.bindingSkipList = 0;
@@ -1145,18 +1152,18 @@ void QDeclarativeCompiler::genValueTypeProperty(QDeclarativeParser::Object *obj,
         }
     }
 
-    output->bytecode << fetch;
+    output->addInstruction(fetch);
 
     foreach(Property *vprop, prop->value->valueProperties) {
         genPropertyAssignment(vprop, prop->value, prop);
     }
 
     QDeclarativeInstruction pop;
-    pop.type = QDeclarativeInstruction::PopValueType;
+    pop.setType(QDeclarativeInstruction::PopValueType);
     pop.fetchValue.property = prop->index;
     pop.fetchValue.type = prop->type;
     pop.fetchValue.bindingSkipList = 0;
-    output->bytecode << pop;
+    output->addInstruction(pop);
 }
 
 void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
@@ -1165,18 +1172,18 @@ void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
     Q_ASSERT(root);
 
     QDeclarativeInstruction create;
-    create.type = QDeclarativeInstruction::CreateComponent;
+    create.setType(QDeclarativeInstruction::CreateComponent);
     create.createComponent.line = root->location.start.line;
     create.createComponent.column = root->location.start.column;
     create.createComponent.endLine = root->location.end.line;
-    output->bytecode << create;
-    int count = output->bytecode.count();
+    int createInstruction = output->addInstruction(create);
+    int nextInstructionIndex = output->nextInstructionIndex();
 
     ComponentCompileState oldCompileState = compileState;
     compileState = componentState(root);
 
     QDeclarativeInstruction init;
-    init.type = QDeclarativeInstruction::Init;
+    init.setType(QDeclarativeInstruction::Init);
     init.init.bindingsSize = compileState.bindings.count();
     init.init.parserStatusSize = compileState.parserStatusCount;
     init.init.contextCache = genContextCache();
@@ -1184,25 +1191,29 @@ void QDeclarativeCompiler::genComponent(QDeclarativeParser::Object *obj)
         init.init.compiledBinding = -1;
     else
         init.init.compiledBinding = output->indexForByteArray(compileState.compiledBindingData);
-    output->bytecode << init;
+    output->addInstruction(init);
 
     genObject(root);
 
     QDeclarativeInstruction def;
-    def.type = QDeclarativeInstruction::SetDefault;
-    output->bytecode << def;
+    def.setType(QDeclarativeInstruction::SetDefault);
+    output->addInstruction(def);
+
+    QDeclarativeInstruction done;
+    done.setType(QDeclarativeInstruction::Done);
+    output->addInstruction(done);
 
-    output->bytecode[count - 1].createComponent.count =
-        output->bytecode.count() - count;
+    output->instruction(createInstruction)->createComponent.count = 
+        output->nextInstructionIndex() - nextInstructionIndex;
 
     compileState = oldCompileState;
 
     if (!obj->id.isEmpty()) {
         QDeclarativeInstruction id;
-        id.type = QDeclarativeInstruction::SetId;
+        id.setType(QDeclarativeInstruction::SetId);
         id.setId.value = output->indexForString(obj->id);
         id.setId.index = obj->idIndex;
-        output->bytecode << id;
+        output->addInstruction(id);
     }
 }
 
@@ -1592,11 +1603,11 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
     int listType = enginePrivate->listType(prop->type);
 
     QDeclarativeInstruction fetch;
-    fetch.type = QDeclarativeInstruction::FetchQList;
+    fetch.setType(QDeclarativeInstruction::FetchQList);
     fetch.fetchQmlList.property = prop->index;
     bool listTypeIsInterface = QDeclarativeMetaType::isInterface(listType);
     fetch.fetchQmlList.type = listType;
-    output->bytecode << fetch;
+    output->addInstruction(fetch);
 
     for (int ii = 0; ii < prop->values.count(); ++ii) {
         QDeclarativeParser::Value *v = prop->values.at(ii);
@@ -1606,13 +1617,13 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
             genObject(v->object);
             if (listTypeIsInterface) {
                 QDeclarativeInstruction assign;
-                assign.type = QDeclarativeInstruction::AssignObjectList;
+                assign.setType(QDeclarativeInstruction::AssignObjectList);
                 assign.assignObjectList.line = prop->location.start.line;
-                output->bytecode << assign;
+                output->addInstruction(assign);
             } else {
                 QDeclarativeInstruction store;
-                store.type = QDeclarativeInstruction::StoreObjectQList;
-                output->bytecode << store;
+                store.setType(QDeclarativeInstruction::StoreObjectQList);
+                output->addInstruction(store);
             }
 
         } else if (v->type == Value::PropertyBinding) {
@@ -1624,8 +1635,8 @@ void QDeclarativeCompiler::genListProperty(QDeclarativeParser::Property *prop,
     }
 
     QDeclarativeInstruction pop;
-    pop.type = QDeclarativeInstruction::PopQList;
-    output->bytecode << pop;
+    pop.setType(QDeclarativeInstruction::PopQList);
+    output->addInstruction(pop);
 }
 
 void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *prop,
@@ -1646,26 +1657,26 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
             if (QDeclarativeMetaType::isInterface(prop->type)) {
 
                 QDeclarativeInstruction store;
-                store.type = QDeclarativeInstruction::StoreInterface;
+                store.setType(QDeclarativeInstruction::StoreInterface);
                 store.storeObject.line = v->object->location.start.line;
                 store.storeObject.propertyIndex = prop->index;
-                output->bytecode << store;
+                output->addInstruction(store);
 
             } else if (prop->type == -1) {
 
                 QDeclarativeInstruction store;
-                store.type = QDeclarativeInstruction::StoreVariantObject;
+                store.setType(QDeclarativeInstruction::StoreVariantObject);
                 store.storeObject.line = v->object->location.start.line;
                 store.storeObject.propertyIndex = prop->index;
-                output->bytecode << store;
+                output->addInstruction(store);
 
             } else {
 
                 QDeclarativeInstruction store;
-                store.type = QDeclarativeInstruction::StoreObject;
+                store.setType(QDeclarativeInstruction::StoreObject);
                 store.storeObject.line = v->object->location.start.line;
                 store.storeObject.propertyIndex = prop->index;
-                output->bytecode << store;
+                output->addInstruction(store);
 
             }
         } else if (v->type == Value::PropertyBinding) {
@@ -1692,7 +1703,7 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
             genObject(v->object);
 
             QDeclarativeInstruction store;
-            store.type = QDeclarativeInstruction::StoreValueSource;
+            store.setType(QDeclarativeInstruction::StoreValueSource);
             if (valueTypeProperty) {
                 store.assignValueSource.property = genValueTypeData(prop, valueTypeProperty);
                 store.assignValueSource.owner = 1;
@@ -1702,13 +1713,13 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
             }
             QDeclarativeType *valueType = toQmlType(v->object);
             store.assignValueSource.castValue = valueType->propertyValueSourceCast();
-            output->bytecode << store;
+            output->addInstruction(store);
 
         } else if (v->type == Value::ValueInterceptor) {
             genObject(v->object);
 
             QDeclarativeInstruction store;
-            store.type = QDeclarativeInstruction::StoreValueInterceptor;
+            store.setType(QDeclarativeInstruction::StoreValueInterceptor);
             if (valueTypeProperty) {
                 store.assignValueInterceptor.property = genValueTypeData(prop, valueTypeProperty);
                 store.assignValueInterceptor.owner = 1;
@@ -1718,7 +1729,7 @@ void QDeclarativeCompiler::genPropertyAssignment(QDeclarativeParser::Property *p
             }
             QDeclarativeType *valueType = toQmlType(v->object);
             store.assignValueInterceptor.castValue = valueType->propertyValueInterceptorCast();
-            output->bytecode << store;
+            output->addInstruction(store);
         }
 
     }
@@ -2805,7 +2816,7 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *bindi
     const BindingReference &ref = compileState.bindings.value(binding);
     if (ref.dataType == BindingReference::Experimental) {
         QDeclarativeInstruction store;
-        store.type = QDeclarativeInstruction::StoreCompiledBinding;
+        store.setType(QDeclarativeInstruction::StoreCompiledBinding);
         store.assignBinding.value = ref.compiledIndex;
         store.assignBinding.context = ref.bindingContext.stack;
         store.assignBinding.owner = ref.bindingContext.owner;
@@ -2816,15 +2827,15 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *bindi
         else 
             store.assignBinding.property = prop->index;
         store.assignBinding.line = binding->location.start.line;
-        output->bytecode << store;
+        output->addInstruction(store);
         return;
     }
 
     QDeclarativeInstruction store;
     if (!prop->isAlias)
-        store.type = QDeclarativeInstruction::StoreBinding;
+        store.setType(QDeclarativeInstruction::StoreBinding);
     else
-        store.type = QDeclarativeInstruction::StoreBindingOnAlias;
+        store.setType(QDeclarativeInstruction::StoreBindingOnAlias);
     store.assignBinding.value = output->indexForByteArray(ref.compiledData);
     store.assignBinding.context = ref.bindingContext.stack;
     store.assignBinding.owner = ref.bindingContext.owner;
@@ -2838,7 +2849,7 @@ void QDeclarativeCompiler::genBindingAssignment(QDeclarativeParser::Value *bindi
         store.assignBinding.property = genPropertyData(prop);
     }
 
-    output->bytecode << store;
+    output->addInstruction(store);
 }
 
 int QDeclarativeCompiler::genContextCache()
index 49bab75..3697d3a 100644 (file)
@@ -117,7 +117,7 @@ public:
     QList<CustomTypeData> customTypeData;
     QList<QByteArray> datas;
     QList<QDeclarativeParser::Location> locations;
-    QList<QDeclarativeInstruction> bytecode;
+    QByteArray bytecode;
     QList<QScriptProgram *> cachedPrograms;
     QList<QScriptValue *> cachedClosures;
     QList<QDeclarativePropertyCache *> propertyCaches;
@@ -127,6 +127,10 @@ public:
 
     void dumpInstructions();
 
+    int addInstruction(const QDeclarativeInstruction &instr);
+    int nextInstructionIndex();
+    QDeclarativeInstruction *instruction(int index);
+
 protected:
     virtual void clear(); // From QDeclarativeCleanup
 
index aa1bbd1..7126746 100644 (file)
@@ -455,7 +455,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const Q
 /*!
     \internal
 */
-QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, int count, QObject *parent)
+QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclarativeCompiledData *cc, int start, QObject *parent)
     : QObject(*(new QDeclarativeComponentPrivate), parent)
 {
     Q_D(QDeclarativeComponent);
@@ -463,7 +463,6 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, QDeclar
     d->cc = cc;
     cc->addref();
     d->start = start;
-    d->count = count;
     d->url = cc->url;
     d->progress = 1.0;
 }
@@ -833,7 +832,7 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context, cons
         return 0;
     }
 
-    return begin(context, creationContext, cc, start, count, &state, 0, bindings);
+    return begin(context, creationContext, cc, start, &state, 0, bindings);
 }
 
 /*
@@ -866,7 +865,7 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject)
 
 QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentContext, 
                                               QDeclarativeContextData *componentCreationContext,
-                                              QDeclarativeCompiledData *component, int start, int count,
+                                              QDeclarativeCompiledData *component, int start, 
                                               ConstructionState *state, QList<QDeclarativeError> *errors,
                                               const QBitField &bindings)
 {
@@ -895,7 +894,7 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *parentCon
 
     QDeclarativeVME vme;
     enginePriv->referenceScarceResources(); // "hold" scarce resources in memory during evaluation.
-    QObject *rv = vme.run(ctxt, component, start, count, bindings);
+    QObject *rv = vme.run(ctxt, component, start, bindings);
     enginePriv->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete.
 
     if (vme.isError()) {
index f46ffdf..72e77da 100644 (file)
@@ -113,7 +113,7 @@ protected:
     Q_INVOKABLE Q_REVISION(1) QScriptValue createObject(QObject* parent, const QScriptValue& valuemap); //XXX Versioning
 
 private:
-    QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, int, QObject *parent);
+    QDeclarativeComponent(QDeclarativeEngine *, QDeclarativeCompiledData *, int, QObject *parent);
 
     Q_DISABLE_COPY(QDeclarativeComponent)
     friend class QDeclarativeVME;
index f8bec2b..9bfbba9 100644 (file)
@@ -79,7 +79,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeComponentPrivate : public QObjectPrivate, pu
     Q_DECLARE_PUBLIC(QDeclarativeComponent)
         
 public:
-    QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), engine(0), creationContext(0) {}
+    QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0) {}
 
     QObject *beginCreate(QDeclarativeContextData *, const QBitField &);
     void completeCreate();
@@ -94,7 +94,6 @@ public:
     qreal progress;
 
     int start;
-    int count;
     QDeclarativeCompiledData *cc;
 
     struct ConstructionState {
@@ -109,7 +108,7 @@ public:
     ConstructionState state;
 
     static QObject *begin(QDeclarativeContextData *parentContext, QDeclarativeContextData *componentCreationContext,
-                          QDeclarativeCompiledData *component, int start, int count, 
+                          QDeclarativeCompiledData *component, int start, 
                           ConstructionState *state, QList<QDeclarativeError> *errors, 
                           const QBitField &bindings = QBitField());
     static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, 
index 237cfa2..202e646 100644 (file)
@@ -53,10 +53,13 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
     Q_UNUSED(instr)
     Q_UNUSED(idx)
 #else
-    switch(instr->type) {
+    switch(instr->type()) {
     case QDeclarativeInstruction::Init:
         qWarning().nospace() << idx << "\t\t" << "INIT\t\t\t" << instr->init.bindingsSize << "\t" << instr->init.parserStatusSize << "\t" << instr->init.contextCache << "\t" << instr->init.compiledBinding;
         break;
+    case QDeclarativeInstruction::Done:
+        qWarning().nospace() << idx << "\t\t" << "DONE";
+        break;
     case QDeclarativeInstruction::CreateObject:
         qWarning().nospace() << idx << "\t\t" << "CREATE\t\t\t" << instr->create.type << "\t" << instr->create.bindingBits << "\t\t" << types.at(instr->create.type).className;
         break;
@@ -214,10 +217,20 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
         qWarning().nospace() << idx << "\t\t" << "DEFER" << "\t\t\t" << instr->defer.deferCount;
         break;
     default:
-        qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instr->type;
+        qWarning().nospace() << idx << "\t\t" << "XXX UNKNOWN INSTRUCTION" << "\t" << instr->type();
         break;
     }
 #endif // QT_NO_DEBUG_STREAM
 }
 
+int QDeclarativeInstruction::size() const
+{
+#define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QDeclarativeInstructionMeta<(int)I>::Size;
+    switch (common.instructionType) {
+    FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
+    default: return 0;
+    }
+#undef QML_RETURN_INSTR_SIZE
+}
+
 QT_END_NAMESPACE
index 3032964..b436ce5 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-class QDeclarativeCompiledData;
-class Q_AUTOTEST_EXPORT QDeclarativeInstruction
-{
-public:
-    enum Type { 
-        //
-        // Object Creation
-        //
-        //    CreateObject - Create a new object instance and push it on the 
-        //                   object stack
-        //    SetId - Set the id of the object on the top of the object stack
-        //    SetDefault - Sets the instance on the top of the object stack to
-        //                 be the context's default object.
-        //    StoreMetaObject - Assign the dynamic metaobject to object on the
-        //                      top of the stack.
-        Init,                     /* init */
-        CreateObject,             /* create */
-        CreateSimpleObject,       /* createSimple */
-        SetId,                    /* setId */
-        SetDefault,
-        CreateComponent,          /* createComponent */
-        StoreMetaObject,          /* storeMeta */
-
-        //
-        // Precomputed single assignment
-        //
-        //    StoreFloat - Store a float in a core property
-        //    StoreDouble - Store a double in a core property
-        //    StoreInteger - Store a int or uint in a core property
-        //    StoreBool - Store a bool in a core property
-        //    StoreString - Store a QString in a core property
-        //    StoreByteArray - Store a QByteArray in a core property
-        //    StoreUrl - Store a QUrl in a core property
-        //    StoreColor - Store a QColor in a core property
-        //    StoreDate - Store a QDate in a core property
-        //    StoreTime - Store a QTime in a core property
-        //    StoreDateTime - Store a QDateTime in a core property
-        //    StoreVariant - Store a QVariant in a core property
-        //    StoreObject - Pop the object on the top of the object stack and
-        //                  store it in a core property
-        StoreFloat,               /* storeFloat */
-        StoreDouble,              /* storeDouble */
-        StoreInteger,             /* storeInteger */
-        StoreBool,                /* storeBool */
-        StoreString,              /* storeString */
-        StoreByteArray,           /* storeByteArray */
-        StoreUrl,                 /* storeUrl */
-        StoreColor,               /* storeColor */
-        StoreDate,                /* storeDate */
-        StoreTime,                /* storeTime */
-        StoreDateTime,            /* storeDateTime */
-        StorePoint,               /* storeRealPair */
-        StorePointF,              /* storeRealPair */
-        StoreSize,                /* storeRealPair */
-        StoreSizeF,               /* storeRealPair */
-        StoreRect,                /* storeRect */
-        StoreRectF,               /* storeRect */
-        StoreVector3D,            /* storeVector3D */
-        StoreVariant,             /* storeString */
-        StoreVariantInteger,      /* storeInteger */
-        StoreVariantDouble,       /* storeDouble */
-        StoreVariantBool,         /* storeBool */
-        StoreObject,              /* storeObject */
-        StoreVariantObject,       /* storeObject */
-        StoreInterface,           /* storeObject */
-
-        StoreSignal,              /* storeSignal */
-        StoreImportedScript,      /* storeScript */
-        StoreScriptString,        /* storeScriptString */
-
-        //
-        // Unresolved single assignment
-        //
-        AssignSignalObject,       /* assignSignalObject */
-        AssignCustomType,         /* assignCustomType */
-
-        StoreBinding,             /* assignBinding */
-        StoreBindingOnAlias,      /* assignBinding */
-        StoreCompiledBinding,     /* assignBinding */
-        StoreValueSource,         /* assignValueSource */
-        StoreValueInterceptor,    /* assignValueInterceptor */
-
-        BeginObject,              /* begin */
-
-        StoreObjectQList,         /* NA */
-        AssignObjectList,         /* assignObjectList */
+#define FOR_EACH_QML_INSTR(F) \
+    F(Init, init) \
+    F(Done, common) \
+    F(CreateObject, create) \
+    F(CreateSimpleObject, createSimple) \
+    F(SetId, setId) \
+    F(SetDefault, common) \
+    F(CreateComponent, createComponent) \
+    F(StoreMetaObject, storeMeta) \
+    F(StoreVariant, storeString) \
+    F(StoreVariantInteger, storeInteger) \
+    F(StoreVariantDouble, storeDouble) \
+    F(StoreVariantBool, storeBool) \
+    F(StoreString, storeString) \
+    F(StoreByteArray, storeByteArray) \
+    F(StoreUrl, storeUrl) \
+    F(StoreFloat, storeFloat) \
+    F(StoreDouble, storeDouble) \
+    F(StoreBool, storeBool) \
+    F(StoreInteger, storeInteger) \
+    F(StoreColor, storeColor) \
+    F(StoreDate, storeDate) \
+    F(StoreTime, storeTime) \
+    F(StoreDateTime, storeDateTime) \
+    F(StorePoint, storeRealPair) \
+    F(StorePointF, storeRealPair) \
+    F(StoreSize, storeRealPair) \
+    F(StoreSizeF, storeRealPair) \
+    F(StoreRect, storeRect) \
+    F(StoreRectF, storeRect) \
+    F(StoreVector3D, storeVector3D) \
+    F(StoreObject, storeObject) \
+    F(AssignCustomType, assignCustomType) \
+    F(AssignSignalObject, assignSignalObject) \
+    F(StoreSignal, storeSignal) \
+    F(StoreImportedScript, storeScript) \
+    F(StoreScriptString, storeScriptString) \
+    F(BeginObject, begin) \
+    F(StoreBinding, assignBinding) \
+    F(StoreBindingOnAlias, assignBinding) \
+    F(StoreCompiledBinding, assignBinding) \
+    F(StoreValueSource, assignValueSource) \
+    F(StoreValueInterceptor, assignValueInterceptor) \
+    F(StoreObjectQList, common) \
+    F(AssignObjectList, assignObjectList) \
+    F(StoreVariantObject, storeObject) \
+    F(StoreInterface, storeObject) \
+    F(FetchAttached, fetchAttached) \
+    F(FetchQList, fetchQmlList) \
+    F(FetchObject, fetch) \
+    F(PopQList, common) \
+    F(Defer, defer) \
+    F(PopFetchedObject, common) \
+    F(FetchValueType, fetchValue) \
+    F(PopValueType, fetchValue) 
 
-        FetchAttached,            /* fetchAttached */
-        FetchQList,               /* fetch */
-        FetchObject,              /* fetch */
-        FetchValueType,           /* fetchValue */
+#ifdef Q_ALIGNOF
+#  define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(QDeclarativeInstruction) - 1)
+#else
+#  define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
+#endif
 
-        //
-        // Stack manipulation
-        // 
-        //    PopFetchedObject - Remove an object from the object stack
-        //    PopQList - Remove a list from the list stack
-        PopFetchedObject,
-        PopQList,
-        PopValueType,            /* fetchValue */
+#define QML_INSTR_HEADER quint8 instructionType;
+#define QML_INSTR_ENUM(I, FMT)  I,
+#define QML_INSTR_SIZE(I, FMT) ((sizeof(QDeclarativeInstruction::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
 
-        // 
-        // Deferred creation
-        //
-        Defer                    /* defer */
+class QDeclarativeCompiledData;
+union QDeclarativeInstruction
+{
+    enum Type { 
+        FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
     };
-    QDeclarativeInstruction() {}
 
-    Type type;
+    inline void setType(Type type) { common.instructionType = type; }
+    inline Type type() const { return (Type)common.instructionType; }
 
-    struct InitInstruction {
+    struct instr_common {
+        QML_INSTR_HEADER
+    };
+    struct instr_init {
+        QML_INSTR_HEADER
         int bindingsSize;
         int parserStatusSize;
         int contextCache;
         int compiledBinding;
     };
-    struct CreateInstruction {
+    struct instr_create {
+        QML_INSTR_HEADER
         int type;
         int data;
         int bindingBits;
         ushort column;
         ushort line; 
     };
-    struct CreateSimpleInstruction {
+    struct instr_createSimple {
+        QML_INSTR_HEADER
         void (*create)(void *);
         int typeSize;
         int type;
         ushort column;
         ushort line; 
     };
-    struct StoreMetaInstruction {
+    struct instr_storeMeta {
+        QML_INSTR_HEADER
         int data;
         int aliasData;
         int propertyCache;
     };
-    struct SetIdInstruction {
+    struct instr_setId {
+        QML_INSTR_HEADER
         int value;
         int index;
     };
-    struct AssignValueSourceInstruction {
+    struct instr_assignValueSource {
+        QML_INSTR_HEADER
         int property;
         int owner;
         int castValue;
     };
-    struct AssignValueInterceptorInstruction {
+    struct instr_assignValueInterceptor {
+        QML_INSTR_HEADER
         int property;
         int owner;
         int castValue;
     };
-    struct AssignBindingInstruction {
+    struct instr_assignBinding {
+        QML_INSTR_HEADER
         unsigned int property;
         int value;
         short context;
         short owner;
         ushort line;
     };
-    struct FetchInstruction {
+    struct instr_fetch {
+        QML_INSTR_HEADER
         int property;
         ushort line;
     };
-    struct FetchValueInstruction {
+    struct instr_fetchValue {
+        QML_INSTR_HEADER
         int property;
         int type;
         quint32 bindingSkipList;
     };
-    struct FetchQmlListInstruction {
+    struct instr_fetchQmlList {
+        QML_INSTR_HEADER
         int property;
         int type;
     };
-    struct BeginInstruction {
+    struct instr_begin {
+        QML_INSTR_HEADER
         int castValue;
     }; 
-    struct StoreFloatInstruction {
+    struct instr_storeFloat {
+        QML_INSTR_HEADER
         int propertyIndex;
         float value;
     };
-    struct StoreDoubleInstruction {
+    struct instr_storeDouble {
+        QML_INSTR_HEADER
         int propertyIndex;
         double value;
     };
-    struct StoreIntegerInstruction {
+    struct instr_storeInteger {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
     };
-    struct StoreBoolInstruction {
+    struct instr_storeBool {
+        QML_INSTR_HEADER
         int propertyIndex;
         bool value;
     };
-    struct StoreStringInstruction {
+    struct instr_storeString {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
     };
-    struct StoreByteArrayInstruction {
+    struct instr_storeByteArray {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
     };
-    struct StoreScriptStringInstruction {
+    struct instr_storeScriptString {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
         int scope;
     }; 
-    struct StoreScriptInstruction {
+    struct instr_storeScript {
+        QML_INSTR_HEADER
         int value;
     };
-    struct StoreUrlInstruction {
+    struct instr_storeUrl {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
     };
-    struct StoreColorInstruction {
+    struct instr_storeColor {
+        QML_INSTR_HEADER
         int propertyIndex;
         unsigned int value;
     };
-    struct StoreDateInstruction {
+    struct instr_storeDate {
+        QML_INSTR_HEADER
         int propertyIndex;
         int value;
     };
-    struct StoreTimeInstruction {
+    struct instr_storeTime {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
     };
-    struct StoreDateTimeInstruction {
+    struct instr_storeDateTime {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
     };
-    struct StoreRealPairInstruction {
+    struct instr_storeRealPair {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
     };
-    struct StoreRectInstruction {
+    struct instr_storeRect {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
     };
-    struct StoreVector3DInstruction {
+    struct instr_storeVector3D {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
     };
-    struct StoreObjectInstruction {
+    struct instr_storeObject {
+        QML_INSTR_HEADER
         int propertyIndex;
         ushort line;
     };
-    struct AssignCustomTypeInstruction {
+    struct instr_assignCustomType {
+        QML_INSTR_HEADER
         int propertyIndex;
         int valueIndex;
         ushort line;
     };
-    struct StoreSignalInstruction {
+    struct instr_storeSignal {
+        QML_INSTR_HEADER
         int signalIndex;
         int value;
         short context;
         int name;
         ushort line;
     };
-    struct AssignSignalObjectInstruction {
+    struct instr_assignSignalObject {
+        QML_INSTR_HEADER
         int signal;
         ushort line; 
     };
-    struct CreateComponentInstruction {
+    struct instr_createComponent {
+        QML_INSTR_HEADER
         int count;
         int endLine;
         int metaObject;
         ushort column;
         ushort line;
     };
-    struct FetchAttachedInstruction {
+    struct instr_fetchAttached {
+        QML_INSTR_HEADER
         int id;
         ushort line;
     };
-    struct DeferInstruction {
+    struct instr_defer {
+        QML_INSTR_HEADER
         int deferCount;
     };
-    struct AssignObjectListInstruction {
+    struct instr_assignObjectList {
+        QML_INSTR_HEADER
         ushort line;
     };
 
-    union {
-        InitInstruction init;
-        CreateInstruction create;
-        CreateSimpleInstruction createSimple;
-        StoreMetaInstruction storeMeta;
-        SetIdInstruction setId;
-        AssignValueSourceInstruction assignValueSource;
-        AssignValueInterceptorInstruction assignValueInterceptor;
-        AssignBindingInstruction assignBinding;
-        FetchInstruction fetch;
-        FetchValueInstruction fetchValue;
-        FetchQmlListInstruction fetchQmlList;
-        BeginInstruction begin;
-        StoreFloatInstruction storeFloat;
-        StoreDoubleInstruction storeDouble;
-        StoreIntegerInstruction storeInteger;
-        StoreBoolInstruction storeBool;
-        StoreStringInstruction storeString;
-        StoreByteArrayInstruction storeByteArray;
-        StoreScriptStringInstruction storeScriptString;
-        StoreScriptInstruction storeScript;
-        StoreUrlInstruction storeUrl;
-        StoreColorInstruction storeColor;
-        StoreDateInstruction storeDate;
-        StoreTimeInstruction storeTime;
-        StoreDateTimeInstruction storeDateTime;
-        StoreRealPairInstruction storeRealPair;
-        StoreRectInstruction storeRect;
-        StoreVector3DInstruction storeVector3D;
-        StoreObjectInstruction storeObject;
-        AssignCustomTypeInstruction assignCustomType;
-        StoreSignalInstruction storeSignal;
-        AssignSignalObjectInstruction assignSignalObject;
-        CreateComponentInstruction createComponent;
-        FetchAttachedInstruction fetchAttached;
-        DeferInstruction defer;
-        AssignObjectListInstruction assignObjectList;
-    };
+    instr_common common;
+    instr_init init;
+    instr_create create;
+    instr_createSimple createSimple;
+    instr_storeMeta storeMeta;
+    instr_setId setId;
+    instr_assignValueSource assignValueSource;
+    instr_assignValueInterceptor assignValueInterceptor;
+    instr_assignBinding assignBinding;
+    instr_fetch fetch;
+    instr_fetchValue fetchValue;
+    instr_fetchQmlList fetchQmlList;
+    instr_begin begin;
+    instr_storeFloat storeFloat;
+    instr_storeDouble storeDouble;
+    instr_storeInteger storeInteger;
+    instr_storeBool storeBool;
+    instr_storeString storeString;
+    instr_storeByteArray storeByteArray;
+    instr_storeScriptString storeScriptString;
+    instr_storeScript storeScript;
+    instr_storeUrl storeUrl;
+    instr_storeColor storeColor;
+    instr_storeDate storeDate;
+    instr_storeTime storeTime;
+    instr_storeDateTime storeDateTime;
+    instr_storeRealPair storeRealPair;
+    instr_storeRect storeRect;
+    instr_storeVector3D storeVector3D;
+    instr_storeObject storeObject;
+    instr_assignCustomType assignCustomType;
+    instr_storeSignal storeSignal;
+    instr_assignSignalObject assignSignalObject;
+    instr_createComponent createComponent;
+    instr_fetchAttached fetchAttached;
+    instr_defer defer;
+    instr_assignObjectList assignObjectList;
 
-    void dump(QDeclarativeCompiledData *);
+    int size() const;
 };
 
+template<int N>
+struct QDeclarativeInstructionMeta {
+};
+
+#define QML_INSTR_META_TEMPLATE(I, FMT) \
+    template<> struct QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I> { \
+        enum { Size = QML_INSTR_SIZE(I, FMT) }; \
+        typedef QDeclarativeInstruction::instr_##FMT DataType; \
+        static const DataType &data(const QDeclarativeInstruction &instr) { return instr.FMT; } \
+    }; 
+FOR_EACH_QML_INSTR(QML_INSTR_META_TEMPLATE);
+#undef QML_INSTR_META_TEMPLATE
+
 QT_END_NAMESPACE
 
 #endif // QDECLARATIVEINSTRUCTION_P_H
index af29991..03abae7 100644 (file)
@@ -102,14 +102,13 @@ struct ListInstance
 };
 
 QObject *QDeclarativeVME::run(QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, 
-                              int start, int count, const QBitField &bindingSkipList)
+                              int start, const QBitField &bindingSkipList)
 {
     QDeclarativeVMEStack<QObject *> stack;
 
     if (start == -1) start = 0;
-    if (count == -1) count = comp->bytecode.count();
 
-    return run(stack, ctxt, comp, start, count, bindingSkipList);
+    return run(stack, ctxt, comp, start, bindingSkipList);
 }
 
 void QDeclarativeVME::runDeferred(QObject *object)
@@ -121,12 +120,11 @@ void QDeclarativeVME::runDeferred(QObject *object)
 
     QDeclarativeContextData *ctxt = data->context;
     QDeclarativeCompiledData *comp = data->deferredComponent;
-    int start = data->deferredIdx + 1;
-    int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
+    int start = data->deferredIdx;
     QDeclarativeVMEStack<QObject *> stack;
     stack.push(object);
 
-    run(stack, ctxt, comp, start, count, QBitField());
+    run(stack, ctxt, comp, start, QBitField());
 }
 
 inline bool fastHasBinding(QObject *o, int index) 
@@ -143,13 +141,20 @@ static void removeBindingOnProperty(QObject *o, int index)
     if (binding) binding->destroy();
 }
 
+#define QML_BEGIN_INSTR(I) \
+    case QDeclarativeInstruction::I: { \
+        const QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::DataType &instr = QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::data(genericInstr); \
+        instructionStream += QDeclarativeInstructionMeta<(int)QDeclarativeInstruction::I>::Size; \
+        Q_UNUSED(instr); 
+
+#define QML_END_INSTR(I) } break;
+
 #define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index)
 
 QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, 
                               QDeclarativeContextData *ctxt, 
                               QDeclarativeCompiledData *comp, 
-                              int start, int count, 
-                              const QBitField &bindingSkipList)
+                              int start, const QBitField &bindingSkipList)
 {
     Q_ASSERT(comp);
     Q_ASSERT(ctxt);
@@ -175,830 +180,746 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
     QDeclarativePropertyPrivate::WriteFlags flags = QDeclarativePropertyPrivate::BypassInterceptor |
                                                     QDeclarativePropertyPrivate::RemoveBindingOnAliasWrite;
 
-    for (int ii = start; !isError() && ii < (start + count); ++ii) {
-        const QDeclarativeInstruction &instr = comp->bytecode.at(ii);
-
-        switch(instr.type) {
-        case QDeclarativeInstruction::Init:
-            {
-                if (instr.init.bindingsSize) 
-                    bindValues = QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding>(instr.init.bindingsSize);
-                if (instr.init.parserStatusSize)
-                    parserStatus = QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus>(instr.init.parserStatusSize);
-                if (instr.init.contextCache != -1) 
-                    ctxt->setIdPropertyData(comp->contextCaches.at(instr.init.contextCache));
-                if (instr.init.compiledBinding != -1) 
-                    ctxt->optimizedBindings = new QDeclarativeV4Bindings(datas.at(instr.init.compiledBinding).constData(), ctxt);
-            }
-            break;
-
-        case QDeclarativeInstruction::CreateObject:
-            {
-                QBitField bindings;
-                if (instr.create.bindingBits != -1) {
-                    const QByteArray &bits = datas.at(instr.create.bindingBits);
-                    bindings = QBitField((const quint32*)bits.constData(),
-                                         bits.size() * 8);
-                }
-                if (stack.isEmpty())
-                    bindings = bindings.united(bindingSkipList);
-
-                QObject *o = 
-                    types.at(instr.create.type).createInstance(ctxt, bindings, &vmeErrors);
-
-                if (!o) {
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className)), instr.create.line);
-                }
-
-                QDeclarativeData *ddata = QDeclarativeData::get(o);
-                Q_ASSERT(ddata);
-
-                if (stack.isEmpty()) {
-                    if (ddata->context) {
-                        Q_ASSERT(ddata->context != ctxt);
-                        Q_ASSERT(ddata->outerContext);
-                        Q_ASSERT(ddata->outerContext != ctxt);
-                        QDeclarativeContextData *c = ddata->context;
-                        while (c->linkedContext) c = c->linkedContext;
-                        c->linkedContext = ctxt;
-                    } else {
-                        ctxt->addObject(o);
-                    }
-
-                    ddata->ownContext = true;
-                } else if (!ddata->context) {
-                    ctxt->addObject(o);
-                }
-
-                ddata->setImplicitDestructible();
-                ddata->outerContext = ctxt;
-                ddata->lineNumber = instr.create.line;
-                ddata->columnNumber = instr.create.column;
-
-                if (instr.create.data != -1) {
-                    QDeclarativeCustomParser *customParser =
-                        types.at(instr.create.type).type->customParser();
-                    customParser->setCustomData(o, datas.at(instr.create.data));
-                }
-                if (!stack.isEmpty()) {
-                    QObject *parent = stack.top();
-                    if (o->isWidgetType()) { 
-                        QWidget *widget = static_cast<QWidget*>(o); 
-                        if (parent->isWidgetType()) { 
-                            QWidget *parentWidget = static_cast<QWidget*>(parent); 
-                            widget->setParent(parentWidget); 
-                        } else { 
-                            // TODO: parent might be a layout 
-                        } 
-                    } else { 
-                           QDeclarative_setParent_noEvent(o, parent);
-                    } 
-                }
-                stack.push(o);
-            }
-            break;
-
-        case QDeclarativeInstruction::CreateSimpleObject:
-            {
-                QObject *o = (QObject *)operator new(instr.createSimple.typeSize + 
-                                                     sizeof(QDeclarativeData));   
-                ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeData));
-                instr.createSimple.create(o);
-
-                QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize);
-                const QDeclarativeCompiledData::TypeReference &ref = types.at(instr.createSimple.type);
-                if (!ddata->propertyCache && ref.typePropertyCache) {
-                    ddata->propertyCache = ref.typePropertyCache;
-                    ddata->propertyCache->addref();
-                }
-                ddata->lineNumber = instr.createSimple.line;
-                ddata->columnNumber = instr.createSimple.column;
-
-                QObjectPrivate::get(o)->declarativeData = ddata;                                                      
-                ddata->context = ddata->outerContext = ctxt;
-                ddata->nextContextObject = ctxt->contextObjects; 
-                if (ddata->nextContextObject) 
-                    ddata->nextContextObject->prevContextObject = &ddata->nextContextObject; 
-                ddata->prevContextObject = &ctxt->contextObjects; 
-                ctxt->contextObjects = ddata; 
-
-                QObject *parent = stack.top();                                                                    
-                QDeclarative_setParent_noEvent(o, parent);                                                        
-
-                stack.push(o);
-            }
-            break;
-
-        case QDeclarativeInstruction::SetId:
-            {
-                QObject *target = stack.top();
-                ctxt->setIdProperty(instr.setId.index, target);
+    const char *instructionStream = comp->bytecode.constData() + start;
+
+    bool done = false;
+    while (!isError() && !done) {
+        const QDeclarativeInstruction &genericInstr = *((QDeclarativeInstruction *)instructionStream);
+
+        switch(genericInstr.type()) {
+        QML_BEGIN_INSTR(Init)
+            if (instr.bindingsSize) 
+                bindValues = QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding>(instr.bindingsSize);
+            if (instr.parserStatusSize)
+                parserStatus = QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus>(instr.parserStatusSize);
+            if (instr.contextCache != -1) 
+                ctxt->setIdPropertyData(comp->contextCaches.at(instr.contextCache));
+            if (instr.compiledBinding != -1) 
+                    ctxt->optimizedBindings = new QDeclarativeV4Bindings(datas.at(instr.compiledBinding).constData(), ctxt);
+        QML_END_INSTR(Init)
+
+        QML_BEGIN_INSTR(Done)
+            done = true;
+        QML_END_INSTR(Done)
+
+        QML_BEGIN_INSTR(CreateObject)
+            QBitField bindings;
+            if (instr.bindingBits != -1) {
+                const QByteArray &bits = datas.at(instr.bindingBits);
+                bindings = QBitField((const quint32*)bits.constData(),
+                                     bits.size() * 8);
             }
-            break;
+            if (stack.isEmpty())
+                bindings = bindings.united(bindingSkipList);
 
+            QObject *o = 
+                types.at(instr.type).createInstance(ctxt, bindings, &vmeErrors);
 
-        case QDeclarativeInstruction::SetDefault:
-            {
-                ctxt->contextObject = stack.top();
+            if (!o) {
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.type).className)), instr.line);
             }
-            break;
-
-        case QDeclarativeInstruction::CreateComponent:
-            {
-                QDeclarativeComponent *qcomp = 
-                    new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count,
-                                              stack.isEmpty() ? 0 : stack.top());
-
-                QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true);
-                Q_ASSERT(ddata);
-
-                ctxt->addObject(qcomp);
-
-                if (stack.isEmpty()) 
-                    ddata->ownContext = true;
-
-                ddata->setImplicitDestructible();
-                ddata->outerContext = ctxt;
-                ddata->lineNumber = instr.createComponent.line;
-                ddata->columnNumber = instr.createComponent.column;
-
-                QDeclarativeComponentPrivate::get(qcomp)->creationContext = ctxt;
-
-                stack.push(qcomp);
-                ii += instr.createComponent.count;
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreMetaObject:
-            {
-                QObject *target = stack.top();
-
-                QMetaObject mo;
-                const QByteArray &metadata = datas.at(instr.storeMeta.data);
-                QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata);
 
-                const QDeclarativeVMEMetaData *data = 
-                    (const QDeclarativeVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData();
-
-                (void)new QDeclarativeVMEMetaObject(target, &mo, data, comp);
-
-                if (instr.storeMeta.propertyCache != -1) {
-                    QDeclarativeData *ddata = QDeclarativeData::get(target, true);
-                    if (ddata->propertyCache) ddata->propertyCache->release();
-                    ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache);
-                    ddata->propertyCache->addref();
+            QDeclarativeData *ddata = QDeclarativeData::get(o);
+            Q_ASSERT(ddata);
+
+            if (stack.isEmpty()) {
+                if (ddata->context) {
+                    Q_ASSERT(ddata->context != ctxt);
+                    Q_ASSERT(ddata->outerContext);
+                    Q_ASSERT(ddata->outerContext != ctxt);
+                    QDeclarativeContextData *c = ddata->context;
+                    while (c->linkedContext) c = c->linkedContext;
+                    c->linkedContext = ctxt;
+                } else {
+                    ctxt->addObject(o);
                 }
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreVariant:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
-
-                // XXX - can be more efficient
-                QVariant v = QDeclarativeStringConverters::variantFromString(primitives.at(instr.storeString.value));
-                void *a[] = { &v, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeString.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreVariantInteger:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
-
-                QVariant v(instr.storeInteger.value);
-                void *a[] = { &v, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeString.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreVariantDouble:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
-
-                QVariant v(instr.storeDouble.value);
-                void *a[] = { &v, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeString.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreVariantBool:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
-
-                QVariant v(instr.storeBool.value);
-                void *a[] = { &v, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeString.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreString:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeString.propertyIndex);
-
-                void *a[] = { (void *)&primitives.at(instr.storeString.value), 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeString.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreByteArray:
-            {
-                QObject *target = stack.top();
-                void *a[] = { (void *)&datas.at(instr.storeByteArray.value), 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty,
-                                      instr.storeByteArray.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreUrl:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeUrl.propertyIndex);
-
-                void *a[] = { (void *)&urls.at(instr.storeUrl.value), 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeUrl.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreFloat:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeFloat.propertyIndex);
-
-                float f = instr.storeFloat.value;
-                void *a[] = { &f, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty,
-                                      instr.storeFloat.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreDouble:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeDouble.propertyIndex);
-
-                double d = instr.storeDouble.value;
-                void *a[] = { &d, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty,
-                                      instr.storeDouble.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreBool:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeBool.propertyIndex);
-
-                void *a[] = { (void *)&instr.storeBool.value, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeBool.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreInteger:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeInteger.propertyIndex);
-
-                void *a[] = { (void *)&instr.storeInteger.value, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeInteger.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreColor:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeColor.propertyIndex);
-
-                QColor c = QColor::fromRgba(instr.storeColor.value);
-                void *a[] = { &c, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeColor.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreDate:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeDate.propertyIndex);
-
-                QDate d = QDate::fromJulianDay(instr.storeDate.value);
-                void *a[] = { &d, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeDate.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreTime:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeTime.propertyIndex);
-
-                QTime t;
-                t.setHMS(intData.at(instr.storeTime.valueIndex),
-                         intData.at(instr.storeTime.valueIndex+1),
-                         intData.at(instr.storeTime.valueIndex+2),
-                         intData.at(instr.storeTime.valueIndex+3));
-                void *a[] = { &t, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeTime.propertyIndex, a);
-            }
-            break;
 
-        case QDeclarativeInstruction::StoreDateTime:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeDateTime.propertyIndex);
-
-                QTime t;
-                t.setHMS(intData.at(instr.storeDateTime.valueIndex+1),
-                         intData.at(instr.storeDateTime.valueIndex+2),
-                         intData.at(instr.storeDateTime.valueIndex+3),
-                         intData.at(instr.storeDateTime.valueIndex+4));
-                QDateTime dt(QDate::fromJulianDay(intData.at(instr.storeDateTime.valueIndex)), t);
-                void *a[] = { &dt, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty,
-                                      instr.storeDateTime.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StorePoint:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
-
-                QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex),
-                                   floatData.at(instr.storeRealPair.valueIndex+1)).toPoint();
-                void *a[] = { &p, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRealPair.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StorePointF:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
-
-                QPointF p(floatData.at(instr.storeRealPair.valueIndex),
-                          floatData.at(instr.storeRealPair.valueIndex+1));
-                void *a[] = { &p, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRealPair.propertyIndex, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreSize:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
-
-                QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex),
-                                 floatData.at(instr.storeRealPair.valueIndex+1)).toSize();
-                void *a[] = { &p, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRealPair.propertyIndex, a);
+                ddata->ownContext = true;
+            } else if (!ddata->context) {
+                ctxt->addObject(o);
             }
-            break;
-
-        case QDeclarativeInstruction::StoreSizeF:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex);
 
-                QSizeF s(floatData.at(instr.storeRealPair.valueIndex),
-                         floatData.at(instr.storeRealPair.valueIndex+1));
-                void *a[] = { &s, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRealPair.propertyIndex, a);
-            }
-            break;
+            ddata->setImplicitDestructible();
+            ddata->outerContext = ctxt;
+            ddata->lineNumber = instr.line;
+            ddata->columnNumber = instr.column;
 
-        case QDeclarativeInstruction::StoreRect:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRect.propertyIndex);
-
-                QRect r = QRectF(floatData.at(instr.storeRect.valueIndex),
-                                 floatData.at(instr.storeRect.valueIndex+1),
-                                 floatData.at(instr.storeRect.valueIndex+2),
-                                 floatData.at(instr.storeRect.valueIndex+3)).toRect();
-                void *a[] = { &r, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRect.propertyIndex, a);
+            if (instr.data != -1) {
+                QDeclarativeCustomParser *customParser =
+                    types.at(instr.type).type->customParser();
+                customParser->setCustomData(o, datas.at(instr.data));
             }
-            break;
-
-        case QDeclarativeInstruction::StoreRectF:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeRect.propertyIndex);
-
-                QRectF r(floatData.at(instr.storeRect.valueIndex),
-                         floatData.at(instr.storeRect.valueIndex+1),
-                         floatData.at(instr.storeRect.valueIndex+2),
-                         floatData.at(instr.storeRect.valueIndex+3));
-                void *a[] = { &r, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeRect.propertyIndex, a);
+            if (!stack.isEmpty()) {
+                QObject *parent = stack.top();
+                if (o->isWidgetType()) { 
+                    QWidget *widget = static_cast<QWidget*>(o); 
+                    if (parent->isWidgetType()) { 
+                        QWidget *parentWidget = static_cast<QWidget*>(parent); 
+                        widget->setParent(parentWidget); 
+                    } else { 
+                        // TODO: parent might be a layout 
+                    } 
+                } else { 
+                        QDeclarative_setParent_noEvent(o, parent);
+                } 
             }
-            break;
-
-        case QDeclarativeInstruction::StoreVector3D:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeVector3D.propertyIndex);
-
-                QVector3D p(floatData.at(instr.storeVector3D.valueIndex),
-                            floatData.at(instr.storeVector3D.valueIndex+1),
-                            floatData.at(instr.storeVector3D.valueIndex+2));
-                void *a[] = { &p, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeVector3D.propertyIndex, a);
+            stack.push(o);
+        QML_END_INSTR(CreateObject)
+
+        QML_BEGIN_INSTR(CreateSimpleObject)
+            QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QDeclarativeData));   
+            ::memset(o, 0, instr.typeSize + sizeof(QDeclarativeData));
+            instr.create(o);
+
+            QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.typeSize);
+            const QDeclarativeCompiledData::TypeReference &ref = types.at(instr.type);
+            if (!ddata->propertyCache && ref.typePropertyCache) {
+                ddata->propertyCache = ref.typePropertyCache;
+                ddata->propertyCache->addref();
             }
-            break;
+            ddata->lineNumber = instr.line;
+            ddata->columnNumber = instr.column;
 
-        case QDeclarativeInstruction::StoreObject:
-            {
-                QObject *assignObj = stack.pop();
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
+            QObjectPrivate::get(o)->declarativeData = ddata;                                                      
+            ddata->context = ddata->outerContext = ctxt;
+            ddata->nextContextObject = ctxt->contextObjects; 
+            if (ddata->nextContextObject) 
+                ddata->nextContextObject->prevContextObject = &ddata->nextContextObject; 
+            ddata->prevContextObject = &ctxt->contextObjects; 
+            ctxt->contextObjects = ddata; 
 
-                void *a[] = { (void *)&assignObj, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeObject.propertyIndex, a);
-            }
-            break;
+            QObject *parent = stack.top();                                                                    
+            QDeclarative_setParent_noEvent(o, parent);                                                        
 
+            stack.push(o);
+        QML_END_INSTR(CreateSimpleObject)
 
-        case QDeclarativeInstruction::AssignCustomType:
-            {
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.assignCustomType.propertyIndex);
-
-                QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex);
-                const QString &primitive = primitives.at(data.index);
-                QDeclarativeMetaType::StringConverter converter = 
-                    QDeclarativeMetaType::customStringConverter(data.type);
-                QVariant v = (*converter)(primitive);
-
-                QMetaProperty prop = 
-                        target->metaObject()->property(instr.assignCustomType.propertyIndex);
-                if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type)) 
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.assignCustomType.line);
-
-                void *a[] = { (void *)v.data(), 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.assignCustomType.propertyIndex, a);
-            }
-            break;
+        QML_BEGIN_INSTR(SetId)
+            QObject *target = stack.top();
+            ctxt->setIdProperty(instr.index, target);
+        QML_END_INSTR(SetId)
 
-        case QDeclarativeInstruction::AssignSignalObject:
-            {
-                // XXX optimize
+        QML_BEGIN_INSTR(SetDefault)
+            ctxt->contextObject = stack.top();
+        QML_END_INSTR(SetDefault)
 
-                QObject *assign = stack.pop();
-                QObject *target = stack.top();
-                int sigIdx = instr.assignSignalObject.signal;
-                const QByteArray &pr = datas.at(sigIdx);
+        QML_BEGIN_INSTR(CreateComponent)
+            QDeclarativeComponent *qcomp = 
+                new QDeclarativeComponent(ctxt->engine, comp, instructionStream - comp->bytecode.constData(),
+                                          stack.isEmpty() ? 0 : stack.top());
 
-                QDeclarativeProperty prop(target, QString::fromUtf8(pr));
-                if (prop.type() & QDeclarativeProperty::SignalProperty) {
+            QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true);
+            Q_ASSERT(ddata);
 
-                    QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign);
-                    if (method.signature() == 0)
-                        VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.assignSignalObject.line);
+            ctxt->addObject(qcomp);
 
-                    if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
-                        VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.assignSignalObject.line);
+            if (stack.isEmpty()) 
+                ddata->ownContext = true;
 
-                    QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex());
+            ddata->setImplicitDestructible();
+            ddata->outerContext = ctxt;
+            ddata->lineNumber = instr.line;
+            ddata->columnNumber = instr.column;
 
-                } else {
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr)), instr.assignSignalObject.line);
-                }
+            QDeclarativeComponentPrivate::get(qcomp)->creationContext = ctxt;
 
+            stack.push(qcomp);
+            instructionStream += instr.count;
+        QML_END_INSTR(CreateComponent)
 
-            }
-            break;
-
-        case QDeclarativeInstruction::StoreSignal:
-            {
-                QObject *target = stack.top();
-                QObject *context = stack.at(stack.count() - 1 - instr.storeSignal.context);
+        QML_BEGIN_INSTR(StoreMetaObject)
+            QObject *target = stack.top();
 
-                QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex);
+            QMetaObject mo;
+            const QByteArray &metadata = datas.at(instr.data);
+            QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata);
 
-                QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
-                QDeclarativeExpression *expr = 
-                    new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value));
-                expr->setSourceLocation(comp->name, instr.storeSignal.line);
-                static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = datas.at(instr.storeSignal.name);
-                bs->setExpression(expr);
-            }
-            break;
+            const QDeclarativeVMEMetaData *data = 
+                (const QDeclarativeVMEMetaData *)datas.at(instr.aliasData).constData();
 
-        case QDeclarativeInstruction::StoreImportedScript:
-            {
-                ctxt->importedScripts << run(ctxt, scripts.at(instr.storeScript.value));
-            }
-            break;
+            (void)new QDeclarativeVMEMetaObject(target, &mo, data, comp);
 
-        case QDeclarativeInstruction::StoreScriptString:
-            {
-                QObject *target = stack.top();
-                QObject *scope = stack.at(stack.count() - 1 - instr.storeScriptString.scope);
-                QDeclarativeScriptString ss;
-                ss.setContext(ctxt->asQDeclarativeContext());
-                ss.setScopeObject(scope);
-                ss.setScript(primitives.at(instr.storeScriptString.value));
-
-                void *a[] = { &ss, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeScriptString.propertyIndex, a);
+            if (instr.propertyCache != -1) {
+                QDeclarativeData *ddata = QDeclarativeData::get(target, true);
+                if (ddata->propertyCache) ddata->propertyCache->release();
+                ddata->propertyCache = propertyCaches.at(instr.propertyCache);
+                ddata->propertyCache->addref();
             }
-            break;
-
-        case QDeclarativeInstruction::BeginObject:
-            {
-                QObject *target = stack.top();
-                QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.begin.castValue);
-                parserStatus.append(status);
-                status->d = &parserStatus.values[parserStatus.count - 1];
-
-                status->classBegin();
+        QML_END_INSTR(StoreMetaObject)
+
+        QML_BEGIN_INSTR(StoreVariant)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            // XXX - can be more efficient
+            QVariant v = QDeclarativeStringConverters::variantFromString(primitives.at(instr.value));
+            void *a[] = { &v, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVariant)
+
+        QML_BEGIN_INSTR(StoreVariantInteger)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QVariant v(instr.value);
+            void *a[] = { &v, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVariantInteger)
+
+        QML_BEGIN_INSTR(StoreVariantDouble)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QVariant v(instr.value);
+            void *a[] = { &v, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVariantDouble)
+
+        QML_BEGIN_INSTR(StoreVariantBool)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QVariant v(instr.value);
+            void *a[] = { &v, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVariantBool)
+
+        QML_BEGIN_INSTR(StoreString)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            void *a[] = { (void *)&primitives.at(instr.value), 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreString)
+
+        QML_BEGIN_INSTR(StoreByteArray)
+            QObject *target = stack.top();
+            void *a[] = { (void *)&datas.at(instr.value), 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty,
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreByteArray)
+
+        QML_BEGIN_INSTR(StoreUrl)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            void *a[] = { (void *)&urls.at(instr.value), 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreUrl)
+
+        QML_BEGIN_INSTR(StoreFloat)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            float f = instr.value;
+            void *a[] = { &f, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty,
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreFloat)
+
+        QML_BEGIN_INSTR(StoreDouble)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            double d = instr.value;
+            void *a[] = { &d, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty,
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreDouble)
+
+        QML_BEGIN_INSTR(StoreBool)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            void *a[] = { (void *)&instr.value, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreBool)
+
+        QML_BEGIN_INSTR(StoreInteger)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            void *a[] = { (void *)&instr.value, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreInteger)
+
+        QML_BEGIN_INSTR(StoreColor)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QColor c = QColor::fromRgba(instr.value);
+            void *a[] = { &c, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreColor)
+
+        QML_BEGIN_INSTR(StoreDate)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QDate d = QDate::fromJulianDay(instr.value);
+            void *a[] = { &d, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreDate)
+
+        QML_BEGIN_INSTR(StoreTime)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QTime t;
+            t.setHMS(intData.at(instr.valueIndex),
+                     intData.at(instr.valueIndex+1),
+                     intData.at(instr.valueIndex+2),
+                     intData.at(instr.valueIndex+3));
+            void *a[] = { &t, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreTime)
+
+        QML_BEGIN_INSTR(StoreDateTime)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QTime t;
+            t.setHMS(intData.at(instr.valueIndex+1),
+                     intData.at(instr.valueIndex+2),
+                     intData.at(instr.valueIndex+3),
+                     intData.at(instr.valueIndex+4));
+            QDateTime dt(QDate::fromJulianDay(intData.at(instr.valueIndex)), t);
+            void *a[] = { &dt, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty,
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreDateTime)
+
+        QML_BEGIN_INSTR(StorePoint)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QPoint p = QPointF(floatData.at(instr.valueIndex),
+                               floatData.at(instr.valueIndex+1)).toPoint();
+            void *a[] = { &p, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StorePoint)
+
+        QML_BEGIN_INSTR(StorePointF)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QPointF p(floatData.at(instr.valueIndex),
+                      floatData.at(instr.valueIndex+1));
+            void *a[] = { &p, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StorePointF)
+
+        QML_BEGIN_INSTR(StoreSize)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QSize p = QSizeF(floatData.at(instr.valueIndex),
+                             floatData.at(instr.valueIndex+1)).toSize();
+            void *a[] = { &p, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreSize)
+
+        QML_BEGIN_INSTR(StoreSizeF)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QSizeF s(floatData.at(instr.valueIndex),
+                     floatData.at(instr.valueIndex+1));
+            void *a[] = { &s, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreSizeF)
+
+        QML_BEGIN_INSTR(StoreRect)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QRect r = QRectF(floatData.at(instr.valueIndex),
+                             floatData.at(instr.valueIndex+1),
+                             floatData.at(instr.valueIndex+2),
+                             floatData.at(instr.valueIndex+3)).toRect();
+            void *a[] = { &r, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreRect)
+
+        QML_BEGIN_INSTR(StoreRectF)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QRectF r(floatData.at(instr.valueIndex),
+                     floatData.at(instr.valueIndex+1),
+                     floatData.at(instr.valueIndex+2),
+                     floatData.at(instr.valueIndex+3));
+            void *a[] = { &r, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreRectF)
+
+        QML_BEGIN_INSTR(StoreVector3D)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QVector3D p(floatData.at(instr.valueIndex),
+                        floatData.at(instr.valueIndex+1),
+                        floatData.at(instr.valueIndex+2));
+            void *a[] = { &p, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVector3D)
+
+        QML_BEGIN_INSTR(StoreObject)
+            QObject *assignObj = stack.pop();
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            void *a[] = { (void *)&assignObj, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreObject)
+
+        QML_BEGIN_INSTR(AssignCustomType)
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.valueIndex);
+            const QString &primitive = primitives.at(data.index);
+            QDeclarativeMetaType::StringConverter converter = 
+                QDeclarativeMetaType::customStringConverter(data.type);
+            QVariant v = (*converter)(primitive);
+
+            QMetaProperty prop = 
+                    target->metaObject()->property(instr.propertyIndex);
+            if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type)) 
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name())), instr.line);
+
+            void *a[] = { (void *)v.data(), 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(AssignCustomType)
+
+        QML_BEGIN_INSTR(AssignSignalObject)
+            // XXX optimize
+
+            QObject *assign = stack.pop();
+            QObject *target = stack.top();
+            int sigIdx = instr.signal;
+            const QByteArray &pr = datas.at(sigIdx);
+
+            QDeclarativeProperty prop(target, QString::fromUtf8(pr));
+            if (prop.type() & QDeclarativeProperty::SignalProperty) {
+
+                QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign);
+                if (method.signature() == 0)
+                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className())), instr.line);
+
+                if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature()))
+                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature())), instr.line);
+
+                QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex());
+
+            } else {
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr)), instr.line);
             }
-            break;
-
-        case QDeclarativeInstruction::StoreBinding:
-        case QDeclarativeInstruction::StoreBindingOnAlias:
-            {
-                QObject *target = 
-                    stack.at(stack.count() - 1 - instr.assignBinding.owner);
-                QObject *context = 
-                    stack.at(stack.count() - 1 - instr.assignBinding.context);
-
-                QDeclarativeProperty mp = 
-                    QDeclarativePropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt);
 
-                int coreIndex = mp.index();
 
-                if ((stack.count() - instr.assignBinding.owner) == 1 && bindingSkipList.testBit(coreIndex)) 
-                    break;
-
-                QDeclarativeBinding *bind = new QDeclarativeBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, comp->name, instr.assignBinding.line, 0);
-                bindValues.append(bind);
-                bind->m_mePtr = &bindValues.values[bindValues.count - 1];
-                bind->setTarget(mp);
-
-                if (instr.type == QDeclarativeInstruction::StoreBindingOnAlias) {
-                    QDeclarativeAbstractBinding *old = QDeclarativePropertyPrivate::setBindingNoEnable(target, coreIndex, QDeclarativePropertyPrivate::valueTypeCoreIndex(mp), bind);
-                    if (old) { old->destroy(); }
-                } else {
-                    bind->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp));
+        QML_END_INSTR(AssignSignalObject)
+
+        QML_BEGIN_INSTR(StoreSignal)
+            QObject *target = stack.top();
+            QObject *context = stack.at(stack.count() - 1 - instr.context);
+
+            QMetaMethod signal = target->metaObject()->method(instr.signalIndex);
+
+            QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
+            QDeclarativeExpression *expr = 
+                new QDeclarativeExpression(ctxt, context, primitives.at(instr.value));
+            expr->setSourceLocation(comp->name, instr.line);
+            static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = datas.at(instr.name);
+            bs->setExpression(expr);
+        QML_END_INSTR(StoreSignal)
+
+        QML_BEGIN_INSTR(StoreImportedScript)
+            ctxt->importedScripts << run(ctxt, scripts.at(instr.value));
+        QML_END_INSTR(StoreImportedScript)
+
+        QML_BEGIN_INSTR(StoreScriptString)
+            QObject *target = stack.top();
+            QObject *scope = stack.at(stack.count() - 1 - instr.scope);
+            QDeclarativeScriptString ss;
+            ss.setContext(ctxt->asQDeclarativeContext());
+            ss.setScopeObject(scope);
+            ss.setScript(primitives.at(instr.value));
+
+            void *a[] = { &ss, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreScriptString)
+
+        QML_BEGIN_INSTR(BeginObject)
+            QObject *target = stack.top();
+            QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue);
+            parserStatus.append(status);
+            status->d = &parserStatus.values[parserStatus.count - 1];
+
+            status->classBegin();
+        QML_END_INSTR(BeginObject)
+
+        QML_BEGIN_INSTR(StoreBinding)
+            QObject *target = 
+                stack.at(stack.count() - 1 - instr.owner);
+            QObject *context = 
+                stack.at(stack.count() - 1 - instr.context);
+
+            QDeclarativeProperty mp = 
+                QDeclarativePropertyPrivate::restore(datas.at(instr.property), target, ctxt);
+
+            int coreIndex = mp.index();
+
+            if ((stack.count() - instr.owner) == 1 && bindingSkipList.testBit(coreIndex)) 
+                break;
+
+            QDeclarativeBinding *bind = new QDeclarativeBinding((void *)datas.at(instr.value).constData(), comp, context, ctxt, comp->name, instr.line, 0);
+            bindValues.append(bind);
+            bind->m_mePtr = &bindValues.values[bindValues.count - 1];
+            bind->setTarget(mp);
+
+            bind->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp));
+        QML_END_INSTR(StoreBinding)
+
+        QML_BEGIN_INSTR(StoreBindingOnAlias)
+            QObject *target = 
+                stack.at(stack.count() - 1 - instr.owner);
+            QObject *context = 
+                stack.at(stack.count() - 1 - instr.context);
+
+            QDeclarativeProperty mp = 
+                QDeclarativePropertyPrivate::restore(datas.at(instr.property), target, ctxt);
+
+            int coreIndex = mp.index();
+
+            if ((stack.count() - instr.owner) == 1 && bindingSkipList.testBit(coreIndex)) 
+                break;
+
+            QDeclarativeBinding *bind = new QDeclarativeBinding((void *)datas.at(instr.value).constData(), comp, context, ctxt, comp->name, instr.line, 0);
+            bindValues.append(bind);
+            bind->m_mePtr = &bindValues.values[bindValues.count - 1];
+            bind->setTarget(mp);
+
+            QDeclarativeAbstractBinding *old = QDeclarativePropertyPrivate::setBindingNoEnable(target, coreIndex, QDeclarativePropertyPrivate::valueTypeCoreIndex(mp), bind);
+            if (old) { old->destroy(); }
+        QML_END_INSTR(StoreBindingOnAlias)
+
+        QML_BEGIN_INSTR(StoreCompiledBinding)
+            QObject *target = 
+                stack.at(stack.count() - 1 - instr.owner);
+            QObject *scope = 
+                stack.at(stack.count() - 1 - instr.context);
+
+            int property = instr.property;
+            if (stack.count() == 1 && bindingSkipList.testBit(property & 0xFFFF))  
+                break;
+
+            QDeclarativeAbstractBinding *binding = 
+                ctxt->optimizedBindings->configBinding(instr.value, target, scope, property);
+            bindValues.append(binding);
+            binding->m_mePtr = &bindValues.values[bindValues.count - 1];
+            binding->addToObject(target, property);
+        QML_END_INSTR(StoreCompiledBinding)
+
+        QML_BEGIN_INSTR(StoreValueSource)
+            QObject *obj = stack.pop();
+            QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
+            QObject *target = stack.at(stack.count() - 1 - instr.owner);
+
+            QDeclarativeProperty prop = 
+                QDeclarativePropertyPrivate::restore(datas.at(instr.property), target, ctxt);
+            obj->setParent(target);
+            vs->setTarget(prop);
+        QML_END_INSTR(StoreValueSource)
+
+        QML_BEGIN_INSTR(StoreValueInterceptor)
+            QObject *obj = stack.pop();
+            QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
+            QObject *target = stack.at(stack.count() - 1 - instr.owner);
+            QDeclarativeProperty prop = 
+                QDeclarativePropertyPrivate::restore(datas.at(instr.property), target, ctxt);
+            obj->setParent(target);
+            vi->setTarget(prop);
+            QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
+            mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
+        QML_END_INSTR(StoreValueInterceptor)
+
+        QML_BEGIN_INSTR(StoreObjectQList)
+            QObject *assign = stack.pop();
+
+            const ListInstance &list = qliststack.top();
+            list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
+        QML_END_INSTR(StoreObjectQList)
+
+        QML_BEGIN_INSTR(AssignObjectList)
+            // This is only used for assigning interfaces
+            QObject *assign = stack.pop();
+            const ListInstance &list = qliststack.top();
+
+            int type = list.type;
+
+            void *ptr = 0;
+
+            const char *iid = QDeclarativeMetaType::interfaceIId(type);
+            if (iid) 
+                ptr = assign->qt_metacast(iid);
+            if (!ptr) 
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to list"), instr.line);
+
+
+            list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
+        QML_END_INSTR(AssignObjectList)
+
+        QML_BEGIN_INSTR(StoreVariantObject)
+            QObject *assign = stack.pop();
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            QVariant v = QVariant::fromValue(assign);
+            void *a[] = { &v, 0, &status, &flags };
+            QMetaObject::metacall(target, QMetaObject::WriteProperty, 
+                                  instr.propertyIndex, a);
+        QML_END_INSTR(StoreVariantObject)
+
+        QML_BEGIN_INSTR(StoreInterface)
+            QObject *assign = stack.pop();
+            QObject *target = stack.top();
+            CLEAN_PROPERTY(target, instr.propertyIndex);
+
+            int coreIdx = instr.propertyIndex;
+            QMetaProperty prop = target->metaObject()->property(coreIdx);
+            int t = prop.userType();
+            const char *iid = QDeclarativeMetaType::interfaceIId(t);
+            bool ok = false;
+            if (iid) {
+                void *ptr = assign->qt_metacast(iid);
+                if (ptr) {
+                    void *a[] = { &ptr, 0, &status, &flags };
+                    QMetaObject::metacall(target, 
+                                          QMetaObject::WriteProperty,
+                                          coreIdx, a);
+                    ok = true;
                 }
-            }
-            break;
+            } 
 
-        case QDeclarativeInstruction::StoreCompiledBinding:
-            {
-                QObject *target = 
-                    stack.at(stack.count() - 1 - instr.assignBinding.owner);
-                QObject *scope = 
-                    stack.at(stack.count() - 1 - instr.assignBinding.context);
-
-                int property = instr.assignBinding.property;
-                if (stack.count() == 1 && bindingSkipList.testBit(property & 0xFFFF))  
-                    break;
-
-                QDeclarativeAbstractBinding *binding = 
-                    ctxt->optimizedBindings->configBinding(instr.assignBinding.value, target, scope, property);
-                bindValues.append(binding);
-                binding->m_mePtr = &bindValues.values[bindValues.count - 1];
-                binding->addToObject(target, property);
-            }
-            break;
+            if (!ok) 
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to interface property"), instr.line);
+        QML_END_INSTR(StoreInterface)
+            
+        QML_BEGIN_INSTR(FetchAttached)
+            QObject *target = stack.top();
 
-        case QDeclarativeInstruction::StoreValueSource:
-            {
-                QObject *obj = stack.pop();
-                QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue);
-                QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner);
+            QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.id, target);
 
-                QDeclarativeProperty prop = 
-                    QDeclarativePropertyPrivate::restore(datas.at(instr.assignValueSource.property), target, ctxt);
-                obj->setParent(target);
-                vs->setTarget(prop);
-            }
-            break;
+            if (!qmlObject)
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create attached object"), instr.line);
 
-        case QDeclarativeInstruction::StoreValueInterceptor:
-            {
-                QObject *obj = stack.pop();
-                QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue);
-                QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner);
-                QDeclarativeProperty prop = 
-                    QDeclarativePropertyPrivate::restore(datas.at(instr.assignValueInterceptor.property), target, ctxt);
-                obj->setParent(target);
-                vi->setTarget(prop);
-                QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject());
-                mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi);
-            }
-            break;
+            stack.push(qmlObject);
+        QML_END_INSTR(FetchAttached)
 
-        case QDeclarativeInstruction::StoreObjectQList:
-            {
-                QObject *assign = stack.pop();
+        QML_BEGIN_INSTR(FetchQList)
+            QObject *target = stack.top();
 
-                const ListInstance &list = qliststack.top();
-                list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign);
-            }
-            break;
+            qliststack.push(ListInstance(instr.type));
 
-        case QDeclarativeInstruction::AssignObjectList:
-            {
-                // This is only used for assigning interfaces
-                QObject *assign = stack.pop();
-                const ListInstance &list = qliststack.top();
+            void *a[1];
+            a[0] = (void *)&(qliststack.top().qListProperty);
+            QMetaObject::metacall(target, QMetaObject::ReadProperty, 
+                                  instr.property, a);
+        QML_END_INSTR(FetchQList)
 
-                int type = list.type;
+        QML_BEGIN_INSTR(FetchObject)
+            QObject *target = stack.top();
 
-                void *ptr = 0;
+            QObject *obj = 0;
+            // NOTE: This assumes a cast to QObject does not alter the 
+            // object pointer
+            void *a[1];
+            a[0] = &obj;
+            QMetaObject::metacall(target, QMetaObject::ReadProperty, 
+                                  instr.property, a);
 
-                const char *iid = QDeclarativeMetaType::interfaceIId(type);
-                if (iid) 
-                    ptr = assign->qt_metacast(iid);
-                if (!ptr) 
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to list"), instr.assignObjectList.line);
+            if (!obj)
+                VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
 
+            stack.push(obj);
+        QML_END_INSTR(FetchObject)
 
-                list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr);
-            }
-            break;
+        QML_BEGIN_INSTR(PopQList)
+            qliststack.pop();
+        QML_END_INSTR(PopQList)
 
-        case QDeclarativeInstruction::StoreVariantObject:
-            {
-                QObject *assign = stack.pop();
+        QML_BEGIN_INSTR(Defer)
+            if (instr.deferCount) {
                 QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
-
-                QVariant v = QVariant::fromValue(assign);
-                void *a[] = { &v, 0, &status, &flags };
-                QMetaObject::metacall(target, QMetaObject::WriteProperty, 
-                                      instr.storeObject.propertyIndex, a);
+                QDeclarativeData *data = 
+                    QDeclarativeData::get(target, true);
+                comp->addref();
+                data->deferredComponent = comp;
+                data->deferredIdx = instructionStream - comp->bytecode.constData();
+                instructionStream += instr.deferCount;
             }
-            break;
-
-        case QDeclarativeInstruction::StoreInterface:
-            {
-                QObject *assign = stack.pop();
-                QObject *target = stack.top();
-                CLEAN_PROPERTY(target, instr.storeObject.propertyIndex);
-
-                int coreIdx = instr.storeObject.propertyIndex;
-                QMetaProperty prop = target->metaObject()->property(coreIdx);
-                int t = prop.userType();
-                const char *iid = QDeclarativeMetaType::interfaceIId(t);
-                bool ok = false;
-                if (iid) {
-                    void *ptr = assign->qt_metacast(iid);
-                    if (ptr) {
-                        void *a[] = { &ptr, 0, &status, &flags };
-                        QMetaObject::metacall(target, 
-                                              QMetaObject::WriteProperty,
-                                              coreIdx, a);
-                        ok = true;
+        QML_END_INSTR(Defer)
+
+        QML_BEGIN_INSTR(PopFetchedObject)
+            stack.pop();
+        QML_END_INSTR(PopFetchedObject)
+
+        QML_BEGIN_INSTR(FetchValueType)
+            QObject *target = stack.top();
+
+            if (instr.bindingSkipList != 0) {
+                // Possibly need to clear bindings
+                QDeclarativeData *targetData = QDeclarativeData::get(target);
+                if (targetData) {
+                    QDeclarativeAbstractBinding *binding = 
+                        QDeclarativePropertyPrivate::binding(target, instr.property, -1);
+
+                    if (binding && binding->bindingType() != QDeclarativeAbstractBinding::ValueTypeProxy) {
+                        QDeclarativePropertyPrivate::setBinding(target, instr.property, -1, 0);
+                        binding->destroy();
+                    } else if (binding) {
+                        QDeclarativeValueTypeProxyBinding *proxy = 
+                            static_cast<QDeclarativeValueTypeProxyBinding *>(binding);
+                        proxy->removeBindings(instr.bindingSkipList);
                     }
-                } 
-
-                if (!ok) 
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to interface property"), instr.storeObject.line);
-            }
-            break;
-            
-        case QDeclarativeInstruction::FetchAttached:
-            {
-                QObject *target = stack.top();
-
-                QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.fetchAttached.id, target);
-
-                if (!qmlObject)
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create attached object"), instr.fetchAttached.line);
-
-                stack.push(qmlObject);
-            }
-            break;
-
-        case QDeclarativeInstruction::FetchQList:
-            {
-                QObject *target = stack.top();
-
-                qliststack.push(ListInstance(instr.fetchQmlList.type));
-
-                void *a[1];
-                a[0] = (void *)&(qliststack.top().qListProperty);
-                QMetaObject::metacall(target, QMetaObject::ReadProperty, 
-                                      instr.fetchQmlList.property, a);
-            }
-            break;
-
-        case QDeclarativeInstruction::FetchObject:
-            {
-                QObject *target = stack.top();
-
-                QObject *obj = 0;
-                // NOTE: This assumes a cast to QObject does not alter the 
-                // object pointer
-                void *a[1];
-                a[0] = &obj;
-                QMetaObject::metacall(target, QMetaObject::ReadProperty, 
-                                      instr.fetch.property, a);
-
-                if (!obj)
-                    VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.fetch.property).name())), instr.fetch.line);
-
-                stack.push(obj);
-            }
-            break;
-
-        case QDeclarativeInstruction::PopQList:
-            {
-                qliststack.pop();
-            }
-            break;
-
-        case QDeclarativeInstruction::Defer:
-            {
-                if (instr.defer.deferCount) {
-                    QObject *target = stack.top();
-                    QDeclarativeData *data = 
-                        QDeclarativeData::get(target, true);
-                    comp->addref();
-                    data->deferredComponent = comp;
-                    data->deferredIdx = ii;
-                    ii += instr.defer.deferCount;
                 }
             }
-            break;
-
-        case QDeclarativeInstruction::PopFetchedObject:
-            {
-                stack.pop();
-            }
-            break;
-
-        case QDeclarativeInstruction::FetchValueType:
-            {
-                QObject *target = stack.top();
-
-                if (instr.fetchValue.bindingSkipList != 0) {
-                    // Possibly need to clear bindings
-                    QDeclarativeData *targetData = QDeclarativeData::get(target);
-                    if (targetData) {
-                        QDeclarativeAbstractBinding *binding = 
-                            QDeclarativePropertyPrivate::binding(target, instr.fetchValue.property, -1);
-
-                        if (binding && binding->bindingType() != QDeclarativeAbstractBinding::ValueTypeProxy) {
-                            QDeclarativePropertyPrivate::setBinding(target, instr.fetchValue.property, -1, 0);
-                            binding->destroy();
-                        } else if (binding) {
-                            QDeclarativeValueTypeProxyBinding *proxy = 
-                                static_cast<QDeclarativeValueTypeProxyBinding *>(binding);
-                            proxy->removeBindings(instr.fetchValue.bindingSkipList);
-                        }
-                    }
-                }
 
-                QDeclarativeValueType *valueHandler = ep->valueTypes[instr.fetchValue.type];
-                valueHandler->read(target, instr.fetchValue.property);
-                stack.push(valueHandler);
-            }
-            break;
+            QDeclarativeValueType *valueHandler = ep->valueTypes[instr.type];
+            valueHandler->read(target, instr.property);
+            stack.push(valueHandler);
+        QML_END_INSTR(FetchValueType)
 
-        case QDeclarativeInstruction::PopValueType:
-            {
-                QDeclarativeValueType *valueHandler = 
-                    static_cast<QDeclarativeValueType *>(stack.pop());
-                QObject *target = stack.top();
-                valueHandler->write(target, instr.fetchValue.property, 
-                                    QDeclarativePropertyPrivate::BypassInterceptor);
-            }
-            break;
+        QML_BEGIN_INSTR(PopValueType)
+            QDeclarativeValueType *valueHandler = 
+                static_cast<QDeclarativeValueType *>(stack.pop());
+            QObject *target = stack.top();
+            valueHandler->write(target, instr.property, QDeclarativePropertyPrivate::BypassInterceptor);
+        QML_END_INSTR(PopValueType)
 
         default:
-            qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", instr.type);
+            qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", genericInstr.type());
             break;
         }
     }
@@ -1061,7 +982,7 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData
         return rv;
     } else {
         Q_ASSERT(component);
-        return QDeclarativeComponentPrivate::begin(ctxt, 0, component, -1, -1, 0, errors, bindings);
+        return QDeclarativeComponentPrivate::begin(ctxt, 0, component, -1, 0, errors, bindings);
     } 
 }
 
index 4c010f1..40343b2 100644 (file)
@@ -64,7 +64,6 @@ QT_BEGIN_NAMESPACE
 class QObject;
 class QScriptValue;
 class QDeclarativeScriptData;
-class QDeclarativeInstruction;
 class QDeclarativeCompiledData;
 class QDeclarativeCompiledData;
 class QDeclarativeContextData;
@@ -103,8 +102,7 @@ public:
     QDeclarativeVME();
 
     QObject *run(QDeclarativeContextData *, QDeclarativeCompiledData *, 
-                 int start = -1, int count = -1, 
-                 const QBitField & = QBitField());
+                 int start = -1, const QBitField & = QBitField());
     QScriptValue run(QDeclarativeContextData *, QDeclarativeScriptData *);
 
     void runDeferred(QObject *);
@@ -115,8 +113,7 @@ public:
 private:
     QObject *run(QDeclarativeVMEStack<QObject *> &, 
                  QDeclarativeContextData *, QDeclarativeCompiledData *, 
-                 int start, int count, 
-                 const QBitField &);
+                 int start, const QBitField &);
     QList<QDeclarativeError> vmeErrors;
 };
 
index 80c7a68..5ef293d 100644 (file)
@@ -774,7 +774,7 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
 #ifdef QML_THREADED_INTERPRETER
     if (table) {
         static void *decode_instr[] = {
-            FOR_EACH_QML_INSTR(QML_INSTR_ADDR)
+            FOR_EACH_V4_INSTR(QML_V4_INSTR_ADDR)
         };
 
         *table = decode_instr;
@@ -792,7 +792,7 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
 
     QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(context->engine);
     const char *code = program->instructions();
-    code += instrIndex * QML_INSTR_SIZE(Jump, jump);
+    code += instrIndex * QML_V4_INSTR_SIZE(Jump, jump);
     const Instr *instr = (const Instr *) code;
 
     const char *data = program->data();
@@ -809,28 +809,28 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         switch (instr->common.type) {
 #endif
 
-    QML_BEGIN_INSTR(Noop, common)
-    QML_END_INSTR(Noop, common)
+    QML_V4_BEGIN_INSTR(Noop, common)
+    QML_V4_END_INSTR(Noop, common)
 
-    QML_BEGIN_INSTR(BindingId, id)
+    QML_V4_BEGIN_INSTR(BindingId, id)
         bindingLine = instr->id.line;
         bindingColumn = instr->id.column;
-    QML_END_INSTR(BindingId, id)
+    QML_V4_END_INSTR(BindingId, id)
 
-    QML_BEGIN_INSTR(SubscribeId, subscribeop)
+    QML_V4_BEGIN_INSTR(SubscribeId, subscribeop)
         subscribeId(context, instr->subscribeop.index, instr->subscribeop.offset);
-    QML_END_INSTR(SubscribeId, subscribeop)
+    QML_V4_END_INSTR(SubscribeId, subscribeop)
 
-    QML_BEGIN_INSTR(Subscribe, subscribeop)
+    QML_V4_BEGIN_INSTR(Subscribe, subscribeop)
     {
         QObject *o = 0;
         const Register &object = registers[instr->subscribeop.reg];
         if (!object.isUndefined()) o = object.getQObject();
         subscribe(o, instr->subscribeop.index, instr->subscribeop.offset);
     }
-    QML_END_INSTR(Subscribe, subscribeop)
+    QML_V4_END_INSTR(Subscribe, subscribeop)
 
-    QML_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
+    QML_V4_BEGIN_INSTR(FetchAndSubscribe, fetchAndSubscribe)
     {
         Register &reg = registers[instr->fetchAndSubscribe.reg];
 
@@ -854,21 +854,21 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             QDeclarativeV4Compiler::fastPropertyAccessor()->accessor(instr->fetchAndSubscribe.function)(object, reg.typeDataPtr(), sub);
         }
     }
-    QML_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
+    QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe)
 
-    QML_BEGIN_INSTR(LoadId, load)
+    QML_V4_BEGIN_INSTR(LoadId, load)
         registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data());
-    QML_END_INSTR(LoadId, load)
+    QML_V4_END_INSTR(LoadId, load)
 
-    QML_BEGIN_INSTR(LoadScope, load)
+    QML_V4_BEGIN_INSTR(LoadScope, load)
         registers[instr->load.reg].setQObject(scope);
-    QML_END_INSTR(LoadScope, load)
+    QML_V4_END_INSTR(LoadScope, load)
 
-    QML_BEGIN_INSTR(LoadRoot, load)
+    QML_V4_BEGIN_INSTR(LoadRoot, load)
         registers[instr->load.reg].setQObject(context->contextObject);
-    QML_END_INSTR(LoadRoot, load)
+    QML_V4_END_INSTR(LoadRoot, load)
 
-    QML_BEGIN_INSTR(LoadAttached, attached)
+    QML_V4_BEGIN_INSTR(LoadAttached, attached)
     {
         const Register &input = registers[instr->attached.reg];
         Register &output = registers[instr->attached.output];
@@ -884,57 +884,57 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             output.setQObject(attached);
         }
     }
-    QML_END_INSTR(LoadAttached, attached)
+    QML_V4_END_INSTR(LoadAttached, attached)
 
-    QML_BEGIN_INSTR(UnaryNot, unaryop)
+    QML_V4_BEGIN_INSTR(UnaryNot, unaryop)
     {
         registers[instr->unaryop.output].setbool(!registers[instr->unaryop.src].getbool());
     }
-    QML_END_INSTR(UnaryNot, unaryop)
+    QML_V4_END_INSTR(UnaryNot, unaryop)
 
-    QML_BEGIN_INSTR(UnaryMinusReal, unaryop)
+    QML_V4_BEGIN_INSTR(UnaryMinusReal, unaryop)
     {
         registers[instr->unaryop.output].setqreal(-registers[instr->unaryop.src].getqreal());
     }
-    QML_END_INSTR(UnaryMinusReal, unaryop)
+    QML_V4_END_INSTR(UnaryMinusReal, unaryop)
 
-    QML_BEGIN_INSTR(UnaryMinusInt, unaryop)
+    QML_V4_BEGIN_INSTR(UnaryMinusInt, unaryop)
     {
         registers[instr->unaryop.output].setint(-registers[instr->unaryop.src].getint());
     }
-    QML_END_INSTR(UnaryMinusInt, unaryop)
+    QML_V4_END_INSTR(UnaryMinusInt, unaryop)
 
-    QML_BEGIN_INSTR(UnaryPlusReal, unaryop)
+    QML_V4_BEGIN_INSTR(UnaryPlusReal, unaryop)
     {
         registers[instr->unaryop.output].setqreal(+registers[instr->unaryop.src].getqreal());
     }
-    QML_END_INSTR(UnaryPlusReal, unaryop)
+    QML_V4_END_INSTR(UnaryPlusReal, unaryop)
 
-    QML_BEGIN_INSTR(UnaryPlusInt, unaryop)
+    QML_V4_BEGIN_INSTR(UnaryPlusInt, unaryop)
     {
         registers[instr->unaryop.output].setint(+registers[instr->unaryop.src].getint());
     }
-    QML_END_INSTR(UnaryPlusInt, unaryop)
+    QML_V4_END_INSTR(UnaryPlusInt, unaryop)
 
-    QML_BEGIN_INSTR(ConvertBoolToInt, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertBoolToInt, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setint(src.getbool());
     }
-    QML_END_INSTR(ConvertBoolToInt, unaryop)
+    QML_V4_END_INSTR(ConvertBoolToInt, unaryop)
 
-    QML_BEGIN_INSTR(ConvertBoolToReal, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertBoolToReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setqreal(src.getbool());
     }
-    QML_END_INSTR(ConvertBoolToReal, unaryop)
+    QML_V4_END_INSTR(ConvertBoolToReal, unaryop)
 
-    QML_BEGIN_INSTR(ConvertBoolToString, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertBoolToString, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -945,27 +945,27 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             STRING_REGISTER(instr->unaryop.output);
         }
     }
-    QML_END_INSTR(ConvertBoolToString, unaryop)
+    QML_V4_END_INSTR(ConvertBoolToString, unaryop)
 
-    QML_BEGIN_INSTR(ConvertIntToBool, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertIntToBool, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setbool(src.getint());
     }
-    QML_END_INSTR(ConvertIntToBool, unaryop)
+    QML_V4_END_INSTR(ConvertIntToBool, unaryop)
 
-    QML_BEGIN_INSTR(ConvertIntToReal, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertIntToReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setqreal(qreal(src.getint()));
     }
-    QML_END_INSTR(ConvertIntToReal, unaryop)
+    QML_V4_END_INSTR(ConvertIntToReal, unaryop)
 
-    QML_BEGIN_INSTR(ConvertIntToString, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertIntToString, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -976,27 +976,27 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             STRING_REGISTER(instr->unaryop.output);
         }
     }
-    QML_END_INSTR(ConvertIntToString, unaryop)
+    QML_V4_END_INSTR(ConvertIntToString, unaryop)
 
-    QML_BEGIN_INSTR(ConvertRealToBool, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertRealToBool, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setbool(src.getqreal() != 0);
     }
-    QML_END_INSTR(ConvertRealToBool, unaryop)
+    QML_V4_END_INSTR(ConvertRealToBool, unaryop)
 
-    QML_BEGIN_INSTR(ConvertRealToInt, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertRealToInt, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setint(toInt32(src.getqreal()));
     }
-    QML_END_INSTR(ConvertRealToInt, unaryop)
+    QML_V4_END_INSTR(ConvertRealToInt, unaryop)
 
-    QML_BEGIN_INSTR(ConvertRealToString, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertRealToString, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -1008,9 +1008,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             STRING_REGISTER(instr->unaryop.output);
         }
     }
-    QML_END_INSTR(ConvertRealToString, unaryop)
+    QML_V4_END_INSTR(ConvertRealToString, unaryop)
 
-    QML_BEGIN_INSTR(ConvertStringToBool, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertStringToBool, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -1028,9 +1028,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             output.setbool(tmp.toBool());
         }
     }
-    QML_END_INSTR(ConvertStringToBool, unaryop)
+    QML_V4_END_INSTR(ConvertStringToBool, unaryop)
 
-    QML_BEGIN_INSTR(ConvertStringToInt, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertStringToInt, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -1048,9 +1048,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             output.setint(tmp.toInt32());
         }
     }
-    QML_END_INSTR(ConvertStringToInt, unaryop)
+    QML_V4_END_INSTR(ConvertStringToInt, unaryop)
 
-    QML_BEGIN_INSTR(ConvertStringToReal, unaryop)
+    QML_V4_BEGIN_INSTR(ConvertStringToReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
@@ -1068,109 +1068,109 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             output.setqreal(tmp.toNumber());
         }
     }
-    QML_END_INSTR(ConvertStringToReal, unaryop)
+    QML_V4_END_INSTR(ConvertStringToReal, unaryop)
 
-    QML_BEGIN_INSTR(MathSinReal, unaryop)
+    QML_V4_BEGIN_INSTR(MathSinReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setqreal(qSin(src.getqreal()));
     }
-    QML_END_INSTR(MathSinReal, unaryop)
+    QML_V4_END_INSTR(MathSinReal, unaryop)
 
-    QML_BEGIN_INSTR(MathCosReal, unaryop)
+    QML_V4_BEGIN_INSTR(MathCosReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setqreal(qCos(src.getqreal()));
     }
-    QML_END_INSTR(MathCosReal, unaryop)
+    QML_V4_END_INSTR(MathCosReal, unaryop)
 
-    QML_BEGIN_INSTR(MathRoundReal, unaryop)
+    QML_V4_BEGIN_INSTR(MathRoundReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setint(qRound(src.getqreal()));
     }
-    QML_END_INSTR(MathRoundReal, unaryop)
+    QML_V4_END_INSTR(MathRoundReal, unaryop)
 
-    QML_BEGIN_INSTR(MathFloorReal, unaryop)
+    QML_V4_BEGIN_INSTR(MathFloorReal, unaryop)
     {
         const Register &src = registers[instr->unaryop.src];
         Register &output = registers[instr->unaryop.output];
         if (src.isUndefined()) output.setUndefined();
         else output.setint(qFloor(src.getqreal()));
     }
-    QML_END_INSTR(MathFloorReal, unaryop)
+    QML_V4_END_INSTR(MathFloorReal, unaryop)
 
-    QML_BEGIN_INSTR(MathPIReal, unaryop)
+    QML_V4_BEGIN_INSTR(MathPIReal, unaryop)
     {
         static const qsreal qmlPI = 2.0 * qAsin(1.0);
         Register &output = registers[instr->unaryop.output];
         output.setqreal(qmlPI);
     }
-    QML_END_INSTR(MathPIReal, unaryop)
+    QML_V4_END_INSTR(MathPIReal, unaryop)
 
-    QML_BEGIN_INSTR(Real, real_value)
+    QML_V4_BEGIN_INSTR(Real, real_value)
         registers[instr->real_value.reg].setqreal(instr->real_value.value);
-    QML_END_INSTR(Real, real_value)
+    QML_V4_END_INSTR(Real, real_value)
 
-    QML_BEGIN_INSTR(Int, int_value)
+    QML_V4_BEGIN_INSTR(Int, int_value)
         registers[instr->int_value.reg].setint(instr->int_value.value);
-    QML_END_INSTR(Int, int_value)
+    QML_V4_END_INSTR(Int, int_value)
 
-    QML_BEGIN_INSTR(Bool, bool_value)
+    QML_V4_BEGIN_INSTR(Bool, bool_value)
         registers[instr->bool_value.reg].setbool(instr->bool_value.value);
-    QML_END_INSTR(Bool, bool_value)
+    QML_V4_END_INSTR(Bool, bool_value)
 
-    QML_BEGIN_INSTR(String, string_value)
+    QML_V4_BEGIN_INSTR(String, string_value)
     {
         Register &output = registers[instr->string_value.reg];
         QChar *string = (QChar *)(data + instr->string_value.offset);
         new (output.getstringptr()) QString(string, instr->string_value.length);
         STRING_REGISTER(instr->string_value.reg);
     }
-    QML_END_INSTR(String, string_value)
+    QML_V4_END_INSTR(String, string_value)
 
-    QML_BEGIN_INSTR(EnableV4Test, string_value)
+    QML_V4_BEGIN_INSTR(EnableV4Test, string_value)
     {
         testBindingSource = new QString((QChar *)(data + instr->string_value.offset), instr->string_value.length);
         testBinding = true;
     }
-    QML_END_INSTR(String, string_value)
+    QML_V4_END_INSTR(String, string_value)
 
-    QML_BEGIN_INSTR(BitAndInt, binaryop)
+    QML_V4_BEGIN_INSTR(BitAndInt, binaryop)
     {
         registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() & 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(BitAndInt, binaryop)
+    QML_V4_END_INSTR(BitAndInt, binaryop)
 
-    QML_BEGIN_INSTR(BitOrInt, binaryop)
+    QML_V4_BEGIN_INSTR(BitOrInt, binaryop)
     {
         registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() | 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(BitAndInt, binaryop)
+    QML_V4_END_INSTR(BitAndInt, binaryop)
 
-    QML_BEGIN_INSTR(BitXorInt, binaryop)
+    QML_V4_BEGIN_INSTR(BitXorInt, binaryop)
     {
         registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() ^ 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(BitXorInt, binaryop)
+    QML_V4_END_INSTR(BitXorInt, binaryop)
 
-    QML_BEGIN_INSTR(AddReal, binaryop)
+    QML_V4_BEGIN_INSTR(AddReal, binaryop)
     {
         registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() + 
                                                    registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(AddReal, binaryop)
+    QML_V4_END_INSTR(AddReal, binaryop)
 
-    QML_BEGIN_INSTR(AddString, binaryop)
+    QML_V4_BEGIN_INSTR(AddString, binaryop)
     {
         QString &string = *registers[instr->binaryop.output].getstringptr();
         if (instr->binaryop.output == instr->binaryop.left) {
@@ -1180,30 +1180,30 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
                      *registers[instr->binaryop.right].getstringptr();
         }
     }
-    QML_END_INSTR(AddString, binaryop)
+    QML_V4_END_INSTR(AddString, binaryop)
 
-    QML_BEGIN_INSTR(SubReal, binaryop)
+    QML_V4_BEGIN_INSTR(SubReal, binaryop)
     {
         registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() - 
                                                    registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(SubReal, binaryop)
+    QML_V4_END_INSTR(SubReal, binaryop)
 
-    QML_BEGIN_INSTR(MulReal, binaryop)
+    QML_V4_BEGIN_INSTR(MulReal, binaryop)
     {
         registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() * 
                                                    registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(MulReal, binaryop)
+    QML_V4_END_INSTR(MulReal, binaryop)
 
-    QML_BEGIN_INSTR(DivReal, binaryop)
+    QML_V4_BEGIN_INSTR(DivReal, binaryop)
     {
         registers[instr->binaryop.output].setqreal(registers[instr->binaryop.left].getqreal() / 
                                                    registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(DivReal, binaryop)
+    QML_V4_END_INSTR(DivReal, binaryop)
 
-    QML_BEGIN_INSTR(ModReal, binaryop)
+    QML_V4_BEGIN_INSTR(ModReal, binaryop)
     {
         Register &target = registers[instr->binaryop.output];
         const Register &left = registers[instr->binaryop.left];
@@ -1213,86 +1213,86 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         else
             target.setqreal(::fmod(left.getqreal(), right.getqreal()));
     }
-    QML_END_INSTR(ModInt, binaryop)
+    QML_V4_END_INSTR(ModInt, binaryop)
 
-    QML_BEGIN_INSTR(LShiftInt, binaryop)
+    QML_V4_BEGIN_INSTR(LShiftInt, binaryop)
     {
         registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() << 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(LShiftInt, binaryop)
+    QML_V4_END_INSTR(LShiftInt, binaryop)
 
-    QML_BEGIN_INSTR(RShiftInt, binaryop)
+    QML_V4_BEGIN_INSTR(RShiftInt, binaryop)
     {
         registers[instr->binaryop.output].setint(registers[instr->binaryop.left].getint() >> 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(RShiftInt, binaryop)
+    QML_V4_END_INSTR(RShiftInt, binaryop)
 
-    QML_BEGIN_INSTR(URShiftInt, binaryop)
+    QML_V4_BEGIN_INSTR(URShiftInt, binaryop)
     {
         registers[instr->binaryop.output].setint((unsigned)registers[instr->binaryop.left].getint() >> 
                                                  registers[instr->binaryop.right].getint());
     }
-    QML_END_INSTR(URShiftInt, binaryop)
+    QML_V4_END_INSTR(URShiftInt, binaryop)
 
-    QML_BEGIN_INSTR(GtReal, binaryop)
+    QML_V4_BEGIN_INSTR(GtReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() > 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(GtReal, binaryop)
+    QML_V4_END_INSTR(GtReal, binaryop)
 
-    QML_BEGIN_INSTR(LtReal, binaryop)
+    QML_V4_BEGIN_INSTR(LtReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() < 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(LtReal, binaryop)
+    QML_V4_END_INSTR(LtReal, binaryop)
 
-    QML_BEGIN_INSTR(GeReal, binaryop)
+    QML_V4_BEGIN_INSTR(GeReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() >= 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(GeReal, binaryop)
+    QML_V4_END_INSTR(GeReal, binaryop)
 
-    QML_BEGIN_INSTR(LeReal, binaryop)
+    QML_V4_BEGIN_INSTR(LeReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() <= 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(LeReal, binaryop)
+    QML_V4_END_INSTR(LeReal, binaryop)
 
-    QML_BEGIN_INSTR(EqualReal, binaryop)
+    QML_V4_BEGIN_INSTR(EqualReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() == 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(EqualReal, binaryop)
+    QML_V4_END_INSTR(EqualReal, binaryop)
 
-    QML_BEGIN_INSTR(NotEqualReal, binaryop)
+    QML_V4_BEGIN_INSTR(NotEqualReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() != 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(NotEqualReal, binaryop)
+    QML_V4_END_INSTR(NotEqualReal, binaryop)
 
-    QML_BEGIN_INSTR(StrictEqualReal, binaryop)
+    QML_V4_BEGIN_INSTR(StrictEqualReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() == 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(StrictEqualReal, binaryop)
+    QML_V4_END_INSTR(StrictEqualReal, binaryop)
 
-    QML_BEGIN_INSTR(StrictNotEqualReal, binaryop)
+    QML_V4_BEGIN_INSTR(StrictNotEqualReal, binaryop)
     {
         registers[instr->binaryop.output].setbool(registers[instr->binaryop.left].getqreal() != 
                                                   registers[instr->binaryop.right].getqreal());
     }
-    QML_END_INSTR(StrictNotEqualReal, binaryop)
+    QML_V4_END_INSTR(StrictNotEqualReal, binaryop)
 
-    QML_BEGIN_INSTR(GtString, binaryop)
+    QML_V4_BEGIN_INSTR(GtString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1303,9 +1303,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(GtString, binaryop)
+    QML_V4_END_INSTR(GtString, binaryop)
 
-    QML_BEGIN_INSTR(LtString, binaryop)
+    QML_V4_BEGIN_INSTR(LtString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1316,9 +1316,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(LtString, binaryop)
+    QML_V4_END_INSTR(LtString, binaryop)
 
-    QML_BEGIN_INSTR(GeString, binaryop)
+    QML_V4_BEGIN_INSTR(GeString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1329,9 +1329,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(GeString, binaryop)
+    QML_V4_END_INSTR(GeString, binaryop)
 
-    QML_BEGIN_INSTR(LeString, binaryop)
+    QML_V4_BEGIN_INSTR(LeString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1342,9 +1342,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(LeString, binaryop)
+    QML_V4_END_INSTR(LeString, binaryop)
 
-    QML_BEGIN_INSTR(EqualString, binaryop)
+    QML_V4_BEGIN_INSTR(EqualString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1355,9 +1355,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(EqualString, binaryop)
+    QML_V4_END_INSTR(EqualString, binaryop)
 
-    QML_BEGIN_INSTR(NotEqualString, binaryop)
+    QML_V4_BEGIN_INSTR(NotEqualString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1368,9 +1368,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(NotEqualString, binaryop)
+    QML_V4_END_INSTR(NotEqualString, binaryop)
 
-    QML_BEGIN_INSTR(StrictEqualString, binaryop)
+    QML_V4_BEGIN_INSTR(StrictEqualString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1381,9 +1381,9 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(StrictEqualString, binaryop)
+    QML_V4_END_INSTR(StrictEqualString, binaryop)
 
-    QML_BEGIN_INSTR(StrictNotEqualString, binaryop)
+    QML_V4_BEGIN_INSTR(StrictNotEqualString, binaryop)
     {
         const QString &a = *registers[instr->binaryop.left].getstringptr();
         const QString &b = *registers[instr->binaryop.right].getstringptr();
@@ -1394,25 +1394,25 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
         }
         registers[instr->binaryop.output].setbool(result);
     }
-    QML_END_INSTR(StrictNotEqualString, binaryop)
+    QML_V4_END_INSTR(StrictNotEqualString, binaryop)
 
-    QML_BEGIN_INSTR(NewString, construct)
+    QML_V4_BEGIN_INSTR(NewString, construct)
     {
         Register &output = registers[instr->construct.reg];
         new (output.getstringptr()) QString;
         STRING_REGISTER(instr->construct.reg);
     }
-    QML_END_INSTR(NewString, construct)
+    QML_V4_END_INSTR(NewString, construct)
 
-    QML_BEGIN_INSTR(NewUrl, construct)
+    QML_V4_BEGIN_INSTR(NewUrl, construct)
     {
         Register &output = registers[instr->construct.reg];
         new (output.geturlptr()) QUrl;
         URL_REGISTER(instr->construct.reg);
     }
-    QML_END_INSTR(NewUrl, construct)
+    QML_V4_END_INSTR(NewUrl, construct)
 
-    QML_BEGIN_INSTR(Fetch, fetch)
+    QML_V4_BEGIN_INSTR(Fetch, fetch)
     {
         Register &reg = registers[instr->fetch.reg];
 
@@ -1430,17 +1430,17 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
             QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv);
         }
     }
-    QML_END_INSTR(Fetch, fetch)
+    QML_V4_END_INSTR(Fetch, fetch)
 
-    QML_BEGIN_INSTR(TestV4Store, storetest)
+    QML_V4_BEGIN_INSTR(TestV4Store, storetest)
     {
         Register &data = registers[instr->storetest.reg];
         testBindingResult(*testBindingSource, bindingLine, bindingColumn, context, 
                           scope, data, instr->storetest.regType);
     }
-    QML_END_INSTR(TestV4Store, storetest)
+    QML_V4_END_INSTR(TestV4Store, storetest)
 
-    QML_BEGIN_INSTR(Store, store)
+    QML_V4_BEGIN_INSTR(Store, store)
     {
         Register &data = registers[instr->store.reg];
 
@@ -1454,38 +1454,38 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
 
         goto programExit;
     }
-    QML_END_INSTR(Store, store)
+    QML_V4_END_INSTR(Store, store)
 
-    QML_BEGIN_INSTR(Copy, copy)
+    QML_V4_BEGIN_INSTR(Copy, copy)
         registers[instr->copy.reg].copy(registers[instr->copy.src]);
         if (registers[instr->copy.reg].gettype() >= FirstCleanupType)
             MARK_REGISTER(instr->copy.reg);
-    QML_END_INSTR(Copy, copy)
+    QML_V4_END_INSTR(Copy, copy)
 
-    QML_BEGIN_INSTR(Jump, jump)
+    QML_V4_BEGIN_INSTR(Jump, jump)
         if (instr->jump.reg == -1 || !registers[instr->jump.reg].getbool())
             code += instr->jump.count;
-    QML_END_INSTR(Jump, jump)
+    QML_V4_END_INSTR(Jump, jump)
 
-    QML_BEGIN_INSTR(BranchTrue, branchop)
+    QML_V4_BEGIN_INSTR(BranchTrue, branchop)
         if (registers[instr->branchop.reg].getbool())
             code += instr->branchop.offset;
-    QML_END_INSTR(BranchTrue, branchop)
+    QML_V4_END_INSTR(BranchTrue, branchop)
 
-    QML_BEGIN_INSTR(BranchFalse, branchop)
+    QML_V4_BEGIN_INSTR(BranchFalse, branchop)
         if (! registers[instr->branchop.reg].getbool())
             code += instr->branchop.offset;
-    QML_END_INSTR(BranchFalse, branchop)
+    QML_V4_END_INSTR(BranchFalse, branchop)
 
-    QML_BEGIN_INSTR(Branch, branchop)
+    QML_V4_BEGIN_INSTR(Branch, branchop)
         code += instr->branchop.offset;
-    QML_END_INSTR(Branch, branchop)
+    QML_V4_END_INSTR(Branch, branchop)
 
-    QML_BEGIN_INSTR(Block, blockop)
+    QML_V4_BEGIN_INSTR(Block, blockop)
         executedBlocks |= instr->blockop.block;
-    QML_END_INSTR(Block, blockop)
+    QML_V4_END_INSTR(Block, blockop)
 
-    QML_BEGIN_INSTR(InitString, initstring)
+    QML_V4_BEGIN_INSTR(InitString, initstring)
         if (!identifiers[instr->initstring.offset].identifier) {
             quint32 len = *(quint32 *)(data + instr->initstring.dataIdx);
             QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32));
@@ -1494,11 +1494,11 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks,
 
             identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str);
         }
-    QML_END_INSTR(InitString, initstring)
+    QML_V4_END_INSTR(InitString, initstring)
 
-    QML_BEGIN_INSTR(CleanupRegister, cleanup)
+    QML_V4_BEGIN_INSTR(CleanupRegister, cleanup)
         registers[instr->cleanup.reg].cleanup();
-    QML_END_INSTR(CleanupRegister, cleanup)
+    QML_V4_END_INSTR(CleanupRegister, cleanup)
 
 #ifdef QML_THREADED_INTERPRETER
     // nothing to do
index 1f24f30..9c3bf91 100644 (file)
@@ -60,18 +60,18 @@ namespace QDeclarativeJS {
 static struct DumpInstrAtStartup {
     DumpInstrAtStartup() {
 #define DUMP_INSTR_AT_STARTUP(Type, FMT) { Instr i; i.common.type = Instr::Type; i.dump(0); }
-        FOR_EACH_QML_INSTR(DUMP_INSTR_AT_STARTUP);
+        FOR_EACH_V4_INSTR(DUMP_INSTR_AT_STARTUP);
     }
 } dump_instr_at_startup;
 #endif
 
 int Instr::size() const
 {
-#define QML_RETURN_INSTR_SIZE(I, FMT) case I: return QML_INSTR_SIZE(I, FMT);
+#define V4_RETURN_INSTR_SIZE(I, FMT) case I: return QML_V4_INSTR_SIZE(I, FMT);
     switch (common.type) {
-    FOR_EACH_QML_INSTR(QML_RETURN_INSTR_SIZE)
+    FOR_EACH_V4_INSTR(V4_RETURN_INSTR_SIZE)
     }
-#undef QML_RETURN_INSTR_SIZE
+#undef V4_RETURN_INSTR_SIZE
     return 0;
 }
 
index f6e0bc7..67b152a 100644 (file)
@@ -61,7 +61,7 @@ QT_BEGIN_HEADER
 
 QT_BEGIN_NAMESPACE
 
-#define FOR_EACH_QML_INSTR(F) \
+#define FOR_EACH_V4_INSTR(F) \
     F(Noop, common) \
     F(BindingId, id) \
     F(Subscribe, subscribeop) \
@@ -146,23 +146,23 @@ QT_BEGIN_NAMESPACE
 #endif
 
 #ifdef Q_ALIGNOF
-#  define QML_INSTR_ALIGN_MASK (Q_ALIGNOF(Instr) - 1)
+#  define QML_V4_INSTR_ALIGN_MASK (Q_ALIGNOF(Instr) - 1)
 #else
-#  define QML_INSTR_ALIGN_MASK (sizeof(void *) - 1)
+#  define QML_V4_INSTR_ALIGN_MASK (sizeof(void *) - 1)
 #endif
 
-#define QML_INSTR_ENUM(I, FMT) I,
-#define QML_INSTR_ADDR(I, FMT) &&op_##I,
-#define QML_INSTR_SIZE(I, FMT) ((sizeof(Instr::instr_##FMT) + QML_INSTR_ALIGN_MASK) & ~QML_INSTR_ALIGN_MASK)
+#define QML_V4_INSTR_ENUM(I, FMT) I,
+#define QML_V4_INSTR_ADDR(I, FMT) &&op_##I,
+#define QML_V4_INSTR_SIZE(I, FMT) ((sizeof(Instr::instr_##FMT) + QML_V4_INSTR_ALIGN_MASK) & ~QML_V4_INSTR_ALIGN_MASK)
 
 #ifdef QML_THREADED_INTERPRETER
-#  define QML_BEGIN_INSTR(I,FMT) op_##I:
-#  define QML_END_INSTR(I,FMT) code += QML_INSTR_SIZE(I, FMT); instr = (const Instr *) code; goto *instr->common.code;
-#  define QML_INSTR_HEADER void *code;
+#  define QML_V4_BEGIN_INSTR(I,FMT) op_##I:
+#  define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const Instr *) code; goto *instr->common.code;
+#  define QML_V4_INSTR_HEADER void *code;
 #else
-#  define QML_BEGIN_INSTR(I,FMT) case Instr::I:
-#  define QML_END_INSTR(I,FMT) code += QML_INSTR_SIZE(I, FMT); instr = (const Instr *) code; break;
-#  define QML_INSTR_HEADER
+#  define QML_V4_BEGIN_INSTR(I,FMT) case Instr::I:
+#  define QML_V4_END_INSTR(I,FMT) code += QML_V4_INSTR_SIZE(I, FMT); instr = (const Instr *) code; break;
+#  define QML_V4_INSTR_HEADER
 #endif
 
 namespace QDeclarativeJS {
@@ -200,30 +200,30 @@ union Instr {
     void block(quint32 mask);
 
     enum {
-        FOR_EACH_QML_INSTR(QML_INSTR_ENUM)
+        FOR_EACH_V4_INSTR(QML_V4_INSTR_ENUM)
     };
 
     struct instr_common {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
     };
 
     struct instr_id {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         quint16 column;
         quint32 line;
     };
 
     struct instr_init {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         quint16 subscriptions;
         quint16 identifiers;
     };
 
     struct instr_subscribeop {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint16 offset;
@@ -231,14 +231,14 @@ union Instr {
     };
 
     struct instr_load {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint32 index;
     };
 
     struct instr_attached {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 output;
         qint8 reg;
@@ -247,7 +247,7 @@ union Instr {
     };
 
     struct instr_store {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 output;
         qint8 reg;
@@ -256,14 +256,14 @@ union Instr {
     };
 
     struct instr_storetest {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         qint32 regType;
     };
 
     struct instr_fetchAndSubscribe {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint8 exceptionId;
@@ -273,7 +273,7 @@ union Instr {
     };
 
     struct instr_fetch{
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint8 exceptionId;
@@ -282,41 +282,41 @@ union Instr {
     };
 
     struct instr_copy {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         qint8 src;
     };
 
     struct instr_construct {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
     };
 
     struct instr_real_value {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         qreal value; // XXX Makes the instruction 12 bytes
     };
 
     struct instr_int_value {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         int value;
     };
 
     struct instr_bool_value {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         bool value;
     };
 
     struct instr_string_value {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint16 length;
@@ -324,7 +324,7 @@ union Instr {
     };
 
     struct instr_binaryop {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 output;
         qint8 left;
@@ -332,21 +332,21 @@ union Instr {
     };
 
     struct instr_unaryop {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 output;
         qint8 src;
     };
 
     struct instr_jump {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         quint32 count;
     };
 
     struct instr_find {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
         qint8 src;
@@ -356,27 +356,27 @@ union Instr {
     };
 
     struct instr_cleanup {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         qint8 reg;
     };
 
     struct instr_initstring {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         quint16 offset;
         quint32 dataIdx;
     };
 
     struct instr_branchop {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         quint8 reg;
         qint16 offset;
     };
 
     struct instr_blockop {
-        QML_INSTR_HEADER
+        QML_V4_INSTR_HEADER
         quint8 type;
         quint32 block;
     };
index 2dba740..789b395 100644 (file)
@@ -68,12 +68,12 @@ void tst_qdeclarativeinstruction::dump()
     QDeclarativeCompiledData *data = new QDeclarativeCompiledData(0);
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::Init;
+        i.setType(QDeclarativeInstruction::Init);
         i.init.bindingsSize = 0;
         i.init.parserStatusSize = 3;
         i.init.contextCache = -1;
         i.init.compiledBinding = -1;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
@@ -82,405 +82,405 @@ void tst_qdeclarativeinstruction::dump()
         data->types << ref;
 
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::CreateObject;
+        i.setType(QDeclarativeInstruction::CreateObject);
         i.create.type = 0;
         i.create.data = -1;
         i.create.bindingBits = -1;
         i.create.column = 10;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->primitives << "testId";
 
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::SetId;
+        i.setType(QDeclarativeInstruction::SetId);
         i.setId.value = data->primitives.count() - 1;
         i.setId.index = 0;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::SetDefault;
-        data->bytecode << i;
+        i.setType(QDeclarativeInstruction::SetDefault);
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::CreateComponent;
+        i.setType(QDeclarativeInstruction::CreateComponent);
         i.createComponent.count = 3;
         i.createComponent.column = 4;
         i.createComponent.endLine = 14;
         i.createComponent.metaObject = 0;
 
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreMetaObject;
+        i.setType(QDeclarativeInstruction::StoreMetaObject);
         i.storeMeta.data = 3;
         i.storeMeta.aliasData = 6;
         i.storeMeta.propertyCache = 7;
 
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreFloat;
+        i.setType(QDeclarativeInstruction::StoreFloat);
         i.storeFloat.propertyIndex = 3;
         i.storeFloat.value = 11.3;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreDouble;
+        i.setType(QDeclarativeInstruction::StoreDouble);
         i.storeDouble.propertyIndex = 4;
         i.storeDouble.value = 14.8;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreInteger;
+        i.setType(QDeclarativeInstruction::StoreInteger);
         i.storeInteger.propertyIndex = 5;
         i.storeInteger.value = 9;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreBool;
+        i.setType(QDeclarativeInstruction::StoreBool);
         i.storeBool.propertyIndex = 6;
         i.storeBool.value = true;
 
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->primitives << "Test String";
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreString;
+        i.setType(QDeclarativeInstruction::StoreString);
         i.storeString.propertyIndex = 7;
         i.storeString.value = data->primitives.count() - 1;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->urls << QUrl("http://www.nokia.com");
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreUrl;
+        i.setType(QDeclarativeInstruction::StoreUrl);
         i.storeUrl.propertyIndex = 8;
         i.storeUrl.value = data->urls.count() - 1;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreColor;
+        i.setType(QDeclarativeInstruction::StoreColor);
         i.storeColor.propertyIndex = 9;
         i.storeColor.value = 0xFF00FF00;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreDate;
+        i.setType(QDeclarativeInstruction::StoreDate);
         i.storeDate.propertyIndex = 10;
         i.storeDate.value = 9;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreTime;
+        i.setType(QDeclarativeInstruction::StoreTime);
         i.storeTime.propertyIndex = 11;
         i.storeTime.valueIndex = 33;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreDateTime;
+        i.setType(QDeclarativeInstruction::StoreDateTime);
         i.storeDateTime.propertyIndex = 12;
         i.storeDateTime.valueIndex = 44;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StorePoint;
+        i.setType(QDeclarativeInstruction::StorePoint);
         i.storeRealPair.propertyIndex = 13;
         i.storeRealPair.valueIndex = 3;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StorePointF;
+        i.setType(QDeclarativeInstruction::StorePointF);
         i.storeRealPair.propertyIndex = 14;
         i.storeRealPair.valueIndex = 9;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreSize;
+        i.setType(QDeclarativeInstruction::StoreSize);
         i.storeRealPair.propertyIndex = 15;
         i.storeRealPair.valueIndex = 8;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreSizeF;
+        i.setType(QDeclarativeInstruction::StoreSizeF);
         i.storeRealPair.propertyIndex = 16;
         i.storeRealPair.valueIndex = 99;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreRect;
+        i.setType(QDeclarativeInstruction::StoreRect);
         i.storeRect.propertyIndex = 17;
         i.storeRect.valueIndex = 2;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreRectF;
+        i.setType(QDeclarativeInstruction::StoreRectF);
         i.storeRect.propertyIndex = 18;
         i.storeRect.valueIndex = 19;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreVector3D;
+        i.setType(QDeclarativeInstruction::StoreVector3D);
         i.storeVector3D.propertyIndex = 19;
         i.storeVector3D.valueIndex = 9;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->primitives << "color(1, 1, 1, 1)";
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreVariant;
+        i.setType(QDeclarativeInstruction::StoreVariant);
         i.storeString.propertyIndex = 20;
         i.storeString.value = data->primitives.count() - 1;
 
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreObject;
+        i.setType(QDeclarativeInstruction::StoreObject);
         i.storeObject.propertyIndex = 21;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreVariantObject;
+        i.setType(QDeclarativeInstruction::StoreVariantObject);
         i.storeObject.propertyIndex = 22;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreInterface;
+        i.setType(QDeclarativeInstruction::StoreInterface);
         i.storeObject.propertyIndex = 23;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->primitives << "console.log(1921)";
 
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreSignal;
+        i.setType(QDeclarativeInstruction::StoreSignal);
         i.storeSignal.signalIndex = 2;
         i.storeSignal.value = data->primitives.count() - 1;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreScriptString;
+        i.setType(QDeclarativeInstruction::StoreScriptString);
         i.storeScriptString.propertyIndex = 24;
         i.storeScriptString.value = 3;
         i.storeScriptString.scope = 1;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         data->datas << "mySignal";
 
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::AssignSignalObject;
+        i.setType(QDeclarativeInstruction::AssignSignalObject);
         i.assignSignalObject.signal = 0;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::AssignCustomType;
+        i.setType(QDeclarativeInstruction::AssignCustomType);
         i.assignCustomType.propertyIndex = 25;
         i.assignCustomType.valueIndex = 4;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreBinding;
+        i.setType(QDeclarativeInstruction::StoreBinding);
         i.assignBinding.property = 26;
         i.assignBinding.value = 3;
         i.assignBinding.context = 2;
         i.assignBinding.owner = 0;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreCompiledBinding;
+        i.setType(QDeclarativeInstruction::StoreCompiledBinding);
         i.assignBinding.property = 27;
         i.assignBinding.value = 2;
         i.assignBinding.context = 4;
         i.assignBinding.owner = 0;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreValueSource;
+        i.setType(QDeclarativeInstruction::StoreValueSource);
         i.assignValueSource.property = 29;
         i.assignValueSource.owner = 1;
         i.assignValueSource.castValue = 4;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreValueInterceptor;
+        i.setType(QDeclarativeInstruction::StoreValueInterceptor);
         i.assignValueInterceptor.property = 30;
         i.assignValueInterceptor.owner = 2;
         i.assignValueInterceptor.castValue = -4;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::BeginObject;
+        i.setType(QDeclarativeInstruction::BeginObject);
         i.begin.castValue = 4;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreObjectQList;
-        data->bytecode << i;
+        i.setType(QDeclarativeInstruction::StoreObjectQList);
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::AssignObjectList;
-        data->bytecode << i;
+        i.setType(QDeclarativeInstruction::AssignObjectList);
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::FetchAttached;
+        i.setType(QDeclarativeInstruction::FetchAttached);
         i.fetchAttached.id = 23;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::FetchQList;
+        i.setType(QDeclarativeInstruction::FetchQList);
         i.fetch.property = 32;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::FetchObject;
+        i.setType(QDeclarativeInstruction::FetchObject);
         i.fetch.property = 33;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::FetchValueType;
+        i.setType(QDeclarativeInstruction::FetchValueType);
         i.fetchValue.property = 34;
         i.fetchValue.type = 6;
         i.fetchValue.bindingSkipList = 7;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::PopFetchedObject;
-        data->bytecode << i;
+        i.setType(QDeclarativeInstruction::PopFetchedObject);
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::PopQList;
-        data->bytecode << i;
+        i.setType(QDeclarativeInstruction::PopQList);
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::PopValueType;
+        i.setType(QDeclarativeInstruction::PopValueType);
         i.fetchValue.property = 35;
         i.fetchValue.type = 8;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::Defer;
+        i.setType(QDeclarativeInstruction::Defer);
         i.defer.deferCount = 7;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::Defer;
+        i.setType(QDeclarativeInstruction::Defer);
         i.defer.deferCount = 7;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreImportedScript;
+        i.setType(QDeclarativeInstruction::StoreImportedScript);
         i.storeScript.value = 2;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = (QDeclarativeInstruction::Type)(1234); // Non-existent
-        data->bytecode << i;
-    }
-
-    {
-        QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreVariantInteger;
+        i.setType(QDeclarativeInstruction::StoreVariantInteger);
         i.storeInteger.value = 11;
         i.storeInteger.propertyIndex = 32;
-        data->bytecode << i;
+        data->addInstruction(i);
     }
 
     {
         QDeclarativeInstruction i;
-        i.type = QDeclarativeInstruction::StoreVariantDouble;
+        i.setType(QDeclarativeInstruction::StoreVariantDouble);
         i.storeDouble.value = 33.7;
         i.storeDouble.propertyIndex = 19;
-        data->bytecode << i;
+        data->addInstruction(i);
+    }
+
+    {
+        QDeclarativeInstruction i;
+        i.setType(QDeclarativeInstruction::Done);
+        data->addInstruction(i);
     }
 
     QStringList expect;
@@ -535,9 +535,9 @@ void tst_qdeclarativeinstruction::dump()
         << "45\t\tDEFER\t\t\t7"
         << "46\t\tDEFER\t\t\t7"
         << "47\t\tSTORE_IMPORTED_SCRIPT\t2"
-        << "48\t\tXXX UNKNOWN INSTRUCTION\t1234"
-        << "49\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
-        << "50\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
+        << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
+        << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
+        << "50\t\tDONE"
         << "-------------------------------------------------------------------------------";
 
     messages = QStringList();