Skip to content

Commit

Permalink
- delete BackendDAEUTil.daeEqns use BackendEquation.daeEqns
Browse files Browse the repository at this point in the history
- delete Expression.getCrefFromExp use Expression.extractCrefsFromExp
- SimCode.mo fix Warnings (local Declarations)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8427 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Mar 31, 2011
1 parent 34063dc commit d30077e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 174 deletions.
11 changes: 0 additions & 11 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -5997,15 +5997,4 @@ algorithm
end matchcontinue;
end selectOptModules1;

public function daeEqns
input BackendDAE.BackendDAE inDAELow;
output BackendDAE.EquationArray inEquationArray;
algorithm
inEquationArray := matchcontinue (inDAELow)
local BackendDAE.EquationArray eq;
case (BackendDAE.DAE(orderedEqs=eq))
then eq;
end matchcontinue;
end daeEqns;

end BackendDAEUtil;
13 changes: 5 additions & 8 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -10461,7 +10461,7 @@ algorithm outOrder := matchcontinue(inDlow)
equation

dovars = BackendVariable.daeVars(inDlow);
deqns = BackendDAEUtil.daeEqns(inDlow);
deqns = BackendEquation.daeEqns(inDlow);
vars = BackendDAEUtil.varList(dovars);
eqns = BackendDAEUtil.equationList(deqns);
derExps = makeCallDerExp(vars);
Expand Down Expand Up @@ -10530,7 +10530,6 @@ algorithm oeqns := matchcontinue(eqns, dlow)
rec;

case(eq::rest,dlow)
local String str;
equation
// str = BackendDAE.equationStr(eq);
Debug.fcall("cppvar",print," FAILURE IN flattenEqns possible unsupported equation...\n" /*+& str*/);
Expand Down Expand Up @@ -10686,14 +10685,14 @@ algorithm (oi,firstOrderDers) := matchcontinue(inDer,inEqns)
case(inDer,(BackendDAE.EQUATION(e1,e2,_)::rest))
equation
true = Expression.expEqual(inDer,e1);
{cr} = Expression.getCrefFromExp(e1);
{cr} = Expression.extractCrefsFromExp(e1);
Debug.fcall("cppvar",print, " found derivative for " +& ExpressionDump.printExpStr(inDer) +& " in equation " +& ExpressionDump.printExpStr(e1) +& " = " +& ExpressionDump.printExpStr(e2) +& "\n");
then
(1,{cr});
case(inDer,(BackendDAE.EQUATION(e1,e2,_)::rest))
equation
true = Expression.expEqual(inDer,e2);
{cr} = Expression.getCrefFromExp(e2);
{cr} = Expression.extractCrefsFromExp(e2);
Debug.fcall("cppvar",print, " found derivative for " +& ExpressionDump.printExpStr(inDer) +& " in equation " +& ExpressionDump.printExpStr(e1) +& " = " +& ExpressionDump.printExpStr(e2) +& "\n");
then
(1,{cr});
Expand Down Expand Up @@ -10807,7 +10806,6 @@ algorithm (new_index) := matchcontinue(var,odered_vars)
then
(i);
case(var,_::rest)
local Integer i;
equation

(i)=stateindex(var,rest);
Expand Down Expand Up @@ -10997,11 +10995,10 @@ algorithm out_varinfo_lst := matchcontinue(in_varinfo_lst)
list<SimVar> rest,dv_list;
SimVar v;
SimVar dv;
Integer var_index;
String s;
case({}) then {};
case( v::rest )
local
Integer var_index;
String s;
equation
dv = generateDerStates2(v);
// s= dumpVarInfo(dv);
Expand Down
155 changes: 0 additions & 155 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -6656,160 +6656,5 @@ algorithm
end match;
end traverseReductionIterators;


public function getCrefFromExp
"function: getCrefFromExp
Return a list of all component
references occuring in the expression."
input Exp inExp;
output list<ComponentRef> outComponentRefLst;
algorithm
outComponentRefLst:=
matchcontinue (inExp)
local
ComponentRef cr;
list<ComponentRef> l1,l2,res,res1,l3,res2;
Exp e1,e2,e3,e;
Operator op;
list<Exp> farg,expl,expl_2;
list<tuple<Exp, Boolean>> expl_1;
case (DAE.ICONST(integer = _)) then {};
case (DAE.RCONST(real = _)) then {};
case (DAE.SCONST(string = _)) then {};
case (DAE.BCONST(bool = _)) then {};
case (DAE.CREF(componentRef = cr)) then {cr};
case (DAE.BINARY(exp1 = e1,operator = op,exp2 = e2))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res = listAppend(l1, l2);
then
res;
case (DAE.UNARY(operator = op,exp = e1))
equation
res = getCrefFromExp(e1);
then
res;
case (DAE.LBINARY(exp1 = e1,operator = op,exp2 = e2))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res = listAppend(l1, l2);
then
res;
case (DAE.LUNARY(operator = op,exp = e1))
equation
res = getCrefFromExp(e1);
then
res;
case (DAE.RELATION(exp1 = e1,operator = op,exp2 = e2))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res = listAppend(l1, l2);
then
res;
case (DAE.IFEXP(expCond = e1,expThen = e2,expElse = e3))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res1 = listAppend(l1, l2);
l3 = getCrefFromExp(e3);
res = listAppend(res1, l3);
then
res;
case (DAE.CALL(expLst = farg))
local list<list<ComponentRef>> res;
equation
res = Util.listMap(farg, getCrefFromExp);
res2 = Util.listFlatten(res);
then
res2;
case(DAE.PARTEVALFUNCTION(expList = farg))
local list<list<ComponentRef>> res;
equation
res = Util.listMap(farg, getCrefFromExp);
res2 = Util.listFlatten(res);
then
res2;
case (DAE.ARRAY(array = expl))
local list<list<ComponentRef>> res1;
equation
res1 = Util.listMap(expl, getCrefFromExp);
res = Util.listFlatten(res1);
then
res;
case (DAE.MATRIX(scalar = expl))
local
list<list<ComponentRef>> res1;
list<list<tuple<Exp, Boolean>>> expl;
equation
expl_1 = Util.listFlatten(expl);
expl_2 = Util.listMap(expl_1, Util.tuple21);
res1 = Util.listMap(expl_2, getCrefFromExp);
res = Util.listFlatten(res1);
then
res;
case (DAE.RANGE(exp = e1,expOption = SOME(e3),range = e2))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res1 = listAppend(l1, l2);
l3 = getCrefFromExp(e3);
res = listAppend(res1, l3);
then
res;
case (DAE.RANGE(exp = e1,expOption = NONE(),range = e2))
equation
l1 = getCrefFromExp(e1);
l2 = getCrefFromExp(e2);
res = listAppend(l1, l2);
then
res;
case (DAE.TUPLE(PR = expl))
equation
//Print.printBuf("Exp.getCrefFromExp(Exp.DAE.TUPLE(...)): Not implemented yet\n");
then
{};
case (DAE.CAST(exp = e))
equation
res = getCrefFromExp(e);
then
res;
case (DAE.ASUB(exp = e))
equation
res = getCrefFromExp(e);
then
res;

/* MetaModelica list */
case (DAE.CONS(e1,e2))
local list<list<ComponentRef>> res;
equation
expl = {e1,e2};
res = Util.listMap(expl, getCrefFromExp);
res2 = Util.listFlatten(res);
then res2;

case (DAE.LIST(expl))
local list<list<ComponentRef>> res;
equation
res = Util.listMap(expl, getCrefFromExp);
res2 = Util.listFlatten(res);
then res2;

/* case (METADAE.TUPLE(expl))
local list<list<ComponentRef>> res;
equation
res = Util.listMap(expl, getCrefFromExp);
res2 = Util.listFlatten(res);
then res2; */
/* --------------------- */

case (_) then {};
end matchcontinue;

end getCrefFromExp;

end Expression;

0 comments on commit d30077e

Please sign in to comment.