aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v4
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r--src/qml/qml/v4/qv4bindings.cpp79
-rw-r--r--src/qml/qml/v4/qv4bindings_p.h2
-rw-r--r--src/qml/qml/v4/qv4compiler.cpp25
-rw-r--r--src/qml/qml/v4/qv4compiler_p_p.h1
-rw-r--r--src/qml/qml/v4/qv4instruction.cpp9
-rw-r--r--src/qml/qml/v4/qv4instruction_p.h3
-rw-r--r--src/qml/qml/v4/qv4ir.cpp3
-rw-r--r--src/qml/qml/v4/qv4ir_p.h1
-rw-r--r--src/qml/qml/v4/qv4irbuilder.cpp9
-rw-r--r--src/qml/qml/v4/qv4program_p.h1
10 files changed, 126 insertions, 7 deletions
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp
index c03292d74d..4fd84945fc 100644
--- a/src/qml/qml/v4/qv4bindings.cpp
+++ b/src/qml/qml/v4/qv4bindings.cpp
@@ -50,6 +50,7 @@
#include <private/qqmlprofilerservice_p.h>
#include <private/qqmlmetatype_p.h>
#include <private/qqmltrace_p.h>
+#include <private/qqmlstringconverters_p.h>
#include <QtQml/qqmlinfo.h>
#include <QtCore/qnumeric.h>
@@ -86,9 +87,11 @@ struct Register {
QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); }
QString *getstringptr() { return (QString *)typeDataPtr(); }
QUrl *geturlptr() { return (QUrl *)typeDataPtr(); }
+ QColor *getcolorptr() { return (QColor *)typeDataPtr(); }
const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); }
const QString *getstringptr() const { return (QString *)typeDataPtr(); }
const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); }
+ const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); }
void *typeDataPtr() { return (void *)&data; }
void *typeMemory() { return (void *)data; }
@@ -112,6 +115,7 @@ struct Register {
inline void cleanup();
inline void cleanupString();
inline void cleanupUrl();
+ inline void cleanupColor();
inline void cleanupVariant();
inline void copy(const Register &other);
@@ -135,6 +139,8 @@ void Register::cleanup()
getstringptr()->~QString();
} else if (dataType == QUrlType) {
geturlptr()->~QUrl();
+ } else if (dataType == QColorType) {
+ getcolorptr()->~QColor();
} else if (dataType == QVariantType) {
getvariantptr()->~QVariant();
}
@@ -154,6 +160,12 @@ void Register::cleanupUrl()
setUndefined();
}
+void Register::cleanupColor()
+{
+ getcolorptr()->~QColor();
+ setUndefined();
+}
+
void Register::cleanupVariant()
{
getvariantptr()->~QVariant();
@@ -168,6 +180,8 @@ void Register::copy(const Register &other)
new (getstringptr()) QString(*other.getstringptr());
else if (other.dataType == QUrlType)
new (geturlptr()) QUrl(*other.geturlptr());
+ else if (other.dataType == QColorType)
+ new (getcolorptr()) QColor(*other.getcolorptr());
else if (other.dataType == QVariantType)
new (getvariantptr()) QVariant(*other.getvariantptr());
}
@@ -181,6 +195,8 @@ void Register::init(Type type)
new (getstringptr()) QString();
else if (dataType == QUrlType)
new (geturlptr()) QUrl();
+ else if (dataType == QColorType)
+ new (getcolorptr()) QColor();
else if (dataType == QVariantType)
new (getvariantptr()) QVariant();
}
@@ -256,7 +272,8 @@ void QV4Bindings::Binding::destroy()
int QV4Bindings::Binding::propertyIndex() const
{
- return property;
+ //mask out the type information set for value types
+ return property & 0xFF00FFFF;
}
QObject *QV4Bindings::Binding::object() const
@@ -662,6 +679,11 @@ inline quint32 QV4Bindings::toUint32(qreal n)
MARK_REGISTER(reg); \
}
+#define COLOR_REGISTER(reg) { \
+ registers[(reg)].settype(QColorType); \
+ MARK_REGISTER(reg); \
+}
+
#define VARIANT_REGISTER(reg) { \
registers[(reg)].settype(QVariantType); \
MARK_REGISTER(reg); \
@@ -1022,6 +1044,27 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
}
QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+ QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QString tmp(*src.getstringptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupString();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ QColor *colorPtr = output.getcolorptr();
+ new (colorPtr) QColor(QQmlStringConverters::colorFromString(tmp));
+
+ COLOR_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertStringToUrl, unaryop)
+
QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop)
{
const Register &src = registers[instr->unaryop.src];
@@ -1059,6 +1102,40 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks,
}
QML_V4_END_INSTR(ConvertUrlToString, unaryop)
+ QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ // for compatibility with color behavior in v8, always true
+ output.setbool(true);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToBool, unaryop)
+
+ QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop)
+ {
+ const Register &src = registers[instr->unaryop.src];
+ Register &output = registers[instr->unaryop.output];
+ // ### NaN
+ if (src.isUndefined()) {
+ output.setUndefined();
+ } else {
+ const QColor tmp(*src.getcolorptr());
+ if (instr->unaryop.src == instr->unaryop.output) {
+ output.cleanupColor();
+ MARK_CLEAN_REGISTER(instr->unaryop.output);
+ }
+ // to maintain behaviour with QtQuick 1.0, we just output normal toString() value.
+ new (output.getstringptr()) QString(QVariant(tmp).toString());
+ STRING_REGISTER(instr->unaryop.output);
+ }
+ }
+ QML_V4_END_INSTR(ConvertColorToString, unaryop)
+
QML_V4_BEGIN_INSTR(ResolveUrl, unaryop)
{
const Register &src = registers[instr->unaryop.src];
diff --git a/src/qml/qml/v4/qv4bindings_p.h b/src/qml/qml/v4/qv4bindings_p.h
index 61d29a6f57..1824fa4ee9 100644
--- a/src/qml/qml/v4/qv4bindings_p.h
+++ b/src/qml/qml/v4/qv4bindings_p.h
@@ -96,6 +96,8 @@ private:
int index:30;
bool enabled:1;
bool updating:1;
+ // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24)
+ // propType and valueTypeIndex are only set if the property is a value type property
int property;
QObject *scope;
int line;
diff --git a/src/qml/qml/v4/qv4compiler.cpp b/src/qml/qml/v4/qv4compiler.cpp
index d61fd580c7..f8fe3b4b57 100644
--- a/src/qml/qml/v4/qv4compiler.cpp
+++ b/src/qml/qml/v4/qv4compiler.cpp
@@ -63,7 +63,7 @@ static bool qmlEnableV4 = true;
using namespace QQmlJS;
QV4CompilerPrivate::QV4CompilerPrivate()
-: _function(0) , _block(0) , _discarded(false)
+ : _function(0) , _block(0) , _discarded(false), registerCount(0)
{
}
@@ -75,6 +75,7 @@ void QV4CompilerPrivate::trace(int line, int column)
bytecode.clear();
this->currentReg = _function->tempCount;
+ this->registerCount = qMax(this->registerCount, this->currentReg);
foreach (IR::BasicBlock *bb, _function->basicBlocks) {
if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size())
@@ -344,6 +345,9 @@ void QV4CompilerPrivate::visitName(IR::Name *e)
case QMetaType::QUrl:
regType = QUrlType;
break;
+ case QMetaType::QColor:
+ regType = QColorType;
+ break;
default:
if (propTy == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
@@ -581,6 +585,12 @@ void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg)
gen(i);
} return;
+ case IR::ColorType: {
+ Instr::ConvertColorToBool i;
+ i.output = i.src = reg;
+ gen(i);
+ } return;
+
default:
discard();
break;
@@ -880,6 +890,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::RealType: opcode = V4Instr::ConvertRealToBool; break;
case IR::StringType: opcode = V4Instr::ConvertStringToBool; break;
case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break;
default: break;
} // switch
} else if (targetTy == IR::IntType) {
@@ -908,6 +919,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::IntType: opcode = V4Instr::ConvertIntToString; break;
case IR::RealType: opcode = V4Instr::ConvertRealToString; break;
case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break;
+ case IR::ColorType: opcode = V4Instr::ConvertColorToString; break;
default: break;
} // switch
} else if (targetTy == IR::UrlType) {
@@ -920,11 +932,17 @@ void QV4CompilerPrivate::visitMove(IR::Move *s)
case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break;
case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break;
case IR::RealType: gen(V4Instr::ConvertRealToString, convToString); sourceTy = IR::StringType; break;
+ case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break;
default: break;
} // switch
if (sourceTy == IR::StringType)
opcode = V4Instr::ConvertStringToUrl;
+ } else if (targetTy == IR::ColorType) {
+ switch (sourceTy) {
+ case IR::StringType: opcode = V4Instr::ConvertStringToColor; break;
+ default: break;
+ } // switch
}
if (opcode != V4Instr::Noop) {
V4Instr conv;
@@ -989,6 +1007,9 @@ void QV4CompilerPrivate::visitRet(IR::Ret *s)
case IR::UrlType:
test.regType = QMetaType::QUrl;
break;
+ case IR::ColorType:
+ test.regType = QMetaType::QColor;
+ break;
case IR::SGAnchorLineType:
test.regType = QQmlMetaType::QQuickAnchorLineMetaTypeId();
break;
@@ -1119,7 +1140,7 @@ bool QV4CompilerPrivate::compile(QQmlJS::AST::Node *node)
qerr << endl;
}
- if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF)
+ if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF || registerCount > 31)
return false;
return true;
diff --git a/src/qml/qml/v4/qv4compiler_p_p.h b/src/qml/qml/v4/qv4compiler_p_p.h
index 4b74a1d1c5..a9209d978f 100644
--- a/src/qml/qml/v4/qv4compiler_p_p.h
+++ b/src/qml/qml/v4/qv4compiler_p_p.h
@@ -231,6 +231,7 @@ private:
void discard() { _discarded = true; }
bool _discarded;
quint8 currentReg;
+ quint8 registerCount;
bool usedSubscriptionIdsChanged;
quint32 currentBlockMask;
diff --git a/src/qml/qml/v4/qv4instruction.cpp b/src/qml/qml/v4/qv4instruction.cpp
index 08b2570747..efbd2b2c1c 100644
--- a/src/qml/qml/v4/qv4instruction.cpp
+++ b/src/qml/qml/v4/qv4instruction.cpp
@@ -171,12 +171,21 @@ void Bytecode::dump(const V4Instr *i, int address) const
case V4Instr::ConvertStringToUrl:
INSTR_DUMP << "\t" << "ConvertStringToUrl" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
+ case V4Instr::ConvertStringToColor:
+ INSTR_DUMP << "\t" << "ConvertStringToColor" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
case V4Instr::ConvertUrlToBool:
INSTR_DUMP << "\t" << "ConvertUrlToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
case V4Instr::ConvertUrlToString:
INSTR_DUMP << "\t" << "ConvertUrlToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
break;
+ case V4Instr::ConvertColorToBool:
+ INSTR_DUMP << "\t" << "ConvertColorToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")";
+ break;
+ case V4Instr::ConvertColorToString:
+ INSTR_DUMP << "\t" << "ConvertColorToString" << "\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;
diff --git a/src/qml/qml/v4/qv4instruction_p.h b/src/qml/qml/v4/qv4instruction_p.h
index 8150eedf54..964c95513f 100644
--- a/src/qml/qml/v4/qv4instruction_p.h
+++ b/src/qml/qml/v4/qv4instruction_p.h
@@ -92,8 +92,11 @@ QT_BEGIN_NAMESPACE
F(ConvertStringToInt, unaryop) \
F(ConvertStringToReal, unaryop) \
F(ConvertStringToUrl, unaryop) \
+ F(ConvertStringToColor, unaryop) \
F(ConvertUrlToBool, unaryop) \
F(ConvertUrlToString, unaryop) \
+ F(ConvertColorToBool, unaryop) \
+ F(ConvertColorToString, unaryop) \
F(ResolveUrl, unaryop) \
F(MathSinReal, unaryop) \
F(MathCosReal, unaryop) \
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp
index be822145a4..3b33898cd1 100644
--- a/src/qml/qml/v4/qv4ir.cpp
+++ b/src/qml/qml/v4/qv4ir.cpp
@@ -59,6 +59,7 @@ inline const char *typeName(Type t)
case VoidType: return "void";
case StringType: return "string";
case UrlType: return "url";
+ case ColorType: return "color";
case SGAnchorLineType: return "SGAnchorLine";
case AttachType: return "AttachType";
case ObjectType: return "object";
@@ -77,7 +78,7 @@ inline bool isNumberType(IR::Type ty)
inline bool isStringType(IR::Type ty)
{
- return ty == IR::StringType || ty == IR::UrlType;
+ return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType;
}
IR::Type maxType(IR::Type left, IR::Type right)
diff --git a/src/qml/qml/v4/qv4ir_p.h b/src/qml/qml/v4/qv4ir_p.h
index 48a08adf9f..e80c7e2869 100644
--- a/src/qml/qml/v4/qv4ir_p.h
+++ b/src/qml/qml/v4/qv4ir_p.h
@@ -142,6 +142,7 @@ enum Type {
VoidType,
StringType,
UrlType,
+ ColorType,
SGAnchorLineType,
AttachType,
ObjectType,
diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp
index 1956be8e72..0efb2686df 100644
--- a/src/qml/qml/v4/qv4irbuilder.cpp
+++ b/src/qml/qml/v4/qv4irbuilder.cpp
@@ -70,6 +70,9 @@ static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine, const QM
case QMetaType::QUrl:
return IR::UrlType;
+ case QMetaType::QColor:
+ return IR::ColorType;
+
default:
if (t == QQmlMetaType::QQuickAnchorLineMetaTypeId()) {
return IR::SGAnchorLineType;
@@ -438,7 +441,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
QQmlPropertyData *data = cache->property(name);
- if (data && data->revision != 0) {
+ if (data && data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
@@ -459,7 +462,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast)
QQmlPropertyData *data = cache->property(name);
- if (data && data->revision != 0) {
+ if (data && data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
@@ -610,7 +613,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
if (!data || data->isFunction())
return false; // Don't support methods (or non-existing properties ;)
- if (data->revision != 0) {
+ if (data->hasRevision()) {
if (qmlVerboseCompiler())
qWarning() << "*** versioned symbol:" << name;
discard();
diff --git a/src/qml/qml/v4/qv4program_p.h b/src/qml/qml/v4/qv4program_p.h
index b6b03e438b..d23cc6192f 100644
--- a/src/qml/qml/v4/qv4program_p.h
+++ b/src/qml/qml/v4/qv4program_p.h
@@ -96,6 +96,7 @@ enum QQmlRegisterType {
QStringType = FirstCleanupType,
QUrlType,
QVariantType,
+ QColorType
};
const char *QV4Program::data() const