Commit 06b0a447 authored by Ahmed's avatar Ahmed

add redefineVariables method to ComponentConverter

redfineVariables redefines every variable type to his correct variable type
parent cc2d6c5a
......@@ -97,7 +97,11 @@ public class ComponentConverter {
ComponentConverter.tuples.put(mathExpressionSymbol, properties);
}
}
redefineVariables(mathExpressionSymbols, bluePrint);
}
//ToDo Redefine Function
if(namesOfFunctions != null) {
for(String nameOfFunction : namesOfFunctions){
usedMathCommand.add(bluePrint.getMathCommandRegister().getMathCommand(nameOfFunction));
......@@ -227,7 +231,6 @@ public class ComponentConverter {
generateInitStaticVariablePart(method, v, bluePrint);
} else {
generateInitNonStaticVariable(method, v, bluePrint);
//TODO: Handle the case for type changes like cube to vector<vector<Point>>
}
if (v.isArray())
v.setName(oldName);
......@@ -406,6 +409,24 @@ public class ComponentConverter {
}
}
public static void redefineVariables(List<MathExpressionSymbol> mathExpressionSymbols, BluePrintCPP bluePrintCPP){
for(MathExpressionSymbol mathExpressionSymbol : mathExpressionSymbols){
if(mathExpressionSymbol.isAssignmentExpression()) {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) ((MathAssignmentExpressionSymbol) mathExpressionSymbol).getExpressionSymbol();
String nameOfFirstParameter = mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols().get(0).getTextualRepresentation();
String nameOfOutput = getNameOfOutput(mathExpressionSymbol);
MathExpressionProperties properties = tuples.get(mathExpressionSymbol);
if (properties.isPreCV()) {
fixVariableType(nameOfFirstParameter, bluePrintCPP, "CommonMatrixType", "cv::Mat", "");
}
if(properties.isSucCV()){
fixVariableType(nameOfOutput, bluePrintCPP, "CommonMatrixType", "cv::Mat", "");
}
}
}
}
public static void fixVariableType(String variableName, BluePrintCPP bluePrint, String typeNameMontiCar, String typeNameTargetLanguage, String includeName){
List<Variable> variables = bluePrint.getVariables();
......
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