diff --git a/org.lflang/src/org/lflang/federated/FedFileConfig.java b/org.lflang/src/org/lflang/federated/FedFileConfig.java index ba988f712d..78bbdf949e 100644 --- a/org.lflang/src/org/lflang/federated/FedFileConfig.java +++ b/org.lflang/src/org/lflang/federated/FedFileConfig.java @@ -53,13 +53,17 @@ public FedFileConfig(FileConfig fileConfig) throws IOException { } /** - * FIXME - * @return + * Return the path to the root of a LF project generated on the basis of a + * federated LF program currently under compilation. */ public Path getFedGenPath() { return srcPkgPath.resolve("fed-gen").resolve(this.name); } + /** + * Return the path for storing generated LF sources that jointly constitute a + * federation. + */ Path getFedSrcPath() { return getFedGenPath().resolve("src"); } diff --git a/org.lflang/src/org/lflang/federated/FedGenerator.java b/org.lflang/src/org/lflang/federated/FedGenerator.java index 6e69699a09..dabd863f86 100644 --- a/org.lflang/src/org/lflang/federated/FedGenerator.java +++ b/org.lflang/src/org/lflang/federated/FedGenerator.java @@ -11,6 +11,7 @@ import org.lflang.ErrorReporter; import org.lflang.generator.LFGeneratorContext; import org.lflang.lf.Instantiation; +import org.lflang.lf.LfFactory; import org.lflang.lf.Reactor; public class FedGenerator { @@ -23,6 +24,13 @@ public FedGenerator(FedFileConfig fileConfig, ErrorReporter errorReporter) { } public boolean doGenerate(Resource resource, LFGeneratorContext context) throws IOException { Reactor fedReactor = FedASTUtils.findFederatedReactor(resource); + + // Create proxies for all instances. + for (Instantiation fedInstantiation : fedReactor.getInstantiations()) { + // this.proxies.add ... + } + + // Generate code for each federate for (Instantiation fedInstantiation : fedReactor.getInstantiations()) { generateFederate(fedInstantiation); } @@ -43,8 +51,13 @@ private void generateFederate(Instantiation fed) throws IOException { // FIXME: Do magic... + // Create import statements for definition of class that fed is an instance of. + + // Go through all instances and + try (var srcWriter = Files.newBufferedWriter(lfFilePath)) { - srcWriter.write(NodeModelUtils.getNode(fed.eContainer()).getText()); + srcWriter.write(NodeModelUtils.getNode(LfFactory.eINSTANCE.createReactor()).getText()); + //srcWriter.write(NodeModelUtils.getNode(fed.eContainer()).getText()); } }