@@ -1817,19 +1817,13 @@ fn new_fn_ctxt(@crate_ctxt cx,
1817
1817
// allocas immediately upon entry; this permits us to GEP into structures we
1818
1818
// were passed and whatnot. Apparently mem2reg will mop up.
1819
1819
1820
- fn copy_args_to_allocas ( @block_ctxt cx , vec[ ast. arg] args , & ast. ann ann ) {
1821
-
1822
- let vec[ typeck. arg ] arg_ts = vec ( ) ;
1823
- let @typeck. ty fty = node_ann_type ( cx. fcx . ccx , ann) ;
1824
- alt ( fty. struct ) {
1825
- case ( typeck. ty_fn ( ?a, _) ) { arg_ts += a; }
1826
- }
1820
+ fn copy_args_to_allocas ( @block_ctxt cx , vec[ ast. arg] args ,
1821
+ vec[ typeck. arg] arg_tys ) {
1827
1822
1828
1823
let uint arg_n = 0 u;
1829
1824
1830
1825
for ( ast. arg aarg in args) {
1831
- auto arg = arg_ts. ( arg_n) ;
1832
- auto arg_t = type_of( cx. fcx. ccx, arg. ty) ;
1826
+ auto arg_t = type_of( cx. fcx. ccx, arg_tys. ( arg_n) . ty) ;
1833
1827
auto alloca = cx. build. Alloca ( arg_t) ;
1834
1828
auto argval = cx. fcx. llargs. get( aarg. id) ;
1835
1829
cx. build. Store ( argval, alloca) ;
@@ -1844,13 +1838,22 @@ fn is_terminated(@block_ctxt cx) -> bool {
1844
1838
ret llvm. LLVMIsATerminatorInst ( inst) as int != 0 ;
1845
1839
}
1846
1840
1841
+ fn arg_tys_of_fn( ast. ann ann) -> vec[ typeck. arg] {
1842
+ alt ( typeck. ann_to_type( ann) . struct ) {
1843
+ case ( typeck. ty_fn( ?arg_tys, _) ) {
1844
+ ret arg_tys;
1845
+ }
1846
+ }
1847
+ fail;
1848
+ }
1849
+
1847
1850
impure fn trans_fn( @crate_ctxt cx, & ast. _fn f, ast. def_id fid,
1848
1851
& ast. ann ann) {
1849
1852
1850
1853
auto fcx = new_fn_ctxt( cx, cx. path, f. inputs, fid) ;
1851
1854
auto bcx = new_top_block_ctxt( fcx) ;
1852
1855
1853
- copy_args_to_allocas( bcx, f. inputs, ann) ;
1856
+ copy_args_to_allocas( bcx, f. inputs, arg_tys_of_fn ( ann) ) ;
1854
1857
1855
1858
auto res = trans_block( bcx, f. body) ;
1856
1859
if ( !is_terminated( res. bcx) ) {
0 commit comments