Skip to content

Commit

Permalink
Fixed if elim
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-Rozek committed May 9, 2023
1 parent f82b95c commit fdd5128
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ function verifyIfElim(node) {
return false;
}

// Check that the current node matches the consequent
// of the if vertex
if (is_if_expression(node.parents[0].expression) && !node.expression.equals(node.parents[0].expression.children[1])) {
return false;
} else if (is_if_expression(node.parents[1].expression) && !node.expression.equals(node.parents[1].expression.children[1])) {
return false;
}

// Second parent is the antecedant of the first
let match1 = is_if_expression(node.parents[0].expression) &&
node.parents[1].expression.equals(node.parents[0].expression.children[0]);
Expand All @@ -191,6 +199,8 @@ function verifyIfElim(node) {
let match2 = is_if_expression(node.parents[1].expression) &&
node.parents[0].expression.equals(node.parents[1].expression.children[0])



if (match1 == false && match2 == false) {
return false;
}
Expand Down

0 comments on commit fdd5128

Please sign in to comment.