diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-12 08:18:01 +1000 |
---|---|---|
committer | Matthew Vogt <matthew.vogt@nokia.com> | 2012-03-12 08:35:40 +1000 |
commit | 1f52c5430144eb7ba6baa7e3954675ca0707b947 (patch) | |
tree | 22106095d5cc61c7b5625c8ff2639e1530d2c3b0 /src/qml/qml/v4/qv4ir.cpp | |
parent | 616bbd1988f3b92f7d980b6c9a1278f11b712573 (diff) | |
parent | ed74ec4c40f1476c545bcaacb12fe3a607172035 (diff) |
Merge branch 'master' of git://gitorious.org/qt/qtdeclarative into api_changes
Change-Id: I578b1e2f1bb374da6194e6ba04a0fd459b2632fe
Diffstat (limited to 'src/qml/qml/v4/qv4ir.cpp')
-rw-r--r-- | src/qml/qml/v4/qv4ir.cpp | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/src/qml/qml/v4/qv4ir.cpp b/src/qml/qml/v4/qv4ir.cpp index 3b33898cd1..68175d3bf4 100644 --- a/src/qml/qml/v4/qv4ir.cpp +++ b/src/qml/qml/v4/qv4ir.cpp @@ -221,7 +221,7 @@ void Name::init(Name *base, Type type, const QString *id, Symbol symbol, quint32 builtin = MathCosBultinFunction; } else if (id->length() == 10 && *id == QLatin1String("Math.round")) { builtin = MathRoundBultinFunction; - } else if (id->length() == 10 && *id == QLatin1String("Math.floor)")) { + } else if (id->length() == 10 && *id == QLatin1String("Math.floor")) { builtin = MathFloorBultinFunction; } else if (id->length() == 7 && *id == QLatin1String("Math.PI")) { builtin = MathPIBuiltinConstant; @@ -448,11 +448,6 @@ Temp *BasicBlock::TEMP(Type type) return TEMP(type, function->tempCount++); } -Expr *BasicBlock::CONST(double value) -{ - return CONST(IR::RealType, value); -} - Expr *BasicBlock::CONST(Type type, double value) { Const *e = function->pool->New<Const>(); @@ -549,28 +544,30 @@ Expr *BasicBlock::BINOP(AluOp op, Expr *left, Expr *right) if (left && right) { if (Const *c1 = left->asConst()) { if (Const *c2 = right->asConst()) { + const IR::Type ty = Binop::typeForOp(op, left, right); + switch (op) { - case OpAdd: return CONST(c1->value + c2->value); - case OpAnd: return CONST(c1->value ? c2->value : 0); - case OpBitAnd: return CONST(int(c1->value) & int(c2->value)); - case OpBitOr: return CONST(int(c1->value) | int(c2->value)); - case OpBitXor: return CONST(int(c1->value) ^ int(c2->value)); - case OpDiv: return CONST(c1->value / c2->value); - case OpEqual: return CONST(c1->value == c2->value); - case OpGe: return CONST(c1->value >= c2->value); - case OpGt: return CONST(c1->value > c2->value); - case OpLe: return CONST(c1->value <= c2->value); - case OpLShift: return CONST(int(c1->value) << int(c2->value)); - case OpLt: return CONST(c1->value < c2->value); - case OpMod: return CONST(::fmod(c1->value, c2->value)); - case OpMul: return CONST(c1->value * c2->value); - case OpNotEqual: return CONST(c1->value != c2->value); - case OpOr: return CONST(c1->value ? c1->value : c2->value); - case OpRShift: return CONST(int(c1->value) >> int(c2->value)); - case OpStrictEqual: return CONST(c1->value == c2->value); - case OpStrictNotEqual: return CONST(c1->value != c2->value); - case OpSub: return CONST(c1->value - c2->value); - case OpURShift: return CONST(unsigned(c1->value) >> int(c2->value)); + case OpAdd: return CONST(ty, c1->value + c2->value); + case OpAnd: return CONST(ty, c1->value ? c2->value : 0); + case OpBitAnd: return CONST(ty, int(c1->value) & int(c2->value)); + case OpBitOr: return CONST(ty, int(c1->value) | int(c2->value)); + case OpBitXor: return CONST(ty, int(c1->value) ^ int(c2->value)); + case OpDiv: return CONST(ty, c1->value / c2->value); + case OpEqual: return CONST(ty, c1->value == c2->value); + case OpGe: return CONST(ty, c1->value >= c2->value); + case OpGt: return CONST(ty, c1->value > c2->value); + case OpLe: return CONST(ty, c1->value <= c2->value); + case OpLShift: return CONST(ty, int(c1->value) << int(c2->value)); + case OpLt: return CONST(ty, c1->value < c2->value); + case OpMod: return CONST(ty, ::fmod(c1->value, c2->value)); + case OpMul: return CONST(ty, c1->value * c2->value); + case OpNotEqual: return CONST(ty, c1->value != c2->value); + case OpOr: return CONST(ty, c1->value ? c1->value : c2->value); + case OpRShift: return CONST(ty, int(c1->value) >> int(c2->value)); + case OpStrictEqual: return CONST(ty, c1->value == c2->value); + case OpStrictNotEqual: return CONST(ty, c1->value != c2->value); + case OpSub: return CONST(ty, c1->value - c2->value); + case OpURShift: return CONST(ty, unsigned(c1->value) >> int(c2->value)); case OpIfTrue: // unary ops case OpNot: |