[meta] Add the ability to bind any type to an instruction;

This commit is contained in:
Benjamin Bouvier
2019-06-21 12:15:09 +02:00
parent 9dcc185264
commit ec5678ab7a
2 changed files with 50 additions and 7 deletions

View File

@@ -376,11 +376,17 @@ pub struct Apply {
impl Apply {
pub fn new(target: InstSpec, args: Vec<Expr>) -> Self {
let (inst, value_types) = match target.into() {
let (inst, value_types) = match target {
InstSpec::Inst(inst) => (inst, Vec::new()),
InstSpec::Bound(bound_inst) => (bound_inst.inst, bound_inst.value_types),
};
// Apply should only operate on concrete value types, not "any".
let value_types = value_types
.into_iter()
.map(|vt| vt.expect("shouldn't be Any"))
.collect();
// Basic check on number of arguments.
assert!(
inst.operands_in.len() == args.len(),