Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
make impure functions be of variability continuous (ticket:5127)
Browse files Browse the repository at this point in the history
- remove the check for impure in NFFrontEnd/NFCeval.mo
- add check for impure in NFFrontEnd/NFCall.mo

Belonging to [master]:
  - #2668
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Sep 19, 2018
1 parent 3048851 commit aa6173b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Compiler/NFFrontEnd/NFCall.mo
Expand Up @@ -343,7 +343,9 @@ uniontype Call
typed_args := matchedFunc.args;

args := {};
var := Variability.CONSTANT;
var := if Function.isImpure(func) or Function.isOMImpure(func) // if is impure, make it highest variability
then Variability.CONTINUOUS
else Variability.CONSTANT;
for a in typed_args loop
(arg_exp, _, arg_var) := a;
args := arg_exp :: args;
Expand Down
4 changes: 1 addition & 3 deletions Compiler/NFFrontEnd/NFCeval.mo
Expand Up @@ -174,9 +174,7 @@ algorithm

case Expression.CALL()
then
if Call.isImpure(exp.call) // do NOT evaluate impure calls!
then exp
else evalCall(exp.call, target);
evalCall(exp.call, target);

case Expression.SIZE(dimIndex = SOME(exp1))
algorithm
Expand Down
5 changes: 5 additions & 0 deletions Compiler/NFFrontEnd/NFFunction.mo
Expand Up @@ -1288,6 +1288,11 @@ uniontype Function
output Boolean isImpure = fn.attributes.isImpure;
end isImpure;

function isOMImpure
input Function fn;
output Boolean isImpure = not fn.attributes.isOpenModelicaPure;
end isOMImpure;

function isFunctionPointer
input Function fn;
output Boolean isPointer = fn.attributes.isFunctionPointer;
Expand Down

0 comments on commit aa6173b

Please sign in to comment.