diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-09-10 15:47:21 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-09-10 15:48:05 -0700 |
| commit | bea6fe0ec12439187617bfc27f23962d018f8463 (patch) | |
| tree | 1d9b15d4523e7787f211dc830e578ca7a4317d9a /src | |
| parent | 10aa849d28d74c2c332f24a0da55833c95d91ab1 (diff) | |
| download | rust-bea6fe0ec12439187617bfc27f23962d018f8463.tar.gz rust-bea6fe0ec12439187617bfc27f23962d018f8463.zip | |
rustc: Trim down and rename trans_compare. Now only eq shape glue remains.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rustc/middle/trans/alt.rs | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 050dcafbfa8..1a663ec260a 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -428,32 +428,18 @@ impl branch_kind : cmp::Eq { } // Compiles a comparison between two things. -fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, - _lhs_t: ty::t, rhs: ValueRef, rhs_t: ty::t) -> Result { - let _icx = cx.insn_ctxt("trans_compare"); +fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) -> + Result { + let _icx = cx.insn_ctxt("compare_values"); if ty::type_is_scalar(rhs_t) { - let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op); + let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, ast::eq); return rslt(rs.bcx, rs.val); } // Determine the operation we need. - let llop = { - match op { - ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq), - ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt), - ast::le | ast::gt => C_u8(abi::cmp_glue_op_le), - _ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op") - } - }; - + let llop = C_u8(abi::cmp_glue_op_eq); let cmpval = glue::call_cmp_glue(cx, lhs, rhs, rhs_t, llop); - - // Invert the result if necessary. - match op { - ast::eq | ast::lt | ast::le => rslt(cx, cmpval), - ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)), - _ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op") - } + rslt(cx, cmpval) } fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], @@ -663,15 +649,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], do with_scope_result(bcx, None, ~"compare_scope") |bcx| { match trans_opt(bcx, opt) { single_result( - Result {bcx, val}) => - { - trans_compare(bcx, ast::eq, test_val, - t, val, t) + Result {bcx, val}) => { + compare_values(bcx, test_val, val, t) } range_result( Result {val: vbegin, _}, - Result {bcx, val: vend}) => - { + Result {bcx, val: vend}) => { let Result {bcx, val: llge} = compare_scalar_types(bcx, test_val, vbegin, t, ast::ge); |
