aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v4/qv4ir.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2011-12-14 11:27:18 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-15 12:17:28 +0100
commitb21f63763d43cecf96c9359d95705411dbdc4ecd (patch)
treea7172e42145431a0b0cede37a02d5517f6f98c09 /src/declarative/qml/v4/qv4ir.cpp
parentb6291c914d9a6f24dbfb0e92e8caedae889b709b (diff)
Add support for QUrl types to V4
Extended the V4 instruction set with instructions to `fast convert' url registers to string and bool registers and `resolve' urls using QDeclarativeContext::resolvedUrl. Also, made IR::UrlType a special `string' type. It's a little trick to ensure that the compiler will generate correct conversions for the binary expressions. Change-Id: Ibc9e5b99302bd513f0cc52b598a1b198b11d4d30 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml/v4/qv4ir.cpp')
-rw-r--r--src/declarative/qml/v4/qv4ir.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp
index 48d6c9b81c..0a0228b894 100644
--- a/src/declarative/qml/v4/qv4ir.cpp
+++ b/src/declarative/qml/v4/qv4ir.cpp
@@ -71,14 +71,30 @@ inline const char *typeName(Type t)
}
}
+inline bool isNumberType(IR::Type ty)
+{
+ return ty >= IR::FirstNumberType;
+}
+
+inline bool isStringType(IR::Type ty)
+{
+ return ty == IR::StringType || ty == IR::UrlType;
+}
+
IR::Type maxType(IR::Type left, IR::Type right)
{
- if (left == right)
+ if (isStringType(left) && isStringType(right)) {
+ // String promotions (url to string) are more specific than
+ // identity conversions (AKA left == right). That's because
+ // we want to ensure we convert urls to strings in binary
+ // expressions.
+ return IR::StringType;
+ } else if (left == right)
return left;
- else if (left >= IR::FirstNumberType && right >= IR::FirstNumberType)
+ else if (isNumberType(left) && isNumberType(right))
return qMax(left, right);
- else if ((left >= IR::FirstNumberType && right == IR::StringType) ||
- (right >= IR::FirstNumberType && left == IR::StringType))
+ else if ((isNumberType(left) && isStringType(right)) ||
+ (isNumberType(right) && isStringType(left)))
return IR::StringType;
else
return IR::InvalidType;