}
QML_V4_END_INSTR(ConvertColorToString, unaryop)
+ QML_V4_BEGIN_INSTR(ConvertObjectToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined())
+ output.setUndefined();
+ else
+ output.setbool(src.getQObject() != 0);
+ }
+ QML_V4_END_INSTR(ConvertObjectToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertNullToObject, unaryop)
+ {
+ Register &output = registers[instr->unaryop.output];
+ output.setQObject(0);
+ }
+ QML_V4_END_INSTR(ConvertNullToObject, unaryop)
+
QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
{
const Register &src = registers[instr->unaryop.src];
case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
+ case IR::ObjectType: opcode = V4Instr::ConvertObjectToBool; break;
default: break;
} // switch
} else if (targetTy == IR::IntType) {
case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
default: break;
} // switch
+ } else if (targetTy == IR::ObjectType) {
+ switch (sourceTy) {
+ case IR::NullType: opcode = V4Instr::ConvertNullToObject; break;
+ default: break;
+ } // switch
}
if (opcode != V4Instr::Noop) {
V4Instr conv;
case V4Instr::ConvertColorToString:
INSTR_DUMP << "\t" << "ConvertColorToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
+ case V4Instr::ConvertObjectToBool:
+ INSTR_DUMP << "\t" << "ConvertObjectToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertNullToObject:
+ INSTR_DUMP << "\t" << "ConvertNullToObject" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
case V4Instr::ResolveUrl:
INSTR_DUMP << "\t" << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
F(ConvertUrlToString, unaryop) \
F(ConvertColorToBool, unaryop) \
F(ConvertColorToString, unaryop) \
+ F(ConvertObjectToBool, unaryop) \
+ F(ConvertNullToObject, unaryop) \
F(ResolveUrl, unaryop) \
F(MathSinReal, unaryop) \
F(MathCosReal, unaryop) \
--- /dev/null
+import QtQuick 2.0
+
+QtObject {
+ property QtObject prop1: null
+ property QtObject prop2: QtObject {}
+
+ property bool test1: prop1 ? true : false
+ property bool test2: prop2 ? true : false
+
+ property bool test3: prop1 == false
+ property bool test4: prop1 === false
+
+ property bool test5: prop2 == false
+ property bool test6: prop2 === false
+}
+
QTest::newRow("double bool jump") << "doubleBoolJump.qml";
QTest::newRow("unary minus") << "unaryMinus.qml";
QTest::newRow("null qobject") << "nullQObject.qml";
+ QTest::newRow("qobject -> bool") << "objectToBool.qml";
}
void tst_v4::unnecessaryReeval()