}
}
-// Important to get types for both lhs and rhs, because one might be _|_
-// and the other not.
fn trans_compare(cx0: &@block_ctxt, op: ast::binop,
lhs0: ValueRef, lhs_t: ty::t, rhs0: ValueRef,
rhs_t: ty::t) -> result {
ast::le. | ast::gt. { llop = C_u8(abi::cmp_glue_op_le); }
}
- if (! ty::type_is_bot(bcx_tcx(cx0), rhs_r.ty) &&
- ! ty::type_is_bot(bcx_tcx(cx0), lhs_r.ty)) {
- let rs = compare(cx, lhs, rhs, rhs_r.ty, llop);
+ let rs = compare(cx, lhs, rhs, rhs_r.ty, llop);
- // Invert the result if necessary.
- alt op {
- ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
- ast::ne. | ast::ge. | ast::gt. {
- ret rslt(rs.bcx, rs.bcx.build.Not(rs.val));
- }
- }
- }
- else {
- // If either is bottom, it diverges. So no need to do the
- // actual comparison.
- ret rslt(cx, cx.build.Unreachable());
+ // Invert the result if necessary.
+ alt op {
+ ast::eq. | ast::lt. | ast::le. { ret rslt(rs.bcx, rs.val); }
+ ast::ne. | ast::ge. | ast::gt. {
+ ret rslt(rs.bcx, rs.bcx.build.Not(rs.val));
+ }
}
}
// and the other not.
fn trans_eager_binop(cx: &@block_ctxt, op: ast::binop, lhs: ValueRef,
lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> result {
+
+ // If either is bottom, it diverges. So no need to do the
+ // operation.
+ if (ty::type_is_bot(bcx_tcx(cx), lhs_t) ||
+ ty::type_is_bot(bcx_tcx(cx), rhs_t)) {
+ ret rslt(cx, cx.build.Unreachable());
+ }
+
let is_float = false;
let intype = lhs_t;
if ty::type_is_bot(bcx_tcx(cx), intype) {
const tycat_str: int = 4;
const tycat_vec: int = 5;
const tycat_struct: int = 6;
+ const tycat_bot: int = 7;
const opcat_add: int = 0;
const opcat_sub: int = 1;
ty_ivec(_) { tycat_vec }
ty_rec(_) { tycat_struct }
ty_tag(_, _) { tycat_struct }
+ ty_bot. { tycat_bot }
_ { tycat_other }
}
}
/*float*/
/*str*/
/*vec*/
+ /*bot*/
tbl =
[[f, f, f, f, t, t, f, f], [f, f, f, f, t, t, t, t],
[t, t, t, t, t, t, t, f], [t, t, t, f, t, t, f, f],
[t, f, f, f, t, t, f, f], [t, f, f, f, t, t, f, f],
- [f, f, f, f, t, t, f, f]]; /*struct*/
+ [f, f, f, f, t, t, f, f],
+ [t, t, t, t, t, t, t, t]]; /*struct*/
ret tbl.(tycat(cx, ty)).(opcat(op));
}