Commit 3992fd04 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Fix: EMADL2CPP/issues/1 + testcase

parent 31032678
Pipeline #94036 failed with stage
in 15 minutes and 20 seconds
......@@ -41,6 +41,7 @@ import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
......@@ -106,7 +107,7 @@ public class ComponentConverterMethodGeneration {
for (currentGenerationIndex = 0; currentGenerationIndex < mathStatementsSymbol.getMathExpressionSymbols().size(); ++currentGenerationIndex) {
int beginIndex = currentGenerationIndex;
MathExpressionSymbol mathExpressionSymbol = mathStatementsSymbol.getMathExpressionSymbols().get(currentGenerationIndex);
if (!visitedMathExpressionSymbols.contains(mathExpressionSymbol)) {
if (!containsExactObject(visitedMathExpressionSymbols, mathExpressionSymbol)) {
if (generatorCPP.useAlgebraicOptimizations()) {
List<MathExpressionSymbol> precedingExpressions = new ArrayList<>();
for (int i = 0; i < counter; ++i)
......@@ -124,6 +125,16 @@ public class ComponentConverterMethodGeneration {
removeUselessVariableDefinitions(method);
}
private static boolean containsExactObject(Collection collection, Object obj){
for(Object other : collection){
//equals is not used on purpose!
//the jvm object id must be the same!
if(other == obj) return true;
}
return false;
}
private static void removeUselessVariableDefinitions(Method method) {
List<Instruction> instructionsToRemove = new ArrayList<>();
for (Instruction instruction1 : method.getInstructions()) {
......
......@@ -327,4 +327,18 @@ public class AutomaticStreamTestGenerationTest extends AbstractSymtabTest {
}
//Maybe add test that executes all stream tests in the resource dir(will take longer than an hour to execute) later
@Test
public void testMultipleAssignments() throws Exception {
AutomaticStreamTestGenerator generator = new AutomaticStreamTestGenerator();
String fullComponentInstanceName = "test.multipleAssignments";
String modelDir = "src/test/resources/streamtests/multipleAssignmentsBase";
generator.generateTests(fullComponentInstanceName,
modelDir, "N:/target/generated-sources-cpp/streamtest/multipleAssignments/", "1", 1);
testGenCPPFilesAndExec("./target/generated-sources-cpp/streamtest", "/multipleAssignments",
modelDir, "./target/generated-sources-cpp/streamtest/multipleAssignments",
fullComponentInstanceName,
"test.MultipleAssignmentsTest");
}
}
Supports Markdown
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