@@ -2016,7 +2016,7 @@ algorithm
20162016 stmt1 = if isCon then DAE . STMT_ASSIGN (typ,exp1,exp2,source) else stmt;
20172017 tplExpsLHS = if isTpl then Expression . getComplexContents(exp1) else {};
20182018 tplExpsRHS = if isTpl then Expression . getComplexContents(exp2) else {};
2019- tplStmts = List . map2( List . intRange(listLength(tplExpsLHS)), makeAssignmentMap, tplExpsLHS,tplExpsRHS);
2019+ tplStmts = makeAssignmentMap( tplExpsLHS,tplExpsRHS);
20202020 stmts1 = if isTpl then tplStmts else {stmt1};
20212021 if Flags . isSet(Flags . EVAL_FUNC_DUMP ) then
20222022 print("evaluated assignment to: \n " + stringDelimitList(List . map(stmts1,DAEDump . ppStatementStr)," \n " )+ " \n " );
@@ -2071,7 +2071,7 @@ algorithm
20712071 stmt1 = if isCon then DAE . STMT_ASSIGN (typ,exp1,exp2,source) else stmt;
20722072 tplExpsLHS = if isTpl then Expression . getComplexContents(exp1) else {};
20732073 tplExpsRHS = if isTpl then Expression . getComplexContents(exp2) else {};
2074- tplStmts = List . map2( List . intRange(listLength(tplExpsLHS)), makeAssignmentMap, tplExpsLHS,tplExpsRHS);
2074+ tplStmts = makeAssignmentMap( tplExpsLHS,tplExpsRHS);
20752075 stmts1 = if isTpl then tplStmts else {stmt1};
20762076 if Flags . isSet(Flags . EVAL_FUNC_DUMP ) then
20772077 print("evaluated array assignment to: \n " + stringDelimitList(List . map(stmts1,DAEDump . ppStatementStr)," \n " )+ " \n " );
@@ -2156,7 +2156,7 @@ algorithm
21562156 tplExpsLHS = if isCon then tplExpsLHS else {};
21572157 tplExpsRHS = DAEUtil . getTupleExps(exp1);
21582158 tplExpsRHS = if isCon then tplExpsRHS else {};
2159- stmtsNew = List . map2( List . intRange(listLength(tplExpsLHS)), makeAssignmentMap, tplExpsLHS,tplExpsRHS); // if the tuple is completely constant
2159+ stmtsNew = makeAssignmentMap( tplExpsLHS,tplExpsRHS); // if the tuple is completely constant
21602160
21612161 stmtsNew = if isCon then stmtsNew else {stmt};
21622162 stmts2 = if intEq(size,0 ) then {DAE . STMT_ASSIGN (typ,exp2,exp1,DAE . emptyElementSource)} else stmtsNew;
@@ -2552,7 +2552,7 @@ algorithm
25522552 print(" check getStatementLHS for WHEN! \n " + DAEDump . ppStatementStr(stmt));
25532553 end if ;
25542554 expLst = List . fold(stmtLst1,getStatementLHS,expsIn);
2555- expLst = List . fold({ stmt1},getStatementLHS ,expLst);
2555+ expLst = getStatementLHS( stmt1,expLst);
25562556 then expLst;
25572557 case (DAE . STMT_WHEN (statementLst= stmtLst1,elseWhen= NONE ()),_)
25582558 equation
@@ -3159,7 +3159,7 @@ algorithm
31593159 // repl = bcallret3(not predicted, BackendVarTransform.removeReplacements,replIn,varCrefs,NONE(),replIn);
31603160 // bcall(not predicted,print,"remove the replacement for: "+stringDelimitList(List.map(varCrefs,ComponentReference.crefStr),"\n")+"\n");
31613161 // build the additional statements and update the old one
3162- addStmts = List . map2( List . intRange(listLength(outExps)), makeAssignmentMap, outExps,expLst);
3162+ addStmts = makeAssignmentMap( outExps,expLst);
31633163 stmtNew = updateStatementsInIfStmt(stmtsLst,stmtIn);
31643164
31653165 // print("the new predicted stmts: \n"+stringDelimitList(List.map({stmtNew},DAEDump.ppStatementStr),"\n")+"\nAnd the additional "+stringDelimitList(List.map(addStmts,DAEDump.ppStatementStr),"\n")+"\n");
@@ -3305,50 +3305,40 @@ end updateStatementsInElse;
33053305protected function compareConstantExps "compares the lists of expressions if there are the same constants at the same position
33063306author:Waurich TUD 2014-04"
33073307 input list< list< DAE . Exp >> expLstLstIn;
3308- output list< Integer > posLstOut;
3309- protected
3310- Integer num;
3311- list< Integer > idcs;
3308+ output list< Integer > posLstOut = {};
33123309algorithm
3313- num : = listLength(listHead(expLstLstIn));
3314- idcs := List . intRange(num );
3315- posLstOut : = List . fold1(idcs,compareConstantExps2,expLstLstIn,{}) ;
3310+ for i in 1 : listLength(listHead(expLstLstIn)) loop
3311+ posLstOut := compareConstantExps2(i, expLstLstIn, posLstOut );
3312+ end for ;
33163313end compareConstantExps;
33173314
33183315protected function compareConstantExps2
33193316 input Integer idx;
33203317 input list< list< DAE . Exp >> expLstLst;
3321- input list< Integer > posIn;
3322- output list< Integer > posOut;
3318+ input output list< Integer > pos;
33233319protected
33243320 Boolean b1,b2;
3325- list< Boolean > bLst;
3326- list< Integer > posLst;
33273321 DAE . Exp firstExp;
33283322 list< DAE . Exp > expLst,rest;
33293323algorithm
33303324 expLst := List . map1(expLstLst,listGet,idx);
3331- firstExp::rest := expLst;
3332- bLst := List . map(expLst,Expression . isConst);
3333- b1 := List . fold(bLst,boolAnd,true );
3334- bLst := List . map1(rest,Expression . expEqual,firstExp);
3335- b2 := List . fold(bLst,boolAnd,true );
3336- posLst := idx::posIn;
3337- posOut := if b1 and b2 then posLst else posIn;
3325+ b1 := List . mapBoolAnd(expLst,Expression . isConst);
3326+ if b1 then
3327+ firstExp::rest := expLst;
3328+ b2 := List . map1BoolAnd(rest,Expression . expEqual,firstExp);
3329+ if b2 then
3330+ pos := idx::pos;
3331+ end if ;
3332+ end if ;
33383333end compareConstantExps2;
33393334
3340- protected function makeAssignmentMap "mapping function fo build the statements for a list of lhs and rhs exps.
3335+ protected function makeAssignmentMap "mapping function to build the statements for a list of lhs and rhs exps.
33413336author:Waurich TUD 2014-04"
3342- input Integer idx;
33433337 input list< DAE . Exp > lhs;
33443338 input list< DAE . Exp > rhs;
3345- output DAE . Statement stmt;
3346- protected
3347- DAE . Exp e1,e2;
3339+ output list< DAE . Statement > stmts;
33483340algorithm
3349- e1 := listGet(lhs,idx);
3350- e2 := listGet(rhs,idx);
3351- stmt := makeAssignment(e1,e2);
3341+ stmts := list(makeAssignment(e1, e2) threaded for e1 in lhs, e2 in rhs);
33523342end makeAssignmentMap;
33533343
33543344protected function makeAssignment "makes an DAE.STMT_ASSIGN of the 2 DAE.Exp"
0 commit comments