Commit 83da7562 authored by Svetlana Pavlitskaya's avatar Svetlana Pavlitskaya

Fixed issue with ASTRange

parent 3bfb1407
Pipeline #67573 failed with stages
in 11 minutes and 43 seconds
......@@ -31,7 +31,7 @@ public class CheckArgument implements CNNArchASTArchArgumentCoCo {
@Override
public void check(ASTArchArgument node) {
ArgumentSymbol argument = (ArgumentSymbol) node.getSymbol().get();
ArgumentSymbol argument = (ArgumentSymbol) node.getSymbolOpt().get();
LayerDeclarationSymbol layerDeclaration = argument.getLayer().getDeclaration();
if (layerDeclaration != null && argument.getParameter() == null){
Log.error("0"+ ErrorCodes.UNKNOWN_ARGUMENT + " Unknown Argument. " +
......
......@@ -50,9 +50,9 @@ public class CheckLayer implements CNNArchASTLayerCoCo{
}
}
LayerDeclarationSymbol layerDeclaration = ((LayerSymbol) node.getSymbol().get()).getDeclaration();
LayerDeclarationSymbol layerDeclaration = ((LayerSymbol) node.getSymbolOpt().get()).getDeclaration();
if (layerDeclaration == null){
ArchitectureSymbol architecture = node.getSymbol().get().getEnclosingScope().<ArchitectureSymbol>resolve("", ArchitectureSymbol.KIND).get();
ArchitectureSymbol architecture = node.getSymbolOpt().get().getEnclosingScope().<ArchitectureSymbol>resolve("", ArchitectureSymbol.KIND).get();
Log.error("0" + ErrorCodes.UNKNOWN_LAYER + " Unknown layer. " +
"Layer with name '" + node.getName() + "' does not exist. " +
"Existing layers: " + Joiners.COMMA.join(architecture.getLayerDeclarations()) + "."
......
......@@ -39,7 +39,7 @@ public class CheckLayerRecursion implements CNNArchASTLayerDeclarationCoCo {
@Override
public void check(ASTLayerDeclaration node) {
done = false;
LayerDeclarationSymbol layerDeclaration = (LayerDeclarationSymbol) node.getSymbol().get();
LayerDeclarationSymbol layerDeclaration = (LayerDeclarationSymbol) node.getSymbolOpt().get();
checkForRecursion(layerDeclaration, layerDeclaration.getBody());
}
......
......@@ -20,7 +20,11 @@
*/
package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.monticar.ranges._ast.ASTRange;
import de.monticore.lang.monticar.ranges._ast.ASTRangeStepResolution;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.numberunit._ast.ASTNumberWithUnit;
import de.monticore.symboltable.CommonSymbol;
import de.monticore.symboltable.MutableScope;
import de.monticore.symboltable.Scope;
......@@ -244,7 +248,11 @@ public class ArchTypeSymbol extends CommonSymbol {
}
public Builder elementType(String start, String end){
domain = new ASTElementType();
domain.setName("Q(" + start + ":" + end +")");
domain.setName("Q"); //("Q(" + start + ":" + end +")");
ASTRange range = new ASTRange();
range.setStartValue(start);
range.setEndValue(end);
domain.setRange(range);
return this;
}
......
......@@ -144,7 +144,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
}
public void endVisit(final ASTArchitecture node) {
//ArchitectureSymbol architecture = (ArchitectureSymbol) node.getSymbol().get();
//ArchitectureSymbol architecture = (ArchitectureSymbol) node.getSymbolOpt().get();
architecture.setBody((ArchitectureElementSymbol) node.getBody().getSymbolOpt().get());
removeCurrentScope();
......@@ -224,7 +224,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
@Override
public void endVisit(ASTLayerDeclaration ast) {
LayerDeclarationSymbol layerDeclaration = (LayerDeclarationSymbol) ast.getSymbol().get();
LayerDeclarationSymbol layerDeclaration = (LayerDeclarationSymbol) ast.getSymbolOpt().get();
layerDeclaration.setBody((CompositeElementSymbol) ast.getBody().getSymbolOpt().get());
List<VariableSymbol> parameters = new ArrayList<>(4);
......@@ -259,7 +259,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
if (ast.isPresentArithmeticExpression()) {
ASTExpression arithmeticExpression = ast.getArithmeticExpression();
if (arithmeticExpression.isPresentSymbol()) {
mathExp = (MathExpressionSymbol) arithmeticExpression.getSymbol().get();
mathExp = (MathExpressionSymbol) arithmeticExpression.getSymbolOpt().get();
}
}
else if (ast.isPresentBooleanExpression()) {
......
......@@ -257,7 +257,8 @@ public class LayerSymbol extends ArchitectureElementSymbol {
public List<ArchTypeSymbol> computeOutputTypes() {
if (getResolvedThis().isPresent()) {
if (getResolvedThis().get() == this) {
return ((PredefinedLayerDeclaration) getDeclaration()).computeOutputTypes(getInputTypes(), this);
List<ArchTypeSymbol> inputTypes = getInputTypes();
return ((PredefinedLayerDeclaration) getDeclaration()).computeOutputTypes(inputTypes, this);
}
else {
return getResolvedThis().get().getOutputTypes();
......
......@@ -190,8 +190,6 @@ abstract public class PredefinedLayerDeclaration extends LayerDeclarationSymbol
}
protected List<String> computeStartAndEndValue(List<ArchTypeSymbol> inputTypes, BinaryOperator<Rational> startValAccumulator, BinaryOperator<Rational> endValAccumulator){
boolean noStartValues = true;
boolean noEndValues = true;
Stream.Builder<Rational> startValues = Stream.builder();
Stream.Builder<Rational> endValues = Stream.builder();
String start = null;
......@@ -203,22 +201,20 @@ abstract public class PredefinedLayerDeclaration extends LayerDeclarationSymbol
start = "-oo";
}
else {
noStartValues = false;
startValues.add(range.get().getStartValue());
}
if (range.get().hasNoUpperLimit()){
end = "oo";
}
else {
noEndValues = false;
endValues.add(range.get().getEndValue());
}
}
}
if (start == null && !noStartValues){
if (start == null){
start = "" + startValues.build().reduce(startValAccumulator).get().doubleValue();
}
if (end == null && !noEndValues){
if (end == null){
end = "" + endValues.build().reduce(endValAccumulator).get().doubleValue();
}
......
architecture MissingMerge(inputs=10, classes=2){
def input Q(-oo:+oo)^{inputs} in1
def output Q(0:1)^{classes} out1
def input Q(-oo:+oo)^{10} in1
def output Q(0:1)^{2} out1
in1 ->
(
......
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