@@ -311,6 +311,7 @@ fn type_of(@crate_ctxt cx, @ty.t t) -> TypeRef {
311
311
ret llty;
312
312
}
313
313
314
+ // NB: this function must match the ABI assumptions of trans_args exactly.
314
315
fn type_of_fn_full ( @crate_ctxt cx ,
315
316
option. t[ TypeRef ] obj_self ,
316
317
vec[ ty. arg] inputs ,
@@ -1758,17 +1759,20 @@ impure fn trans_alt(@block_ctxt cx, @ast.expr expr, vec[ast.arm] arms)
1758
1759
1759
1760
type lval_result = rec( result res,
1760
1761
bool is_mem,
1762
+ option. t[ vec[ ValueRef ] ] lltys,
1761
1763
option. t[ ValueRef ] llobj) ;
1762
1764
1763
1765
fn lval_mem( @block_ctxt cx, ValueRef val) -> lval_result {
1764
1766
ret rec( res=res( cx, val) ,
1765
1767
is_mem=true ,
1768
+ lltys=none[ vec[ ValueRef ] ] ,
1766
1769
llobj=none[ ValueRef ] ) ;
1767
1770
}
1768
1771
1769
1772
fn lval_val( @block_ctxt cx, ValueRef val) -> lval_result {
1770
1773
ret rec( res=res( cx, val) ,
1771
1774
is_mem=false ,
1775
+ lltys=none[ vec[ ValueRef ] ] ,
1772
1776
llobj=none[ ValueRef ] ) ;
1773
1777
}
1774
1778
@@ -1800,11 +1804,19 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
1800
1804
auto fn_item = cx. fcx. ccx. items. get( did) ;
1801
1805
auto monoty = node_ann_type( cx. fcx. ccx, ann) ;
1802
1806
auto tys = ty. resolve_ty_params( fn_item, monoty) ;
1807
+ auto vt = none[ vec[ ValueRef ] ] ;
1803
1808
1804
- // TODO: build a closure with the type parameters that
1805
- // result
1809
+ if ( _vec. len[ @ty. t] ( tys) != 0 u) {
1810
+ let vec[ ValueRef ] tydescs = vec( ) ;
1811
+ for ( @ty. t t in tys) {
1812
+ append[ ValueRef ] ( tydescs,
1813
+ get_tydesc( cx, t) ) ;
1814
+ }
1815
+ vt = some[ vec[ ValueRef ] ] ( tydescs) ;
1816
+ }
1806
1817
1807
- ret lval_val( cx, cx. fcx. ccx. fn_pairs. get( did) ) ;
1818
+ auto lv = lval_val( cx, cx. fcx. ccx. fn_pairs. get( did) ) ;
1819
+ ret rec( lltys = vt with lv) ;
1808
1820
}
1809
1821
case ( ast. def_obj( ?did) ) {
1810
1822
check ( cx. fcx. ccx. fn_pairs. contains_key( did) ) ;
@@ -1952,9 +1964,13 @@ impure fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
1952
1964
}
1953
1965
1954
1966
1955
- impure fn trans_args( @block_ctxt cx, ValueRef llclosure,
1967
+ // NB: this function must match the ABI assumptions of type_of_fn_full exactly.
1968
+ impure fn trans_args( @block_ctxt cx,
1969
+ ValueRef llclosure,
1956
1970
option. t[ ValueRef ] llobj,
1957
- & vec[ @ast. expr] es, @ty. t fn_ty)
1971
+ option. t[ vec[ ValueRef ] ] lltydescs,
1972
+ & vec[ @ast. expr] es,
1973
+ @ty. t fn_ty)
1958
1974
-> tup( @block_ctxt, vec[ ValueRef ] ) {
1959
1975
let vec[ ValueRef ] vs = vec( cx. fcx. lltaskptr) ;
1960
1976
let @block_ctxt bcx = cx;
@@ -1965,6 +1981,15 @@ impure fn trans_args(@block_ctxt cx, ValueRef llclosure,
1965
1981
case ( _) { fail; }
1966
1982
}
1967
1983
1984
+ alt ( lltydescs) {
1985
+ case ( some[ vec[ ValueRef ] ] ( ?tys) ) {
1986
+ for ( ValueRef t in tys) {
1987
+ vs += t;
1988
+ }
1989
+ }
1990
+ case ( _) { }
1991
+ }
1992
+
1968
1993
alt ( llobj) {
1969
1994
case ( some[ ValueRef ] ( ?ob) ) {
1970
1995
// Every object is always found in memory,
@@ -2250,7 +2275,9 @@ impure fn trans_call(@block_ctxt cx, @ast.expr f,
2250
2275
}
2251
2276
auto fn_ty = ty. expr_ty( f) ;
2252
2277
auto ret_ty = ty. ann_to_type( ann) ;
2253
- auto args_res = trans_args( f_res. res. bcx, llclosure, f_res. llobj,
2278
+ auto args_res = trans_args( f_res. res. bcx,
2279
+ llclosure, f_res. llobj,
2280
+ f_res. lltys,
2254
2281
args, fn_ty) ;
2255
2282
2256
2283
auto real_retval = args_res. _0. build. FastCall ( faddr, args_res. _1) ;
0 commit comments