diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 12:27:22 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 12:28:44 (GMT) |
commit | ab8d845ac9f1397706f517fcc24ed4e1978ef259 (patch) | |
tree | 3a11f7a2d9688c5ade57a2ff8391bc26c9d6f105 /src/declarative/qml/qmlscriptparser.cpp | |
parent | 61f8c6f4d6af1a2e73c918b43da8f25871b254b7 (diff) | |
download | Qt-ab8d845ac9f1397706f517fcc24ed4e1978ef259.zip Qt-ab8d845ac9f1397706f517fcc24ed4e1978ef259.tar.gz Qt-ab8d845ac9f1397706f517fcc24ed4e1978ef259.tar.bz2 |
Ensure negative numeric literals are not treated as bindings
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 4de9e40..0cd52d9 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -479,23 +479,26 @@ bool ProcessAST::visit(AST::UiObjectBinding *node) QmlParser::Variant ProcessAST::getVariant(AST::ExpressionNode *expr) { - QmlParser::Variant rv; - if (AST::StringLiteral *lit = AST::cast<AST::StringLiteral *>(expr)) { // hack: emulate weird XML feature that string literals are not quoted. //This needs to be fixed in the qmlcompiler once xml goes away. - rv = QmlParser::Variant(lit->value->asString()); + return QmlParser::Variant(lit->value->asString()); } else if (expr->kind == AST::Node::Kind_TrueLiteral) { - rv = QmlParser::Variant(true); + return QmlParser::Variant(true); } else if (expr->kind == AST::Node::Kind_FalseLiteral) { - rv = QmlParser::Variant(false); - } else if(AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) { - rv = QmlParser::Variant(lit->value); + return QmlParser::Variant(false); + } else if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(expr)) { + return QmlParser::Variant(lit->value); } else { - rv = QmlParser::Variant(asString(expr), QmlParser::Variant::Script); - } - return rv; + if (AST::UnaryMinusExpression *unaryMinus = AST::cast<AST::UnaryMinusExpression *>(expr)) { + if (AST::NumericLiteral *lit = AST::cast<AST::NumericLiteral *>(unaryMinus->expression)) { + return QmlParser::Variant(-lit->value); + } + } + + return QmlParser::Variant(asString(expr), QmlParser::Variant::Script); + } } |