{
TRACE1(value);
- if (value.isInteger())
+ // +0 != -0, so we need to convert to double when negating 0
+ if (value.isInteger() && value.integerValue())
return Value::fromInt32(-value.integerValue());
double n = __qmljs_to_number(value, ctx);
return Value::fromDouble(-n);
return;
} else if (IR::Const *c = s->source->asConst()) {
Address dest = _asm->loadTempAddress(Assembler::ScratchRegister, t);
- Value v;
- switch (c->type) {
- case IR::NullType:
- v = Value::nullValue();
- break;
- case IR::UndefinedType:
- v = Value::undefinedValue();
- break;
- case IR::BoolType:
- v = Value::fromBoolean(c->value != 0);
- break;
- case IR::NumberType: {
- int ival = (int)c->value;
- if (ival == c->value) {
- v = Value::fromInt32(ival);
- } else {
- v = Value::fromDouble(c->value);
- }
- }
- break;
- default:
- Q_UNIMPLEMENTED();
- assert(!"TODO");
- }
+ Value v = convertToValue(c);
_asm->storeValue(v, dest);
return;
} else if (IR::Temp *t2 = s->source->asTemp()) {
return VM::Value::fromBoolean(c->value != 0);
case IR::NumberType: {
int ival = (int)c->value;
- if (ival == c->value) {
+ // +0 != -0, so we need to convert to double when negating 0
+ if (ival == c->value && c->value != -0) {
return VM::Value::fromInt32(ival);
} else {
return VM::Value::fromDouble(c->value);