Skip to content

Commit

Permalink
Check opaque uniqueness
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Sep 25, 2023
1 parent 002c0d4 commit 396ffec
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions crates/wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use by_address::ByAddress;
use indexmap::{IndexMap, IndexSet};
use indexmap::{map::Entry, IndexMap, IndexSet};
use rose::{id, Binop, Expr, Func, Instr, Node, Refs, Ty, Unop};
use std::{hash::Hash, mem::take};
use wasm_encoder::{
Expand Down Expand Up @@ -74,14 +74,18 @@ impl<'a, O: Hash + Eq, T: Refs<'a, Opaque = O>> Topsort<'a, O, T> {
}
}
Node::Opaque { def, .. } => {
// TODO: check that the value matches if the key is already present
self.imports.insert(
(def, gens),
(
args.iter().map(|x| types[f.vars[x.var()].ty()]).collect(),
types[f.vars[instr.var.var()].ty()],
),
let resolved = (
args.iter().map(|x| types[f.vars[x.var()].ty()]).collect(),
types[f.vars[instr.var.var()].ty()],
);
match self.imports.entry((def, gens)) {
Entry::Occupied(entry) => {
assert_eq!(entry.get(), &resolved);
}
Entry::Vacant(entry) => {
entry.insert(resolved);
}
}
}
}
}
Expand Down

0 comments on commit 396ffec

Please sign in to comment.