@@ -427,6 +427,35 @@ impl branch_kind : cmp::Eq {
427
427
pure fn ne ( & & other: branch_kind ) -> bool { !self . eq ( other) }
428
428
}
429
429
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
+
430
459
fn compile_submatch ( bcx : block , m : match_ , vals : ~[ ValueRef ] ,
431
460
chk : Option < mk_fail > , & exits: ~[ exit_node ] ) {
432
461
/*
0 commit comments