Skip to content

Commit

Permalink
[NB] replace pre variables in when conditions (#11927)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
kabdelhak committed Feb 1, 2024
1 parent ad7e3f6 commit 8fae7db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,13 @@ protected
Pointer.update(bucket_ptr, bucket);
then exp;

// replace $PRE variables with auxiliaries
// necessary if the $PRE variable is a when condition (cannot check the pre of a pre variable)
case Expression.CALL(call = Call.TYPED_CALL(arguments = {Expression.CREF()})) guard(Call.isNamed(exp.call, "pre")) algorithm
(exp, bucket) := CompositeEvent.add(Condition.CONDITION(exp, iter), Pointer.access(bucket_ptr), true);
Pointer.update(bucket_ptr, bucket);
then exp;

// ToDo: math events (check the call name in a function and merge with sample case?)

else exp;
Expand Down

0 comments on commit 8fae7db

Please sign in to comment.