diff --git a/CHANGES.txt b/CHANGES.txt index 1d355354a..d8c1ecc68 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,20 @@ # MiniZinc Changelog # ====================== +Version 2.0.6 +============= + +Changes: + - Add parser support for hexadecimal floating point constants. + +Bug fixes: + - Fix bounds computation for some calls (abs, int_times). + - Fix flattening of some array declarations (when right hand side is + an identifier). + - Add four missing GC locks (could lead to incorrect garbage collection). + - Compact output model only after optimisation phase (could lead to + incorrect items being removed from output model). + Version 2.0.5 ============= diff --git a/CMakeLists.txt b/CMakeLists.txt index 68dca994c..7ee357430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ project (libminizinc CXX) # The version number. set (libminizinc_VERSION_MAJOR 2) set (libminizinc_VERSION_MINOR 0) -set (libminizinc_VERSION_PATCH 5) +set (libminizinc_VERSION_PATCH 6) if (ADDITIONAL_DATE_STRING) set (libminizinc_VERSION_PATCH "${libminizinc_VERSION_PATCH}.${ADDITIONAL_DATE_STRING}") diff --git a/lib/eval_par.cpp b/lib/eval_par.cpp index c8e08498f..8b4392c14 100644 --- a/lib/eval_par.cpp +++ b/lib/eval_par.cpp @@ -1684,9 +1684,6 @@ namespace MiniZinc { _bounds.push_back(Bounds(0,0)); } } else if (c.id() == "int_times") { - BottomUpIterator cbi(*this); - cbi.run(c.args()[0]); - cbi.run(c.args()[1]); Bounds b1 = _bounds.back(); _bounds.pop_back(); Bounds b0 = _bounds.back(); _bounds.pop_back(); if (!b1.first.isFinite() || !b1.second.isFinite() || !b0.first.isFinite() || !b0.second.isFinite()) { @@ -1704,8 +1701,6 @@ namespace MiniZinc { } else if (c.id() == constants().ids.bool2int) { _bounds.push_back(Bounds(0,1)); } else if (c.id() == "abs") { - BottomUpIterator cbi(*this); - cbi.run(c.args()[0]); Bounds b0 = _bounds.back(); if (b0.first < 0) { _bounds.pop_back(); diff --git a/lib/flatten.cpp b/lib/flatten.cpp index 286e839da..1f887dc7b 100644 --- a/lib/flatten.cpp +++ b/lib/flatten.cpp @@ -120,11 +120,13 @@ namespace MiniZinc { /// Check if \a e is NULL or true bool istrue(EnvI& env, Expression* e) { + GCLock lock; return e==NULL || (e->type().ispar() && e->type().isbool() && eval_bool(env,e)); } /// Check if \a e is non-NULL and false bool isfalse(EnvI& env, Expression* e) { + GCLock lock; return e!=NULL && e->type().ispar() && e->type().isbool() && !eval_bool(env,e); } @@ -2477,7 +2479,7 @@ namespace MiniZinc { if (vd==NULL) { vd = flat_exp(env,Ctx(),id->decl(),NULL,constants().var_true).r()->cast()->decl(); id->decl()->flat(vd); - ArrayLit* al = vd->e()->cast(); + ArrayLit* al = follow_id(vd->id())->cast(); if (al->v().size()==0) { if (r==NULL) ret.r = al; @@ -3483,7 +3485,12 @@ namespace MiniZinc { case BOT_IMPL: { if (ctx.b==C_ROOT && r==constants().var_true && boe0->type().ispar()) { - if (eval_bool(env,boe0)) { + bool b; + { + GCLock lock; + b = eval_bool(env,boe0); + } + if (b) { Ctx nctx = ctx; nctx.neg = negArgs; nctx.b = negArgs ? C_NEG : C_ROOT; @@ -3497,7 +3504,12 @@ namespace MiniZinc { break; } if (ctx.b==C_ROOT && r==constants().var_true && boe1->type().ispar()) { - if (eval_bool(env,boe1)) { + bool b; + { + GCLock lock; + b = eval_bool(env,boe1); + } + if (b) { Ctx nctx = ctx; nctx.neg = negArgs; nctx.b = negArgs ? C_NEG : C_ROOT; @@ -5233,7 +5245,6 @@ namespace MiniZinc { } } } - e.output->compact(); for (IdMap::iterator it = e.output_vo._m.begin(); it != e.output_vo._m.end(); ++it) { @@ -6153,6 +6164,7 @@ namespace MiniZinc { } m->compact(); + e.envi().output->compact(); for (IdMap::iterator it = env.vo._m.begin(); it != env.vo._m.end(); ++it) { diff --git a/lib/lexer.lxx b/lib/lexer.lxx index 21d0fc9a5..869130480 100644 --- a/lib/lexer.lxx +++ b/lib/lexer.lxx @@ -179,7 +179,15 @@ char* bufferData(void* parm) { else return MZN_INVALID_INTEGER_LITERAL; } -0x[0-9A-Fa-f]+ { beginToken(yyget_extra(yyscanner), yylloc, yytext); + +0[xX]([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.)([pP][+-]?[0-9]+)|(0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+) { beginToken(yyget_extra(yyscanner), yylloc, yytext); + if (strtofloatval(yytext, yylval->dValue)) + return MZN_FLOAT_LITERAL; + else + return MZN_INVALID_FLOAT_LITERAL; + } + +0[xX][0-9A-Fa-f]+ { beginToken(yyget_extra(yyscanner), yylloc, yytext); if (strtointval(yytext, yylval->iValue)) return MZN_INTEGER_LITERAL; else diff --git a/mzn2fzn.cpp b/mzn2fzn.cpp index adfbca697..6cee0ee2a 100644 --- a/mzn2fzn.cpp +++ b/mzn2fzn.cpp @@ -389,6 +389,7 @@ int main(int argc, char** argv) { std::cerr << " done (" << stoptime(lasttime) << ")" << std::endl; } else { env.flat()->compact(); + env.output()->compact(); } if (flag_statistics) {