Skip to content
Snippets Groups Projects
Commit 94e82a7b authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Simplify preconditions when possible

parent c6ed682f
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ object TreeOps {
import Common._
import TypeTrees._
import Definitions._
import xlang.Trees.LetDef
import Trees._
import Extractors._
......@@ -1131,6 +1132,23 @@ object TreeOps {
def simplifyTautologies(solver : Solver)(expr : Expr) : Expr = {
def pre(e : Expr) = e match {
case LetDef(fd, expr) if fd.hasPrecondition =>
val pre = fd.precondition.get
solver.solve(pre) match {
case Some(true) =>
fd.precondition = None
case Some(false) => solver.solve(Not(pre)) match {
case Some(true) =>
fd.precondition = Some(BooleanLiteral(false))
case _ =>
}
case None =>
}
e
case IfExpr(cond, then, elze) =>
try {
solver.solve(cond) match {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment