Skip to content

Commit

Permalink
- Moved list functions from Util to a new List package.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9908 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Sep 23, 2011
1 parent f645074 commit c3a0e9e
Show file tree
Hide file tree
Showing 86 changed files with 9,038 additions and 9,266 deletions.
233 changes: 117 additions & 116 deletions Compiler/BackEnd/BackendDAECreate.mo

Large diffs are not rendered by default.

235 changes: 117 additions & 118 deletions Compiler/BackEnd/BackendDAEOptimize.mo

Large diffs are not rendered by default.

209 changes: 105 additions & 104 deletions Compiler/BackEnd/BackendDAETransform.mo

Large diffs are not rendered by default.

185 changes: 93 additions & 92 deletions Compiler/BackEnd/BackendDAEUtil.mo

Large diffs are not rendered by default.

65 changes: 33 additions & 32 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -54,6 +54,7 @@ protected import Error;
protected import Expression;
protected import ExpressionDump;
protected import IOStream;
protected import List;
protected import SCode;
protected import Util;

Expand Down Expand Up @@ -121,7 +122,7 @@ algorithm
equation
fs = Absyn.pathString(fcn);
argstr = Util.stringDelimitList(
Util.listMap3(args, ExpressionDump.printExp2Str, stringDelimiter,opcreffunc, SOME(printCallFunction2StrDIVISION)), ",");
List.map3(args, ExpressionDump.printExp2Str, stringDelimiter,opcreffunc, SOME(printCallFunction2StrDIVISION)), ",");
s = stringAppend(fs, "(");
s_1 = stringAppend(s, argstr);
s_2 = stringAppend(s_1, ")");
Expand Down Expand Up @@ -355,11 +356,11 @@ algorithm
String str_r_f,str_r_1,str_t_f,str_t_1,str,sr,st;
case (residualeqns::r,tearingvars::t)
equation
str_r = Util.listMap(residualeqns, intString);
str_r = List.map(residualeqns, intString);
str_r_f = Util.stringDelimitList(str_r, ", ");
str_r_1 = stringAppend(str_r_f, "\n");
sr = stringAppend("ResidualEqns: ",str_r_1);
str_t = Util.listMap(tearingvars, intString);
str_t = List.map(tearingvars, intString);
str_t_f = Util.stringDelimitList(str_t, ", ");
str_t_1 = stringAppend(str_t_f, "\n");
st = stringAppend("TearingVars: ",str_t_1);
Expand Down Expand Up @@ -453,7 +454,7 @@ algorithm
equation
dumpBackendDAEEqnList2(res,printExpTree);
print("ARRAY_EQUATION: ");
strList = Util.listMap(expList,ExpressionDump.printExpStr);
strList = List.map(expList,ExpressionDump.printExpStr);
str = Util.stringDelimitList(strList," | ");
print(str);
print("\n");
Expand All @@ -463,11 +464,11 @@ algorithm
equation
dumpBackendDAEEqnList2(res,printExpTree);
print("ALGORITHM: ");
strList = Util.listMap(expList,ExpressionDump.printExpStr);
strList = List.map(expList,ExpressionDump.printExpStr);
str = Util.stringDelimitList(strList," | ");
print(str);
print("\n");
strList = Util.listMap(expList2,ExpressionDump.printExpStr);
strList = List.map(expList2,ExpressionDump.printExpStr);
str = Util.stringDelimitList(strList," | ");
print(str);
print("\n");
Expand Down Expand Up @@ -527,9 +528,9 @@ algorithm
list<BackendDAE.Value> eq,wc;
case BackendDAE.ZERO_CROSSING(relation_ = e as DAE.RELATION(index=index_),occurEquLst = eq,occurWhenLst = wc)
equation
eq_s_list = Util.listMap(eq, intString);
eq_s_list = List.map(eq, intString);
eq_s = Util.stringDelimitList(eq_s_list, ",");
wc_s_list = Util.listMap(wc, intString);
wc_s_list = List.map(wc, intString);
wc_s = Util.stringDelimitList(wc_s_list, ",");
str = ExpressionDump.printExpStr(e);
str_index=intString(index_);
Expand All @@ -556,15 +557,15 @@ algorithm
case BackendDAE.WHEN_CLAUSE(condition = c,reinitStmtLst = reinitStmtLst,elseClause = SOME(i))
equation
sc = ExpressionDump.printExpStr(c);
s1 = Util.stringDelimitList(Util.listMap(reinitStmtLst,dumpWhenOperatorStr)," ");
s1 = Util.stringDelimitList(List.map(reinitStmtLst,dumpWhenOperatorStr)," ");
si = intString(i);
str = stringAppendList({" whenclause = ",sc," then ",s1," else whenclause",si});
then
str;
case BackendDAE.WHEN_CLAUSE(condition = c,reinitStmtLst = reinitStmtLst,elseClause = NONE())
equation
sc = ExpressionDump.printExpStr(c);
s1 = Util.stringDelimitList(Util.listMap(reinitStmtLst,dumpWhenOperatorStr)," ");
s1 = Util.stringDelimitList(List.map(reinitStmtLst,dumpWhenOperatorStr)," ");
str = stringAppendList({" whenclause = ",sc," then ",s1});
then
str;
Expand Down Expand Up @@ -694,13 +695,13 @@ algorithm
dumpEqns(ieqnsl);
print("Zero Crossings :\n");
print("===============\n");
ss = Util.listMap(zc, dumpZcStr);
ss = List.map(zc, dumpZcStr);
s = Util.stringDelimitList(ss, ",\n");
print(s);
print("\n");
print("When Clauses :\n");
print("===============\n");
ss = Util.listMap(wc, dumpWcStr);
ss = List.map(wc, dumpWcStr);
s = Util.stringDelimitList(ss, ",\n");
print(s);
print("\n");
Expand Down Expand Up @@ -948,7 +949,7 @@ algorithm
case (BackendDAE.ARRAY_EQUATION(index = indx,crefOrDerCref = expl))
equation
indx_str = intString(indx);
var_str=Util.stringDelimitList(Util.listMap(expl,ExpressionDump.printExpStr),", ");
var_str=Util.stringDelimitList(List.map(expl,ExpressionDump.printExpStr),", ");
res = stringAppendList({"Array eqn no: ",indx_str," for variables: ",var_str /*,"\n"*/});
then
res;
Expand Down Expand Up @@ -986,8 +987,8 @@ algorithm
case (BackendDAE.ALGORITHM(index = i, in_ = inps, out = outs))
equation
is = intString(i);
intsStr = Util.stringDelimitList(Util.listMap(inps, ExpressionDump.printExpStr), ", ");
outsStr = Util.stringDelimitList(Util.listMap(outs, ExpressionDump.printExpStr), ", ");
intsStr = Util.stringDelimitList(List.map(inps, ExpressionDump.printExpStr), ", ");
outsStr = Util.stringDelimitList(List.map(outs, ExpressionDump.printExpStr), ", ");
res = stringAppendList({"Algorithm no: ", is, " for inputs: (",
intsStr, ") => outputs: (",
outsStr, ")" /*,"\n"*/});
Expand Down Expand Up @@ -1017,7 +1018,7 @@ algorithm
print("\n extends ExternalObject;");
print("\n origin: ");
paths = DAEUtil.getElementSourceTypes(source);
paths_lst = Util.listMap(paths, Absyn.pathString);
paths_lst = List.map(paths, Absyn.pathString);
path_str = Util.stringDelimitList(paths_lst, ", ");
print(path_str +& "\n");
print("end ");print(Absyn.pathString(path));
Expand Down Expand Up @@ -1087,7 +1088,7 @@ algorithm
dumpKind(kind);
dumpAttributes(dae_var_attr);
paths = DAEUtil.getElementSourceTypes(source);
paths_lst = Util.listMap(paths, Absyn.pathString);
paths_lst = List.map(paths, Absyn.pathString);
path_str = Util.stringDelimitList(paths_lst, ", ");
comment_str = DAEDump.dumpCommentOptionStr(comment);
print(" = ");
Expand Down Expand Up @@ -1128,7 +1129,7 @@ algorithm
print(" ");
str = ComponentReference.printComponentRefStr(cr);
paths = DAEUtil.getElementSourceTypes(source);
path_strs = Util.listMap(paths, Absyn.pathString);
path_strs = List.map(paths, Absyn.pathString);
path_str = Util.stringDelimitList(path_strs, ", ");
comment_str = DAEDump.dumpCommentOptionStr(comment);
print(str);
Expand Down Expand Up @@ -1546,9 +1547,9 @@ algorithm
case(i,n,m,mT,ass1,ass2)
equation
eqns = BackendDAETransform.reachableNodes(i, m, mT, ass1, ass2);
llst = Util.listMap(eqns,Util.listCreate);
llst = Util.listMap1(llst,Util.listCons,i);
slst = Util.listMap(llst,intListStr);
llst = List.map(eqns,List.create);
llst = List.map1(llst, List.consr, i);
slst = List.map(llst,intListStr);
str = Util.stringDelimitList(slst,",");
str = stringAppendList({"{",str,"}"});
strLst = dumpComponentsGraphStr2(i+1,n,m,mT,ass1,ass2);
Expand All @@ -1566,7 +1567,7 @@ public function dumpList "function: dumpList
list<String> s;
String sl;
algorithm
s := Util.listMap(l, intString);
s := List.map(l, intString);
sl := Util.stringDelimitList(s, ", ");
print(str);
print(sl);
Expand Down Expand Up @@ -1605,7 +1606,7 @@ algorithm
case ((l :: lst),i)
equation
print("{");
ls = Util.listMap(l, intString);
ls = List.map(l, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("}\n");
Expand All @@ -1620,7 +1621,7 @@ protected function intListStr "Takes a list of Integers and produces a string o
input list<Integer> lst;
output String res;
algorithm
res := Util.stringDelimitList(Util.listMap(lst,intString),",");
res := Util.stringDelimitList(List.map(lst,intString),",");
res := stringAppendList({"{",res,"}"});
end intListStr;

Expand Down Expand Up @@ -1769,7 +1770,7 @@ algorithm
case ((l :: lst),i,v2,vars)
equation
print("{");
ls = Util.listMap(l, intString);
ls = List.map(l, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("} ");
Expand Down Expand Up @@ -1839,7 +1840,7 @@ public function dumpComponents
algorithm
print("StrongComponents\n");
print("=======\n");
Util.listMap0(inComps,dumpComponent);
List.map_0(inComps,dumpComponent);
end dumpComponents;

public function dumpComponent
Expand All @@ -1865,11 +1866,11 @@ algorithm
case BackendDAE.EQUATIONSYSTEM(eqns=ilst,vars=vlst,jacType=jacType)
equation
print("{");
ls = Util.listMap(ilst, intString);
ls = List.map(ilst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print(":");
ls = Util.listMap(vlst, intString);
ls = List.map(vlst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("} Size: ");
Expand All @@ -1882,11 +1883,11 @@ algorithm
case BackendDAE.MIXEDEQUATIONSYSTEM(condSystem=comp,disc_eqns=ilst,disc_vars=vlst)
equation
print("{{");
ls = Util.listMap(ilst, intString);
ls = List.map(ilst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print(":");
ls = Util.listMap(vlst, intString);
ls = List.map(vlst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("},\n");
Expand All @@ -1901,7 +1902,7 @@ algorithm
print("Array ");
print(intString(i));
print(" {");
ls = Util.listMap(vlst, intString);
ls = List.map(vlst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("}\n");
Expand All @@ -1912,7 +1913,7 @@ algorithm
print("Algorithm ");
print(intString(i));
print(" {");
ls = Util.listMap(vlst, intString);
ls = List.map(vlst, intString);
s = Util.stringDelimitList(ls, ", ");
print(s);
print("}\n");
Expand Down
17 changes: 9 additions & 8 deletions Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -52,6 +52,7 @@ protected import Debug;
protected import Error;
protected import Expression;
protected import ExpressionSimplify;
protected import List;
protected import Util;

public function getWhenEquationExpr
Expand Down Expand Up @@ -208,7 +209,7 @@ algorithm
// Special Case for Records
case ((e as DAE.CREF(componentRef = cr,ty= DAE.ET_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(_))),(vars,vars1)))
equation
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr);
expl = List.map1(varLst,Expression.generateCrefsExpFromExpVar,cr);
((_,(vars,vars1))) = Expression.traverseExpList(expl,checkEquationsVarsExp,(vars,vars1));
then
((e, (vars,vars1)));
Expand Down Expand Up @@ -290,7 +291,7 @@ algorithm
case((e as DAE.CREF(componentRef=cr), (crefs,vars)))
equation
true = BackendVariable.isState(cr,vars);
crefs = Util.listUnionEltOnTrue(cr,crefs,ComponentReference.crefEqual);
crefs = List.unionEltOnTrue(cr,crefs,ComponentReference.crefEqual);
then
((e, (crefs,vars) ));

Expand Down Expand Up @@ -934,7 +935,7 @@ public function addEquations "function: addEquations
input BackendDAE.EquationArray eqns;
output BackendDAE.EquationArray eqns_1;
algorithm
eqns_1 := Util.listFold(eqnlst, equationAdd, eqns);
eqns_1 := List.fold(eqnlst, equationAdd, eqns);
end addEquations;

public function equationAdd "function: equationAdd
Expand Down Expand Up @@ -1062,8 +1063,8 @@ public function getEqns "function: getEqns
protected
list<BackendDAE.Value> indxs;
algorithm
indxs := Util.listMap1(inIndxes, intSub, 1);
outEqns := Util.listMap1r(indxs, BackendDAEUtil.equationNth, inEquationArray);
indxs := List.map1(inIndxes, intSub, 1);
outEqns := List.map1r(indxs, BackendDAEUtil.equationNth, inEquationArray);
end getEqns;

public function equationDelete "function: equationDelete
Expand All @@ -1082,7 +1083,7 @@ algorithm
case (inEquationArray,inIntLst)
equation
eqnlst = BackendDAEUtil.equationList(inEquationArray);
eqnlst1 = Util.listDeletePositions(eqnlst,inIntLst);
eqnlst1 = List.deletePositions(eqnlst,inIntLst);
outEquationArray = BackendDAEUtil.listEquation(eqnlst1);
then
outEquationArray;
Expand Down Expand Up @@ -1174,7 +1175,7 @@ algorithm
equation
BackendDAE.MULTIDIM_EQUATION(dimSize=ds,left=e1, right=e2) = arrayEqs[index+1];
new_exp = Expression.expSub(e1,e2);
ad = Util.listMap(ds,Util.makeOption);
ad = List.map(ds,Util.makeOption);
(subs,entrylst1) = BackendDAEUtil.getArrayEquationSub(index,ad,entrylst);
new_exp1 = Expression.applyExpSubscripts(new_exp,subs);
rhs_exp = BackendDAEUtil.getEqnsysRhsExp(new_exp1, v);
Expand Down Expand Up @@ -1232,7 +1233,7 @@ algorithm
Integer indx;
case ((eqn as BackendDAE.ALGORITHM(index=indx),(indexes,algarr,algs)))
equation
false = Util.listMemberWithCompareFunc(indx,indexes,intEq);
false = List.isMemberOnTrue(indx,indexes,intEq);
alg = algarr[indx + 1];
then
((eqn,(indx::indexes,algarr,alg::algs)));
Expand Down

0 comments on commit c3a0e9e

Please sign in to comment.