From 1912c65e985dd06f645c2a915e7c0132eb70f2c1 Mon Sep 17 00:00:00 2001 From: eal Date: Thu, 10 Mar 2022 08:51:25 -0800 Subject: [PATCH 1/2] Removed unused imports --- org.lflang/src/org/lflang/generator/ReactorInstance.java | 1 - org.lflang/src/org/lflang/validation/LFValidator.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ReactorInstance.java b/org.lflang/src/org/lflang/generator/ReactorInstance.java index 1693a25913..bc994b7639 100644 --- a/org.lflang/src/org/lflang/generator/ReactorInstance.java +++ b/org.lflang/src/org/lflang/generator/ReactorInstance.java @@ -35,7 +35,6 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY import org.lflang.ASTUtils; import org.lflang.ErrorReporter; -import org.lflang.ASTUtils; import org.lflang.TimeValue; import org.lflang.generator.TriggerInstance.BuiltinTriggerVariable; import org.lflang.lf.Action; diff --git a/org.lflang/src/org/lflang/validation/LFValidator.java b/org.lflang/src/org/lflang/validation/LFValidator.java index 52e3b41435..d3d88a1c26 100644 --- a/org.lflang/src/org/lflang/validation/LFValidator.java +++ b/org.lflang/src/org/lflang/validation/LFValidator.java @@ -29,12 +29,12 @@ import static org.lflang.ASTUtils.inferPortWidth; import static org.lflang.ASTUtils.isGeneric; import static org.lflang.ASTUtils.isInteger; +import static org.lflang.ASTUtils.isOfTimeType; import static org.lflang.ASTUtils.isParameterized; import static org.lflang.ASTUtils.isValidTime; import static org.lflang.ASTUtils.isZero; import static org.lflang.ASTUtils.toDefinition; import static org.lflang.ASTUtils.toText; -import static org.lflang.ASTUtils.isOfTimeType; import java.io.IOException; import java.util.ArrayList; @@ -56,7 +56,6 @@ import org.eclipse.xtext.validation.CheckType; import org.eclipse.xtext.validation.ValidationMessageAcceptor; import org.lflang.ASTUtils; -import org.lflang.ASTUtils; import org.lflang.ModelInfo; import org.lflang.Target; import org.lflang.TargetProperty; From 1aae575069f77530b3b2b83fef76bfc57bfe5366 Mon Sep 17 00:00:00 2001 From: eal Date: Thu, 10 Mar 2022 09:55:46 -0800 Subject: [PATCH 2/2] Fixed test to remove reaction self-loop cycle that was masked. --- .../generator/ReactionInstanceGraph.java | 18 ++++++++---------- test/C/src/modal_models/ModalCycleBreaker.lf | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/org.lflang/src/org/lflang/generator/ReactionInstanceGraph.java b/org.lflang/src/org/lflang/generator/ReactionInstanceGraph.java index ccd5090a3e..5f99791a04 100644 --- a/org.lflang/src/org/lflang/generator/ReactionInstanceGraph.java +++ b/org.lflang/src/org/lflang/generator/ReactionInstanceGraph.java @@ -135,15 +135,13 @@ protected void addDownstreamReactions(PortInstance port, ReactionInstance reacti List dstRuntimes = dstReaction.getRuntimeInstances(); Runtime srcRuntime = srcRuntimes.get(srcIndex); Runtime dstRuntime = dstRuntimes.get(dstIndex); - if (dstRuntime != srcRuntime) { - // Only add this dependency if the reactions are not in modes at all or in the same mode or in modes of separate reactors - // This allows modes to break cycles since modes are always mutually exclusive. - if (srcRuntime.getReaction().getMode(true) == null || - dstRuntime.getReaction().getMode(true) == null || - srcRuntime.getReaction().getMode(true) == dstRuntime.getReaction().getMode(true) || - srcRuntime.getReaction().getParent() != dstRuntime.getReaction().getParent()) { - addEdge(dstRuntime, srcRuntime); - } + // Only add this dependency if the reactions are not in modes at all or in the same mode or in modes of separate reactors + // This allows modes to break cycles since modes are always mutually exclusive. + if (srcRuntime.getReaction().getMode(true) == null || + dstRuntime.getReaction().getMode(true) == null || + srcRuntime.getReaction().getMode(true) == dstRuntime.getReaction().getMode(true) || + srcRuntime.getReaction().getParent() != dstRuntime.getReaction().getParent()) { + addEdge(dstRuntime, srcRuntime); } // Propagate the deadlines, if any. @@ -263,7 +261,7 @@ private void assignLevels() { Set toRemove = new LinkedHashSet(); Set downstreamAdjacentNodes = getDownstreamAdjacentNodes(origin); // All downstream adjacent nodes start with a level 0. Adjust the - // maxNumOfReactionPerLevel field accordingly (to be + // numReactionsPerLevel field accordingly (to be // updated in the for loop below). adjustNumReactionsPerLevel(0, downstreamAdjacentNodes.size()); // Visit effect nodes. diff --git a/test/C/src/modal_models/ModalCycleBreaker.lf b/test/C/src/modal_models/ModalCycleBreaker.lf index b4e1b8af8f..ce8298fd03 100644 --- a/test/C/src/modal_models/ModalCycleBreaker.lf +++ b/test/C/src/modal_models/ModalCycleBreaker.lf @@ -18,8 +18,8 @@ reactor Modal { mode Two { // Defining reaction to in2 before in1 would cause cycle if no mode were present timer wait(150msec, 1sec) - reaction(in2) -> out {= - SET(out, in2->value); + reaction(in2) {= + // SET(out, in2->value); =} reaction(wait) -> One {=