Skip to content

Commit

Permalink
- fixed detectImplicitDiscreteAlgsStatemens for tuples
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11095 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Feb 13, 2012
1 parent 3b6880c commit e82116a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -2258,6 +2258,31 @@ algorithm
end matchcontinue;
end detectImplicitDiscreteAlgs;

protected function getVarsFromExp
"function: getVarsFromExp
This function collects all variables from an expression-list."
input list<DAE.Exp> inExpLst;
input BackendDAE.Variables inVariables;
output list<BackendDAE.Var> outVarLst;
algorithm
outVarLst := matchcontinue(inExpLst, inVariables)
local
DAE.ComponentRef cref;
list<DAE.Exp> expLst;
BackendDAE.Variables variables;
BackendDAE.Var var;
list<BackendDAE.Var> varLst;
case({}, _) then {};
case(DAE.CREF(componentRef=cref)::expLst, variables) equation
((var::_), _) = BackendVariable.getVar(cref, variables);
varLst = getVarsFromExp(expLst, variables);
then var::varLst;
case(_::expLst, variables) equation
varLst = getVarsFromExp(expLst, variables);
then varLst;
end matchcontinue;
end getVarsFromExp;

protected function detectImplicitDiscreteAlgsStatemens
"function: detectImplicitDiscreteAlgsStatemens
This function updates the variable kind to discrete
Expand All @@ -2280,7 +2305,7 @@ algorithm
DAE.Type tp;
DAE.Ident iteratorName;
DAE.Exp e,iteratorExp;
list<DAE.Exp> iteratorexps;
list<DAE.Exp> iteratorexps, expExpLst;
case (v,_,{},_) then v;
case (v,knv,(DAE.STMT_ASSIGN(exp1 =DAE.CREF(componentRef = cr)) :: xs),true)
equation
Expand All @@ -2290,6 +2315,14 @@ algorithm
v_2 = detectImplicitDiscreteAlgsStatemens(v_1,knv, xs,true);
then
v_2;

case(v, knv, (DAE.STMT_TUPLE_ASSIGN(expExpLst=expExpLst)::xs), true) equation
vars = getVarsFromExp(expExpLst, v);
vars = List.map1(vars, BackendVariable.setVarKind, BackendDAE.DISCRETE());
v_1 = BackendVariable.addVars(vars, v);
v_2 = detectImplicitDiscreteAlgsStatemens(v_1, knv, xs, true);
then v_2;

case (v,knv,(DAE.STMT_ASSIGN_ARR(componentRef = cr) :: xs),true)
equation
(vars,_) = BackendVariable.getVar(cr, v);
Expand Down

0 comments on commit e82116a

Please sign in to comment.