Skip to content

Commit

Permalink
obtain grand parent from previously stored parent
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Mar 1, 2016
1 parent 3a7d119 commit 769e528
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -473,7 +473,6 @@ protected
algorithm
clockFactor := MMath.RAT1;
branchClockKind := DAE.INFERRED_CLOCK();
grandParentIdx := 0;
outSubClocks := arrayCreate(BackendVariable.varsSize(inVars), (BackendDAE.DEFAULT_SUBCLOCK, 0));
for comp in inComps loop
outClockKind := matchcontinue comp
Expand Down Expand Up @@ -501,28 +500,27 @@ algorithm
if parentIdx == 0 then
// start clock of new branch
branchClockKind := DAE.INFERRED_CLOCK();
grandParentIdx := 0;
end if;
(branchClockKind, _) := setClockKind(branchClockKind, clockKind, clockFactor);
(clockKind, clockFactor) := setClockKind(outClockKind, clockKind, clockFactor);
if parentIdx == 0 then
// adapt uppermost subClock in a branch to possibly multiple bases
subClock.factor := MMath.multRational(subClock.factor, clockFactor);
end if;
grandParentIdx := match branchClockKind
outSubClocks := match branchClockKind
case DAE.INFERRED_CLOCK()
guard parentIdx <> 0
algorithm
// apply the inverse subClock to a parent without base as
// the clock propagates backwards
subClock.factor := MMath.divRational(MMath.RAT1, subClock.factor);
subClock.shift := MMath.subRational(MMath.RAT0, subClock.shift);
(_, grandParentIdx) := arrayGet(outSubClocks, parentIdx);
then
arrayUpdate(outSubClocks, parentIdx, (subClock, grandParentIdx));
then parentIdx;
else
algorithm
arrayUpdate(outSubClocks, varIdx, (subClock, parentIdx));
then parentIdx;
// regular subClock update
arrayUpdate(outSubClocks, varIdx, (subClock, parentIdx));
end match;
/*
print("var " + intString(varIdx) + ": " +
Expand Down

0 comments on commit 769e528

Please sign in to comment.