Commit 0e1f7c17 authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

updated test and removed some deprecated classes

parent c47ba70c
......@@ -94,7 +94,7 @@ public class PortUsage implements EmbeddedMontiArcASTComponentCoCo {
.forEach(sc -> connectorTargets.addAll(getTargetNames(sc.getSimpleConnectors())));
remainingPorts.removeAll(connectorTargets);
if (!remainingPorts.isEmpty()) {
if (!remainingPorts.isEmpty()&&node.getSubComponents().size()!=0) {
remainingPorts.forEach(p -> Log.error(String.format("0xAC007 Port %s is not used!", p),
node.get_SourcePositionStart()));
}
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
* <p>
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p>
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
......@@ -30,6 +29,7 @@ import de.monticore.lang.embeddedmontiarc.helper.ArcTypePrinter;
import de.monticore.lang.embeddedmontiarc.helper.Timing;
import de.monticore.lang.embeddedmontiarc.trafos.AutoConnection;
import de.monticore.lang.monticar.ValueSymbol;
import de.monticore.lang.monticar.common2._ast.ASTArrayAccess;
import de.monticore.lang.monticar.common2._ast.ASTParameter;
import de.monticore.lang.monticar.common2._ast.ASTQualifiedNameWithArray;
import de.monticore.lang.monticar.common2._ast.ASTStereoValue;
......@@ -390,7 +390,6 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
private List<String> getPortNameParts(ASTQualifiedNameWithArray portName, int amountSources) {
List<String> names = new ArrayList<String>();
String name = "";
//ignore for now
......@@ -404,8 +403,8 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
} else if (portName.getPortArray().get().getLowerbound().isPresent()) {
names = getmnPortNameParts(name, portName);
} else {
int size = countPortArrayInstances(name, portName.getCompName().orElse(null));
System.out.println(portName.toString());
int size = countPortArrayInstances(name, portName.getCompName().orElse(null), portName.getCompArray().orElse(null));
Log.debug("Size" + size, "PortNameParts");
for (int i = 1; i <= size; ++i) {
......@@ -436,15 +435,29 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
return names;
}
private int countPortArrayInstances(String portName, String compName) {
private String getNameArrayPart(ASTArrayAccess arrayPart) {
String result = "";
if (arrayPart.getIntLiteral().isPresent())
result += "[" + arrayPart.getIntLiteral().get().getNumber().get().intValue() + "]";
//Not handled here change handling this case after refactoring
/*else if (arrayPart.getLowerbound().isPresent() && arrayPart.getUpperbound().isPresent()) {
}*/
return result;
}
private int countPortArrayInstances(String portName, String compName, ASTArrayAccess arrayPart) {
MutableScope curScope = currentScope().get();
boolean present = true;
int counter = 0;
if (arrayPart != null) {
compName += getNameArrayPart(arrayPart);
}
while (present) {
present = curScope.resolve(portName + "[" + (counter + 1) + "]", PortSymbol.KIND).isPresent();
if (present) ++counter;
else {
System.out.println(curScope.toString());
Log.debug("Could not resolve " + portName + "[" + (counter + 1) + "]", "countPortArrayInstances");
}
}
......@@ -452,7 +465,9 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
//TODO
present = true;
Log.debug("compInstanceName: " + compName, "Resolving");
ComponentInstanceSymbol symbol = curScope.<ComponentInstanceSymbol>resolve(compName, ComponentInstanceSymbol.KIND).get();
System.out.println(compName);
ComponentInstanceSymbol symbol;
symbol= curScope.<ComponentInstanceSymbol>resolve(compName, ComponentInstanceSymbol.KIND).get();
for (PortSymbol portSymbol : symbol.getComponentType().getAllPorts()) {
Log.debug(portSymbol.toString(), "PortInfo");
......
......@@ -236,8 +236,10 @@ public class ExpandedComponentInstanceBuilder {
inst.getSubComponents().stream()
.forEachOrdered(s -> {
if (s.getActualTypeArguments().size() != s.getComponentType().getFormalTypeParameters().size()) {
Log.error(String.format("instance '%s' has a subcomponent instance '%s' where the given generics '%s' distinguish from the generics definition '%s'",
/*Log.error(String.format("instance '%s' has a subcomponent instance '%s' where the given generics '%s' distinguish from the generics definition '%s'",
inst.getFullName(), s.getName(), s.getActualTypeArguments(), s.getComponentType().getFormalTypeParameters()));
*/
//TODO change this after removing everything that is related to Java/JavaDSL
} else {
Log.debug(s.getComponentType().toString(), "ComponentType");
Log.debug(s.getComponentType().getFormalTypeParameters().toString(), "FormalTypeParameters");
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
/* generated from model null*/
/* generated by template symboltable.SymbolReference*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.Scope;
import de.monticore.symboltable.modifiers.AccessModifier;
import de.monticore.symboltable.references.CommonSymbolReference;
import de.monticore.symboltable.references.SymbolReference;
/**
* Represents a reference of {@link PortSymbol}.
*/
public class PortSymbolReference extends PortSymbol
implements SymbolReference<PortSymbol> {
protected final SymbolReference<PortSymbol> reference;
public PortSymbolReference(final String name, final Scope definingScopeOfReference) {
super(name);
reference = new CommonSymbolReference<>(name, PortSymbol.KIND, definingScopeOfReference);
}
/*
* Methods of SymbolReference interface
*/
@Override
public PortSymbol getReferencedSymbol() {
return reference.getReferencedSymbol();
}
@Override
public boolean existsReferencedSymbol() {
return reference.existsReferencedSymbol();
}
@Override
public boolean isReferencedSymbolLoaded() {
return reference.isReferencedSymbolLoaded();
}
/*
* Methods of Symbol interface
*/
@Override
public String getName() {
return getReferencedSymbol().getName();
}
@Override
public String getFullName() {
return getReferencedSymbol().getFullName();
}
@Override
public Scope getEnclosingScope() {
return getReferencedSymbol().getEnclosingScope();
}
@Override
public void setEnclosingScope(MutableScope scope) {
getReferencedSymbol().setEnclosingScope(scope);
}
@Override
public AccessModifier getAccessModifier() {
return getReferencedSymbol().getAccessModifier();
}
@Override
public void setAccessModifier(AccessModifier accessModifier) {
getReferencedSymbol().setAccessModifier(accessModifier);
}
/*
* Methods of ArcPortSymbol class
*/
@Override
public void setDirection(boolean direction) {
getReferencedSymbol().setDirection(direction);
}
@Override
public boolean isIncoming() {
return getReferencedSymbol().isIncoming();
}
@Override
public boolean isOutgoing() {
return getReferencedSymbol().isOutgoing();
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc.types;
/**
* @author Sascha Schneiders
*/
public class StringInt {
protected String string;
protected int integer;
public StringInt() {
}
public StringInt(String string, int integer) {
this.string = string;
this.integer = integer;
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
public int getInteger() {
return integer;
}
public void setInteger(int integer) {
this.integer = integer;
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc.unit.constant;
/**
* Represents a constant Char which is used for constant connectors
*/
@Deprecated
public class EMAConstantChar extends EMAConstantValue {
public EMAConstantChar(char value) {
super(value);
}
public char getChar() {
return (Character) value;
}
@Override
public boolean isChar() {
return true;
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc.unit.constant;
/**
* Represents a constant Number which is used for constant connectors
*/
@Deprecated
public class EMAConstantNumber extends EMAConstantValue {
public EMAConstantNumber(Number value) {
super(value);
}
public Number getNumber() {
return (Number) value;
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc.unit.constant;
/**
* Represents a constant String which is used for ConstantConnectors
*/
@Deprecated
public class EMAConstantString extends EMAConstantValue {
public EMAConstantString(String value) {
super(value);
}
public String getString() {
return (String) value;
}
@Override
public boolean isString(){
return true;
}
}
......@@ -405,9 +405,9 @@ public class SymtabTest extends AbstractSymtabTest {
ComponentSymbol cs = symTab.<ComponentSymbol>resolve("testing.ComponentArray", ComponentSymbol.KIND).orElse(null);
assertNotNull("ComponentSymbol is null", cs);
//test if amount of SubComponents is correct
assertEquals(51, cs.getSubComponents().size());
assertEquals(5, cs.getSubComponents().size());
//test if every SubComponent can be accessed by its corresponding name
for (int i = 1; i <= 51; ++i) {
for (int i = 1; i <= 5; ++i) {
assertEquals(true, cs.getSubComponent("portArray[" + i + "]").isPresent());
//add type check
}
......
package de.monticore.lang.embeddedmontiarc.cocos;
import org.junit.Test;
/**
* @author Sascha Schneiders
*/
public class BasicCoCoTest extends AbstractCoCoTest {
@Test
public void testBasicTests(){
checkValid("", "testing.BasicParameter");
checkValid("", "testing.BasicParameterInstance");
checkValid("", "testing.BasicResolution");
checkValid("", "testing.BasicResolutionDefaultInstance");
checkValid("", "testing.BasicTypeInstance");
checkValid("", "testing.BasicTypeTest");
checkValid("", "testing.BooleanConnector");
checkValid("", "testing.BooleanPortType");
/*checkValid("", "testing.ComponentArray");
checkValid("", "testing.ConnectorArray");
checkValid("", "testing.ConnectorArraymn");
checkValid("", "testing.ConnectorInstancing");*/
}
}
package testing;
component BasicResolution<N1 n=2> {
component BasicResolution<N1 n = 2> {
port
in Boolean in1[n],
out Boolean out1;
}
......@@ -9,5 +9,5 @@ component BasicResolutionDefaultInstance {
connect a1[1]->br1.in1[1];
connect a1[2]->br1.in1[2];
connect br1.out1 -> out1;
}
......@@ -7,5 +7,5 @@ component BasicTypeInstance {
instance BasicTypeTest<Boolean> b1;
connect in1->b1.in1;
connect in1.out1->out1;
connect b1.out1 -> out1;
}
package testing;
component ComponentArray{
instance PortArray portArray[51];
ports in Boolean lightsIn[25],
out Boolean lightOut[25];
instance PortArray portArray[5];
}
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