Commit 2df1956f authored by Ahmed's avatar Ahmed
Browse files

extends some features

parent 57ffa902
...@@ -68,7 +68,7 @@ public class ErodeCommand extends ArgumentReturnMathCommand{ ...@@ -68,7 +68,7 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
//add parameters //add parameters
Variable src = new Variable(); Variable src = new Variable();
method.addParameter(src, "src", "CommonMatrix",MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());; method.addParameter(src, "src", "CommonMatrixType",MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable(); Variable dst = new Variable();
method.addParameter(dst, "dst", "CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()); method.addParameter(dst, "dst", "CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());
Variable erosion_elem = new Variable(); Variable erosion_elem = new Variable();
......
...@@ -76,7 +76,7 @@ public class ComponentConverter { ...@@ -76,7 +76,7 @@ public class ComponentConverter {
} }
} else if(mathExpresionSymbol.isValueExpression()) { } else if(mathExpresionSymbol.isValueExpression()) {
if (((MathValueSymbol) mathExpresionSymbol).getValue() instanceof MathMatrixNameExpressionSymbol) { if (((MathValueSymbol) mathExpresionSymbol).getValue() instanceof MathMatrixNameExpressionSymbol) {
boolean bool = namesOfFunctions.add(((MathMatrixNameExpressionSymbol) ((MathValueSymbol) mathExpresionSymbol).getValue()).getNameToAccess()); namesOfFunctions.add(((MathMatrixNameExpressionSymbol) ((MathValueSymbol) mathExpresionSymbol).getValue()).getNameToAccess());
} }
} }
} }
......
...@@ -138,8 +138,6 @@ public class ComponentConverterMethodGeneration { ...@@ -138,8 +138,6 @@ public class ComponentConverterMethodGeneration {
} }
generateInstruction(method, mathExpressionSymbol, bluePrint, includeStrings); generateInstruction(method, mathExpressionSymbol, bluePrint, includeStrings);
//lastIndex = currentGenerationIndex; //lastIndex = currentGenerationIndex;
//fix argumentReturnFunctionsInstructions
} }
handleInstructionReOrdering(method, beginIndex); handleInstructionReOrdering(method, beginIndex);
} }
...@@ -345,23 +343,33 @@ public class ComponentConverterMethodGeneration { ...@@ -345,23 +343,33 @@ public class ComponentConverterMethodGeneration {
} }
private static String fixArgumentReturnInstruction(String instruction, Method method, MathExpressionSymbol mathExpressionSymbol, BluePrintCPP bluePrintCPP){ private static String fixArgumentReturnInstruction(String instruction, Method method, MathExpressionSymbol mathExpressionSymbol, BluePrintCPP bluePrintCPP){
String newInstruction = ""; String newInstruction1 = "";
String newInstruction2 = "";
if(instruction.contains("=")){ if(instruction.contains("=")){
int indexOfEqualOperator = instruction.indexOf("="); int indexOfEqualOperator = instruction.indexOf("=");
String beforeEqualOperatorSubString = instruction.substring(0,indexOfEqualOperator-1); String beforeEqualOperatorSubString = instruction.substring(0,indexOfEqualOperator-1);
String afterEqualOperatorSubString = instruction.substring(indexOfEqualOperator+2); String afterEqualOperatorSubString = instruction.substring(indexOfEqualOperator+2);
if(beforeEqualOperatorSubString.contains(" ")){
//there is two words
int indexOfWhiteSpace = beforeEqualOperatorSubString.indexOf(" ");
String firstWord = beforeEqualOperatorSubString.substring(0,indexOfWhiteSpace);
String secondWord = beforeEqualOperatorSubString.substring(indexOfWhiteSpace+1);
newInstruction1 = beforeEqualOperatorSubString + ";\n";
beforeEqualOperatorSubString = secondWord;
}
if(afterEqualOperatorSubString.contains(",")){ if(afterEqualOperatorSubString.contains(",")){
int indexOfCommaOperator = afterEqualOperatorSubString.indexOf(","); int indexOfCommaOperator = afterEqualOperatorSubString.indexOf(",");
newInstruction = afterEqualOperatorSubString.substring(0,indexOfCommaOperator) + ", " + beforeEqualOperatorSubString + newInstruction2 = afterEqualOperatorSubString.substring(0,indexOfCommaOperator) + ", " + beforeEqualOperatorSubString +
afterEqualOperatorSubString.substring(indexOfCommaOperator); afterEqualOperatorSubString.substring(indexOfCommaOperator);
}else{ }else{
int indexOfBracket = afterEqualOperatorSubString.indexOf(")"); int indexOfBracket = afterEqualOperatorSubString.indexOf(")");
newInstruction = afterEqualOperatorSubString.substring(0,indexOfBracket) + ", " + beforeEqualOperatorSubString + newInstruction2 = afterEqualOperatorSubString.substring(0,indexOfBracket) + ", " + beforeEqualOperatorSubString +
afterEqualOperatorSubString.substring(indexOfBracket); afterEqualOperatorSubString.substring(indexOfBracket);
} }
newInstruction = removeBracket(newInstruction); newInstruction2 = removeBracket(newInstruction2);
return newInstruction; return newInstruction1 + newInstruction2;
} }
return instruction; return instruction;
} }
......
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