Skip to content

Commit

Permalink
Merge pull request #2277 from lf-lang/fix-imports-with-feds-modes
Browse files Browse the repository at this point in the history
Search for imported reactors to include reactors instantiated in modes
  • Loading branch information
erlingrj authored May 8, 2024
2 parents 435b45b + 8b2e3a3 commit 6f77b37
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.lflang.lf.ImportedReactor;
import org.lflang.lf.Input;
import org.lflang.lf.Instantiation;
import org.lflang.lf.Mode;
import org.lflang.lf.Output;
import org.lflang.lf.Parameter;
import org.lflang.lf.ParameterReference;
Expand Down Expand Up @@ -320,6 +321,14 @@ private boolean references(Instantiation instantiation, ReactorDecl declaration)
return true;
}
}
// Check if it is instantiated in a mode
for (Mode mode : reactorDef.getModes()) {
for (Instantiation child : mode.getInstantiations()) {
if (references(child, declaration)) {
return true;
}
}
}
// Check if the reactor is a super class
for (var parent : reactorDef.getSuperClasses()) {
if (declaration instanceof Reactor r) {
Expand Down
15 changes: 15 additions & 0 deletions test/C/src/federated/ImportsInModes.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
target C {
timeout: 1 msec
}

import Count from "../lib/Count.lf"

reactor R {
initial mode {
c = new Count()
}
}

federated reactor {
fed = new R()
}

0 comments on commit 6f77b37

Please sign in to comment.