Commit ab9a5588 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Relaxed getInitLine error handling: some types dont need init lines

parent 63ae391f
Pipeline #57102 passed with stage
in 2 minutes and 5 seconds
......@@ -15,6 +15,7 @@ import de.monticore.lang.monticar.generator.optimization.MathInformationRegister
import de.se_rwth.commons.logging.Log;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -174,7 +175,8 @@ public class ComponentConverter {
method.addInstruction(new TargetCodeInstruction("this->" + MathInformationRegister.getVariableInitName(v, bluePrint) + "=" + MathInformationRegister.getVariableInitName(v, bluePrint) + ";\n"));
method.addParameter(v);
}else {
method.addInstruction(new TargetCodeInstruction(MathConverter.getInitLine(v,bluePrint)));
Optional<String> initLine = MathConverter.getInitLine(v, bluePrint);
initLine.ifPresent(s -> method.addInstruction(new TargetCodeInstruction(s)));
}
}
......
......@@ -12,6 +12,8 @@ import de.monticore.lang.monticar.generator.optimization.MathInformationRegister
import de.monticore.numberunit._ast.ASTNumberWithUnit;
import de.se_rwth.commons.logging.Log;
import java.util.Optional;
/**
* @author Sascha Schneiders
*/
......@@ -145,7 +147,7 @@ public class MathConverter {
return String.format("%s = %s(%s, %s, %s);\n", MathInformationRegister.getVariableInitName(v, bluePrint), curBackend.getWholeNumberCubeTypeName(), v.getDimensionalInformation().get(0), v.getDimensionalInformation().get(1), v.getDimensionalInformation().get(2));
}
public static String getInitLine(Variable v,BluePrintCPP bluePrint) {
public static Optional<String> getInitLine(Variable v, BluePrintCPP bluePrint) {
String initLine = null;
if (v.getVariableType().getTypeNameTargetLanguage().equals(MathConverter.curBackend.getMatrixTypeName())) {
initLine = MathConverter.getMatrixInitLine(v, bluePrint);
......@@ -171,10 +173,6 @@ public class MathConverter {
initLine = "";
}
if(initLine == null) {
Log.error("0x3b097: Type not supported");
}
return initLine;
return Optional.ofNullable(initLine);
}
}
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