Skip to content

Commit

Permalink
- Ceval now handles custom reductions (including guard-expressions)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8186 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 11, 2011
1 parent 4a1885d commit b1529ce
Show file tree
Hide file tree
Showing 17 changed files with 330 additions and 268 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -222,7 +222,7 @@ algorithm
((e, (vars1,crefs1)));

// case for Reductions
case ((e as DAE.REDUCTION(ident = ident),(vars,crefs)))
case ((e as DAE.REDUCTION(reductionInfo = DAE.REDUCTIONINFO(ident = ident)),(vars,crefs)))
equation
// add ident to vars
cr = ComponentReference.makeCrefIdent(ident,DAE.ET_INT(),{});
Expand Down
10 changes: 6 additions & 4 deletions Compiler/BackEnd/Derive.mo
Expand Up @@ -353,6 +353,7 @@ algorithm
Option<DAE.Exp> guardExp,foldExp;
Option<Values.Value> v;
list<DAE.ExpVar> varLst;
DAE.ReductionInfo reductionInfo;

case (DAE.ICONST(integer = _),_) then DAE.RCONST(0.0);
case (DAE.RCONST(real = _),_) then DAE.RCONST(0.0);
Expand Down Expand Up @@ -716,12 +717,12 @@ algorithm
then
Expression.makeASUB(e,sub);

case (DAE.REDUCTION(path = a,expr = e1,ident = str,guardExp = guardExp,range = e2,defaultValue = v,foldExp = foldExp),(timevars,functions))
case (DAE.REDUCTION(reductionInfo = reductionInfo,expr = e1,guardExp = guardExp,range = e2),(timevars,functions))
equation
e1_1 = differentiateExpTime(e1, (timevars,functions));
e2_1 = differentiateExpTime(e2, (timevars,functions));
then
DAE.REDUCTION(a,e1_1,str,guardExp,e2_1,v,foldExp);
DAE.REDUCTION(reductionInfo,e1_1,guardExp,e2_1);

case (e,_)
equation
Expand Down Expand Up @@ -1219,6 +1220,7 @@ algorithm
list<Boolean> bLst;
Option<DAE.Exp> guardExp,foldExp;
Option<Values.Value> v;
DAE.ReductionInfo reductionInfo;

case (DAE.ICONST(integer = _),_,_) then DAE.RCONST(0.0);

Expand Down Expand Up @@ -1427,12 +1429,12 @@ algorithm
then
Expression.makeASUB(e_1,sub);

case (DAE.REDUCTION(path = a,expr = e1,ident = str,guardExp = guardExp, range = e2, defaultValue = v, foldExp = foldExp),tv,differentiateIfExp)
case (DAE.REDUCTION(reductionInfo=reductionInfo,expr = e1,guardExp = guardExp, range = e2),tv,differentiateIfExp)
equation
e1_1 = differentiateExp(e1, tv, differentiateIfExp);
e2_1 = differentiateExp(e2, tv, differentiateIfExp);
then
DAE.REDUCTION(a,e1_1,str,guardExp,e2_1,v,foldExp);
DAE.REDUCTION(reductionInfo,e1_1,guardExp,e2_1);

// derivative of arbitrary function, not dependent of variable, i.e. constant
/* Caught by rule below...
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/TaskGraph.mo
Expand Up @@ -996,7 +996,7 @@ algorithm
print("TaskGraph.buildExpression(CODE) not impl. yet\n");
then
fail();
case (DAE.REDUCTION(path = _))
case (DAE.REDUCTION(expr = _))
equation
print("TaskGraph.buildExpression(REDUCTION) not impl. yet\n");
then
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/XMLDump.mo
Expand Up @@ -1867,7 +1867,7 @@ algorithm
equation
// NOT PART OF THE MODELICA LANGUAGE
then ();
case (DAE.REDUCTION(path = fcn,expr = exp,ident = id,range = iterexp))
case (DAE.REDUCTION(expr = _))
equation
// NOT PART OF THE MODELICA LANGUAGE
then ();
Expand Down

0 comments on commit b1529ce

Please sign in to comment.