Skip to content

Commit

Permalink
Fixed findSingleDominatingReaction, which was erroneously returning o…
Browse files Browse the repository at this point in the history
…ne that was not a single dominating reaction. Fixes #346
  • Loading branch information
edwardalee authored and lhstrh committed Jun 4, 2021
1 parent 4de5ed5 commit 7473ae1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions org.lflang/src/org/lflang/generator/ReactionInstanceGraph.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ import org.lflang.graph.DirectedGraph
* Upon creation, reactions are assigned levels, chainIDs, and their
* deadlines are propagated.
*
* This class is distinct from the ReactionGraph class in the graph
* package because it deals with instance objects rather than AST nodes.
*
* @author{Marten Lohstroh <marten@berkeley.edu>}
* @author{Edward A. Lee <eal@berkeley.edu>}
*/
Expand Down Expand Up @@ -90,17 +87,9 @@ class ReactionInstanceGraph extends DirectedGraph<ReactionInstance> {
* null otherwise.
*/
def findSingleDominatingReaction(ReactionInstance reaction) {
this.nodes.forEach[node|node.visitsLeft = 1]
val reactions = reaction.upstreamAdjacentNodes
if (reactions.size > 0) {
val minLevel = reactions.fold(newLinkedList, [ list, r |
list.add(r.level)
return list
]).min
val maximalReactions = maximal(reactions.toSet, minLevel)
if (maximalReactions.size == 1) {
return maximalReactions.get(0)
}
val reactions = getUpstreamAdjacentNodes(reaction)
if (reactions.size == 1) {
return reactions.get(0)
}
return null
}
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/Alignment.lf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ reactor Destination {
}
self->last_invoked = current_tag;
=}
}
}
main reactor {
source = new Source();
sieve = new Sieve();
Expand Down

0 comments on commit 7473ae1

Please sign in to comment.