Skip to content

Commit

Permalink
eliminate List.isNotEmpty() and List.first() (replaced by listEmpty()…
Browse files Browse the repository at this point in the history
… and listHead())

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25708 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Henning Kiel committed Apr 23, 2015
1 parent 045668a commit 7bf8847
Show file tree
Hide file tree
Showing 41 changed files with 227 additions and 241 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -818,15 +818,15 @@ algorithm
case (NONE(), NONE(), _, _, _)
equation
i = listLength(inNames);
s1 = listGet(inNames, 1);
s1 = listHead(inNames);
namee1 = Absyn.joinPaths(inPath, Absyn.IDENT(s1));
sn = listGet(inNames, i);
nameen = Absyn.joinPaths(inPath, Absyn.IDENT(sn));
then
DAEUtil.setMinMax(inVarAttr, SOME(DAE.ENUM_LITERAL(namee1, 1)), SOME(DAE.ENUM_LITERAL(nameen, i)));
case (NONE(), SOME(e), _, _, _)
equation
s1 = listGet(inNames, 1);
s1 = listHead(inNames);
namee1 = Absyn.joinPaths(inPath, Absyn.IDENT(s1));
then
DAEUtil.setMinMax(inVarAttr, SOME(DAE.ENUM_LITERAL(namee1, 1)), SOME(e));
Expand Down
12 changes: 6 additions & 6 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -1858,7 +1858,7 @@ algorithm
//BackendDump.dumpBackendDAEEqnList({eqn},"AN EQUATION",true);
//BackendDump.dumpEquationList({eqn},"");
(_,(numAdd,numMul,numDiv,numTrig,numRel,numLog,numOth,numFuncs)) = BackendEquation.traverseExpsOfEquation(eqn,function countOperationsExp(shared=ishared),(0,0,0,0,0,0,0,0));
compInfo = BackendDAE.COUNTER(List.first(inComps),numAdd,numMul,numDiv,numTrig,numRel,numLog,numOth,numFuncs);
compInfo = BackendDAE.COUNTER(listHead(inComps),numAdd,numMul,numDiv,numTrig,numRel,numLog,numOth,numFuncs);
if Flags.isSet(Flags.COUNT_OPERATIONS) then BackendDump.dumpCompInfo(compInfo); end if;
then countOperationstraverseComps(rest,isyst,ishared,compInfo::compInfosIn);

Expand All @@ -1867,7 +1867,7 @@ algorithm
eqn = BackendEquation.equationNth1(BackendEquation.getEqnsFromEqSystem(isyst), eqIdx);
//BackendDump.printEquation(eqn);
(_,(numAdd,numMul,numDiv,numTrig,numRel,numLog,numOth,numFuncs)) = BackendEquation.traverseExpsOfEquation(eqn,function countOperationsExp(shared=ishared),(0,0,0,0,0,0,0,0));
compInfo = BackendDAE.COUNTER(List.first(inComps),numAdd,numMul,numDiv,numTrig,numRel,numLog+1,numOth,numFuncs);
compInfo = BackendDAE.COUNTER(listHead(inComps),numAdd,numMul,numDiv,numTrig,numRel,numLog+1,numOth,numFuncs);
if Flags.isSet(Flags.COUNT_OPERATIONS) then BackendDump.dumpCompInfo(compInfo); end if;
then countOperationstraverseComps(rest,isyst,ishared,compInfo::compInfosIn);

Expand Down Expand Up @@ -1926,7 +1926,7 @@ algorithm

case (BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(tearingvars=vlst, residualequations=tornEqs, otherEqnVarTpl= eqnvartpllst), linear = true)::rest,_,BackendDAE.SHARED(functionTree=funcs),_)
equation
comp = List.first(inComps);
comp = listHead(inComps);
eqns = BackendEquation.getEqnsFromEqSystem(isyst);
vars = BackendVariable.daeVars(isyst);
// the torn equations
Expand All @@ -1948,7 +1948,7 @@ algorithm
countOperationstraverseComps(rest,isyst,ishared,compInfo::compInfosIn);
case (BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(residualequations=tornEqs, otherEqnVarTpl= eqnvartpllst), linear = false)::rest,_,BackendDAE.SHARED(),_)
equation
comp = List.first(inComps);
comp = listHead(inComps);
eqns = BackendEquation.getEqnsFromEqSystem(isyst);
_ = BackendVariable.daeVars(isyst);
// the torn equations
Expand Down Expand Up @@ -2871,7 +2871,7 @@ algorithm
tbsRest = List.map(tbs,List.rest);
rest_res = makeResidualIfExpLst(conds, tbsRest, fbs);

tbsFirst = List.map(tbs,List.first);
tbsFirst = List.map(tbs,listHead);

ifexp = Expression.makeNestedIf(conds,tbsFirst,fb);
then
Expand Down Expand Up @@ -2955,7 +2955,7 @@ algorithm
tbsRest = List.map(inExpLst2, List.rest);
rest_res = makeEquationsFromResiduals(inExp1, tbsRest, fbs, inSource, inEqAttr);

tbsFirst = List.map(inExpLst2, List.first);
tbsFirst = List.map(inExpLst2, listHead);

ifexp = Expression.makeNestedIf(inExp1,tbsFirst,fb);
eq = BackendDAE.EQUATION(DAE.RCONST(0.0), ifexp, inSource, inEqAttr);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/BackendDAETransform.mo
Expand Up @@ -479,7 +479,7 @@ algorithm
case (BackendDAE.EQUATIONSYSTEM(eqns=elst, vars=vlst), eqns, vars) equation
eqnlst = BackendEquation.getEqns(elst, eqns);
varlst = List.map1r(vlst, BackendVariable.getVarAt, vars);
e = List.first(elst);
e = listHead(elst);
then (eqnlst, varlst, e);

case (BackendDAE.SINGLEARRAY(eqn=e, vars=vlst), eqns, vars) equation
Expand Down Expand Up @@ -514,7 +514,7 @@ algorithm
varlst1 = List.map1r(List.flatten(List.map(eqnvartpllst, Util.tuple22)), BackendVariable.getVarAt, vars);
eqnlst = listAppend(eqnlst, eqnlst1);
varlst = listAppend(varlst, varlst1);
e = List.first(elst);
e = listHead(elst);
then (eqnlst, varlst, e);

else equation
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -3701,7 +3701,7 @@ algorithm
_ = BackendEquation.equationSize(eqn);
(row,_) = incidenceRow(eqn,vars,inIndxType,functionTree,{});
scalarindxs = iMapEqnIncRow[abse];
oldvars = getOldVars(m,listGet(scalarindxs,1));
oldvars = getOldVars(m,listHead(scalarindxs));
(_,outvars,invars) = List.intersection1OnTrue(oldvars,row,intEq);
// do the same for each scalar indxs
m_1 = List.fold1r(scalarindxs,arrayUpdate,row,m);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -2352,7 +2352,7 @@ algorithm
subslst = Expression.dimensionSizesSubscripts(ds);
subslst = Expression.rangesToSubscripts(subslst);
elst1 = List.map1r(subslst,Expression.applyExpSubscripts,rhs);
e = listGet(elst1,1);
e = listHead(elst1);
tp = Expression.typeof(e);
statementLst = List.threadFold2(elst,elst1,validLhsAssignSTMT,tp,source,inStatementLst);
then
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Causalize.mo
Expand Up @@ -252,7 +252,7 @@ algorithm
vars := Matching.getUnassigned(n, inAssignments2, {});
vars := List.fold1(unmatched,getAssignedVars,inAssignments1,vars);
var_str := BackendDump.dumpMarkedVars(isyst, vars);
source := BackendEquation.markedEquationSource(isyst, listGet(unmatched1,1));
source := BackendEquation.markedEquationSource(isyst, listHead(unmatched1));
info := DAEUtil.getElementSourceFileInfo(source);

Error.addSourceMessage(if BackendDAEUtil.isInitializationDAE(ishared) then Error.STRUCTURAL_SINGULAR_INITIAL_SYSTEM else Error.STRUCT_SINGULAR_SYSTEM, {eqn_str,var_str}, info);
Expand Down

0 comments on commit 7bf8847

Please sign in to comment.