diff options
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 40 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction.cpp | 6 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 29 |
5 files changed, 21 insertions, 58 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 7abd2aa..8990732 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -1050,8 +1050,9 @@ bool QmlCompiler::compileListProperty(QmlParser::Property *prop, COMPILE_EXCEPTION("Can only assign one binding to lists"); assignedBinding = true; - compileBinding(v->value.asScript(), prop, ctxt, - obj->metaObject(), v->location.start.line); + COMPILE_CHECK(compileBinding(v->value.asScript(), prop, ctxt, + obj->metaObject(), + v->location.start.line)); v->type = Value::PropertyBinding; } else { COMPILE_EXCEPTION("Cannot assign primitives to lists"); @@ -1204,8 +1205,9 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop, { if (v->value.isScript()) { - compileBinding(v->value.asScript(), prop, ctxt, obj->metaObject(), - v->location.start.line); + COMPILE_CHECK(compileBinding(v->value.asScript(), prop, ctxt, + obj->metaObject(), + v->location.start.line)); v->type = Value::PropertyBinding; @@ -1329,7 +1331,7 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) return true; } -void QmlCompiler::compileBinding(const QString &bind, QmlParser::Property *prop, +bool QmlCompiler::compileBinding(const QString &bind, QmlParser::Property *prop, int ctxt, const QMetaObject *mo, qint64 line) { QmlBasicScript bs; @@ -1342,10 +1344,12 @@ void QmlCompiler::compileBinding(const QString &bind, QmlParser::Property *prop, bref = output->indexForString(bind); } - QmlInstruction assign; - assign.assignBinding.context = ctxt; - assign.line = line; if (prop->index != -1) { + + QmlInstruction assign; + assign.assignBinding.context = ctxt; + assign.line = line; + if (bs.isValid()) assign.type = QmlInstruction::StoreCompiledBinding; else @@ -1355,20 +1359,18 @@ void QmlCompiler::compileBinding(const QString &bind, QmlParser::Property *prop, assign.assignBinding.value = bref; assign.assignBinding.category = QmlMetaProperty::Unknown; if (mo) { - //XXX we should generate an exception if the property is read-only + // ### we should generate an exception if the property is read-only QMetaProperty mp = mo->property(assign.assignBinding.property); assign.assignBinding.category = QmlMetaProperty::propertyCategory(mp); } + + output->bytecode << assign; + } else { - if (bs.isValid()) - assign.type = QmlInstruction::AssignCompiledBinding; - else - assign.type = QmlInstruction::AssignBinding; - assign.assignBinding.property = output->indexForByteArray(prop->name); - assign.assignBinding.value = bref; - assign.assignBinding.category = QmlMetaProperty::Unknown; + COMPILE_EXCEPTION2(prop, "Cannot assign binding to non-existant property" << prop->name); } - output->bytecode << assign; + + return true; } int QmlCompiler::optimizeExpressions(int start, int end, int patch) @@ -1401,9 +1403,7 @@ int QmlCompiler::optimizeExpressions(int start, int end, int patch) continue; } - if (instr.type == QmlInstruction::AssignBinding || - instr.type == QmlInstruction::AssignCompiledBinding || - instr.type == QmlInstruction::StoreBinding || + if (instr.type == QmlInstruction::StoreBinding || instr.type == QmlInstruction::StoreCompiledBinding) { ++bindingsCount; } else if (instr.type == QmlInstruction::TryBeginObject || diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 64400c5..87c1b82 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -164,7 +164,7 @@ private: int ctxt); bool compileDynamicMeta(QmlParser::Object *obj); - void compileBinding(const QString &, QmlParser::Property *prop, + bool compileBinding(const QString &, QmlParser::Property *prop, int ctxt, const QMetaObject *, qint64); int optimizeExpressions(int start, int end, int patch = -1); diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index ef333b1..923d36f 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -127,12 +127,6 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) case QmlInstruction::AssignSignalObject: qWarning() << idx << "\t" << line << "\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << datas.at(instr->assignSignalObject.signal); break; - case QmlInstruction::AssignBinding: - qWarning() << idx << "\t" << line << "\t" << "ASSIGN_BINDING\t\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context << datas.at(instr->assignBinding.property) << primitives.at(instr->assignBinding.value); - break; - case QmlInstruction::AssignCompiledBinding: - qWarning() << idx << "\t" << line << "\t" << "ASSIGN_COMPILED_BINDING\t" << instr->assignBinding.property << "\t" << instr->assignBinding.value << "\t\t" << instr->assignBinding.context << datas.at(instr->assignBinding.property); - break; case QmlInstruction::AssignValueSource: qWarning() << idx << "\t" << line << "\t" << "ASSIGN_VALUE_SOURCE\t" << instr->assignValueSource.property << "\t\t\t" << datas.at(instr->assignValueSource.property); break; diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index cca99d3..323735b 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -113,8 +113,6 @@ public: AssignSignalObject, /* assignSignalObject */ AssignCustomType, /* assignCustomType */ - AssignBinding, /* assignBinding */ - AssignCompiledBinding, /* assignBinding */ AssignValueSource, /* assignValueSource */ StoreBinding, /* assignBinding */ StoreCompiledBinding, /* assignBinding */ diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index faee545..53ed05a 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -89,8 +89,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxCompiler) { Q_DECLARE_PERFORMANCE_METRIC(InstrStoreObjectQmlList); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignConstant); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignSignalObject); - Q_DECLARE_PERFORMANCE_METRIC(InstrAssignBinding); - Q_DECLARE_PERFORMANCE_METRIC(InstrAssignCompiledBinding); Q_DECLARE_PERFORMANCE_METRIC(InstrAssignValueSource); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreBinding); Q_DECLARE_PERFORMANCE_METRIC(InstrStoreCompiledBinding); @@ -138,8 +136,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxCompiler, "QFxCompiler") { Q_DEFINE_PERFORMANCE_METRIC(InstrStoreObjectQmlList, "StoreObjectQmlList"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignConstant, "AssignConstant"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignSignalObject, "AssignSignalObject"); - Q_DEFINE_PERFORMANCE_METRIC(InstrAssignBinding, "AssignBinding"); - Q_DEFINE_PERFORMANCE_METRIC(InstrAssignCompiledBinding, "AssignCompiledBinding"); Q_DEFINE_PERFORMANCE_METRIC(InstrAssignValueSource, "AssignValueSource"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreBinding, "StoreBinding"); Q_DEFINE_PERFORMANCE_METRIC(InstrStoreCompiledBinding, "StoreCompiledBinding"); @@ -472,31 +468,6 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in } break; - case QmlInstruction::AssignCompiledBinding: - case QmlInstruction::AssignBinding: - { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxCompilerTimer<QFxCompiler::InstrAssignBinding> cc; -#endif - QObject *target = stack.top(); - const QByteArray &pr = datas.at(instr.fetch.property); - int idx = qIndexOfProperty(target, pr); - - // XXX - need to check if the type is QmlBindableValue* - if (idx == -1) { - VME_EXCEPTION("Unknown property" << pr); - } else { - if (QmlInstruction::AssignCompiledBinding == instr.type) - instr.type = QmlInstruction::StoreCompiledBinding; - else - instr.type = QmlInstruction::StoreBinding; - instr.assignBinding.property = idx; - instr.assignBinding.category = QmlMetaProperty::Unknown; - } - ii--; - } - break; - case QmlInstruction::AssignValueSource: { QObject *target = stack.at(stack.count() - 2); |