case BoolType:
c->value = !(c->value == 0 || std::isnan(c->value));
break;
+ case NullType:
+ case UndefinedType:
+ c->value = qSNaN();
+ c->type = targetType;
default:
Q_UNIMPLEMENTED();
Q_ASSERT(!"Unimplemented!");
}
}
+ if (e1->type == IR::NullType && e2->type == IR::NullType)
+ return true;
+ if (e1->type == IR::UndefinedType && e2->type == IR::UndefinedType)
+ return true;
+
return false;
}
};
expr = leftConst;
return true;
case OpStrictEqual:
- if (!strictlyEqualTypes(leftConst->type, rightConst->type))
- return false;
- // intentional fall-through
+ leftConst->value = Runtime::compareStrictEqual(&l, &r);
+ leftConst->type = BoolType;
+ expr = leftConst;
+ return true;
case OpEqual:
leftConst->value = Runtime::compareEqual(&l, &r);
leftConst->type = BoolType;
expr = leftConst;
return true;
case OpStrictNotEqual:
- if (!strictlyEqualTypes(leftConst->type, rightConst->type))
- return false;
- // intentional fall-through
+ leftConst->value = Runtime::compareStrictNotEqual(&l, &r);
+ leftConst->type = BoolType;
+ expr = leftConst;
+ return true;
case OpNotEqual:
leftConst->value = Runtime::compareNotEqual(&l, &r);
leftConst->type = BoolType;
// constant propagation:
if (Const *sourceConst = m->source->asConst()) {
- if (sourceConst->type & NumberType || sourceConst->type == BoolType) {
- // TODO: when propagating other constants, e.g. undefined, the other
- // optimization passes have to be changed to cope with them.
- W += replaceUses(targetTemp, sourceConst);
- defUses.removeDef(*targetTemp);
- W.clear(s);
- }
+ W += replaceUses(targetTemp, sourceConst);
+ defUses.removeDef(*targetTemp);
+ W.clear(s);
continue;
}
if (Member *member = m->source->asMember()) {