Skip to content

Commit

Permalink
[NF] Improve Ceval.evalRecordElement.
Browse files Browse the repository at this point in the history
- Handle binding records in Ceval.evalRecordElement.
  • Loading branch information
perost committed Jan 20, 2020
1 parent c6029d1 commit 80b40a6
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions OMCompiler/Compiler/NFFrontEnd/NFCeval.mo
Expand Up @@ -3290,18 +3290,24 @@ algorithm
Expression.RECORD_ELEMENT(recordExp = e, index = index) := exp;
e := evalExp_impl(e, target);

result := match e
case Expression.RECORD()
then listGet(e.elements, index);
try
result := Expression.bindingExpMap(e, function evalRecordElement2(index = index));
else
Error.assertion(false, getInstanceName() + " could not evaluate " +
Expression.toString(exp), sourceInfo());
end try;
end evalRecordElement;

else
algorithm
Error.assertion(false, getInstanceName() + " could not evaluate " +
Expression.toString(exp), sourceInfo());
then
fail();
function evalRecordElement2
input Expression exp;
input Integer index;
output Expression result;
algorithm
result := match exp
case Expression.RECORD()
then listGet(exp.elements, index);
end match;
end evalRecordElement;
end evalRecordElement2;

protected

Expand Down

0 comments on commit 80b40a6

Please sign in to comment.