@@ -5201,7 +5201,7 @@ fn trans_index(&@block_ctxt cx, &span sp, &@ast::expr base, &@ast::expr idx,
5201
5201
// The additional bool returned indicates whether it's mem (that is
5202
5202
// represented as an alloca or heap, hence needs a 'load' to be used as an
5203
5203
// immediate).
5204
- fn trans_lval ( & @block_ctxt cx, & @ast:: expr e) -> lval_result {
5204
+ fn trans_lval_gen ( & @block_ctxt cx, & @ast:: expr e) -> lval_result {
5205
5205
alt ( e. node) {
5206
5206
case ( ast:: expr_path( ?p) ) { ret trans_path( cx, p, e. id) ; }
5207
5207
case ( ast:: expr_field( ?base, ?ident) ) {
@@ -5263,6 +5263,23 @@ fn trans_lval(&@block_ctxt cx, &@ast::expr e) -> lval_result {
5263
5263
}
5264
5264
}
5265
5265
5266
+ fn trans_lval( & @block_ctxt cx, & @ast:: expr e) -> lval_result {
5267
+ auto lv = trans_lval_gen( cx, e) ;
5268
+ alt ( lv. generic) {
5269
+ case ( some( ?gi) ) {
5270
+ auto t = ty:: expr_ty( cx. fcx. lcx. ccx. tcx, e) ;
5271
+ auto n_args =
5272
+ std:: ivec:: len( ty:: ty_fn_args( cx. fcx. lcx. ccx. tcx, t) ) ;
5273
+ auto args = std:: ivec:: init_elt( none[ @ast:: expr] , n_args) ;
5274
+ auto bound = trans_bind_1( lv. res. bcx, e, lv, args, e. id) ;
5275
+ ret lval_val( bound. bcx, bound. val) ;
5276
+ }
5277
+ case ( none) {
5278
+ ret lv;
5279
+ }
5280
+ }
5281
+ }
5282
+
5266
5283
fn int_cast( & @block_ctxt bcx, TypeRef lldsttype, TypeRef llsrctype,
5267
5284
ValueRef llsrc, bool signed) -> ValueRef {
5268
5285
if ( llvm:: LLVMGetIntTypeWidth ( lldsttype) >
@@ -5489,7 +5506,12 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
5489
5506
5490
5507
fn trans_bind( & @block_ctxt cx, & @ast:: expr f,
5491
5508
& ( option:: t[ @ast:: expr] ) [ ] args, ast:: node_id id) -> result {
5492
- auto f_res = trans_lval( cx, f) ;
5509
+ auto f_res = trans_lval_gen( cx, f) ;
5510
+ ret trans_bind_1( cx, f, f_res, args, id) ;
5511
+ }
5512
+
5513
+ fn trans_bind_1( & @block_ctxt cx, & @ast:: expr f, & lval_result f_res,
5514
+ & ( option:: t[ @ast:: expr] ) [ ] args, ast:: node_id id) -> result {
5493
5515
if ( f_res. is_mem) {
5494
5516
cx. fcx. lcx. ccx. sess. unimpl( "re-binding existing function") ;
5495
5517
} else {
@@ -5839,7 +5861,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
5839
5861
// expression because of the hack that allows us to process self-calls
5840
5862
// with trans_call.
5841
5863
5842
- auto f_res = trans_lval ( cx, f) ;
5864
+ auto f_res = trans_lval_gen ( cx, f) ;
5843
5865
let ty:: t fn_ty;
5844
5866
alt ( f_res. method_ty) {
5845
5867
case ( some( ?meth) ) {
@@ -6361,7 +6383,9 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
6361
6383
6362
6384
auto t = ty:: expr_ty( cx. fcx. lcx. ccx. tcx, e) ;
6363
6385
auto sub = trans_lval( cx, e) ;
6364
- ret rslt( sub. res. bcx, load_if_immediate( sub. res. bcx, sub. res. val, t) ) ;
6386
+ auto v = sub. res. val;
6387
+ if ( sub. is_mem) { v = load_if_immediate( sub. res. bcx, v, t) ; }
6388
+ ret rslt( sub. res. bcx, v) ;
6365
6389
}
6366
6390
6367
6391
fn with_out_method( fn ( & out_method) -> result work, @block_ctxt cx,
0 commit comments