Skip to content

Commit

Permalink
do not use listAppend to prepend one element
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel authored and OpenModelica-Hudson committed Mar 6, 2016
1 parent 12ddb6a commit 8236a0d
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -7719,7 +7719,7 @@ protected
BackendDAE.Variables knvars;
algorithm
BackendDAE.DAE(eqs=eqs,shared = BackendDAE.SHARED(knownVars=knvars)) := dae;
varLst := List.flatten(List.map(listAppend({knvars}, List.map(eqs, BackendVariable.daeVars)), BackendVariable.varList));
varLst := List.flatten(List.map(knvars::List.map(eqs, BackendVariable.daeVars), BackendVariable.varList));
end getAllVarLst;

public function isClockedSyst
Expand Down
16 changes: 8 additions & 8 deletions Compiler/BackEnd/Differentiate.mo
Expand Up @@ -411,7 +411,7 @@ algorithm
case eqn::rest
equation
(eqn, funcs) = differentiateEquation(eqn, inDiffwrtCref, inInputData, inDiffType, inFunctionTree);
eqns = listAppend({eqn}, inEquationsAccum);
eqns = eqn::inEquationsAccum;
(eqns, funcs) = differentiateEquations(rest, inDiffwrtCref, inInputData, inDiffType, eqns, funcs);
then (eqns, funcs);

Expand Down Expand Up @@ -449,7 +449,7 @@ algorithm
case eqns::rest
equation
(eqns, funcs) = differentiateEquations(eqns, inDiffwrtCref, inInputData, inDiffType, {}, inFunctionTree);
eqnsLst = listAppend({eqns}, inEquationsLstAccum);
eqnsLst = eqns::inEquationsLstAccum;
(eqnsLst, funcs) = differentiateEquationsLst(rest, inDiffwrtCref, inInputData, inDiffType, eqnsLst, funcs);
then (eqnsLst, funcs);

Expand Down Expand Up @@ -774,7 +774,7 @@ end differentiateExp;
// skip discrete statements
case currStatement::restStatements guard( isDiscreteAssignStatment(currStatement) )
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements2, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements2, functions);

Expand Down Expand Up @@ -882,31 +882,31 @@ end differentiateExp;

case (currStatement as DAE.STMT_TERMINATE())::restStatements
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements2, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements2, functions);

case (currStatement as DAE.STMT_REINIT())::restStatements
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements1, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements1, functions);

case (currStatement as DAE.STMT_NORETCALL())::restStatements
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements1, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements1, functions);

case (currStatement as DAE.STMT_RETURN())::restStatements
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements1, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements1, functions);

case (currStatement as DAE.STMT_BREAK())::restStatements
equation
derivedStatements1 = listAppend({currStatement}, inStmtsAccum);
derivedStatements1 = currStatement::inStmtsAccum;
(derivedStatements1, functions) = differentiateStatements(restStatements, inDiffwrtCref, inInputData, inDiffType, derivedStatements1, inFunctionTree, maxIter, expStack);
then (derivedStatements1, functions);

Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -1707,7 +1707,7 @@ algorithm
print("evaluated assignment to:\n"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
end if;

//stmts1 = listAppend({alg},lstIn);
//stmts1 = alg::lstIn;
stmts1 = listAppend(stmts1,lstIn);
//print("\nthe traverse LIST after :"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
(rest,(funcTree,repl,idx)) = evaluateFunctions_updateStatement(rest,(funcTree,repl,idx),stmts1);
Expand Down Expand Up @@ -1773,7 +1773,7 @@ algorithm
print("evaluated array assignment to:\n"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
end if;

//stmts1 = listAppend({alg},lstIn);
//stmts1 = alg::lstIn;
stmts1 = listAppend(stmts1,lstIn);
//print("\nthe traverse LIST after :"+stringDelimitList(List.map(stmts1,DAEDump.ppStatementStr),"\n")+"\n");
(rest,(funcTree,repl,idx)) = evaluateFunctions_updateStatement(rest,(funcTree,repl,idx),stmts1);
Expand Down
8 changes: 4 additions & 4 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -393,7 +393,7 @@ algorithm

(stmts, preStmts2, vars, index) = encapsulateWhenConditions_Algorithms(rest, vars, index);
preStmts = listAppend(preStmts, preStmts2);
stmts_ = listAppend({DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, NONE(), source)}, stmts);
stmts_ = DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, NONE(), source)::stmts;
then (stmts_, preStmts, vars, index);

// when statement
Expand All @@ -403,7 +403,7 @@ algorithm
vars = listAppend(vars, inVars);

(stmts, stmts_, vars, index) = encapsulateWhenConditions_Algorithms(rest, vars, index);
stmts_ = listAppend({DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, NONE(), source)}, stmts_);
stmts_ = DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, NONE(), source)::stmts_;
stmts_ = listAppend(stmts_, stmts);
then (stmts_, preStmts, vars, index);

Expand All @@ -422,7 +422,7 @@ algorithm

(stmts, preStmts2, vars, index) = encapsulateWhenConditions_Algorithms(rest, vars, index);
preStmts = listAppend(preStmts, preStmts2);
stmts_ = listAppend({DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, SOME(elseWhen), source)}, stmts);
stmts_ = DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, SOME(elseWhen), source)::stmts;
then (stmts_, preStmts, vars, index);

// when - elsewhen statement
Expand All @@ -435,7 +435,7 @@ algorithm
preStmts = listAppend(preStmts, preStmts2);

(stmts, stmts_, vars, index) = encapsulateWhenConditions_Algorithms(rest, vars, index);
stmts_ = listAppend({DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, SOME(elseWhen), source)}, stmts_);
stmts_ = DAE.STMT_WHEN(condition, conditions, initialCall, stmts1, SOME(elseWhen), source)::stmts_;
stmts_ = listAppend(stmts_, stmts);
then (stmts_, preStmts, vars, index);

Expand Down
20 changes: 10 additions & 10 deletions Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -3199,7 +3199,7 @@ protected function equalNonFreeStartValues "author: Frenkel TUD 2012-12"
input tuple<Option<DAE.Exp>, Option<DAE.Exp>, DAE.ComponentRef> iValue;
output tuple<Option<DAE.Exp>, Option<DAE.Exp>, DAE.ComponentRef> oValue;
algorithm
oValue := matchcontinue(iValues, knVars, iValue)
oValue := match(iValues, knVars, iValue)
local
list<tuple<Option<DAE.Exp>, DAE.ComponentRef>> values;
DAE.Exp e, e1, e2;
Expand All @@ -3213,8 +3213,8 @@ algorithm
then
equalNonFreeStartValues(values, knVars, iValue);
case (((NONE(), cr))::values, _, (SOME(e2), _, _))
equation
true = Expression.isZero(e2);
guard
Expression.isZero(e2)
then
equalNonFreeStartValues(values, knVars, (NONE(), NONE(), cr));
case (((SOME(e), _))::values, _, (SOME(e2), _, _))
Expand All @@ -3224,7 +3224,7 @@ algorithm
true = Expression.expEqual(e1, e2);
then
equalNonFreeStartValues(values, knVars, iValue);
end matchcontinue;
end match;
end equalNonFreeStartValues;

protected function equalFreeStartValues "author: Frenkel TUD 2012-12"
Expand Down Expand Up @@ -3813,13 +3813,13 @@ algorithm
((_, (_, {startTimeE}, _))) = replaceOptExprTraverser((startTimeE, (irepl, {}, false)));
((_, (_, {finalTimeE}, _))) = replaceOptExprTraverser((finalTimeE, (irepl, {}, false)));
(_, classAttributes) = replaceOptimicaExps({}, restClassAtr, irepl);
classAttributes = listAppend({DAE.OPTIMIZATION_ATTRS(objetiveE, objectiveIntegrandE, startTimeE, finalTimeE)}, classAttributes);
classAttributes = DAE.OPTIMIZATION_ATTRS(objetiveE, objectiveIntegrandE, startTimeE, finalTimeE)::classAttributes;
then ({}, classAttributes);
case (DAE.CONSTRAINT_EXPS(constraintLstExps)::rest, _, _)
equation
(constraintLstExps) = replaceOptimicaContraints(constraintLstExps, irepl);
(constraintLst, _) = replaceOptimicaExps(rest, iclassAttributes, irepl);
constraintLst = listAppend({DAE.CONSTRAINT_EXPS(constraintLstExps)}, constraintLst);
constraintLst = DAE.CONSTRAINT_EXPS(constraintLstExps)::constraintLst;
then (constraintLst, iclassAttributes);
end match;
end replaceOptimicaExps;
Expand All @@ -3838,7 +3838,7 @@ algorithm
equation
((_, (_, {e}, _))) = replaceExprTraverser((e, (irepl, {}, false)));
(constraintLst) = replaceOptimicaContraints(rest, irepl);
constraintLst = listAppend({e}, constraintLst);
constraintLst = e::constraintLst;
then (constraintLst);
end match;
end replaceOptimicaContraints;
Expand Down Expand Up @@ -3911,7 +3911,7 @@ algorithm
case ((exp, (repl, exps, b)))
equation
(exp1, b1) = BackendVarTransform.replaceExp(exp, repl, SOME(BackendVarTransform.skipPreChangeEdgeOperator));
exps = listAppend({exp1}, exps);
exps = exp1::exps;
then ((exp, (repl, exps, b or b1)));
end match;
end replaceExprTraverser;
Expand All @@ -3930,12 +3930,12 @@ algorithm
Boolean b, b1;
case ((NONE(), (repl, exps, b)))
equation
exps = listAppend({NONE()}, exps);
exps = NONE()::exps;
then ((NONE(), (repl, exps, b)));
case ((SOME(exp), (repl, exps, b)))
equation
(exp1, b1) = BackendVarTransform.replaceExp(exp, repl, SOME(BackendVarTransform.skipPreChangeEdgeOperator));
exps = listAppend({SOME(exp1)}, exps);
exps = SOME(exp1)::exps;
then ((SOME(exp), (repl, exps, b or b1)));
end match;
end replaceOptExprTraverser;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -1434,7 +1434,7 @@ algorithm
equation
index = arrayGet(inColors, i);
lst = arrayGet(inArray, index);
lst = listAppend({i},lst);
lst = i::lst;
arrayUpdate(inArray, index, lst);
then
mapIndexColors(inColors, i-1, inArray);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Graphviz.mo
Expand Up @@ -116,7 +116,7 @@ algorithm
equation
nm = nodename(typ);
typlbl = makeLabel({typ});
newattr = listAppend({ATTR("label",typlbl)}, attr);
newattr = ATTR("label",typlbl)::attr;
out = makeNode(nm, newattr);
print(out);
dumpChildren(nm, children);
Expand Down
5 changes: 2 additions & 3 deletions Compiler/Script/Refactor.mo
Expand Up @@ -1328,9 +1328,8 @@ algorithm
equation
res = Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info) :: res;
coord = getCoordSysAnn(listAppend(res,rest),p);
res = listAppend({Absyn.MODIFICATION(false, Absyn.NON_EACH(),
Absyn.IDENT("Diagram"),
SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info),Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("Icon"), SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info)},res);
res = Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("Diagram"), SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info)
:: Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("Icon"), SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info) :: res;
res = transformClassAnnList(rest,context,res,p);
then List.deleteMember(res,Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info));

Expand Down
12 changes: 6 additions & 6 deletions Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -1065,7 +1065,7 @@ algorithm
(eqs2, symjacs2, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(eqs2, {}, countLinearSys, countNonLinSys+1, countMixedSys, countJacobians, {}, {});
(symJac, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symjacs) = countandIndexAlgebraicLoopsSymJac(symJac, countLinearSys, countNonLinSys, countMixedSys, countJacobians);
(symJac2, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symjacs2) = countandIndexAlgebraicLoopsSymJac(symJac2, countLinearSys, countNonLinSys, countMixedSys, countJacobians);
(res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(rest, listAppend(symjacs2,listAppend(symjacs,inSymJacs)), countLinearSys, countNonLinSys, countMixedSys, countJacobians, SimCode.SES_NONLINEAR(SimCode.NONLINEARSYSTEM(index, eqs, crefs, inNonLinSysIndex, SOME(symJac), linearTearing, homotopySupport, mixedSystem), SOME(SimCode.NONLINEARSYSTEM(index2, eqs2, crefs2, inNonLinSysIndex+1, SOME(symJac2), linearTearing2, homotopySupport2, mixedSystem2)))::inEqnsAcc, listAppend({symJac2, symJac}, inSymJacsAcc));
(res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(rest, listAppend(symjacs2,listAppend(symjacs,inSymJacs)), countLinearSys, countNonLinSys, countMixedSys, countJacobians, SimCode.SES_NONLINEAR(SimCode.NONLINEARSYSTEM(index, eqs, crefs, inNonLinSysIndex, SOME(symJac), linearTearing, homotopySupport, mixedSystem), SOME(SimCode.NONLINEARSYSTEM(index2, eqs2, crefs2, inNonLinSysIndex+1, SOME(symJac2), linearTearing2, homotopySupport2, mixedSystem2)))::inEqnsAcc, symJac2::symJac::inSymJacsAcc);
then (res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians);

case (SimCode.SES_LINEAR(SimCode.LINEARSYSTEM(index, partOfMixed, vars, beqs, simJac, eqs, NONE(), sources, _), SOME(SimCode.LINEARSYSTEM(index2, partOfMixed2, vars2, beqs2, simJac2, eqs2, NONE(), sources2, _)))::rest, _, _, _, _, _, _, _)
Expand All @@ -1081,7 +1081,7 @@ algorithm
(eqs2, symjacs2, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(eqs2, {}, countLinearSys+1, countNonLinSys, countMixedSys, countJacobians, {}, {});
(symJac, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symjacs) = countandIndexAlgebraicLoopsSymJac(symJac, countLinearSys, countNonLinSys, countMixedSys, countJacobians);
(symJac2, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symjacs2) = countandIndexAlgebraicLoopsSymJac(symJac2, countLinearSys, countNonLinSys, countMixedSys, countJacobians);
(res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(rest, listAppend(symjacs2,listAppend(symjacs,inSymJacs)), countLinearSys, countNonLinSys, countMixedSys, countJacobians, SimCode.SES_LINEAR(SimCode.LINEARSYSTEM(index, partOfMixed, vars, beqs, simJac, eqs, SOME(symJac), sources, inLinearSysIndex), SOME(SimCode.LINEARSYSTEM(index2, partOfMixed2, vars2, beqs2, simJac2, eqs2, SOME(symJac2), sources2, inLinearSysIndex+1)))::inEqnsAcc, listAppend({symJac2, symJac}, inSymJacsAcc));
(res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians) = countandIndexAlgebraicLoopsWork(rest, listAppend(symjacs2,listAppend(symjacs,inSymJacs)), countLinearSys, countNonLinSys, countMixedSys, countJacobians, SimCode.SES_LINEAR(SimCode.LINEARSYSTEM(index, partOfMixed, vars, beqs, simJac, eqs, SOME(symJac), sources, inLinearSysIndex), SOME(SimCode.LINEARSYSTEM(index2, partOfMixed2, vars2, beqs2, simJac2, eqs2, SOME(symJac2), sources2, inLinearSysIndex+1)))::inEqnsAcc, symJac2::symJac::inSymJacsAcc);
then (res, symjacs, countLinearSys, countNonLinSys, countMixedSys, countJacobians);

case (SimCode.SES_MIXED(index, cont, discVars, discEqs, _)::rest, _, _, _, _, _, _, _)
Expand Down Expand Up @@ -1154,7 +1154,7 @@ algorithm
case ((eqns, vars, str)::rest, _, _, _, _, _) equation
(eqns1, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symJacs) = countandIndexAlgebraicLoops(eqns, inLinearSysIndex, inNonLinSysIndex, inMixedSysIndex, inJacobianIndex, inSymJacs);
(res1, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symJacs) = countandIndexAlgebraicLoopsSymJacColumn(rest, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symJacs);
result = listAppend({(eqns1, vars, str)},res1);
result = (eqns1, vars, str)::res1;
then (result, countLinearSys, countNonLinSys, countMixedSys, countJacobians, symJacs);
end match;
end countandIndexAlgebraicLoopsSymJacColumn;
Expand Down Expand Up @@ -4599,7 +4599,7 @@ algorithm
(equations_, uniqueEqIndex, tempvars) = createEquationsfromList(eqns, inVars, genDiscrete, iuniqueEqIndex, itempvars, ei);
ifbranch = ((condition, equations_));
(ifbranches, uniqueEqIndex, tempvars) = createEquationsIfBranch(conditionList, eqnsLst, inVars, shared, genDiscrete, uniqueEqIndex, tempvars);
ifbranches = listAppend({ifbranch}, ifbranches);
ifbranches = ifbranch::ifbranches;
then (ifbranches, uniqueEqIndex, tempvars);

else equation
Expand Down Expand Up @@ -11176,9 +11176,9 @@ protected
list<SimCode.SimEqSystem> odes;
algorithm
odes := listGet(simCodeOut.odeEquations, sysIdx);
odes := listAppend({simEqSys}, odes);
odes := simEqSys::odes;
simCodeOut.odeEquations := List.set(simCodeOut.odeEquations, sysIdx, odes);
simCodeOut.allEquations := listAppend({simEqSys}, simCodeOut.allEquations);
simCodeOut.allEquations := simEqSys::simCodeOut.allEquations;
end addSimEqSysToODEquations;

public function addSimEqSysToInitialEquations"adds the given simEqSys to both to the initialEquations"
Expand Down

0 comments on commit 8236a0d

Please sign in to comment.