Commit 82d8a08f authored by Nils Kaminski's avatar Nils Kaminski
Browse files

Test for ema instance symbols

parent 0d91f02b
Pipeline #82851 failed with stage
in 29 seconds
......@@ -47,6 +47,7 @@ import java.util.stream.Collectors;
* @author ernst
*
*/
public class ImplementExecutionOrder {
private static Map<EMAComponentInstanceSymbol, Collection<EMAPortInstanceSymbol>> dependencies = new HashMap<>();
private static int s = 0;
......@@ -439,6 +440,8 @@ public class ImplementExecutionOrder {
public static Collection<EMAConnectorInstanceSymbol> getAllConnectors(EMAComponentInstanceSymbol inst){
//TODO: Change this method because it will create to many connectors ...
if(inst instanceof EMADynamicComponentInstanceSymbol) {
Collection<EMAConnectorInstanceSymbol> result = new ArrayList<>();
......
......@@ -30,6 +30,11 @@ public class DynamicPortConnectDynamicInstanceTest extends AbstractSymtabTest {
test("instanceRequest.test3", "./target/generated-sources-cpp/dynamics/DynamicPortConnectDynamicInstanceTest_Test_03_Test3");
}
@Test
public void Test_04_Big() throws IOException {
test("instanceRequest.testBig", "./target/generated-sources-cpp/dynamics/DynamicPortConnectDynamicInstanceTest_Test_04_Big");
}
protected void test(String instName, String target){
try {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
......
package de.monticore.lang.monticar.generator.dynamics;
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.LogConfig;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcLanguage;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.helper.ConstantPortHelper;
import de.monticore.lang.monticar.enumlang._symboltable.EnumLangLanguage;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.lang.monticar.generator.cpp.converter.MathConverter;
import de.monticore.lang.monticar.generator.optimization.MathOptimizer;
import de.monticore.lang.monticar.generator.optimization.ThreadingOptimizer;
import de.monticore.lang.monticar.generator.order.nfp.TagBreakpointsTagSchema.TagBreakpointsTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagDelayTagSchema.TagDelayTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagExecutionOrderTagSchema.TagExecutionOrderTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagInitTagSchema.TagInitTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagMinMaxTagSchema.TagMinMaxTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagTableTagSchema.TagTableTagSchema;
import de.monticore.lang.monticar.generator.order.nfp.TagThresholdTagSchema.TagThresholdTagSchema;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertNotNull;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class EMAGenerationTest {
public static TaggingResolver createSymTabAndTaggingResolver(String... modelPath) {
Scope scope = createSymTab(modelPath);
TaggingResolver tagging = new TaggingResolver(scope, Arrays.asList(modelPath));
TagMinMaxTagSchema.registerTagTypes(tagging);
TagTableTagSchema.registerTagTypes(tagging);
TagBreakpointsTagSchema.registerTagTypes(tagging);
TagExecutionOrderTagSchema.registerTagTypes(tagging);
TagInitTagSchema.registerTagTypes(tagging);
TagThresholdTagSchema.registerTagTypes(tagging);
TagDelayTagSchema.registerTagTypes(tagging);
return tagging;
}
public static Scope createSymTab(String... modelPath) {
// ConstantPortSymbol.resetLastID();
ConstantPortHelper.resetLastID();
MathConverter.resetIDs();
ThreadingOptimizer.resetID();
MathOptimizer.resetIDs();
ModelingLanguageFamily fam = new ModelingLanguageFamily();
EmbeddedMontiArcLanguage montiArcLanguage = new EmbeddedMontiArcLanguage();
fam.addModelingLanguage(montiArcLanguage);
fam.addModelingLanguage(new StreamUnitsLanguage());
fam.addModelingLanguage(new StructLanguage());
fam.addModelingLanguage(new EnumLangLanguage());
final ModelPath mp = new ModelPath();
for (String m : modelPath) {
mp.addEntry(Paths.get(m));
}
LogConfig.init();//TODO comment for debug output
GlobalScope scope = new GlobalScope(mp, fam);
de.monticore.lang.monticar.Utils.addBuiltInTypes(scope);
return scope;
}
@BeforeClass
public static void setUp() {
// ensure an empty log
Log.getFindings().clear();
Log.enableFailQuick(false);
}
@Test
public void Test_01_PassThrough() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve("ema.passThrough", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/dynamics/ema/test01");
generatorCPP.setGenerateCMake(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
files.stream().forEach(f -> System.out.println("Generated: "+f.getName()));
}
@Test
public void Test_02_Components() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve("ema.components", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/dynamics/ema/test02");
generatorCPP.setGenerateCMake(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
files.stream().forEach(f -> System.out.println("Generated: "+f.getName()));
}
}
package ema;
component Components {
ports
in B a,
out B b,
in Q c,
out Q d;
instance PassThrough pt;
instance PassThrough at[5];
connect a -> pt.inB;
connect pt.outB -> b;
connect c -> at[5].inQ;
connect at[5].outQ -> at[3].inQ;
connect at[3].outQ -> at[1].inQ;
connect at[1].outQ -> at[4].inQ;
connect at[4].outQ -> at[2].inQ;
connect at[2].outQ -> d;
}
\ No newline at end of file
package ema;
component PassThrough {
ports
in B inB,
in Q inQ,
out Q outQ,
out B outB,
out Z outZ;
connect 42 -> outZ;
connect inQ -> outQ;
connect inB -> outB;
}
\ No newline at end of file
package instanceRequest;
dynamic component TestBig{
port
dynamic in B a[0:1024],
dynamic out B b[0:1024];
component PassThrough {
ports
in B in1,
out B out1;
connect in1 -> out1;
}
instance PassThrough pt[0:1024];
@ a::connect && b::connect {
connect a[?] -> pt[?].in1;
connect pt[?].out1 -> b[?];
}
}
\ No newline at end of file
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