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

Commit d2c673d

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Optionally strip loop subscript from clocked states
Belonging to [master]: - #2692 - OpenModelica/OpenModelica-testsuite#1044
1 parent e37e5cc commit d2c673d

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ algorithm
430430
end for;
431431
for i in 1:BackendEquation.getNumberOfEquations(inSyst.orderedEqs) loop
432432
eq := BackendEquation.get(inSyst.orderedEqs, i);
433-
(_, prevVars) := BackendEquation.traverseExpsOfEquation(eq, collectPrevVars, prevVars);
433+
(_, (prevVars, _)) := BackendEquation.traverseExpsOfEquation(eq, collectPrevVars, (prevVars, BackendEquation.getForEquationIterIdent(eq)));
434434
end for;
435435
for i in 1:BackendEquation.getNumberOfEquations(inSyst.removedEqs) loop
436436
eq := BackendEquation.get(inSyst.removedEqs, i);
437-
(_, prevVars) := BackendEquation.traverseExpsOfEquation(eq, collectPrevVars, prevVars);
437+
(_, (prevVars, _)) := BackendEquation.traverseExpsOfEquation(eq, collectPrevVars, (prevVars, BackendEquation.getForEquationIterIdent(eq)));
438438
end for;
439439
for cr in prevVars loop
440440
varIxs := getVarIxs(cr, inSyst.orderedVars);
@@ -461,25 +461,39 @@ end markClockedStates;
461461

462462
protected function collectPrevVars
463463
input DAE.Exp inExp;
464-
input list<DAE.ComponentRef> inPrevVars;
464+
input tuple<list<DAE.ComponentRef>, Option<DAE.Ident>> inPrevVars;
465465
output DAE.Exp outExp;
466-
output list<DAE.ComponentRef> outPrevVars;
466+
output tuple<list<DAE.ComponentRef>, Option<DAE.Ident>> outPrevVars;
467467
algorithm
468468
(outExp, outPrevVars) := Expression.traverseExpBottomUp(inExp, collectPrevVars1, inPrevVars);
469469
end collectPrevVars;
470470

471471
protected function collectPrevVars1
472+
"Append cref found in previous(cref) to outPrevVars.
473+
Optionally strip for iterator to get array variable (no NF_SCALARIZE)."
472474
input DAE.Exp inExp;
473-
input list<DAE.ComponentRef> inPrevCompRefs;
475+
input tuple<list<DAE.ComponentRef>, Option<DAE.Ident>> inPrevVars;
474476
output DAE.Exp outExp = inExp;
475-
output list<DAE.ComponentRef> outPrevCompRefs;
477+
output tuple<list<DAE.ComponentRef>, Option<DAE.Ident>> outPrevVars;
476478
algorithm
477-
outPrevCompRefs := match inExp
479+
outPrevVars := match inExp
478480
local
481+
list<DAE.ComponentRef> inPrevCompRefs;
482+
Option<DAE.Ident> inForIter;
483+
DAE.Ident forIter;
479484
DAE.ComponentRef cr;
480485
case DAE.CALL(path=Absyn.IDENT("previous"), expLst={DAE.CREF(cr, _)})
481-
then cr::inPrevCompRefs;
482-
else inPrevCompRefs;
486+
algorithm
487+
(inPrevCompRefs, inForIter) := inPrevVars;
488+
_ := match inForIter
489+
case SOME(forIter)
490+
algorithm
491+
cr := ComponentReference.crefStripIterSub(cr, forIter);
492+
then ();
493+
else ();
494+
end match;
495+
then (cr :: inPrevCompRefs, inForIter);
496+
else inPrevVars;
483497
end match;
484498
end collectPrevVars1;
485499

@@ -2676,6 +2690,7 @@ algorithm
26762690
SourceInfo info;
26772691
case BackendDAE.EQUATION(scalar = e) then isClockExp(e);
26782692
case BackendDAE.ARRAY_EQUATION(right = e) then isClockExp(e);
2693+
case BackendDAE.FOR_EQUATION(right = e) then isClockExp(e);
26792694
case BackendDAE.SOLVED_EQUATION(exp = e) then isClockExp(e);
26802695
case BackendDAE.RESIDUAL_EQUATION(exp = e) then isClockExp(e);
26812696
case BackendDAE.ALGORITHM() then false;

0 commit comments

Comments
 (0)