mirror of
https://github.com/circify/circ.git
synced 2026-01-10 22:27:55 -05:00
Type checks for ABY translation (#76)
This commit is contained in:
@@ -136,9 +136,14 @@ impl ToABY {
|
||||
|
||||
/// Given term `t`, type-check `t` is of type Bool
|
||||
fn check_bool(&self, t: &Term) {
|
||||
self.cache
|
||||
match self
|
||||
.cache
|
||||
.get(t)
|
||||
.unwrap_or_else(|| panic!("Missing wire for {:?}", t));
|
||||
.unwrap_or_else(|| panic!("Missing wire for {:?}", t))
|
||||
{
|
||||
EmbeddedTerm::Bool(_) => (),
|
||||
_ => panic!("Non-bool for {:?}", t),
|
||||
}
|
||||
}
|
||||
|
||||
fn embed_bool(&mut self, t: Term) {
|
||||
@@ -186,8 +191,8 @@ impl ToABY {
|
||||
let op = "MUX";
|
||||
|
||||
self.check_bool(&t.cs[0]);
|
||||
self.check_bv(&t.cs[1]);
|
||||
self.check_bv(&t.cs[2]);
|
||||
self.check_bool(&t.cs[1]);
|
||||
self.check_bool(&t.cs[2]);
|
||||
|
||||
let sel = self.term_to_share_cnt.get(&t.cs[0]).unwrap();
|
||||
let a = self.term_to_share_cnt.get(&t.cs[1]).unwrap();
|
||||
@@ -260,9 +265,14 @@ impl ToABY {
|
||||
|
||||
/// Given term `t`, type-check `t` is of type Bv
|
||||
fn check_bv(&self, t: &Term) {
|
||||
self.cache
|
||||
match self
|
||||
.cache
|
||||
.get(t)
|
||||
.unwrap_or_else(|| panic!("Missing wire for {:?}", t));
|
||||
.unwrap_or_else(|| panic!("Missing wire for {:?}", t))
|
||||
{
|
||||
EmbeddedTerm::Bv(_) => (),
|
||||
_ => panic!("Non-bv for {:?}", t),
|
||||
}
|
||||
}
|
||||
|
||||
fn embed_bv(&mut self, t: Term) {
|
||||
|
||||
Reference in New Issue
Block a user