Skip to content

Commit

Permalink
[FE] correctly check for constant value
Browse files Browse the repository at this point in the history
 - we do not want to use simple functions on all expressions that are constant, only on those that are literals (constant values)
  • Loading branch information
kabdelhak committed Apr 17, 2024
1 parent c3d1dae commit 3d35fe4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions OMCompiler/Compiler/FrontEnd/Inline.mo
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ algorithm
Boolean b;
case (e,(SOME(functionTree),_),source)
guard
Expression.isConst(inExp)
Expression.isConstValue(inExp)
equation
e_1 = Ceval.cevalSimpleWithFunctionTreeReturnExp(inExp, functionTree);
source = ElementSource.addSymbolicTransformation(source,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e_1)));
Expand All @@ -707,8 +707,8 @@ algorithm
(e_1,_) = Expression.traverseExpBottomUp(e,function forceInlineCall(fns=fns, visitedPaths=AvlSetPath.Tree.EMPTY()),{});
b = not referenceEq(e, e_1);
if b then
source = ElementSource.addSymbolicTransformation(source,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e_1)));
(DAE.PARTIAL_EQUATION(e_1),source) = ExpressionSimplify.simplifyAddSymbolicOperation(DAE.PARTIAL_EQUATION(e_1), source);
source = ElementSource.addSymbolicTransformation(source,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e_1)));
(DAE.PARTIAL_EQUATION(e_1),source) = ExpressionSimplify.simplifyAddSymbolicOperation(DAE.PARTIAL_EQUATION(e_1), source);
end if;
then
(e_1,source,b);
Expand Down Expand Up @@ -975,7 +975,6 @@ algorithm

case (e1 as DAE.CALL(p,args,DAE.CALL_ATTR(inlineType=inlineType))) guard not AvlSetPath.hasKey(visitedPaths, p)
equation
//print(printInlineTypeStr(inlineType));
false = Config.acceptMetaModelicaGrammar();
true = checkInlineType(inlineType,fns);
(fn,comment) = getFunctionBody(p,fns);
Expand Down

0 comments on commit 3d35fe4

Please sign in to comment.