Skip to content

Commit a7a6d5f

Browse files
committed
---
yaml --- r: 30451 b: refs/heads/incoming c: d6ceef9 h: refs/heads/master i: 30449: 5948dcb 30447: 51acd32 v: v3
1 parent e6afc86 commit a7a6d5f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: a93de20148f215c6d542ea57a37825d7fa4d950d
9+
refs/heads/incoming: d6ceef95bae928dbaf6050c95939d39ac33e1725
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/rustc/middle/trans/alt.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,35 @@ impl branch_kind : cmp::Eq {
427427
pure fn ne(&&other: branch_kind) -> bool { !self.eq(other) }
428428
}
429429

430+
// Compiles a comparison between two things.
431+
fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef,
432+
_lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> Result {
433+
let _icx = cx.insn_ctxt("trans_compare");
434+
if ty::type_is_scalar(rhs_t) {
435+
let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op);
436+
return rslt(rs.bcx, rs.val);
437+
}
438+
439+
// Determine the operation we need.
440+
let llop = {
441+
match op {
442+
ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq),
443+
ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt),
444+
ast::le | ast::gt => C_u8(abi::cmp_glue_op_le),
445+
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
446+
}
447+
};
448+
449+
let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop);
450+
451+
// Invert the result if necessary.
452+
match op {
453+
ast::eq | ast::lt | ast::le => rslt(cx, cmpval),
454+
ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)),
455+
_ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op")
456+
}
457+
}
458+
430459
fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
431460
chk: Option<mk_fail>, &exits: ~[exit_node]) {
432461
/*

0 commit comments

Comments
 (0)