Make codegen_call_inner a bit more readable

This commit is contained in:
bjorn3 2019-02-07 20:28:55 +01:00
parent 2709d2ee78
commit c8f19f1cb2

View file

@ -619,28 +619,26 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>(
_ => None, _ => None,
}; };
let func_ref: Option<Value>; // Indirect call target // | Indirect call target
// v v the first argument to be passed
let first_arg = { let (func_ref, first_arg) = match instance {
if let Some(Instance { // Trait object call
Some(Instance {
def: InstanceDef::Virtual(_, idx), def: InstanceDef::Virtual(_, idx),
.. ..
}) = instance }) => {
{
let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx);
func_ref = Some(method); (Some(method), Some(ptr))
Some(ptr) }
} else {
func_ref = if instance.is_none() { // Normal call
let func = trans_operand(fx, func.expect("indirect call without func Operand")); Some(_) => (None, args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))),
Some(func.load_scalar(fx))
} else { // Indirect call
None None => {
}; let func = trans_operand(fx, func.expect("indirect call without func Operand")).load_scalar(fx);
(Some(func), args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)))
args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))
} }
.into_iter()
}; };
let call_args: Vec<Value> = return_ptr let call_args: Vec<Value> = return_ptr