int n;
if (value.isConvertibleToInt())
- n = ~value.int_32;
+ n = value.int_32;
else
- n = Value::toInteger(__qmljs_to_number(value, ctx));
+ n = Value::toInt32(__qmljs_to_number(value, ctx));
return Value::fromInt32(~n);
}
return Value::fromDouble(fmod(lval, rval));
}
-// ### unsigned shl missing?
-
inline Value __qmljs_shl(Value left, Value right, ExecutionContext *ctx)
{
TRACE2(left, right);
{
TRACE2(left, right);
- if (Value::integerCompatible(left, right))
- return Value::fromInt32(uint(left.integerValue()) >> ((uint(right.integerValue()) & 0x1f)));
+ uint result;
+ if (Value::integerCompatible(left, right)) {
+ result = uint(left.integerValue()) >> (uint(right.integerValue()) & 0x1f);
+ } else {
+ unsigned lval = Value::toUInt32(__qmljs_to_number(left, ctx));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
+ result = lval >> rval;
+ }
- unsigned lval = Value::toUInt32(__qmljs_to_number(left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
- return Value::fromInt32(lval >> rval);
+ if (result > INT_MAX)
+ return Value::fromDouble(result);
+ return Value::fromInt32(result);
}
inline Value __qmljs_gt(Value left, Value right, ExecutionContext *ctx)
case IR::OpGt: return _block->CONST(IR::BoolType, c1->value > c2->value);
case IR::OpLe: return _block->CONST(IR::BoolType, c1->value <= c2->value);
case IR::OpLt: return _block->CONST(IR::BoolType, c1->value < c2->value);
- case IR::OpLShift: return _block->CONST(IR::NumberType, int(c1->value) << int(c2->value));
+ case IR::OpLShift: return _block->CONST(IR::NumberType, VM::Value::toInt32(c1->value) << (VM::Value::toUInt32(c2->value) & 0x1f));
case IR::OpMod: return _block->CONST(IR::NumberType, ::fmod(c1->value, c2->value));
case IR::OpMul: return _block->CONST(IR::NumberType, c1->value * c2->value);
case IR::OpOr: return _block->CONST(IR::NumberType, c1->value ? c1->value : c2->value);
- case IR::OpRShift: return _block->CONST(IR::NumberType, int(c1->value) >> int(c2->value));
+ case IR::OpRShift: return _block->CONST(IR::NumberType, VM::Value::toInt32(c1->value) << (VM::Value::toUInt32(c2->value) & 0x1f));
case IR::OpSub: return _block->CONST(IR::NumberType, c1->value - c2->value);
- case IR::OpURShift: return _block->CONST(IR::NumberType, unsigned(c1->value) >> int(c2->value));
+ case IR::OpURShift: return _block->CONST(IR::NumberType,VM::Value::toUInt32(c1->value) << (VM::Value::toUInt32(c2->value) & 0x1f));
case IR::OpInstanceof:
case IR::OpIn: