Commit d4163365 authored by Thomas Michael Timmermanns's avatar Thomas Michael Timmermanns Committed by Thomas Michael Timmermanns

Changed ShapeSymbol to ArchTypeSymbol which combines Shape and Type.

IOLayer arrays do not exist anymore at symbol level. They all are now split up at symbol table creation.
Added output type check and test.
parent e9136aec
...@@ -5,8 +5,8 @@ grammar CNNArch extends de.monticore.lang.math.Math { ...@@ -5,8 +5,8 @@ grammar CNNArch extends de.monticore.lang.math.Math {
CNNArchCompilationUnit = Architecture; CNNArchCompilationUnit = Architecture;
symbol scope Architecture = "architecture" symbol scope Architecture = "architecture"
name:Name& "(" name:Name&
(ArchitectureParameter || ",")* ")" "{" ( "(" (ArchitectureParameter || ",")* ")" )? "{"
declarations:ArchDeclaration* declarations:ArchDeclaration*
body:ArchBody "}"; body:ArchBody "}";
......
...@@ -20,23 +20,23 @@ ...@@ -20,23 +20,23 @@
*/ */
package de.monticore.lang.monticar.cnnarch._cocos; package de.monticore.lang.monticar.cnnarch._cocos;
import de.monticore.lang.monticar.cnnarch._ast.ASTArchType;
import de.monticore.lang.monticar.cnnarch._ast.ASTDimensionArgument; import de.monticore.lang.monticar.cnnarch._ast.ASTDimensionArgument;
import de.monticore.lang.monticar.cnnarch._ast.ASTShape;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.ShapeSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes; import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import java.util.Optional; import java.util.Optional;
public class CheckIOShape implements CNNArchASTShapeCoCo { public class CheckIOShape implements CNNArchASTArchTypeCoCo {
@Override @Override
public void check(ASTShape node) { public void check(ASTArchType node) {
boolean hasHeight = false; boolean hasHeight = false;
boolean hasWidth = false; boolean hasWidth = false;
boolean hasChannels = false; boolean hasChannels = false;
for (ASTDimensionArgument dimensionArg : node.getDimensions()){ for (ASTDimensionArgument dimensionArg : node.getShape().getDimensions()){
if (dimensionArg.getWidth().isPresent()){ if (dimensionArg.getWidth().isPresent()){
if (hasWidth){ if (hasWidth){
repetitionError(dimensionArg); repetitionError(dimensionArg);
...@@ -58,7 +58,7 @@ public class CheckIOShape implements CNNArchASTShapeCoCo { ...@@ -58,7 +58,7 @@ public class CheckIOShape implements CNNArchASTShapeCoCo {
} }
ShapeSymbol shape = (ShapeSymbol) node.getSymbol().get(); ArchTypeSymbol shape = (ArchTypeSymbol) node.getSymbol().get();
for (ArchSimpleExpressionSymbol dimension : shape.getDimensionSymbols()){ for (ArchSimpleExpressionSymbol dimension : shape.getDimensionSymbols()){
Optional<Integer> value = dimension.getIntValue(); Optional<Integer> value = dimension.getIntValue();
if (!value.isPresent() || value.get() <= 0){ if (!value.isPresent() || value.get() <= 0){
......
...@@ -27,6 +27,6 @@ public class CheckLayerInputs implements CNNArchASTArchitectureCoCo { ...@@ -27,6 +27,6 @@ public class CheckLayerInputs implements CNNArchASTArchitectureCoCo {
@Override @Override
public void check(ASTArchitecture node) { public void check(ASTArchitecture node) {
ArchitectureSymbol architecture = (ArchitectureSymbol) node.getSymbol().get(); ArchitectureSymbol architecture = (ArchitectureSymbol) node.getSymbol().get();
architecture.getBody().checkInputAndOutput(); architecture.getBody().checkInput();
} }
} }
...@@ -26,7 +26,7 @@ import de.monticore.lang.monticar.cnnarch._ast.ASTArchSimpleExpression; ...@@ -26,7 +26,7 @@ import de.monticore.lang.monticar.cnnarch._ast.ASTArchSimpleExpression;
import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.ArchSimpleExpressionSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.VariableSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes; import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.lang.monticar.cnnarch.helper.ExpressionHelper; import de.monticore.lang.monticar.cnnarch.helper.Utils;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import java.util.Collection; import java.util.Collection;
...@@ -39,7 +39,7 @@ public class CheckNameExpression implements CNNArchASTArchSimpleExpressionCoCo { ...@@ -39,7 +39,7 @@ public class CheckNameExpression implements CNNArchASTArchSimpleExpressionCoCo {
if (expression.getMathExpression().isPresent()){ if (expression.getMathExpression().isPresent()){
MathExpressionSymbol mathExpression = expression.getMathExpression().get(); MathExpressionSymbol mathExpression = expression.getMathExpression().get();
for (MathExpressionSymbol subMathExp : ExpressionHelper.createSubExpressionList(mathExpression)){ for (MathExpressionSymbol subMathExp : Utils.createSubExpressionList(mathExpression)){
if (subMathExp instanceof MathNameExpressionSymbol){ if (subMathExp instanceof MathNameExpressionSymbol){
String name = ((MathNameExpressionSymbol) subMathExp).getNameToAccess(); String name = ((MathNameExpressionSymbol) subMathExp).getNameToAccess();
Collection<VariableSymbol> variableCollection = node.getEnclosingScope().get().resolveMany(name, VariableSymbol.KIND); Collection<VariableSymbol> variableCollection = node.getEnclosingScope().get().resolveMany(name, VariableSymbol.KIND);
......
...@@ -24,25 +24,22 @@ import de.monticore.lang.monticar.cnnarch._ast.ASTIOLayer; ...@@ -24,25 +24,22 @@ import de.monticore.lang.monticar.cnnarch._ast.ASTIOLayer;
import de.monticore.lang.monticar.cnnarch._symboltable.CompositeLayerSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.CompositeLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IODeclarationSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.IODeclarationSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.IOLayerSymbol; import de.monticore.lang.monticar.cnnarch._symboltable.IOLayerSymbol;
import de.monticore.lang.monticar.cnnarch._symboltable.LayerSymbol;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes; import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.monticore.symboltable.Symbol; import de.monticore.symboltable.Symbol;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import java.util.Collection;
import java.util.Collections;
public class CheckUnknownIO implements CNNArchASTIOLayerCoCo { public class CheckUnknownIO implements CNNArchASTIOLayerCoCo {
@Override @Override
public void check(ASTIOLayer node) { public void check(ASTIOLayer node) {
Symbol symbol = node.getSymbol().get(); Symbol symbol = node.getSymbol().get();
IODeclarationSymbol ioDeclaration = null; Collection<IODeclarationSymbol> ioDeclarations = node.getEnclosingScope().get().<IODeclarationSymbol>resolveMany(node.getName(), IODeclarationSymbol.KIND);
if (symbol instanceof IOLayerSymbol){
ioDeclaration = ((IOLayerSymbol) symbol).getDefinition();
}
else if (symbol instanceof CompositeLayerSymbol){
IOLayerSymbol layer = (IOLayerSymbol) ((CompositeLayerSymbol) symbol).getLayers().get(0);
ioDeclaration = layer.getDefinition();
}
if (ioDeclaration == null){ if (ioDeclarations.isEmpty()){
Log.error("0" + ErrorCodes.UNKNOWN_IO + " Unknown input or output name. " + Log.error("0" + ErrorCodes.UNKNOWN_IO + " Unknown input or output name. " +
"The input or output '" + node.getName() + "' does not exist" "The input or output '" + node.getName() + "' does not exist"
, node.get_SourcePositionStart()); , node.get_SourcePositionStart());
......
...@@ -22,7 +22,7 @@ package de.monticore.lang.monticar.cnnarch._symboltable; ...@@ -22,7 +22,7 @@ package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.math.math._symboltable.expression.*; import de.monticore.lang.math.math._symboltable.expression.*;
import de.monticore.lang.monticar.cnnarch.helper.Calculator; import de.monticore.lang.monticar.cnnarch.helper.Calculator;
import de.monticore.lang.monticar.cnnarch.helper.ExpressionHelper; import de.monticore.lang.monticar.cnnarch.helper.Utils;
import java.util.*; import java.util.*;
...@@ -100,7 +100,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol { ...@@ -100,7 +100,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
protected void computeUnresolvableVariables(Set<VariableSymbol> unresolvableVariables, Set<VariableSymbol> allVariables) { protected void computeUnresolvableVariables(Set<VariableSymbol> unresolvableVariables, Set<VariableSymbol> allVariables) {
if (getMathExpression().isPresent()) { if (getMathExpression().isPresent()) {
for (MathExpressionSymbol exp : ExpressionHelper.createSubExpressionList(getMathExpression().get())) { for (MathExpressionSymbol exp : Utils.createSubExpressionList(getMathExpression().get())) {
if (exp instanceof MathNameExpressionSymbol) { if (exp instanceof MathNameExpressionSymbol) {
String name = ((MathNameExpressionSymbol) exp).getNameToAccess(); String name = ((MathNameExpressionSymbol) exp).getNameToAccess();
Optional<VariableSymbol> variable = getEnclosingScope().resolve(name, VariableSymbol.KIND); Optional<VariableSymbol> variable = getEnclosingScope().resolve(name, VariableSymbol.KIND);
...@@ -164,7 +164,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol { ...@@ -164,7 +164,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
} }
else { else {
Map<String, String> replacementMap = new HashMap<>(); Map<String, String> replacementMap = new HashMap<>();
for (MathExpressionSymbol exp : ExpressionHelper.createSubExpressionList(getMathExpression().get())) { for (MathExpressionSymbol exp : Utils.createSubExpressionList(getMathExpression().get())) {
if (exp instanceof MathNameExpressionSymbol) { if (exp instanceof MathNameExpressionSymbol) {
String name = ((MathNameExpressionSymbol) exp).getNameToAccess(); String name = ((MathNameExpressionSymbol) exp).getNameToAccess();
VariableSymbol variable = (VariableSymbol) getEnclosingScope().resolve(name, VariableSymbol.KIND).get(); VariableSymbol variable = (VariableSymbol) getEnclosingScope().resolve(name, VariableSymbol.KIND).get();
...@@ -174,7 +174,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol { ...@@ -174,7 +174,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
} }
} }
String resolvedString = ExpressionHelper.replace(getTextualRepresentation(), replacementMap); String resolvedString = Utils.replace(getTextualRepresentation(), replacementMap);
return Calculator.getInstance().calculate(resolvedString); return Calculator.getInstance().calculate(resolvedString);
} }
} }
...@@ -191,7 +191,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol { ...@@ -191,7 +191,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
public String getTextualRepresentation() { public String getTextualRepresentation() {
if (isResolved()){ if (isResolved()){
if (isTuple()){ if (isTuple()){
return ExpressionHelper.createTupleTextualRepresentation(getTupleValues().get(), Object::toString); return Utils.createTupleTextualRepresentation(getTupleValues().get(), Object::toString);
} }
else { else {
return getValue().get().toString(); return getValue().get().toString();
......
...@@ -22,9 +22,9 @@ package de.monticore.lang.monticar.cnnarch._symboltable; ...@@ -22,9 +22,9 @@ package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.symboltable.SymbolKind; import de.monticore.symboltable.SymbolKind;
public class ShapeKind implements SymbolKind { public class ArchTypeKind implements SymbolKind {
private static final String NAME = "de.monticore.lang.monticar.cnnarch._symboltable.ShapeKind"; private static final String NAME = "de.monticore.lang.monticar.cnnarch._symboltable.ArchTypeKind";
@Override @Override
public String getName() { public String getName() {
......
...@@ -20,24 +20,40 @@ ...@@ -20,24 +20,40 @@
*/ */
package de.monticore.lang.monticar.cnnarch._symboltable; package de.monticore.lang.monticar.cnnarch._symboltable;
import de.monticore.lang.monticar.types2._ast.ASTElementType;
import de.monticore.symboltable.CommonSymbol; import de.monticore.symboltable.CommonSymbol;
import de.monticore.symboltable.MutableScope; import de.monticore.symboltable.MutableScope;
import java.util.*; import java.util.*;
public class ShapeSymbol extends CommonSymbol { public class ArchTypeSymbol extends CommonSymbol {
public static final ShapeKind KIND = new ShapeKind(); public static final ArchTypeKind KIND = new ArchTypeKind();
protected static final String DEFAULT_ELEMENT_TYPE = "Q(-oo:oo)";
private ASTElementType elementType;
private int channelIndex = -1; private int channelIndex = -1;
private int heightIndex = -1; private int heightIndex = -1;
private int widthIndex = -1; private int widthIndex = -1;
private List<ArchSimpleExpressionSymbol> dimensions = new ArrayList<>(); private List<ArchSimpleExpressionSymbol> dimensions = new ArrayList<>();
public ShapeSymbol() { public ArchTypeSymbol() {
super("", KIND); super("", KIND);
ASTElementType elementType = new ASTElementType();
elementType.setTElementType(DEFAULT_ELEMENT_TYPE);
setElementType(elementType);
}
public ASTElementType getElementType() {
return elementType;
}
public void setElementType(ASTElementType elementType) {
this.elementType = elementType;
} }
public int getHeightIndex() { public int getHeightIndex() {
...@@ -178,6 +194,7 @@ public class ShapeSymbol extends CommonSymbol { ...@@ -178,6 +194,7 @@ public class ShapeSymbol extends CommonSymbol {
private int height = 1; private int height = 1;
private int width = 1; private int width = 1;
private int channels = 1; private int channels = 1;
private ASTElementType elementType = null;
public Builder height(int height){ public Builder height(int height){
this.height = height; this.height = height;
...@@ -191,13 +208,28 @@ public class ShapeSymbol extends CommonSymbol { ...@@ -191,13 +208,28 @@ public class ShapeSymbol extends CommonSymbol {
this.channels = channels; this.channels = channels;
return this; return this;
} }
public Builder elementType(ASTElementType elementType){
this.elementType = elementType;
return this;
}
public Builder elementType(String start, String end){
elementType = new ASTElementType();
elementType.setTElementType("Q(" + start + ":" + end +")");
return this;
}
public ShapeSymbol build(){ public ArchTypeSymbol build(){
ShapeSymbol sym = new ShapeSymbol(); ArchTypeSymbol sym = new ArchTypeSymbol();
sym.setChannelIndex(0); sym.setChannelIndex(0);
sym.setHeightIndex(1); sym.setHeightIndex(1);
sym.setWidthIndex(2); sym.setWidthIndex(2);
sym.setDimensions(Arrays.asList(channels, height, width)); sym.setDimensions(Arrays.asList(channels, height, width));
if (elementType == null){
elementType = new ASTElementType();
elementType.setTElementType(DEFAULT_ELEMENT_TYPE);
}
sym.setElementType(elementType);
return sym; return sym;
} }
} }
......
...@@ -98,6 +98,8 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP { ...@@ -98,6 +98,8 @@ public class ArchitectureSymbol extends ArchitectureSymbolTOP {
} }
} }
//todo: deep copy method for instances
public List<LayerSymbol> getFirstLayers(){ public List<LayerSymbol> getFirstLayers(){
if (!getBody().isResolved()){ if (!getBody().isResolved()){
resolve(); resolve();
......
...@@ -61,10 +61,6 @@ public class ArgumentSymbol extends CommonSymbol { ...@@ -61,10 +61,6 @@ public class ArgumentSymbol extends CommonSymbol {
return rhs; return rhs;
} }
public Optional<Object> getValue(){
return getRhs().getValue();
}
protected void setRhs(ArchExpressionSymbol rhs) { protected void setRhs(ArchExpressionSymbol rhs) {
if (getName().equals(AllPredefinedVariables.FOR_NAME) if (getName().equals(AllPredefinedVariables.FOR_NAME)
&& rhs instanceof ArchSimpleExpressionSymbol && rhs instanceof ArchSimpleExpressionSymbol
...@@ -192,6 +188,7 @@ public class ArgumentSymbol extends CommonSymbol { ...@@ -192,6 +188,7 @@ public class ArgumentSymbol extends CommonSymbol {
public static class Builder{ public static class Builder{
private String name;
private VariableSymbol parameter; private VariableSymbol parameter;
private ArchExpressionSymbol value; private ArchExpressionSymbol value;
...@@ -200,19 +197,31 @@ public class ArgumentSymbol extends CommonSymbol { ...@@ -200,19 +197,31 @@ public class ArgumentSymbol extends CommonSymbol {
return this; return this;
} }
public Builder parameter(String name) {
this.name = name;
return this;
}
public Builder value(ArchExpressionSymbol value) { public Builder value(ArchExpressionSymbol value) {
this.value = value; this.value = value;
return this; return this;
} }
public ArgumentSymbol build(){ public ArgumentSymbol build(){
if (parameter == null){ if (parameter == null && name == null){
throw new IllegalStateException("Missing parameter for ArgumentSymbol"); throw new IllegalStateException("Missing parameter for ArgumentSymbol");
} }
ArgumentSymbol sym = new ArgumentSymbol(parameter.getName()); if (parameter == null){
sym.setParameter(parameter); ArgumentSymbol sym = new ArgumentSymbol(name);
sym.setRhs(value); sym.setRhs(value);
return sym; return sym;
}
else {
ArgumentSymbol sym = new ArgumentSymbol(parameter.getName());
sym.setParameter(parameter);
sym.setRhs(value);
return sym;
}
} }
} }
} }
...@@ -30,7 +30,6 @@ import de.monticore.lang.monticar.cnnarch._visitor.CNNArchVisitor; ...@@ -30,7 +30,6 @@ import de.monticore.lang.monticar.cnnarch._visitor.CNNArchVisitor;
import de.monticore.lang.monticar.cnnarch._visitor.CommonCNNArchDelegatorVisitor; import de.monticore.lang.monticar.cnnarch._visitor.CommonCNNArchDelegatorVisitor;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedMethods; import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedMethods;
import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables; import de.monticore.lang.monticar.cnnarch.predefined.AllPredefinedVariables;
import de.monticore.lang.monticar.types2._ast.ASTType;
import de.monticore.symboltable.*; import de.monticore.symboltable.*;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
...@@ -173,9 +172,8 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy ...@@ -173,9 +172,8 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
if (ast.getArrayDeclaration().isPresent()){ if (ast.getArrayDeclaration().isPresent()){
iODeclaration.setArrayLength(ast.getArrayDeclaration().get().getIntLiteral().getNumber().get().getDividend().intValue()); iODeclaration.setArrayLength(ast.getArrayDeclaration().get().getIntLiteral().getNumber().get().getDividend().intValue());
} }
iODeclaration.setShape((ShapeSymbol) ast.getType().getShape().getSymbol().get()); iODeclaration.setType((ArchTypeSymbol) ast.getType().getSymbol().get());
iODeclaration.setInput(ast.getIn().isPresent()); iODeclaration.setInput(ast.getIn().isPresent());
iODeclaration.setType(ast.getType().getElementType());
if (iODeclaration.isInput()){ if (iODeclaration.isInput()){
inputs.add(iODeclaration); inputs.add(iODeclaration);
} }
...@@ -185,23 +183,19 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy ...@@ -185,23 +183,19 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
} }
@Override @Override
public void endVisit(ASTType node) { public void visit(ASTArchType ast) {
//todo ArchTypeSymbol sym = new ArchTypeSymbol();
}
@Override
public void visit(ASTShape ast) {
ShapeSymbol sym = new ShapeSymbol();
addToScopeAndLinkWithNode(sym, ast); addToScopeAndLinkWithNode(sym, ast);
} }
@Override @Override
public void endVisit(ASTShape node) { public void endVisit(ASTArchType node) {
ShapeSymbol sym = (ShapeSymbol) node.getSymbol().get(); ArchTypeSymbol sym = (ArchTypeSymbol) node.getSymbol().get();
List<ASTDimensionArgument> astDimensions = node.getShape().getDimensions();
List<ArchSimpleExpressionSymbol> dimensionList = new ArrayList<>(3); List<ArchSimpleExpressionSymbol> dimensionList = new ArrayList<>(3);
for (int i = 0; i < node.getDimensions().size(); i++){ for (int i = 0; i < astDimensions.size(); i++){
ASTDimensionArgument dimensionArg = node.getDimensions().get(i); ASTDimensionArgument dimensionArg = astDimensions.get(i);
if (dimensionArg.getHeight().isPresent()){ if (dimensionArg.getHeight().isPresent()){
sym.setHeightIndex(i); sym.setHeightIndex(i);
ArchSimpleExpressionSymbol exp = (ArchSimpleExpressionSymbol) dimensionArg.getHeight().get().getSymbol().get(); ArchSimpleExpressionSymbol exp = (ArchSimpleExpressionSymbol) dimensionArg.getHeight().get().getSymbol().get();
...@@ -219,6 +213,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy ...@@ -219,6 +213,7 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
} }
} }
sym.setDimensionSymbols(dimensionList); sym.setDimensionSymbols(dimensionList);
sym.setElementType(node.getElementType());
addToScopeAndLinkWithNode(sym, node); addToScopeAndLinkWithNode(sym, node);
} }
...@@ -405,26 +400,21 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy ...@@ -405,26 +400,21 @@ public class CNNArchSymbolTableCreator extends de.monticore.symboltable.CommonSy
isInput = ioDeclaration.isInput(); isInput = ioDeclaration.isInput();
} }
if (!node.getIndex().isPresent() && arrayLength > 1 && isInput){ if (!node.getIndex().isPresent() && arrayLength > 1){
List<LayerSymbol> ioLayers = new ArrayList<>(arrayLength); //transform io array into parallel composite
IOLayerSymbol ioLayer; List<LayerSymbol> parallelLayers = createSerialIOLayerPart(node, arrayLength, isInput);
for (int i = 0; i < arrayLength; i++){
ioLayer = new IOLayerSymbol(node.getName());
ioLayer.setArrayAccess(i);
ioLayers.add(ioLayer);
}
CompositeLayerSymbol composite = new CompositeLayerSymbol.Builder() CompositeLayerSymbol composite = new CompositeLayerSymbol.Builder()
.parallel(true) .parallel(true)
.layers(ioLayers) .layers(parallelLayers)
.build(); .build();
addToScopeAndLinkWithNode(composite, node); addToScopeAndLinkWithNode(composite, node);
for (LayerSymbol layer : ioLayers){ for (LayerSymbol layer : parallelLayers){
addToScope(layer); layer.putInScope(composite.getSpannedScope());
layer.setAstNode(node); layer.setAstNode(node);
} }
} }