Skip to content

Commit 8fae7db

Browse files
authored
[NB] replace pre variables in when conditions (#11927)
- necessary to parse when pre(b) because the condition is checked if it differs from its pre value. there is no pre value for a variable that already is a pre value
1 parent ad7e3f6 commit 8fae7db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,13 @@ protected
10291029
Pointer.update(bucket_ptr, bucket);
10301030
then exp;
10311031

1032+
// replace $PRE variables with auxiliaries
1033+
// necessary if the $PRE variable is a when condition (cannot check the pre of a pre variable)
1034+
case Expression.CALL(call = Call.TYPED_CALL(arguments = {Expression.CREF()})) guard(Call.isNamed(exp.call, "pre")) algorithm
1035+
(exp, bucket) := CompositeEvent.add(Condition.CONDITION(exp, iter), Pointer.access(bucket_ptr), true);
1036+
Pointer.update(bucket_ptr, bucket);
1037+
then exp;
1038+
10321039
// ToDo: math events (check the call name in a function and merge with sample case?)
10331040

10341041
else exp;

0 commit comments

Comments
 (0)