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

Commit aa6173b

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
make impure functions be of variability continuous (ticket:5127)
- remove the check for impure in NFFrontEnd/NFCeval.mo - add check for impure in NFFrontEnd/NFCall.mo Belonging to [master]: - #2668
1 parent 3048851 commit aa6173b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Compiler/NFFrontEnd/NFCall.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ uniontype Call
343343
typed_args := matchedFunc.args;
344344

345345
args := {};
346-
var := Variability.CONSTANT;
346+
var := if Function.isImpure(func) or Function.isOMImpure(func) // if is impure, make it highest variability
347+
then Variability.CONTINUOUS
348+
else Variability.CONSTANT;
347349
for a in typed_args loop
348350
(arg_exp, _, arg_var) := a;
349351
args := arg_exp :: args;

Compiler/NFFrontEnd/NFCeval.mo

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ algorithm
174174

175175
case Expression.CALL()
176176
then
177-
if Call.isImpure(exp.call) // do NOT evaluate impure calls!
178-
then exp
179-
else evalCall(exp.call, target);
177+
evalCall(exp.call, target);
180178

181179
case Expression.SIZE(dimIndex = SOME(exp1))
182180
algorithm

Compiler/NFFrontEnd/NFFunction.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ uniontype Function
12881288
output Boolean isImpure = fn.attributes.isImpure;
12891289
end isImpure;
12901290

1291+
function isOMImpure
1292+
input Function fn;
1293+
output Boolean isImpure = not fn.attributes.isOpenModelicaPure;
1294+
end isOMImpure;
1295+
12911296
function isFunctionPointer
12921297
input Function fn;
12931298
output Boolean isPointer = fn.attributes.isFunctionPointer;

0 commit comments

Comments
 (0)