Simplify check_arg_types().

Iterator tricks.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-19 14:53:14 -07:00
parent 49c1209572
commit d9ddf4fc5a

View File

@@ -290,21 +290,9 @@ fn convert_to_abi<PutArg>(dfg: &mut DataFlowGraph,
/// Check if a sequence of arguments match a desired sequence of argument types. /// Check if a sequence of arguments match a desired sequence of argument types.
fn check_arg_types(dfg: &DataFlowGraph, args: &[Value], types: &[ArgumentType]) -> bool { fn check_arg_types(dfg: &DataFlowGraph, args: &[Value], types: &[ArgumentType]) -> bool {
let mut n = 0; let arg_types = args.iter().map(|&v| dfg.value_type(v));
for &arg in args { let sig_types = types.iter().map(|&at| at.value_type);
match types.get(n) { arg_types.eq(sig_types)
Some(&ArgumentType { value_type, .. }) => {
if dfg.value_type(arg) != value_type {
return false;
}
}
None => return false,
}
n += 1
}
// Also verify that the number of arguments matches.
n == types.len()
} }
/// Check if the arguments of the call `inst` match the signature. /// Check if the arguments of the call `inst` match the signature.