1
0
Fork 0
mirror of synced 2025-09-23 12:18:44 +00:00

Fix boolean or bugs

This commit is contained in:
Tjaden Hess 2018-10-31 18:39:15 -04:00
parent 36a49d8a23
commit 4bd136285d
2 changed files with 8 additions and 8 deletions

View file

@ -1,6 +1,6 @@
// example using if-then-else-fi with || // example using if-then-else-fi with ||
def main(field a, field b) -> (field): def main(field a, field b) -> (field):
field y = if x + 2 == 4 || x * 2 == 2 then 1 else 0 fi field y = if a + 2 == 4 || b * 2 == 2 then 1 else 0 fi
field z = if y == 1 || y == 0 then y else 1 fi field z = if y == 1 || y == 0 then y else 1 fi
z == 1 z == 1
return z return z

View file

@ -369,15 +369,15 @@ impl Flattener {
rhs rhs
); );
assert!(x.is_linear() && y.is_linear()); assert!(x.is_linear() && y.is_linear());
let name_x_or_y = self.use_sym(); let name_x_and_y = self.use_sym();
statements_flattened.push(FlatStatement::Definition( statements_flattened.push(FlatStatement::Definition(
name_x_or_y, name_x_and_y,
FlatExpression::Sub( FlatExpression::Mult(x.clone(), y.clone())
box FlatExpression::Add(x.clone(), y.clone()),
box FlatExpression::Mult(x, y)
)
)); ));
FlatExpression::Identifier(name_x_or_y) FlatExpression::Sub(
box FlatExpression::Add(x, y),
box FlatExpression::Identifier(name_x_and_y)
)
}, },
BooleanExpression::And(box lhs, box rhs) => { BooleanExpression::And(box lhs, box rhs) => {
let x = self.flatten_boolean_expression( let x = self.flatten_boolean_expression(