@@ -4193,14 +4193,17 @@ fn copy_args_to_allocas(fcx: @fn_ctxt, bcx: @block_ctxt, args: [ast::arg],
4193
4193
// Ties up the llstaticallocas -> llloadenv -> llderivedtydescs ->
4194
4194
// lldynamicallocas -> lltop edges, and builds the return block.
4195
4195
fn finish_fn ( fcx : @fn_ctxt , lltop : BasicBlockRef ) {
4196
+ tie_up_header_blocks ( fcx, lltop) ;
4197
+ let ret_cx = new_raw_block_ctxt ( fcx, fcx. llreturn ) ;
4198
+ trans_fn_cleanups ( fcx, ret_cx) ;
4199
+ RetVoid ( ret_cx) ;
4200
+ }
4201
+
4202
+ fn tie_up_header_blocks ( fcx : @fn_ctxt , lltop : BasicBlockRef ) {
4196
4203
Br ( new_raw_block_ctxt ( fcx, fcx. llstaticallocas ) , fcx. llloadenv ) ;
4197
4204
Br ( new_raw_block_ctxt ( fcx, fcx. llloadenv ) , fcx. llderivedtydescs_first ) ;
4198
4205
Br ( new_raw_block_ctxt ( fcx, fcx. llderivedtydescs ) , fcx. lldynamicallocas ) ;
4199
4206
Br ( new_raw_block_ctxt ( fcx, fcx. lldynamicallocas ) , lltop) ;
4200
-
4201
- let ret_cx = new_raw_block_ctxt ( fcx, fcx. llreturn ) ;
4202
- trans_fn_cleanups ( fcx, ret_cx) ;
4203
- RetVoid ( ret_cx) ;
4204
4207
}
4205
4208
4206
4209
enum self_arg { impl_self( ty:: t ) , no_self, }
@@ -4552,13 +4555,20 @@ fn param_bounds(ccx: @crate_ctxt, tp: ast::ty_param) -> ty::param_bounds {
4552
4555
ccx. tcx . ty_param_bounds . get ( tp. id )
4553
4556
}
4554
4557
4555
- fn register_fn_full ( ccx : @crate_ctxt , sp : span , path : path , _flav : str ,
4558
+ fn register_fn_full ( ccx : @crate_ctxt , sp : span , path : path , flav : str ,
4556
4559
tps : [ ast:: ty_param ] , node_id : ast:: node_id ,
4557
4560
node_type : ty:: t ) {
4558
4561
let llfty = type_of_fn_from_ty ( ccx, node_type,
4559
4562
vec:: map ( tps, { |p| param_bounds ( ccx, p) } ) ) ;
4563
+ register_fn_fuller ( ccx, sp, path, flav, node_id, node_type,
4564
+ lib:: llvm:: CCallConv , llfty) ;
4565
+ }
4566
+
4567
+ fn register_fn_fuller ( ccx : @crate_ctxt , sp : span , path : path , _flav : str ,
4568
+ node_id : ast:: node_id , node_type : ty:: t ,
4569
+ cc : lib:: llvm:: CallConv , llfty : TypeRef ) {
4560
4570
let ps: str = mangle_exported_name ( ccx, path, node_type) ;
4561
- let llfn: ValueRef = decl_cdecl_fn ( ccx. llmod , ps, llfty) ;
4571
+ let llfn: ValueRef = decl_fn ( ccx. llmod , ps, cc , llfty) ;
4562
4572
ccx. item_ids . insert ( node_id, llfn) ;
4563
4573
ccx. item_symbols . insert ( node_id, ps) ;
4564
4574
@@ -4747,9 +4757,13 @@ fn collect_item(ccx: @crate_ctxt, abi: @mutable option<ast::native_abi>,
4747
4757
either:: right ( abi_) { * abi = option:: some ( abi_) ; }
4748
4758
}
4749
4759
}
4750
- ast:: item_fn ( _, tps, _) {
4751
- register_fn ( ccx, i. span , my_path, "fn" , tps,
4752
- i. id ) ;
4760
+ ast:: item_fn ( decl, tps, _) {
4761
+ if decl. purity != ast:: crust_fn {
4762
+ register_fn ( ccx, i. span , my_path, "fn" , tps,
4763
+ i. id ) ;
4764
+ } else {
4765
+ native:: register_crust_fn ( ccx, i. span , my_path, i. id ) ;
4766
+ }
4753
4767
}
4754
4768
ast:: item_impl ( tps, _, _, methods) {
4755
4769
let path = my_path + [ path_name ( int:: str ( i. id ) ) ] ;
0 commit comments