@@ -4272,9 +4272,16 @@ algorithm
42724272 (eqs, vars, updated) := simplifyComplexFunctionWork(eqn, withTmpVars);
42734273 if updated
42744274 then
4275- indRemove := i :: indRemove;
4276- eqsAll := listAppend(eqs, eqsAll);
4277- varsAll := listAppend(vars, varsAll);
4275+ if listLength(eqs) == 1
4276+ then
4277+ // BackendDump.printEquation(eqn);
4278+ {eqn} := eqs;
4279+ eqns := BackendEquation . setAtIndex(eqns, i, eqn);
4280+ else
4281+ indRemove := i :: indRemove;
4282+ eqsAll := listAppend(eqs, eqsAll);
4283+ varsAll := listAppend(vars, varsAll);
4284+ end if ;
42784285 end if ;
42794286 else
42804287 // BackendDump.printEquation(BackendEquation.equationNth1(eqns, i));
@@ -4371,30 +4378,8 @@ protected
43714378 list< DAE . Exp > left_lst, right_lst;
43724379 Boolean expanted = true , _updated;
43734380 BackendDAE . Equation eqn;
4374- Boolean expandLeft = true , expandRight = true , restart;
4375- DAE . Exp lhs, rhs;
43764381algorithm
43774382
4378- restart := match(left, right)
4379- case (DAE . ARRAY (array = {lhs}),_)
4380- equation
4381- rhs = Expression . makeASUB(right,{DAE . ICONST (1 )});
4382- then
4383- true ;
4384- case (_, DAE . ARRAY (array = {rhs}))
4385- equation
4386- lhs = Expression . makeASUB(left,{DAE . ICONST (1 )});
4387- then
4388- true ;
4389- else false ;
4390- end match;
4391- if restart
4392- then
4393- (eqs, vars, updated) := simplifyComplexFunctionWorkCE_AE_WORK(lhs, rhs, withTmpVars, source, attr);
4394- return ;
4395- end if ;
4396-
4397-
43984383 if Expression . isTuple(left)
43994384 then
44004385 DAE . TUPLE (PR = left_lst) := left;
@@ -4408,7 +4393,6 @@ algorithm
44084393 DAE . ARRAY (array= left_lst) := left;
44094394 else
44104395 expanted := false ;
4411- expandLeft := false ;
44124396 end if ;
44134397
44144398 if Expression . isTuple(right)
@@ -4424,24 +4408,11 @@ algorithm
44244408 DAE . ARRAY (array= right_lst) := right;
44254409 else
44264410 expanted := false ;
4427- expandRight := false ;
44284411 end if ;
44294412
4430-
4431- if expanted
4432- then
4413+ if expanted then
44334414 (eqs, vars, updated) := simplifyComplexFunctionWorkTT(left_lst, right_lst, withTmpVars, source, attr);
44344415
4435- elseif expandRight and Expression . isCall(left) and Expression . hasWild(right_lst)
4436- then
4437- // print(ExpressionDump.printExpStr(left));
4438- (right_lst, left_lst) := simplifyComplexFunctionWorkWild(right_lst, left);
4439- (eqs, vars, updated) := simplifyComplexFunctionWorkTT(left_lst, right_lst, withTmpVars, source, attr);
4440- elseif expandLeft and Expression . isCall(right) and Expression . hasWild(left_lst)
4441- then
4442- // print(ExpressionDump.printExpStr(left));
4443- (left_lst, right_lst) := simplifyComplexFunctionWorkWild(left_lst, right);
4444- (eqs, vars, updated) := simplifyComplexFunctionWorkTT(left_lst, right_lst, withTmpVars, source, attr);
44454416 elseif Expression . isWild(left) or Expression . isWild(right)
44464417 then // _ = ... or ... = _
44474418 eqs := {};
@@ -4468,37 +4439,13 @@ algorithm
44684439
44694440 else
44704441 eqn := BackendEquation . generateEquation(left, right, source, attr);
4471- eqs := {eqn};
4442+ eqs := {eqn};
44724443 vars := {};
44734444 updated := false ;
44744445 end if ;
44754446end simplifyComplexFunctionWorkCE_AE_WORK;
44764447
44774448
4478-
4479- protected function simplifyComplexFunctionWorkWild
4480- input list< DAE . Exp > _left_lst;
4481- input DAE . Exp right;
4482- output list< DAE . Exp > left_lst = {};
4483- output list< DAE . Exp > right_lst = {};
4484- protected
4485- DAE . Type ty;
4486- Integer idx = 1 ;
4487- algorithm
4488- for left in _left_lst
4489- loop
4490- if not Expression . isWild(left)
4491- then
4492- ty := Expression . typeof(left);
4493- left_lst := left :: left_lst;
4494- right_lst := DAE . TSUB (right, idx, ty) :: right_lst;
4495- idx := idx + 1 ;
4496- end if ;
4497- end for ;
4498-
4499- end simplifyComplexFunctionWorkWild;
4500-
4501-
45024449protected function simplifyComplexFunctionWorkTT
45034450 input list< DAE . Exp > _left_lst;
45044451 input list< DAE . Exp > _right_lst;
@@ -4528,17 +4475,10 @@ algorithm
45284475 loop
45294476 lhs :: left_lst := left_lst;
45304477 rhs :: right_lst := right_lst;
4531- if Expression . isWild(lhs) or Expression . isWild(rhs)
4532- then
4533- // print(ExpressionDump.printExpStr(lhs));
4534- // print(ExpressionDump.printExpStr(rhs));
4535- updated := true ;
4536- else
4537- (_eqs, _vars, _updated) := simplifyComplexFunctionWorkCE_AE_WORK(lhs, rhs, withTmpVars, source, attr);
4538- eqs := listAppend(_eqs, eqs);
4539- vars := listAppend(_vars, vars);
4540- updated := updated or _updated;
4541- end if ;
4478+ (_eqs, _vars, _updated) := simplifyComplexFunctionWorkCE_AE_WORK(lhs, rhs, withTmpVars, source, attr);
4479+ eqs := listAppend(_eqs, eqs);
4480+ vars := listAppend(_vars, vars);
4481+ updated := updated or _updated;
45424482 end for ;
45434483end simplifyComplexFunctionWorkTT;
45444484
0 commit comments