Skip to content

Commit

Permalink
For operator x in a..b, check if a=b and set right and side of x acco…
Browse files Browse the repository at this point in the history
…rdingly. Enables some additional constant folding. Partially fixes #149.
  • Loading branch information
guidotack committed Mar 16, 2017
1 parent 497fc68 commit 032d72b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/flatten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4275,6 +4275,7 @@ namespace MiniZinc {

if (ctx.b==C_ROOT && r==constants().var_true && e1.r()->type().ispar() &&
e0.r()->isa<Id>() && (bot==BOT_IN || bot==BOT_SUBSET) ) {
/// TODO: check for float
VarDecl* vd = e0.r()->cast<Id>()->decl();
if (vd->ti()->domain()==NULL) {
vd->ti()->domain(e1.r());
Expand Down Expand Up @@ -4302,6 +4303,9 @@ namespace MiniZinc {
} else if (changeDom) {
id->decl()->ti()->setComputedDomain(false);
id->decl()->ti()->domain(new SetLit(Location().introduce(),newdom));
if (id->decl()->e()==NULL && newdom->min()==newdom->max()) {
id->decl()->e(IntLit::a(newdom->min()));
}
}
id = id->decl()->e() ? id->decl()->e()->dyn_cast<Id>() : NULL;
}
Expand Down

0 comments on commit 032d72b

Please sign in to comment.