Commit 242d221d authored by Abdallah Atouani's avatar Abdallah Atouani

Merge remote-tracking branch 'origin/feature/path_tagging' into feature/path_tagging

# Conflicts:
#	src/main/java/de/monticore/lang/monticar/emadl/generator/EMADLGenerator.java
#	src/test/java/de/monticore/lang/monticar/emadl/GenerationTest.java
#	src/test/resources/models/tagging/AlexNet.tag
parents 663f0619 c10db833
...@@ -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.embeddedmontiarcdynamic.embeddedmontiarcdynamic._symboltable.cncModel.EMADynamicComponentSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstantiationSymbol;
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,6 +34,8 @@ import de.monticore.lang.monticar.cnnarch._symboltable.ArchitectureSymbol; ...@@ -34,6 +34,8 @@ 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._cocos.CheckArchitecture;
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;
...@@ -47,19 +49,17 @@ import de.monticore.symboltable.Scope; ...@@ -47,19 +49,17 @@ import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Splitters; 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 de.monticore.lang.monticar.emadl.tagging.dltag.DataPathSymbol;
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.security.DigestInputStream; import java.util.*;
import javax.xml.bind.DatatypeConverter;
public class EMADLGenerator { public class EMADLGenerator {
...@@ -69,8 +69,6 @@ public class EMADLGenerator { ...@@ -69,8 +69,6 @@ public class EMADLGenerator {
private Backend backend; private Backend backend;
private String modelsPath; private String modelsPath;
public EMADLGenerator(Backend backend) { public EMADLGenerator(Backend backend) {
this.backend = backend; this.backend = backend;
...@@ -86,24 +84,22 @@ public class EMADLGenerator { ...@@ -86,24 +84,22 @@ 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();
} }
...@@ -111,24 +107,27 @@ public class EMADLGenerator { ...@@ -111,24 +107,27 @@ public class EMADLGenerator {
return emamGen; return emamGen;
} }
public void generate(String modelPath, String qualifiedName, String pythonPath, String forced, boolean doCompile) throws IOException, TemplateException { public void generate(String modelPath, String qualifiedName, String pythonPath, String forced, boolean doCompile)
setModelsPath( modelPath ); throws IOException, TemplateException {
setModelsPath(modelPath);
TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath()); TaggingResolver symtab = EMADLAbstractSymtab.createSymTabAndTaggingResolver(getModelsPath());
EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND).orElse(null); EMAComponentSymbol component = symtab.<EMAComponentSymbol>resolve(qualifiedName, EMAComponentSymbol.KIND)
.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>resolve(instanceName, EMAComponentInstanceSymbol.KIND).get(); EMAComponentInstanceSymbol instance = component.getEnclosingScope()
.<EMAComponentInstanceSymbol>resolve(instanceName, EMAComponentInstanceSymbol.KIND).get();
generateFiles(symtab, instance, symtab, pythonPath, forced); generateFiles(symtab, instance, symtab, pythonPath, forced);
if (doCompile) { if (doCompile) {
compile(); compile();
} }
...@@ -141,11 +140,11 @@ public class EMADLGenerator { ...@@ -141,11 +140,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 {
...@@ -153,11 +152,10 @@ public class EMADLGenerator { ...@@ -153,11 +152,10 @@ 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( Writer streamWriter = new OutputStreamWriter(new FileOutputStream(tempScript));
tempScript));
PrintWriter printWriter = new PrintWriter(streamWriter); PrintWriter printWriter = new PrintWriter(streamWriter);
printWriter.println("#!/bin/bash"); printWriter.println("#!/bin/bash");
...@@ -168,7 +166,7 @@ public class EMADLGenerator { ...@@ -168,7 +166,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);
} }
...@@ -191,9 +189,11 @@ public class EMADLGenerator { ...@@ -191,9 +189,11 @@ public class EMADLGenerator {
} }
} }
public void generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol, Scope symtab, String pythonPath, String forced) throws IOException { public void generateFiles(TaggingResolver taggingResolver, EMAComponentInstanceSymbol EMAComponentSymbol,
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, forced); List<FileContent> fileContents = generateStrings(taggingResolver, EMAComponentSymbol, symtab, allInstances,
forced);
for (FileContent fileContent : fileContents) { for (FileContent fileContent : fileContents) {
emamGen.generateFile(fileContent); emamGen.generateFile(fileContent);
...@@ -201,74 +201,77 @@ public class EMADLGenerator { ...@@ -201,74 +201,77 @@ 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("", ArchitectureSymbol.KIND); Optional<ArchitectureSymbol> architecture = componentInstance.getSpannedScope().resolve("",
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(), componentInstance.getFullName(), componentInstance.getName()); String configFilename = getConfigFilename(componentInstance.getComponentType().getFullName(),
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().replaceAll("\\.", "/"); String componentConfigFilename = componentInstance.getComponentType().getReferencedSymbol().getFullName()
.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) || isAlreadyTrained(trainingHash, componentInstance); boolean alreadyTrained = newHashes.contains(trainingHash)
if(alreadyTrained && !forced.equals("y")) { || isAlreadyTrained(trainingHash, componentInstance);
if (alreadyTrained && !forced.equals("y")) {
Log.warn("Training of model " + componentInstance.getFullName() + " skipped"); Log.warn("Training of model " + componentInstance.getFullName() + " skipped");
} } else {
else { String parsedFullName = componentInstance.getFullName().substring(0, 1).toLowerCase()
String parsedFullName = componentInstance.getFullName().substring(0, 1).toLowerCase() + componentInstance.getFullName().substring(1).replaceAll("\\.", "_"); + 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.add(new FileContent(trainingHash, componentConfigFilename + ".training_hash")); fileContentsTrainingHashes
.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.");
} }
} }
...@@ -283,8 +286,7 @@ public class EMADLGenerator { ...@@ -283,8 +286,7 @@ 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) stringBuffer.append(Integer.toString((arrayBytes[i] & 0xff) + 0x100, 16).substring(1));
.substring(1));
} }
return stringBuffer.toString(); return stringBuffer.toString();
} }
...@@ -295,24 +297,25 @@ public class EMADLGenerator { ...@@ -295,24 +297,25 @@ 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, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab, Set<EMAComponentInstanceSymbol> allInstances, String forced){ public List<FileContent> generateStrings(TaggingResolver taggingResolver,
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);
...@@ -326,14 +329,16 @@ public class EMADLGenerator { ...@@ -326,14 +329,16 @@ public class EMADLGenerator {
if (cnnArchGenerator.isCMakeRequired()) { if (cnnArchGenerator.isCMakeRequired()) {
cnnArchGenerator.setGenerationTargetPath(getGenerationTargetPath()); cnnArchGenerator.setGenerationTargetPath(getGenerationTargetPath());
Map<String, String> cmakeContentsMap = cnnArchGenerator.generateCMakeContent(componentInstanceSymbol.getFullName()); Map<String, String> cmakeContentsMap = cnnArchGenerator
for (String fileName : cmakeContentsMap.keySet()){ .generateCMakeContent(componentInstanceSymbol.getFullName());
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.get(0))); // fileContents.add(emamGen.getMainClassFileContent(componentInstanceSymbol,
// fileContents.get(0)));
} else if (emamGen.shouldGenerateSimulatorInterface()) { } else if (emamGen.shouldGenerateSimulatorInterface()) {
fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent()); fileContents.addAll(SimulatorIntegrationHelper.getSimulatorIntegrationHelperFileContent());
} }
...@@ -343,17 +348,41 @@ public class EMADLGenerator { ...@@ -343,17 +348,41 @@ 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> instanceTags = (List<TagSymbol>) taggingResolver.getTags(instance, DataPathSymbol.KIND); List<TagSymbol> tags = !instanceTags.isEmpty() ? instanceTags
List<TagSymbol> tags = !instanceTags.isEmpty() ? instanceTags : : (List<TagSymbol>) taggingResolver.getTags(component, DataPathSymbol.KIND);
(List<TagSymbol>) taggingResolver.getTags(component, DataPathSymbol.KIND);
String dataPath; String dataPath;
if (!tags.isEmpty()) { if (!tags.isEmpty()) {
dataPath = (String) tags.get(0).getValues().get(0); DataPathSymbol dataPathSymbol = (DataPathSymbol) tags.get(0);
} DataPathCocos.check(dataPathSymbol);
else {
dataPath = dataPathSymbol.getPath();
// TODO: Replace warinings with errors, until then use this method
stopGeneratorIfWarning();
Log.warn("Tagging info for symbol was found, ignoring data_paths.txt: " + dataPath);
} 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());
} }
...@@ -361,103 +390,104 @@ public class EMADLGenerator { ...@@ -361,103 +390,104 @@ public class EMADLGenerator {
return dataPath; return dataPath;
} }
protected void generateComponent(List<FileContent> fileContents, protected void generateComponent(List<FileContent> fileContents, Set<EMAComponentInstanceSymbol> allInstances,
Set<EMAComponentInstanceSymbol> allInstances, TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab) {
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("", ArchitectureSymbol.KIND); Optional<ArchitectureSymbol> architecture = componentInstanceSymbol.getSpannedScope().resolve("",
Optional<MathStatementsSymbol> mathStatements = EMAComponentSymbol.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND); ArchitectureSymbol.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()); generateCNN(fileContents, taggingResolver, componentInstanceSymbol, architecture.get());
} } else if (mathStatements.isPresent()) {
else if (mathStatements.isPresent()){
generateMathComponent(fileContents, taggingResolver, componentInstanceSymbol, mathStatements.get()); generateMathComponent(fileContents, taggingResolver, componentInstanceSymbol, mathStatements.get());
} } else {
else {
generateSubComponents(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab); generateSubComponents(fileContents, allInstances, taggingResolver, componentInstanceSymbol, symtab);
} }
} }