Commit fa83e16d authored by Alexander Ryndin's avatar Alexander Ryndin
Browse files

Merge branch 'master' into ryndin

parents d5e80795 13c5e314
script:
- git checkout ${TRAVIS_BRANCH}
- mvn clean install cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report --settings "settings.xml"
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install cobertura:cobertura org.eluder.coveralls:coveralls-maven-plugin:report --settings "settings.xml"
after_success:
- mvn deploy --debug --settings "./settings.xml"
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B deploy --debug --settings "./settings.xml"
......@@ -117,7 +117,7 @@ public class EmbeddedMontiArcExpandedComponentInstanceSymbolCreator {
createInstance(inst.getComponentType(), filters, inst.getComponentType().getReferencedSymbol().getResolutionDeclarationSymbols())
.setName(inst.getName())
.addActualTypeArguments(inst.getComponentType().getFormalTypeParameters(),
inst.getComponentType().getActualTypeArguments()).addResolvingFilters(filters).addResolutionDeclarationSymbols(inst.getComponentType().getReferencedSymbol().getResolutionDeclarationSymbols()).addParameters(inst.getComponentType().getReferencedSymbol().getParameters()).addArguments(inst.getComponentType().getReferencedSymbol().getArguments()).build());
inst.getComponentType().getActualTypeArguments()).addResolvingFilters(filters).addResolutionDeclarationSymbols(inst.getComponentType().getResolutionDeclarationSymbols()).addParameters(inst.getComponentType().getReferencedSymbol().getParameters()).addArguments(inst.getComponentType().getReferencedSymbol().getArguments()).build());
Log.debug(inst.getInstanceInformation().get().getInstanceNumberForArgumentIndex(0) + "", "InstanceInformation:");
Log.debug(inst.toString(), "ComponentInstance CreateInstance PostSub");
......
......@@ -54,18 +54,7 @@ import de.monticore.lang.monticar.ts.MontiCarSymbolFactory;
import de.monticore.lang.monticar.ts.references.CommonMCTypeReference;
import de.monticore.lang.monticar.ts.references.MCTypeReference;
import de.monticore.lang.monticar.ts.references.MontiCarTypeSymbolReference;
import de.monticore.lang.monticar.types2._ast.ASTComplexArrayType;
import de.monticore.lang.monticar.types2._ast.ASTComplexReferenceType;
import de.monticore.lang.monticar.types2._ast.ASTImportStatement;
import de.monticore.lang.monticar.types2._ast.ASTReferenceType;
import de.monticore.lang.monticar.types2._ast.ASTSimpleReferenceType;
import de.monticore.lang.monticar.types2._ast.ASTType;
import de.monticore.lang.monticar.types2._ast.ASTTypeNameResolutionDeclaration;
import de.monticore.lang.monticar.types2._ast.ASTTypeParameters;
import de.monticore.lang.monticar.types2._ast.ASTTypeVariableDeclaration;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberTypeArgument;
import de.monticore.lang.monticar.types2._ast.ASTWildcardType;
import de.monticore.lang.monticar.types2._ast.*;
import de.monticore.symboltable.ArtifactScope;
import de.monticore.symboltable.ImportStatement;
import de.monticore.symboltable.MutableScope;
......@@ -790,6 +779,11 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
InstanceInformation instanceInformation = new InstanceInformation();
instanceInformation.setCompName(name);
instanceInformation.setASTSubComponent(node);
String reslString = "";
for (ResolutionDeclarationSymbol resolutionDeclarationSymbol : componentTypeReference.getResolutionDeclarationSymbols()) {
reslString+="Name:"+resolutionDeclarationSymbol.getNameToResolve()+"value: "+((ASTUnitNumberResolution)resolutionDeclarationSymbol.getASTResolution()).getNumber().get().intValue();
}
Log.info(reslString, "CompInst");
InstancingRegister.addInstanceInformation(instanceInformation);
Log.debug(name, "created SubComponentInstance:");
}
......@@ -1135,6 +1129,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
if (astType instanceof ASTSimpleReferenceType) {
ASTSimpleReferenceType astSimpleReferenceType = (ASTSimpleReferenceType) astType;
if (!astSimpleReferenceType.getTypeArguments().isPresent()) {
//Log.error("Not TypeArgs present");
return;
}
setActualTypeArguments(typeReference,
......@@ -1146,6 +1141,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
// TODO
/* ASTComplexReferenceType represents types like class or interface types which always have
* ASTSimpleReferenceType as qualification. For example: a.b.c<Arg>.d.e<Arg> */
}
}
......
......@@ -303,8 +303,10 @@ public class ExpandedComponentInstanceBuilder {
public ExpandedComponentInstanceBuilder addResolutionDeclarationSymbols(List<ResolutionDeclarationSymbol> resolutionDeclarationSymbols) {
for (ResolutionDeclarationSymbol symbol : resolutionDeclarationSymbols) {
if (!this.resolutionDeclarationSymbols.contains(symbol))
if (!this.resolutionDeclarationSymbols.contains(symbol)) {
Log.info("name: "+symbol.getNameToResolve() +" astResolution: "+symbol.getASTResolution().toString(),"Added ResolutionDeclarationSymbol To ExpandedComponentInstanceBuilder");
this.resolutionDeclarationSymbols.add(symbol);
}
}
return this;
......
......@@ -134,6 +134,15 @@ public class ExpandedComponentInstanceSymbol
return resolutionDeclarationSymbols;
}
public ResolutionDeclarationSymbol getResolutionDeclarationSymbol(String name) {
for (ResolutionDeclarationSymbol resolutionDeclarationSymbol : resolutionDeclarationSymbols) {
if (resolutionDeclarationSymbol.getNameToResolve().equals(name))
return resolutionDeclarationSymbol;
}
return null;
}
public Optional<InstanceInformation> getInstanceInformation() {
return InstancingRegister.getInstanceInformation(getName());
}
......
......@@ -21,6 +21,7 @@
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTSubComponent;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTSubComponentInstance;
import de.monticore.lang.monticar.resolution._ast.ASTTypeArgument;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTSimpleReferenceType;
......@@ -124,9 +125,15 @@ public class InstanceInformation {
int counter = 0;
for (ASTTypeArgument astTypeArgument : simpleReferenceType.getTypeArguments().get().getTypeArguments()) {
int result = handleSimpleReferenceType(astTypeArgument, index, counter);
if (result != -1)
if (result != -1 && counter == index)
return result;
else {
//Log.error("HERE");
}
++counter;
}
} else {
//Log.error("No arguments");
}
return -1;
}
......@@ -137,15 +144,15 @@ public class InstanceInformation {
if (((ASTUnitNumberTypeArgument) astTypeArgument).getUnitNumber().getNumber().isPresent()) {
if (counter == index)
result = ((ASTUnitNumberTypeArgument) astTypeArgument).getUnitNumber().getNumber().get().intValue();
++counter;
}
} else if (astTypeArgument instanceof ASTUnitNumberResolution) {
if (((ASTUnitNumberResolution) astTypeArgument).getUnitNumber().isPresent()) {
if (counter == index)
result = ((ASTUnitNumberResolution) astTypeArgument).getNumber().get().intValue();
++counter;
}
} else {
//Log.error(astTypeArgument.getClass().toString());
}
return result;
}
......@@ -191,4 +198,13 @@ public class InstanceInformation {
}
}
@Override
public String toString() {
String subComponentString = "";
for (ASTSubComponentInstance astSubComponentInstance : astSubComponent.getInstances()) {
subComponentString += " " + astSubComponentInstance;
}
return "ComponentName: " + getCompName() + " " + subComponentString;
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
......@@ -34,6 +35,7 @@ public class InstancingRegister {
public static void addInstanceInformation(InstanceInformation i) {
instanceInformation.add(i);
Log.info(i.toString(), "Added InstanceInformation");
}
public static Optional<InstanceInformation> getInstanceInformation(String name) {
......@@ -43,4 +45,8 @@ public class InstancingRegister {
}
return Optional.empty();
}
public static void reset() {
instanceInformation.clear();
}
}
......@@ -23,6 +23,8 @@ package de.monticore.lang.embeddedmontiarc;
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcLanguage;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.InstanceInformation;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.InstancingRegister;
import de.monticore.lang.monticar.stream._symboltable.StreamLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.symboltable.GlobalScope;
......@@ -35,20 +37,21 @@ import java.nio.file.Paths;
*
*/
public class AbstractSymtabTest {
protected static Scope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
fam.addModelingLanguage(new EmbeddedMontiArcLanguage());
fam.addModelingLanguage(new StreamLanguage());
fam.addModelingLanguage(new StructLanguage());
final ModelPath mp = new ModelPath();
for (String m : modelPath) {
mp.addEntry(Paths.get(m));
}
GlobalScope scope = new GlobalScope(mp, fam);
protected static Scope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
fam.addModelingLanguage(new EmbeddedMontiArcLanguage());
fam.addModelingLanguage(new StreamLanguage());
fam.addModelingLanguage(new StructLanguage());
final ModelPath mp = new ModelPath();
for (String m : modelPath) {
mp.addEntry(Paths.get(m));
}
GlobalScope scope = new GlobalScope(mp, fam);
de.monticore.lang.monticar.Utils.addBuiltInTypes(scope);
de.monticore.lang.monticar.Utils.addBuiltInTypes(scope);
LogConfig.init();//TODO comment for logger output
return scope;
}
LogConfig.init();//TODO comment for logger output
InstancingRegister.reset();
return scope;
}
}
......@@ -22,6 +22,8 @@ package de.monticore.lang.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.monticar.mcexpressions._ast.ASTExpression;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.monticore.lang.monticar.types2._ast.ASTUnitNumberResolution;
import de.monticore.symboltable.Scope;
import de.monticore.symboltable.Symbol;
import de.se_rwth.commons.logging.Log;
......@@ -43,7 +45,7 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
public void testFAS() throws Exception {
Scope symTab = createSymTab("src/test/resources");
ExpandedComponentInstanceSymbol inst = symTab.<ExpandedComponentInstanceSymbol>resolve(
"fas.demo_fas_Fkt_m.fAS", ExpandedComponentInstanceSymbol.KIND).orElse(null);
"fas.demo_fas_Fkt_m.fAS", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(inst);
}
......@@ -224,6 +226,28 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
System.out.println(inst);
}
@Test
public void testTypeVariableGenericsInstanciation2() {
Scope symTab = createSymTab("src/test/resources");
ExpandedComponentInstanceSymbol csInner = symTab.<ExpandedComponentInstanceSymbol>resolve("testing.basicResolutionInstance.br1", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(csInner);
Log.debug(csInner.getFullName() + " " + csInner.getComponentType().getReferencedSymbol().howManyResolutionDeclarationSymbol(), "Amount ResolutionDeclarationSymbols :");
ResolutionDeclarationSymbol jt = csInner.getResolutionDeclarationSymbol("n");
assertNotNull(jt);
//This works for all generic indices
int result = InstanceInformation.getInstanceNumberFromASTSubComponent(csInner.getInstanceInformation().get().getASTSubComponent(), 0);
assertEquals(6, result);
//not working in expandedcomponentInstanceSymbols, use InstanceInformation.getInstanceNumber... as seen above
//assertEquals(6, ((ASTUnitNumberResolution) jt.getASTResolution()).getNumber().get().intValue());
assertEquals("br1", csInner.getName());
assertEquals(6, csInner.getComponentType().getIncomingPorts().size());
result = InstanceInformation.getInstanceNumberFromASTSubComponent(csInner.getInstanceInformation().get().getASTSubComponent(), 1);
assertEquals(3, result);
}
/*
@Test
public void testGenericInstance() throws Exception {
......
......@@ -20,14 +20,7 @@
*/
package de.monticore.lang.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConnectorSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ConstantPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortArraySymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.UnitNumberExpressionSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.unit.constant.EMAConstantSIUnit;
import de.monticore.lang.monticar.mcexpressions._ast.ASTExpression;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
......@@ -639,6 +632,35 @@ public class SymtabTest extends AbstractSymtabTest {
assertEquals("br1", csInner.getName());
assertEquals(2, csInner.getComponentType().getIncomingPorts().size());
ResolutionDeclarationSymbol jk = csInner.getComponentType().getResolutionDeclarationSymbol("k").get();
assertNotNull(jk);
assertEquals(1, ((ASTUnitNumberResolution) jk.getASTResolution()).getNumber().get().intValue());
}
@Test
public void testTypeVariableGenericsInstanciation2() {
Scope symTab = createSymTab("src/test/resources");
ComponentSymbol cs = symTab.<ComponentSymbol>resolve("testing.BasicResolutionInstance", ComponentSymbol.KIND).orElse(null);
assertNotNull(cs);
ComponentInstanceSymbol csInner = symTab.<ComponentInstanceSymbol>resolve("testing.BasicResolutionDefaultInstance.br1", ComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(csInner);
Log.debug(csInner.getFullName() + " " + csInner.getComponentType().getReferencedSymbol().howManyResolutionDeclarationSymbol(), "Amount ResolutionDeclarationSymbols :");
ResolutionDeclarationSymbol jt = csInner.getComponentType().getResolutionDeclarationSymbol("n").get();
assertNotNull(jt);
assertEquals(6, ((ASTUnitNumberResolution) jt.getASTResolution()).getNumber().get().intValue());
assertEquals("br1", csInner.getName());
assertEquals(6, csInner.getComponentType().getIncomingPorts().size());
ResolutionDeclarationSymbol jk = csInner.getComponentType().getResolutionDeclarationSymbol("k").get();
assertNotNull(jk);
assertEquals(3, InstanceInformation.getInstanceNumberFromASTSubComponent(csInner.getInstanceInformation().get().getASTSubComponent(),1));
}
......
package testing;
component BasicResolution<N1 n = 2> {
component BasicResolution<N1 n = 2, N1 k = 1> {
port
in B in1[n],
out B out1;
......
......@@ -3,9 +3,10 @@ package testing;
component BasicResolutionInstance {
port
in B a1[6],
in B a2[3],
out B out1;
instance BasicResolution<6> br1;
instance BasicResolution<6,3> br1;
connect a1[1]->br1.in1[1];
connect a1[2]->br1.in1[2];
......@@ -13,5 +14,4 @@ component BasicResolutionInstance {
connect a1[4]->br1.in1[4];
connect a1[5]->br1.in1[5];
connect a1[6]->br1.in1[6];
}
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