Commit b6cd614e authored by Malte Heithoff's avatar Malte Heithoff

type update

parent e2675b21
Pipeline #388315 failed with stage
in 1 minute and 9 seconds
......@@ -12,10 +12,15 @@ import org.apache.commons.lang3.StringUtils;
*/
public class Helper {
public static MathStatementsSymbol getMathStatementsSymbolFor(EMAComponentInstanceSymbol instanceSymbol, Scope symtab) {
String resolveName = instanceSymbol.getPackageName() + "." + StringUtils.capitalize(instanceSymbol.getName()) + ".MathStatements";
MathStatementsSymbol mathSymbol = symtab.<MathStatementsSymbol>resolve(resolveName, MathStatementsSymbol.KIND).orElse(null);
String resolveName = "MathStatements";
MathStatementsSymbol mathSymbol = instanceSymbol.getSpannedScope().<MathStatementsSymbol>resolve(resolveName, MathStatementsSymbol.KIND).orElse(null);
if (mathSymbol == null) {
resolveName = instanceSymbol.getPackageName() + "." + StringUtils.capitalize(instanceSymbol.getName()) + ".MathStatements";
mathSymbol = symtab.<MathStatementsSymbol>resolve(resolveName, MathStatementsSymbol.KIND).orElse(null);
}
if (mathSymbol == null && instanceSymbol.getComponentType() != null) {
EMAComponentSymbol symbol = instanceSymbol.getComponentType().getReferencedSymbol();
resolveName = symbol.getPackageName() + "." + symbol.getName() + ".MathStatements";
mathSymbol = symtab.<MathStatementsSymbol>resolve(resolveName, MathStatementsSymbol.KIND).orElse(null);
......
......@@ -16,6 +16,7 @@ import de.monticore.lang.monticar.generator.cpp.Dynamics.EventPortValueCheck;
import de.monticore.lang.monticar.generator.cpp.converter.*;
import de.monticore.lang.monticar.generator.cpp.instruction.ConnectInstructionCPP;
import de.monticore.lang.monticar.generator.cpp.loopSolver.CPPEquationSystemHelper;
import de.monticore.lang.monticar.generator.cpp.loopSolver.EquationSystemComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.cpp.loopSolver.daecpp.DAECPPEquationSystemGenerator;
import de.monticore.lang.monticar.generator.cpp.loopSolver.daecpp.DAECPPOptions;
import de.monticore.lang.monticar.generator.cpp.loopSolver.odeint.OdeintEquationSystemGenerator;
......@@ -37,6 +38,7 @@ import de.monticore.lang.monticar.semantics.resolve.SymbolTableHelper;
import de.monticore.lang.monticar.ts.MCTypeSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Joiners;
import de.se_rwth.commons.logging.Log;
import org.apache.commons.lang3.StringUtils;
......@@ -279,8 +281,7 @@ public class GeneratorCPP implements EMAMGenerator {
if (componentInstanceSymbol instanceof LoopComponentInstanceSymbol) {
((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem()
.setName(String.join("_",
NameHelper.replaceWithUnderScore(NameHelper.calculateFullQualifiedNameOf(rootModel)),
.setName(Joiners.DOT.join(rootModel.getFullName(),
((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem().getName()));
for (CMakeFindModule dependency : OdeintOptions.getDependencies())
cMakeConfig.addModuleDependency(dependency);
......@@ -347,9 +348,12 @@ public class GeneratorCPP implements EMAMGenerator {
if (componentInstanceSymbol instanceof LoopComponentInstanceSymbol) {
if (!equationSystemsAlreadyBuild.contains(((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem())) {
fileContents.addAll(OdeintEquationSystemGenerator.generateEquationSystem(
((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem()));
EMAEquationSystem equationSystem = ((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem();
if (!equationSystemsAlreadyBuild.contains(equationSystem)) {
// fileContents.addAll(OdeintEquationSystemGenerator.generateEquationSystem(
// ((LoopComponentInstanceSymbol) componentInstanceSymbol).getEquationSystem()));
fileContents.addAll(generateStrings(taggingResolver,
new EquationSystemComponentInstanceSymbol(equationSystem)));
}
}
......
......@@ -188,6 +188,7 @@ public final class TestsGeneratorCPP {
private void processBluePrint(EMAMBluePrintCPP b, EMAComponentInstanceSymbol s) {
//TODO: 123 : check if EMAComponentSymbol is correct choice here: ComponentSymbol cs = s.getComponentType().getReferencedSymbol();
if (s.getComponentType() == null) return;
EMAComponentSymbol cs = s.getComponentType().getReferencedSymbol();
if (testedComponents.add(cs.getFullName())) {
processBluePrint(b, cs);
......
......@@ -16,6 +16,7 @@ import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cpp.*;
import de.monticore.lang.monticar.generator.cpp.instruction.ConstantConnectInstructionCPP;
import de.monticore.lang.monticar.generator.cpp.loopSolver.EquationSystemComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.optimization.MathInformationRegister;
import de.monticore.lang.monticar.semantics.executionOrder.ExecutionOrder;
import de.se_rwth.commons.logging.Log;
......@@ -253,7 +254,11 @@ public class ComponentConverter {
parameterString += getExpressionParameterConversion(var);
}
String result = "";
result += GeneralHelperMethods.getTargetLanguageVariableInstanceName(subComponent.getName()) + ".init(" + parameterString + ");\n";
if (componentSymbol instanceof EquationSystemComponentInstanceSymbol)
result += GeneralHelperMethods.getTargetLanguageVariableInstanceName(subComponent.getFullName()) + ".init(" + parameterString + ");\n";
else
result += GeneralHelperMethods.getTargetLanguageVariableInstanceName(subComponent.getName()) + ".init(" + parameterString + ");\n";
if((componentSymbol instanceof EMADynamicComponentInstanceSymbol) && (subComponent instanceof EMADynamicComponentInstanceSymbol)){
if(((EMADynamicComponentInstanceSymbol) componentSymbol).isDynamic() && ((EMADynamicComponentInstanceSymbol) subComponent).isDynamic()){
......
......@@ -5,6 +5,8 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarcdynamic.embeddedmontiarcdynamic._symboltable.instanceStructure.EMADynamicComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.Variable;
import de.monticore.lang.monticar.generator.cpp.GeneralHelperMethods;
import de.monticore.lang.monticar.generator.cpp.loopSolver.EquationSystemComponentInstanceSymbol;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.symboltable.ImportStatement;
import de.se_rwth.commons.logging.Log;
......@@ -23,8 +25,13 @@ public class ComponentInstanceConverter {
Variable variable = new Variable();
variable.setName(instanceSymbol.getName());
variable.setVariableType(TypeConverter.getVariableTypeForMontiCarInstance(instanceSymbol));
if (componentSymbol instanceof EquationSystemComponentInstanceSymbol) {
variable.setName(GeneralHelperMethods.getTargetLanguageComponentName(instanceSymbol.getFullName()));
variable.setVariableType(((EquationSystemComponentInstanceSymbol) componentSymbol).getTypeOfSubComponent(instanceSymbol));
} else {
variable.setName(instanceSymbol.getName());
variable.setVariableType(TypeConverter.getVariableTypeForMontiCarInstance(instanceSymbol));
}
//String res = getTargetCodeImportString(instanceSymbol, componentSymbol);
//if (res != null)
// variable.setTargetCodeImport(res);
......
package de.monticore.lang.monticar.generator.cpp.loopSolver;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbolReference;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.VariableType;
import de.monticore.lang.monticar.generator.cpp.GeneralHelperMethods;
import de.monticore.lang.monticar.generator.cpp.converter.TypeConverter;
import de.monticore.lang.monticar.semantics.helper.NameHelper;
import de.monticore.lang.monticar.semantics.loops.symbols.EMAEquationSystem;
import de.se_rwth.commons.Joiners;
import java.util.Collection;
import java.util.Optional;
public class EquationSystemComponentInstanceSymbol extends EMAComponentInstanceSymbol {
private EMAEquationSystem system;
public EquationSystemComponentInstanceSymbol(EMAEquationSystem system) {
super(system.getName(), null);
this.system = system;
}
public String getSubComponentName(EMAComponentInstanceSymbol subComponent) {
String parentName = NameHelper.getPackageOfFullQualifiedName(getFullName());
String fullName = NameHelper.calculatePartialName(subComponent.getFullName(), parentName);
return Joiners.DOT.join(getFullName(), fullName);
}
public VariableType getTypeOfSubComponent(EMAComponentInstanceSymbol subComponent) {
String fullName = getSubComponentName(subComponent);
VariableType type = new VariableType();
type.setTypeNameMontiCar(fullName);
type.setTypeNameTargetLanguage(GeneralHelperMethods.getTargetLanguageComponentName(fullName));
type.setIncludeName(type.getTypeNameTargetLanguage());
TypeConverter.addNonPrimitiveVariableType(type);
return type;
}
@Override
public Collection<EMAComponentInstanceSymbol> getSubComponents() {
return system.getComponentInstanceSymbols();
}
@Override
public Optional<EMAComponentInstanceSymbol> getSubComponent(String name) {
return getSubComponents().stream().filter(s -> s.getName().equals(name) || s.getFullName().equals(name)).findAny();
}
@Override
public Optional<EMAComponentInstanceSymbol> getParent() {
return Optional.empty();
}
@Override
public String toString() {
return getName();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment