Skip to content

Commit

Permalink
- BackendDump.mo
Browse files Browse the repository at this point in the history
  - fix bugs (BackendDAE.Variables to Variables and remove newline for zero crossings)
- BackendDAEUtil.mo
  - use traverseExpTopDown for isDiscreteExp, statesEqns, incidenceRow
  - delete unused function incidenceRowStmts
- BackendDAECreate.mo
  - delete function expandDerOperatorStmts and use DAEUtil.traverseDAEEquationsStmts

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6886 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Nov 4, 2010
1 parent 7b43eea commit 276fd18
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 781 deletions.
119 changes: 1 addition & 118 deletions Compiler/BackendDAECreate.mo
Expand Up @@ -2439,128 +2439,11 @@ algorithm
(outAlg,outVars) := matchcontinue(alg,vars)
local list<Algorithm.Statement> stmts;
case(DAE.ALGORITHM_STMTS(stmts),vars) equation
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
(stmts,vars) = DAEUtil.traverseDAEEquationsStmts(stmts,expandDerExp,vars);
then (DAE.ALGORITHM_STMTS(stmts),vars);
end matchcontinue;
end expandDerOperatorAlg;

protected function expandDerOperatorStmts
"Help function to expandDerOperatorAlg"
input list<Algorithm.Statement> stmts;
input tuple<BackendDAE.Variables,DAE.FunctionTree> vars;
output list<Algorithm.Statement> outStmts;
output tuple<BackendDAE.Variables,DAE.FunctionTree> outVars;
algorithm
(outStmts,outVars) := matchcontinue(stmts,vars)
local Algorithm.Statement s;
case({},vars) then ({},vars);
case(s::stmts,vars) equation
(s,vars) = expandDerOperatorStmt(s,vars);
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
then (s::stmts,vars);
end matchcontinue;
end expandDerOperatorStmts;

protected function expandDerOperatorStmt
"Help function to expandDerOperatorAlg."
input Algorithm.Statement stmt;
input tuple<BackendDAE.Variables,DAE.FunctionTree> vars;
output Algorithm.Statement outStmt;
output tuple<BackendDAE.Variables,DAE.FunctionTree> outVars;
algorithm
(outStmt,outVars) := matchcontinue(stmt,vars)
local DAE.ExpType tp; DAE.ComponentRef cr;
list<DAE.Exp> expl;
Algorithm.Ident id; Boolean b;
list<Algorithm.Statement> stmts;
list<Integer> hv;
Algorithm.Statement stmt;
DAE.Exp e1,e2;
Algorithm.Else elseB;
DAE.ElementSource source;

case(DAE.STMT_ASSIGN(tp,e2,e1,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
((e2,vars)) = Expression.traverseExp(e2,expandDerExp,vars);
then (DAE.STMT_ASSIGN(tp,e2,e1,source),vars);

case(DAE.STMT_TUPLE_ASSIGN(tp,expl,e1,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
(expl,vars) = expandDerExps(expl,vars);
then (DAE.STMT_TUPLE_ASSIGN(tp,expl,e1,source),vars);

case(DAE.STMT_ASSIGN_ARR(tp,cr,e1,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_ASSIGN_ARR(tp,cr,e1,source),vars);

case(DAE.STMT_IF(e1,stmts,elseB,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
(elseB,vars) = expandDerOperatorElseBranch(elseB,vars);
then (DAE.STMT_IF(e1,stmts,elseB,source),vars);

case(DAE.STMT_FOR(tp,b,id,e1,stmts,source),vars) equation
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_FOR(tp,b,id,e1,stmts,source),vars);

case(DAE.STMT_WHILE(e1,stmts,source),vars) equation
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_WHILE(e1,stmts,source),vars);

case(DAE.STMT_WHEN(e1,stmts,SOME(stmt),hv,source),vars) equation
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
(stmt,vars) = expandDerOperatorStmt(stmt,vars);
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_WHEN(e1,stmts,SOME(stmt),hv,source),vars);

case(DAE.STMT_WHEN(e1,stmts,NONE(),hv,source),vars) equation
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_WHEN(e1,stmts,NONE(),hv,source),vars);

case(DAE.STMT_ASSERT(e1,e2,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
((e2,vars)) = Expression.traverseExp(e2,expandDerExp,vars);
then (DAE.STMT_ASSERT(e1,e2,source),vars);

case(DAE.STMT_TERMINATE(e1,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
then (DAE.STMT_TERMINATE(e1,source),vars);

case(DAE.STMT_REINIT(e1,e2,source),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
((e2,vars)) = Expression.traverseExp(e2,expandDerExp,vars);
then (DAE.STMT_REINIT(e1,e2,source),vars);

case(stmt,vars) then (stmt,vars);

end matchcontinue;
end expandDerOperatorStmt;

protected function expandDerOperatorElseBranch
"Help function to expandDerOperatorStmt, for else branches in if statements"
input Algorithm.Else elseB;
input tuple<BackendDAE.Variables,DAE.FunctionTree> vars;
output Algorithm.Else outElseB;
output tuple<BackendDAE.Variables,DAE.FunctionTree> outVars;
algorithm
(outElseB,outVars) := matchcontinue(elseB,vars)
local DAE.Exp e1;
list<Algorithm.Statement> stmts;
Algorithm.Else elseB;

case(DAE.NOELSE(),vars) then (DAE.NOELSE(),vars);

case(DAE.ELSEIF(e1,stmts,elseB),vars) equation
((e1,vars)) = Expression.traverseExp(e1,expandDerExp,vars);
(stmts,vars) = expandDerOperatorStmts(stmts,vars);
(elseB,vars) = expandDerOperatorElseBranch(elseB,vars);
then (DAE.ELSEIF(e1,stmts,elseB),vars);
end matchcontinue;
end expandDerOperatorElseBranch;

protected function expandDerOperatorArrEqns
"Help function to expandDerOperator"
input list<BackendDAE.MultiDimEquation> eqns;
Expand Down

0 comments on commit 276fd18

Please sign in to comment.