diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2012-03-28 10:25:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-03 16:22:04 +0200 |
commit | 7a2400641295603b37221dfae2b5ba289dd2a1c9 (patch) | |
tree | 061362a465e3c45a0866587cc3b81fe8d85d38b5 /src | |
parent | faa4e0254525baf9eef6971810c839d01fca57ab (diff) |
Add floats to the high level IR type system.
Change-Id: If78870000eb72231e6eac67ec8a3d6441b5a4877
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/v4/qv4ir.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4ir_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4irbuilder.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4irbuilder_p.h | 1 |
4 files changed, 10 insertions, 3 deletions
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp index 69de52249c..d2b9605192 100644 --- a/src/qml/qml/v4/qv4ir.cpp +++ b/src/qml/qml/v4/qv4ir.cpp @@ -65,6 +65,7 @@ inline const char *typeName(Type t) case ObjectType: return "object"; case BoolType: return "bool"; case IntType: return "int"; + case FloatType: return "float"; case NumberType: return "number"; default: return "invalid"; } @@ -90,9 +91,10 @@ IR::Type maxType(IR::Type left, IR::Type right) return IR::StringType; } else if (left == right) return left; - else if (isNumberType(left) && isNumberType(right)) - return qMax(left, right); - else if ((isNumberType(left) && isStringType(right)) || + else if (isNumberType(left) && isNumberType(right)) { + IR::Type ty = qMax(left, right); + return ty == FloatType ? NumberType : ty; // promote floats + } else if ((isNumberType(left) && isStringType(right)) || (isNumberType(right) && isStringType(left))) return IR::StringType; else diff --git a/src/qml/qml/v4/qv4ir_p.h b/src/qml/qml/v4/qv4ir_p.h index 3a686954cd..0f5128ebf8 100644 --- a/src/qml/qml/v4/qv4ir_p.h +++ b/src/qml/qml/v4/qv4ir_p.h @@ -150,6 +150,7 @@ enum Type { FirstNumberType, BoolType = FirstNumberType, IntType, + FloatType, NumberType }; Type maxType(IR::Type left, IR::Type right); diff --git a/src/qml/qml/v4/qv4irbuilder.cpp b/src/qml/qml/v4/qv4irbuilder.cpp index 57cea57088..b8210b863f 100644 --- a/src/qml/qml/v4/qv4irbuilder.cpp +++ b/src/qml/qml/v4/qv4irbuilder.cpp @@ -61,6 +61,9 @@ static IR::Type irTypeFromVariantType(int t, QQmlEnginePrivate *engine, const QM case QMetaType::Int: return IR::IntType; + case QMetaType::Float: + return IR::FloatType; + case QMetaType::Double: return IR::NumberType; diff --git a/src/qml/qml/v4/qv4irbuilder_p.h b/src/qml/qml/v4/qv4irbuilder_p.h index f519209ebc..e73ec22750 100644 --- a/src/qml/qml/v4/qv4irbuilder_p.h +++ b/src/qml/qml/v4/qv4irbuilder_p.h @@ -95,6 +95,7 @@ protected: case QQmlJS::IR::StringType: case QQmlJS::IR::BoolType: case QQmlJS::IR::IntType: + case QQmlJS::IR::FloatType: case QQmlJS::IR::NumberType: return true; |