Commit 663f0619 authored by Abdallah Atouani's avatar Abdallah Atouani

Merge branch 'feature/path_tagging' of...

Merge branch 'feature/path_tagging' of /home/abdallah/Documents/SLE_Poject/EMADL2CPP with conflicts.
parent 9109db47
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<properties> <properties>
<!-- .. SE-Libraries .................................................. --> <!-- .. SE-Libraries .................................................. -->
<emadl.version>0.2.6</emadl.version> <emadl.version>0.2.7-SNAPSHOT</emadl.version>
<CNNTrain.version>0.2.6</CNNTrain.version> <CNNTrain.version>0.2.6</CNNTrain.version>
<cnnarch-mxnet-generator.version>0.2.14-SNAPSHOT</cnnarch-mxnet-generator.version> <cnnarch-mxnet-generator.version>0.2.14-SNAPSHOT</cnnarch-mxnet-generator.version>
<cnnarch-caffe2-generator.version>0.2.11-SNAPSHOT</cnnarch-caffe2-generator.version> <cnnarch-caffe2-generator.version>0.2.11-SNAPSHOT</cnnarch-caffe2-generator.version>
...@@ -62,6 +62,12 @@ ...@@ -62,6 +62,12 @@
<!-- MontiCore Dependencies --> <!-- MontiCore Dependencies -->
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>common-monticar</artifactId>
<version>0.0.17-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-opt-generator</artifactId> <artifactId>embedded-montiarc-math-opt-generator</artifactId>
......
...@@ -26,7 +26,7 @@ import com.google.common.base.Splitter; ...@@ -26,7 +26,7 @@ import com.google.common.base.Splitter;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstantiationSymbol; import de.monticore.lang.embeddedmontiarcdynamic.embeddedmontiarcdynamic._symboltable.cncModel.EMADynamicComponentSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbol; import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.monticar.cnnarch.CNNArchGenerator; import de.monticore.lang.monticar.cnnarch.CNNArchGenerator;
import de.monticore.lang.monticar.cnnarch.DataPathConfigParser; import de.monticore.lang.monticar.cnnarch.DataPathConfigParser;
...@@ -34,7 +34,6 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol; ...@@ -34,7 +34,6 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol;
import de.monticore.lang.monticar.cnntrain.CNNTrainGenerator; import de.monticore.lang.monticar.cnntrain.CNNTrainGenerator;
import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol; import de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol;
import de.monticore.lang.monticar.emadl._cocos.EMADLCocos; import de.monticore.lang.monticar.emadl._cocos.EMADLCocos;
import de.monticore.lang.monticar.emadl._cocos.DataPathCocos;
import de.monticore.lang.monticar.emadl.tagging.dltag.DataPathSymbol; import de.monticore.lang.monticar.emadl.tagging.dltag.DataPathSymbol;
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.cpp.ArmadilloHelper; import de.monticore.lang.monticar.generator.cpp.ArmadilloHelper;
...@@ -49,15 +48,18 @@ import de.se_rwth.commons.Splitters; ...@@ -49,15 +48,18 @@ import de.se_rwth.commons.Splitters;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException; import freemarker.template.TemplateException;
import javax.xml.bind.DatatypeConverter;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.*; import java.security.DigestInputStream;
import javax.xml.bind.DatatypeConverter;
public class EMADLGenerator { public class EMADLGenerator {
...@@ -68,6 +70,8 @@ public class EMADLGenerator { ...@@ -68,6 +70,8 @@ public class EMADLGenerator {
private String modelsPath; private String modelsPath;
public EMADLGenerator(Backend backend) { public EMADLGenerator(Backend backend) {
this.backend = backend; this.backend = backend;
emamGen = new GeneratorEMAMOpt2CPP(); emamGen = new GeneratorEMAMOpt2CPP();
...@@ -82,22 +86,24 @@ public class EMADLGenerator { ...@@ -82,22 +86,24 @@ public class EMADLGenerator {
} }
public void setModelsPath(String modelsPath) { public void setModelsPath(String modelsPath) {
if (!(modelsPath.substring(modelsPath.length() - 1).equals("/"))) { if (!(modelsPath.substring(modelsPath.length() - 1).equals("/"))){
this.modelsPath = modelsPath + "/"; this.modelsPath = modelsPath + "/";
} else { }
else {
this.modelsPath = modelsPath; this.modelsPath = modelsPath;
} }
} }
public void setGenerationTargetPath(String generationTargetPath) { public void setGenerationTargetPath(String generationTargetPath){
if (!(generationTargetPath.substring(generationTargetPath.length() - 1).equals("/"))) { if (!(generationTargetPath.substring(generationTargetPath.length() - 1).equals("/"))){
getEmamGen().setGenerationTargetPath(generationTargetPath + "/"); getEmamGen().setGenerationTargetPath(generationTargetPath + "/");
} else { }
else {
getEmamGen().setGenerationTargetPath(generationTargetPath); getEmamGen().setGenerationTargetPath(generationTargetPath);
} }
} }
public String getGenerationTargetPath() { public String getGenerationTargetPath(){
return getEmamGen().getGenerationTargetPath(); return getEmamGen().getGenerationTargetPath();
} }
...@@ -105,24 +111,21 @@ public class EMADLGenerator { ...@@ -105,24 +111,21 @@ public class EMADLGenerator {
return emamGen; return emamGen;
} }
public void generate(String modelPath, String qualifiedName, String pythonPath, String forced, boolean doCompile) public void generate(String modelPath, String qualifiedName, String pythonPath, String forced, boolean doCompile) throws IOException, TemplateException {
throws IOException, TemplateException { setModelsPath( modelPath );
setModelsPath(modelPath);
TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath()); TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath());
EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND) EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND).orElse(null);
.orElse(null);
List<String> splitName = Splitters.DOT.splitToList(qualifiedName); List<String> splitName = Splitters.DOT.splitToList(qualifiedName);
String componentName = splitName.get(splitName.size() - 1); String componentName = splitName.get(splitName.size() - 1);
String instanceName = componentName.substring(0, 1).toLowerCase() + componentName.substring(1); String instanceName = componentName.substring(0, 1).toLowerCase() + componentName.substring(1);
if (component == null) { if (component == null){
Log.error("Component with name '" + componentName + "' does not exist."); Log.error("Component with name '" + componentName + "' does not exist.");
System.exit(1); System.exit(1);
} }
EMAComponentInstanceSymbol instance = component.getEnclosingScope() EMAComponentInstanceSymbol instance = component.getEnclosingScope().<EMAComponentInstanceSymbol>resolve(instanceName, EMAComponentInstanceSymbol.KIND).get();
.<EMAComponentInstanceSymbol>resolve(instanceName, EMAComponentInstanceSymbol.KIND).get();
generateFiles(symtab, instance, symtab, pythonPath, forced); generateFiles(symtab, instance, symtab, pythonPath, forced);
...@@ -138,11 +141,11 @@ public class EMADLGenerator { ...@@ -138,11 +141,11 @@ public class EMADLGenerator {
pb.inheritIO(); pb.inheritIO();
Process process = pb.start(); Process process = pb.start();
int returnCode = process.waitFor(); int returnCode = process.waitFor();
if (returnCode != 0) { if(returnCode != 0) {
Log.error("During compilation, an error occured. See above for more details."); Log.error("During compilation, an error occured. See above for more details.");
System.exit(1); System.exit(1);
} }
} catch (Exception e) { }catch(Exception e){
Log.error("During compilation, the following error occured: '" + e.toString() + "'"); Log.error("During compilation, the following error occured: '" + e.toString() + "'");
System.exit(1); System.exit(1);
} finally { } finally {
...@@ -150,10 +153,11 @@ public class EMADLGenerator { ...@@ -150,10 +153,11 @@ public class EMADLGenerator {
} }
} }
public File createTempScript() throws IOException { public File createTempScript() throws IOException{
File tempScript = File.createTempFile("script", null); File tempScript = File.createTempFile("script", null);
try { try{
Writer streamWriter = new OutputStreamWriter(new FileOutputStream(tempScript)); Writer streamWriter = new OutputStreamWriter(new FileOutputStream(
tempScript));
PrintWriter printWriter = new PrintWriter(streamWriter); PrintWriter printWriter = new PrintWriter(streamWriter);
printWriter.println("#!/bin/bash"); printWriter.println("#!/bin/bash");
...@@ -164,7 +168,7 @@ public class EMADLGenerator { ...@@ -164,7 +168,7 @@ public class EMADLGenerator {
printWriter.println("make"); printWriter.println("make");
printWriter.close(); printWriter.close();
} catch (Exception e) { }catch(Exception e){
System.out.println(e); System.out.println(e);
} }
...@@ -187,11 +191,9 @@ public class EMADLGenerator { ...@@ -187,11 +191,9 @@ public class EMADLGenerator {
} }
} }
public void generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol, public void generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol, Scope symtab, String pythonPath, String forced) throws IOException {
Scope symtab, String pythonPath, String forced) throws IOException {
Set<EMAComponentInstanceSymbol> allInstances = new HashSet<>(); Set<EMAComponentInstanceSymbol> allInstances = new HashSet<>();
List<FileContent> fileContents = generateStrings(taggingResolver, EMAComponentSymbol, symtab, allInstances, List<FileContent> fileContents = generateStrings(taggingResolver, EMAComponentSymbol, symtab, allInstances, forced);
forced);
for (FileContent fileContent : fileContents) { for (FileContent fileContent : fileContents) {
emamGen.generateFile(fileContent); emamGen.generateFile(fileContent);
...@@ -199,77 +201,74 @@ public class EMADLGenerator { ...@@ -199,77 +201,74 @@ public class EMADLGenerator {
// train // train
Map<String, String> fileContentMap = new HashMap<>(); Map<String, String> fileContentMap = new HashMap<>();
for (FileContent f : fileContents) { for(FileContent f : fileContents) {
fileContentMap.put(f.getFileName(), f.getFileContent()); fileContentMap.put(f.getFileName(), f.getFileContent());
} }
List<FileContent> fileContentsTrainingHashes = new ArrayList<>(); List<FileContent> fileContentsTrainingHashes = new ArrayList<>();
List<String> newHashes = new ArrayList<>(); List<String> newHashes = new ArrayList<>();
for (EMAComponentInstanceSymbol componentInstance : allInstances) { for (EMAComponentInstanceSymbol componentInstance : allInstances) {
Optional<ArchitectureSymbol> architecture = componentInstance.getSpannedScope().resolve("", Optional<ArchitectureSymbol> architecture = componentInstance.getSpannedScope().resolve("", ArchitectureSymbol.KIND);
ArchitectureSymbol.KIND);
if (!architecture.isPresent()) { if(!architecture.isPresent()) {
continue; continue;
} }
if (forced.equals("n")) { if(forced.equals("n")) {
continue; continue;
} }
String configFilename = getConfigFilename(componentInstance.getComponentType().getFullName(), String configFilename = getConfigFilename(componentInstance.getComponentType().getFullName(), componentInstance.getFullName(), componentInstance.getName());
componentInstance.getFullName(), componentInstance.getName());
String emadlPath = getModelsPath() + configFilename + ".emadl"; String emadlPath = getModelsPath() + configFilename + ".emadl";
String cnntPath = getModelsPath() + configFilename + ".cnnt"; String cnntPath = getModelsPath() + configFilename + ".cnnt";
String emadlHash = getChecksumForFile(emadlPath); String emadlHash = getChecksumForFile(emadlPath);
String cnntHash = getChecksumForFile(cnntPath); String cnntHash = getChecksumForFile(cnntPath);
String componentConfigFilename = componentInstance.getComponentType().getReferencedSymbol().getFullName() String componentConfigFilename = componentInstance.getComponentType().getReferencedSymbol().getFullName().replaceAll("\\.", "/");
.replaceAll("\\.", "/");
String b = backend.getBackendString(backend); String b = backend.getBackendString(backend);
String trainingDataHash = ""; String trainingDataHash = "";
String testDataHash = ""; String testDataHash = "";
if (b.equals("CAFFE2")) { if(b.equals("CAFFE2")){
trainingDataHash = getChecksumForFile(architecture.get().getDataPath() + "/train_lmdb/data.mdb"); trainingDataHash = getChecksumForFile(architecture.get().getDataPath() + "/train_lmdb/data.mdb");
testDataHash = getChecksumForFile(architecture.get().getDataPath() + "/test_lmdb/data.mdb"); testDataHash = getChecksumForFile(architecture.get().getDataPath() + "/test_lmdb/data.mdb");
} else { }else{
trainingDataHash = getChecksumForFile(architecture.get().getDataPath() + "/train.h5"); trainingDataHash = getChecksumForFile(architecture.get().getDataPath() + "/train.h5");
testDataHash = getChecksumForFile(architecture.get().getDataPath() + "/test.h5"); testDataHash = getChecksumForFile(architecture.get().getDataPath() + "/test.h5");
} }
String trainingHash = emadlHash + "#" + cnntHash + "#" + trainingDataHash + "#" + testDataHash; String trainingHash = emadlHash + "#" + cnntHash + "#" + trainingDataHash + "#" + testDataHash;
boolean alreadyTrained = newHashes.contains(trainingHash) boolean alreadyTrained = newHashes.contains(trainingHash) || isAlreadyTrained(trainingHash, componentInstance);
|| isAlreadyTrained(trainingHash, componentInstance); if(alreadyTrained && !forced.equals("y")) {
if (alreadyTrained && !forced.equals("y")) {
Log.warn("Training of model " + componentInstance.getFullName() + " skipped"); Log.warn("Training of model " + componentInstance.getFullName() + " skipped");
} else { }
String parsedFullName = componentInstance.getFullName().substring(0, 1).toLowerCase() else {
+ componentInstance.getFullName().substring(1).replaceAll("\\.", "_"); String parsedFullName = componentInstance.getFullName().substring(0, 1).toLowerCase() + componentInstance.getFullName().substring(1).replaceAll("\\.", "_");
String trainerScriptName = "CNNTrainer_" + parsedFullName + ".py"; String trainerScriptName = "CNNTrainer_" + parsedFullName + ".py";
String trainingPath = getGenerationTargetPath() + trainerScriptName; String trainingPath = getGenerationTargetPath() + trainerScriptName;
if (Files.exists(Paths.get(trainingPath))) { if(Files.exists(Paths.get(trainingPath))){
ProcessBuilder pb = new ProcessBuilder(Arrays.asList(pythonPath, trainingPath)).inheritIO(); ProcessBuilder pb = new ProcessBuilder(Arrays.asList(pythonPath, trainingPath)).inheritIO();
Process p = pb.start(); Process p = pb.start();
int exitCode = 0; int exitCode = 0;
try { try {
exitCode = p.waitFor(); exitCode = p.waitFor();
} catch (InterruptedException e) { }
catch(InterruptedException e) {
Log.error("Training aborted: exit code " + Integer.toString(exitCode)); Log.error("Training aborted: exit code " + Integer.toString(exitCode));
System.exit(1); System.exit(1);
} }
if (exitCode != 0) { if(exitCode != 0) {
Log.error("Training failed: exit code " + Integer.toString(exitCode)); Log.error("Training failed: exit code " + Integer.toString(exitCode));
System.exit(1); System.exit(1);
} }
fileContentsTrainingHashes fileContentsTrainingHashes.add(new FileContent(trainingHash, componentConfigFilename + ".training_hash"));
.add(new FileContent(trainingHash, componentConfigFilename + ".training_hash"));
newHashes.add(trainingHash); newHashes.add(trainingHash);
} else { }
else{
System.out.println("Trainingfile " + trainingPath + " not found."); System.out.println("Trainingfile " + trainingPath + " not found.");
} }
} }
...@@ -284,7 +283,8 @@ public class EMADLGenerator { ...@@ -284,7 +283,8 @@ public class EMADLGenerator {
private static String convertByteArrayToHexString(byte[] arrayBytes) { private static String convertByteArrayToHexString(byte[] arrayBytes) {
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < arrayBytes.length; i++) { for (int i = 0; i < arrayBytes.length; i++) {
stringBuffer.append(Integer.toString((arrayBytes[i] & 0xff) + 0x100, 16).substring(1)); stringBuffer.append(Integer.toString((arrayBytes[i] & 0xff) + 0x100, 16)
.substring(1));
} }
return stringBuffer.toString(); return stringBuffer.toString();
} }
...@@ -295,25 +295,24 @@ public class EMADLGenerator { ...@@ -295,25 +295,24 @@ public class EMADLGenerator {
String componentConfigFilename = component.getFullName().replaceAll("\\.", "/"); String componentConfigFilename = component.getFullName().replaceAll("\\.", "/");
String checkFilePathString = getGenerationTargetPath() + componentConfigFilename + ".training_hash"; String checkFilePathString = getGenerationTargetPath() + componentConfigFilename + ".training_hash";
Path checkFilePath = Paths.get(checkFilePathString); Path checkFilePath = Paths.get( checkFilePathString);
if (Files.exists(checkFilePath)) { if(Files.exists(checkFilePath)) {
List<String> hashes = Files.readAllLines(checkFilePath); List<String> hashes = Files.readAllLines(checkFilePath);
for (String hash : hashes) { for(String hash : hashes) {
if (hash.equals(trainingHash)) { if(hash.equals(trainingHash)) {
return true; return true;
} }
} }
} }
return false; return false;
} catch (Exception e) { }
catch(Exception e) {
return false; return false;
} }
} }
public List<FileContent> generateStrings(TaggingResolver taggingResolver, public List<FileContent> generateStrings(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab, Set<EMAComponentInstanceSymbol> allInstances, String forced){
EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab,
Set<EMAComponentInstanceSymbol> allInstances, String forced) {
List<FileContent> fileContents = new ArrayList<>(); List<FileContent> fileContents = new ArrayList<>();
generateComponent(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab); generateComponent(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab);
...@@ -327,16 +326,14 @@ public class EMADLGenerator { ...@@ -327,16 +326,14 @@ public class EMADLGenerator {
if (cnnArchGenerator.isCMakeRequired()) { if (cnnArchGenerator.isCMakeRequired()) {
cnnArchGenerator.setGenerationTargetPath(getGenerationTargetPath()); cnnArchGenerator.setGenerationTargetPath(getGenerationTargetPath());
Map<String, String> cmakeContentsMap = cnnArchGenerator Map<String, String> cmakeContentsMap = cnnArchGenerator.generateCMakeContent(componentInstanceSymbol.getFullName());
.generateCMakeContent(componentInstanceSymbol.getFullName()); for (String fileName : cmakeContentsMap.keySet()){
for (String fileName : cmakeContentsMap.keySet()) {
fileContents.add(new FileContent(cmakeContentsMap.get(fileName), fileName)); fileContents.add(new FileContent(cmakeContentsMap.get(fileName), fileName));
} }
} }
if (emamGen.shouldGenerateMainClass()) { if (emamGen.shouldGenerateMainClass()) {
// fileContents.add(emamGen.getMainClassFileContent(componentInstanceSymbol, //fileContents.add(emamGen.getMainClassFileContent(componentInstanceSymbol, fileContents.get(0)));
// fileContents.get(0)));
} else if (emamGen.shouldGenerateSimulatorInterface()) { } else if (emamGen.shouldGenerateSimulatorInterface()) {
fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent()); fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent());
} }
...@@ -346,36 +343,17 @@ public class EMADLGenerator { ...@@ -346,36 +343,17 @@ public class EMADLGenerator {
return fileContents; return fileContents;
} }
/** protected String getDataPath(TaggingResolver taggingResolver, EMAComponentSymbol component, EMAComponentInstanceSymbol instance){
* returns data path either from tags or data_paths.txt
*/
protected String getDataPath(TaggingResolver taggingResolver, EMAComponentSymbol component,
EMAComponentInstanceSymbol instance) {
List<TagSymbol> instanceTags = new LinkedList<>();
boolean isChildComponent = instance.getEnclosingComponent().isPresent();
if (isChildComponent) {
// get all instantiated components of parent
List<EMAComponentInstantiationSymbol> instantiationSymbols = (List<EMAComponentInstantiationSymbol>) instance
.getEnclosingComponent().get().getComponentType().getReferencedSymbol().getSubComponents();
// filter corresponding instantiation of instance and add tags
instantiationSymbols.stream().filter(e -> e.getName().equals(instance.getName())).findFirst()
.ifPresent(symbol -> instanceTags.addAll(taggingResolver.getTags(symbol, DataPathSymbol.KIND)));
}
// instance tags have priority // instance tags have priority
List<TagSymbol> tags = !instanceTags.isEmpty() ? instanceTags List<TagSymbol> instanceTags = (List<TagSymbol>) taggingResolver.getTags(instance, DataPathSymbol.KIND);
: (List<TagSymbol>) taggingResolver.getTags(component, DataPathSymbol.KIND); List<TagSymbol> tags = !instanceTags.isEmpty() ? instanceTags :
(List<TagSymbol>) taggingResolver.getTags(component, DataPathSymbol.KIND);
String dataPath; String dataPath;
if (!tags.isEmpty()) { if (!tags.isEmpty()) {
DataPathCocos.check(component, taggingResolver);
dataPath = (String) tags.get(0).getValues().get(0); dataPath = (String) tags.get(0).getValues().get(0);
Log.warn("Tagfile was found, ignoring data_paths.txt: " + dataPath); }
} else { else {
DataPathConfigParser newParserConfig = new DataPathConfigParser(getModelsPath() + "data_paths.txt"); DataPathConfigParser newParserConfig = new DataPathConfigParser(getModelsPath() + "data_paths.txt");
dataPath = newParserConfig.getDataPath(component.getFullName()); dataPath = newParserConfig.getDataPath(component.getFullName());
} }
...@@ -383,104 +361,103 @@ public class EMADLGenerator { ...@@ -383,104 +361,103 @@ public class EMADLGenerator {
return dataPath; return dataPath;
} }
protected void generateComponent(List<FileContent> fileContents, Set<EMAComponentInstanceSymbol> allInstances, protected void generateComponent(List<FileContent> fileContents,
TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab) { Set<EMAComponentInstanceSymbol> allInstances,
TaggingResolver taggingResolver,
EMAComponentInstanceSymbol componentInstanceSymbol,
Scope symtab){
allInstances.add(componentInstanceSymbol); allInstances.add(componentInstanceSymbol);
EMAComponentSymbol EMAComponentSymbol = componentInstanceSymbol.getComponentType().getReferencedSymbol(); EMAComponentSymbol EMAComponentSymbol = componentInstanceSymbol.getComponentType().getReferencedSymbol();
/* /* remove the following two lines if the component symbol full name bug with generic variables is fixed */
* remove the following two lines if the component symbol full name bug with
* generic variables is fixed
*/
EMAComponentSymbol.setFullName(null); EMAComponentSymbol.setFullName(null);
EMAComponentSymbol.getFullName(); EMAComponentSymbol.getFullName();
/* */ /* */
Optional<ArchitectureSymbol> architecture = componentInstanceSymbol.getSpannedScope().resolve("", Optional<ArchitectureSymbol> architecture = componentInstanceSymbol.getSpannedScope().resolve("", ArchitectureSymbol.KIND);
ArchitectureSymbol.KIND); Optional<MathStatementsSymbol> mathStatements = EMAComponentSymbol.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND);
Optional<MathStatementsSymbol> mathStatements = EMAComponentSymbol.getSpannedScope().resolve("MathStatements",
MathStatementsSymbol.KIND);
EMADLCocos.checkAll(componentInstanceSymbol); EMADLCocos.checkAll(componentInstanceSymbol);
if (architecture.isPresent()) { if (architecture.isPresent()){
String dPath = getDataPath(taggingResolver, EMAComponentSymbol, componentInstanceSymbol); String dPath = getDataPath(taggingResolver, EMAComponentSymbol, componentInstanceSymbol);
architecture.get().setDataPath(dPath); architecture.get().setDataPath(dPath);
architecture.get().setComponentName(EMAComponentSymbol.getFullName()); architecture.get().setComponentName(EMAComponentSymbol.getFullName());
generateCNN(fileContents, taggingResolver, componentInstanceSymbol, architecture.get());