From ae52580ac6cd02b8f0729ca5cafe14fa592bb998 Mon Sep 17 00:00:00 2001 From: erlingrj Date: Wed, 8 May 2024 19:27:31 +0200 Subject: [PATCH 1/3] Also search for imported reactors in modes --- .../org/lflang/federated/generator/FederateInstance.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java index 4521546ae9..fdfa6c11bb 100644 --- a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java +++ b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java @@ -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; @@ -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) { From e6f6db269ce134f913b591218dc410dc19f84a6e Mon Sep 17 00:00:00 2001 From: erlingrj Date: Wed, 8 May 2024 19:54:52 +0200 Subject: [PATCH 2/3] Add test-case for the fix --- test/C/src/federated/ImportsInModes.lf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/C/src/federated/ImportsInModes.lf diff --git a/test/C/src/federated/ImportsInModes.lf b/test/C/src/federated/ImportsInModes.lf new file mode 100644 index 0000000000..ac780c7000 --- /dev/null +++ b/test/C/src/federated/ImportsInModes.lf @@ -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() +} \ No newline at end of file From 8b2e3a3a33955e96676cbb0e82e2cd0626fdd6cb Mon Sep 17 00:00:00 2001 From: erlingrj Date: Wed, 8 May 2024 19:55:06 +0200 Subject: [PATCH 3/3] Spotless --- test/C/src/federated/ImportsInModes.lf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/C/src/federated/ImportsInModes.lf b/test/C/src/federated/ImportsInModes.lf index ac780c7000..6fd4aa0ec5 100644 --- a/test/C/src/federated/ImportsInModes.lf +++ b/test/C/src/federated/ImportsInModes.lf @@ -1,5 +1,5 @@ target C { - timeout: 1 msec, + timeout: 1 msec } import Count from "../lib/Count.lf" @@ -12,4 +12,4 @@ reactor R { federated reactor { fed = new R() -} \ No newline at end of file +}