@@ -39,6 +39,7 @@ use lib;
3939use metadata:: csearch;
4040use middle:: def;
4141use middle:: lang_items:: MallocFnLangItem ;
42+ use middle:: mem_categorization:: Typer ;
4243use middle:: trans:: _match;
4344use middle:: trans:: adt;
4445use middle:: trans:: asm;
@@ -65,6 +66,7 @@ use middle::ty::{AutoBorrowObj, AutoDerefRef, AutoAddEnv, AutoObject, AutoUnsafe
6566use middle:: ty:: { AutoPtr , AutoBorrowVec , AutoBorrowVecRef } ;
6667use middle:: ty;
6768use middle:: typeck:: MethodCall ;
69+ use middle:: typeck;
6870use util:: common:: indenter;
6971use util:: ppaux:: Repr ;
7072use util:: nodemap:: NodeMap ;
@@ -713,7 +715,20 @@ fn trans_rvalue_dps_unadjusted<'a>(bcx: &'a Block<'a>,
713715 closure:: trans_expr_fn ( bcx, store, decl, body, expr. id , dest)
714716 }
715717 ast:: ExprCall ( f, ref args) => {
716- callee:: trans_call ( bcx, expr, f, callee:: ArgExprs ( args. as_slice ( ) ) , dest)
718+ if bcx. tcx ( ) . is_method_call ( expr. id ) {
719+ let callee_datum = unpack_datum ! ( bcx, trans( bcx, f) ) ;
720+ trans_overloaded_call ( bcx,
721+ expr,
722+ callee_datum,
723+ args. as_slice ( ) ,
724+ Some ( dest) )
725+ } else {
726+ callee:: trans_call ( bcx,
727+ expr,
728+ f,
729+ callee:: ArgExprs ( args. as_slice ( ) ) ,
730+ dest)
731+ }
717732 }
718733 ast:: ExprMethodCall ( _, _, ref args) => {
719734 callee:: trans_method_call ( bcx,
@@ -1461,6 +1476,76 @@ fn trans_overloaded_op<'a, 'b>(
14611476 dest)
14621477}
14631478
1479+ fn trans_overloaded_call < ' a > (
1480+ mut bcx : & ' a Block < ' a > ,
1481+ expr : & ast:: Expr ,
1482+ callee : Datum < Expr > ,
1483+ args : & [ @ast:: Expr ] ,
1484+ dest : Option < Dest > )
1485+ -> & ' a Block < ' a > {
1486+ // Evaluate and tuple the arguments.
1487+ let tuple_type = ty:: mk_tup ( bcx. tcx ( ) ,
1488+ args. iter ( )
1489+ . map ( |e| expr_ty ( bcx, * e) )
1490+ . collect ( ) ) ;
1491+ let repr = adt:: represent_type ( bcx. ccx ( ) , tuple_type) ;
1492+ let numbered_fields: Vec < ( uint , @ast:: Expr ) > =
1493+ args. iter ( ) . enumerate ( ) . map ( |( i, arg) | ( i, * arg) ) . collect ( ) ;
1494+ let argument_scope = bcx. fcx . push_custom_cleanup_scope ( ) ;
1495+ let tuple_datum =
1496+ unpack_datum ! ( bcx,
1497+ lvalue_scratch_datum( bcx,
1498+ tuple_type,
1499+ "tupled_arguments" ,
1500+ false ,
1501+ cleanup:: CustomScope (
1502+ argument_scope) ,
1503+ ( ) ,
1504+ |( ) , bcx, addr| {
1505+ trans_adt( bcx,
1506+ & * repr,
1507+ 0 ,
1508+ numbered_fields. as_slice( ) ,
1509+ None ,
1510+ SaveIn ( addr) )
1511+ } ) ) ;
1512+
1513+ let method_call = typeck:: MethodCall :: expr ( expr. id ) ;
1514+ let method_type = bcx. tcx ( )
1515+ . method_map
1516+ . borrow ( )
1517+ . get ( & method_call)
1518+ . ty ;
1519+ let callee_rvalue = unpack_datum ! ( bcx,
1520+ callee. to_rvalue_datum( bcx, "callee" ) ) ;
1521+ let tuple_datum = tuple_datum. to_expr_datum ( ) ;
1522+ let tuple_rvalue = unpack_datum ! ( bcx,
1523+ tuple_datum. to_rvalue_datum( bcx,
1524+ "tuple" ) ) ;
1525+ let argument_values = [
1526+ callee_rvalue. add_clean ( bcx. fcx ,
1527+ cleanup:: CustomScope ( argument_scope) ) ,
1528+ tuple_rvalue. add_clean ( bcx. fcx , cleanup:: CustomScope ( argument_scope) )
1529+ ] ;
1530+ unpack_result ! ( bcx,
1531+ callee:: trans_call_inner( bcx,
1532+ Some ( expr_info( expr) ) ,
1533+ monomorphize_type( bcx,
1534+ method_type) ,
1535+ |bcx, arg_cleanup_scope| {
1536+ meth:: trans_method_callee(
1537+ bcx,
1538+ method_call,
1539+ None ,
1540+ arg_cleanup_scope)
1541+ } ,
1542+ callee:: ArgVals ( argument_values) ,
1543+ dest) ) ;
1544+
1545+ bcx. fcx . pop_custom_cleanup_scope ( argument_scope) ;
1546+ bcx
1547+ }
1548+
14641549fn int_cast ( bcx : & Block ,
14651550 lldsttype : Type ,
14661551 llsrctype : Type ,
0 commit comments