fn gen_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
                    name: &str,
                    inputs: Vec<Ty<'tcx>>,
                    output: Ty<'tcx>,
                    trans: &mut for<'b> FnMut(Block<'b, 'tcx>))
                    -> ValueRef {
    let ccx = fcx.ccx;
    let sig = ty::FnSig {
        inputs: inputs,
        output: output,
        variadic: false,
    };
    let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]);

    let rust_fn_ty = ccx.tcx().mk_fn_ptr(ccx.tcx().mk_bare_fn(ty::BareFnTy {
        unsafety: hir::Unsafety::Unsafe,
        abi: Abi::Rust,
        sig: ty::Binder(sig)
    }));
    let llfn = declare::define_internal_fn(ccx, name, rust_fn_ty);
    let (fcx, block_arena);
    block_arena = TypedArena::new();
    fcx = FunctionContext::new(ccx, llfn, fn_ty, None, &block_arena);
    trans(fcx.init(true));
    fcx.cleanup();
    llfn
}
// Helper function to give a Block to a closure to translate a shim function.
// This is currently primarily used for the `try` intrinsic functions above.
Helper function to give a Block to a closure to translate a shim function.
This is currently primarily used for the `try` intrinsic functions above.
Helper function to give a Block to a closure to translate a shim function . This is currently primarily used for the ` try ` intrinsic functions above .
fn gen_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
                    name: &str,
                    inputs: Vec<Ty<'tcx>>,
                    output: Ty<'tcx>,
                    trans: &mut for<'b> FnMut(Block<'b, 'tcx>))
                    -> ValueRef {
    let ccx = fcx.ccx;
    let sig = ty::FnSig {
        inputs: inputs,
        output: output,
        variadic: false,
    };
    let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]);
    let rust_fn_ty = ccx.tcx().mk_fn_ptr(ccx.tcx().mk_bare_fn(ty::BareFnTy {
        unsafety: hir::Unsafety::Unsafe,
        abi: Abi::Rust,
        sig: ty::Binder(sig)
    }));
    let llfn = declare::define_internal_fn(ccx, name, rust_fn_ty);
    let (fcx, block_arena);
    block_arena = TypedArena::new();
    fcx = FunctionContext::new(ccx, llfn, fn_ty, None, &block_arena);
    trans(fcx.init(true));
    fcx.cleanup();
    llfn
}
fn gen_fn < ' a , ' tcx > ( fcx : & FunctionContext < ' a , ' tcx > , name : & str , inputs : Vec < Ty < ' tcx > > , output : Ty < ' tcx > , trans : & mut for < ' b > FnMut ( Block < ' b , ' tcx > ) ) -> ValueRef { let ccx = fcx . ccx ; let sig = ty :: FnSig { inputs : inputs , output : output , variadic : false , } ; let fn_ty = FnType :: new ( ccx , Abi :: Rust , & sig , & [ ] ) ; let rust_fn_ty = ccx . tcx ( ) . mk_fn_ptr ( ccx . tcx ( ) . mk_bare_fn ( ty :: BareFnTy { unsafety : hir :: Unsafety :: Unsafe , abi : Abi :: Rust , sig : ty :: Binder ( sig ) } ) ) ; let llfn = declare :: define_internal_fn ( ccx , name , rust_fn_ty ) ; let ( fcx , block_arena ) ; block_arena = TypedArena :: new ( ) ; fcx = FunctionContext :: new ( ccx , llfn , fn_ty , None , & block_arena ) ; trans ( fcx . init ( true ) ) ; fcx . cleanup ( ) ; llfn }
Helper function to give a Block to a closure to translate a shim function.
Helper function to give a Block to a closure to translate a shim function .
fcx
&FunctionContext<'a, 'tcx>
name
&str
inputs
Vec<Ty<'tcx>>
output
Ty<'tcx>
trans
&mut for<'b> FnMut(Block<'b, 'tcx>)
fcx
&FunctionContext<'a, 'tcx>
name
&str
inputs
Vec<Ty<'tcx>>
output
Ty<'tcx>
trans
&mut for<'b> FnMut(Block<'b, 'tcx>)