Skip to content

Commit

Permalink
fix frontend part of ticket:4157
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Apr 21, 2017
1 parent ac1663d commit dd5fb2b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -3126,6 +3126,10 @@ outCrefs := match inElems
equation crefs = collectWhenCrefs1(e, source, inCrefs);
then verifyBoolWhenEquation1(rest, initCond, crefs);

case DAE.COMPLEX_EQUATION(lhs = e, source = source)::rest
equation crefs = collectWhenCrefs1(e, source, inCrefs);
then verifyBoolWhenEquation1(rest, initCond, crefs);

case DAE.EQUEQUATION(cr1 = cr)::rest
then verifyBoolWhenEquation1(rest, initCond, cr::inCrefs);

Expand Down
27 changes: 26 additions & 1 deletion Compiler/FrontEnd/Expression.mo
Expand Up @@ -11936,8 +11936,10 @@ algorithm
local
DAE.ComponentRef cr;
list<DAE.ComponentRef> crlst;
list<DAE.Exp> expl;
list<DAE.Exp> expl = {}, expl1, expl2;
String msg;
DAE.Exp e1, e2;
DAE.Operator op;

case (DAE.CREF(cr,_))
algorithm
Expand All @@ -11950,6 +11952,28 @@ algorithm
expl := list(DAE.UNARY(inExp.operator, exp) for exp in expandExpression(inExp.exp));
then expl;

case (DAE.BINARY())
algorithm
// TODO! FIXME! we should change the type in the operator,
// i.e. use Types.unliftArray on the type inside the operator
op := inExp.operator;
expl1 := expandExpression(inExp.exp1);
expl2 := expandExpression(inExp.exp2);
// TODO! FIXME! maybe we should also support (array op scalar)
// make sure the lists have the same length
if listLength(expl1) <> listLength(expl2) then
fail();
end if;
e1 := listGet(expl1, 1);
e2 := listGet(expl1, 2);
for i in 1:listLength(expl1) loop
e1 := listGet(expl1, i);
e2 := listGet(expl2, i);
expl := DAE.BINARY(e1, op, e2)::expl;
end for;
expl := listReverse(expl);
then expl;

case DAE.ARRAY(_,_,expl)
algorithm
expl := List.mapFlat(expl,expandExpression);
Expand All @@ -11962,6 +11986,7 @@ algorithm
then
fail();
end match;

end expandExpression;

public function extendArrExp "author: Frenkel TUD 2010-07
Expand Down

0 comments on commit dd5fb2b

Please sign in to comment.