-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5e411e
commit 2fbd047
Showing
4 changed files
with
59 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.lflang.federated; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.eclipse.emf.ecore.resource.Resource; | ||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils; | ||
|
||
import org.lflang.ASTUtils; | ||
import org.lflang.ErrorReporter; | ||
import org.lflang.generator.LFGeneratorContext; | ||
import org.lflang.lf.Instantiation; | ||
import org.lflang.lf.Reactor; | ||
|
||
public class FedGenerator { | ||
|
||
private FedFileConfig fileConfig; | ||
|
||
public FedGenerator(FedFileConfig fileConfig, ErrorReporter errorReporter) { | ||
|
||
this.fileConfig = fileConfig; | ||
} | ||
public boolean doGenerate(Resource resource, LFGeneratorContext context) throws IOException { | ||
Reactor fedReactor = FedASTUtils.findFederatedReactor(resource); | ||
for (Instantiation fedInstantiation : fedReactor.getInstantiations()) { | ||
System.out.println("Generating code for federate " + fedInstantiation.getName() + " in directory " | ||
+ fileConfig.getFedSrcPath()); | ||
Files.createDirectories(fileConfig.getFedSrcPath()); | ||
|
||
Path lfFilePath = fileConfig.getFedSrcPath().resolve(fedInstantiation.getName() + ".lf"); | ||
try (var srcWriter = Files.newBufferedWriter(lfFilePath)) { | ||
srcWriter.write(NodeModelUtils.getNode(fedReactor.eContainer()).getText()); | ||
} | ||
|
||
} | ||
return false; | ||
} | ||
|
||
// private void generateFederate(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters