Merge lp:~verifypn-cpn/verifypn/eq-push-fix-trunk into lp:verifypn

Proposed by Peter Gjøl Jensen on 2019-04-23
Status: Merged
Approved by: Jiri Srba on 2019-04-23
Approved revision: 219
Merged at revision: 219
Proposed branch: lp:~verifypn-cpn/verifypn/eq-push-fix-trunk
Merge into: lp:verifypn
Diff against target: 30 lines (+8/-10)
1 file modified
PetriEngine/PQL/Expressions.cpp (+8/-10)
To merge this branch: bzr merge lp:~verifypn-cpn/verifypn/eq-push-fix-trunk
Reviewer Review Type Date Requested Status
Jiri Srba 2019-04-23 Approve on 2019-04-23
Review via email: mp+366401@code.launchpad.net
To post a comment you must log in.
Jiri Srba (srba) wrote :

Tested and fixes the bug

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'PetriEngine/PQL/Expressions.cpp'
2--- PetriEngine/PQL/Expressions.cpp 2018-08-25 19:48:34 +0000
3+++ PetriEngine/PQL/Expressions.cpp 2019-04-23 13:42:17 +0000
4@@ -3489,18 +3489,16 @@
5 Condition_ptr pushEqual(CompareCondition* org, bool negated, bool noteq, const EvaluationContext& context)
6 {
7 if(org->isTrivial()) return BooleanCondition::getShared(org->evaluate(context) xor negated);
8- if((*org)[0]->placeFree() && (*org)[0]->evaluate(context) == 0)
9- {
10- if(negated == noteq) return std::make_shared<LessThanOrEqualCondition>((*org)[1], std::make_shared<LiteralExpr>(0));
11- else return std::make_shared<GreaterThanOrEqualCondition>((*org)[1], std::make_shared<LiteralExpr>(1));
12- }
13- if((*org)[1]->placeFree() && (*org)[1]->evaluate(context) == 0)
14- {
15- if(negated == noteq) return std::make_shared<LessThanOrEqualCondition>((*org)[1], std::make_shared<LiteralExpr>(0));
16- else return std::make_shared<GreaterThanOrEqualCondition>((*org)[1], std::make_shared<LiteralExpr>(1));
17+ for(auto i : {0,1})
18+ {
19+ if((*org)[i]->placeFree() && (*org)[i]->evaluate(context) == 0)
20+ {
21+ if(negated == noteq) return std::make_shared<LessThanOrEqualCondition>((*org)[(i + 1) % 2], std::make_shared<LiteralExpr>(0));
22+ else return std::make_shared<GreaterThanOrEqualCondition>((*org)[(i + 1) % 2], std::make_shared<LiteralExpr>(1));
23+ }
24 }
25 if(negated == noteq) return std::make_shared<EqualCondition>((*org)[0], (*org)[1]);
26- else return std::make_shared<NotEqualCondition>((*org)[0], (*org)[1]);
27+ else return std::make_shared<NotEqualCondition>((*org)[0], (*org)[1]);
28 }
29
30 Condition_ptr NotEqualCondition::pushNegation(negstat_t& stats, const EvaluationContext& context, bool nested, bool negated, bool initrw) {

Subscribers

People subscribed via source and target branches