Skip to content

Commit

Permalink
[NF] update statement conversion (OpenModelica#12614)
Browse files Browse the repository at this point in the history
- update it to have the correct structure if there is only one branch with condition "true"
  • Loading branch information
kabdelhak committed Jun 19, 2024
1 parent 53a0a89 commit 537f41e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFConvertDAE.mo
Original file line number Diff line number Diff line change
Expand Up @@ -972,14 +972,15 @@ protected
list<Statement> stmts;
list<DAE.Statement> dstmts;
Boolean first = true;
Boolean single = listLength(ifBranches) == 1;
DAE.Else else_stmt = DAE.Else.NOELSE();
algorithm
for b in listReverse(ifBranches) loop
(cond, stmts) := b;
dcond := Expression.toDAE(cond);
dstmts := convertStatements(stmts);

if first and Expression.isTrue(cond) then
if first and not single and Expression.isTrue(cond) then
else_stmt := DAE.Else.ELSE(dstmts);
else
else_stmt := DAE.Else.ELSEIF(dcond, dstmts, else_stmt);
Expand Down

0 comments on commit 537f41e

Please sign in to comment.