}
})).collect::<Vec<_>>();
- let inst = match trans_operand(fx, func) {
- CValue::Func(func, _) => fx.bcx.ins().call(func, &call_args),
- func => {
+ let call_inst = match fn_ty.sty {
+ TypeVariants::TyFnDef(def_id, substs) => {
+ let func_ref = fx.get_function_ref(
+ Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(),
+ );
+ fx.bcx.ins().call(func_ref, &call_args)
+ }
+ _ => {
+ let func = trans_operand(fx, func);
let func = func.load_value(fx);
let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty));
fx.bcx.ins().call_indirect(sig, func, &call_args)
PassMode::NoPass => {}
PassMode::ByVal(_) => {
if let Some((ret_place, _)) = destination {
- let results = fx.bcx.inst_results(inst);
+ let results = fx.bcx.inst_results(call_inst);
ret_place.write_cvalue(fx, CValue::ByVal(results[0], ret_layout));
}
}
pub enum CValue<'tcx> {
ByRef(Value, TyLayout<'tcx>),
ByVal(Value, TyLayout<'tcx>),
- Func(FuncRef, TyLayout<'tcx>),
}
impl<'tcx> CValue<'tcx> {
pub fn layout(&self) -> TyLayout<'tcx> {
match *self {
- CValue::ByRef(_, layout) | CValue::ByVal(_, layout) | CValue::Func(_, layout) => layout,
+ CValue::ByRef(_, layout) | CValue::ByVal(_, layout) => layout,
}
}
fx.bcx.ins().stack_store(value, stack_slot, 0);
fx.bcx.ins().stack_addr(types::I64, stack_slot, 0)
}
- CValue::Func(func, ty) => {
- let func = fx.bcx.ins().func_addr(types::I64, func);
- CValue::ByVal(func, ty).force_stack(fx)
- }
}
}
fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0)
}
CValue::ByVal(value, _layout) => value,
- CValue::Func(func, _layout) => fx.bcx.ins().func_addr(types::I64, func),
}
}
match self {
CValue::ByRef(value, layout) => (value, layout),
CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal: {:?}", self),
- CValue::Func(_, _) => bug!("Expected CValue::ByRef, found CValue::Func: {:?}", self),
}
}
match self {
CValue::ByRef(addr, _) => CValue::ByRef(addr, layout),
CValue::ByVal(val, _) => CValue::ByVal(val, layout),
- CValue::Func(fun, _) => CValue::Func(fun, layout),
}
}
}
let func_ref = fx.get_function_ref(
Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(),
);
- CValue::Func(func_ref, layout)
+ let func_addr = fx.bcx.ins().func_addr(types::I64, func_ref);
+ CValue::ByVal(func_addr, layout)
}
_ => trans_const_place(fx, const_).to_cvalue(fx),
}