Commit 68547afc authored by Ahmed's avatar Ahmed

add new addParameter to method class

parent a9cf7e71
......@@ -42,6 +42,13 @@ public class Method {
parameters.add(v);
}
public void addParameter(Variable var, String variableName, String typeNameMontiCar,
String typeNameTargetLangauge, String includeName){
var.setName(variableName);
var.setVariableType(new VariableType(typeNameMontiCar, typeNameTargetLangauge, includeName));
parameters.add(var);
}
public boolean addParameterUnique(Variable v) {
boolean added = !containsParameter(v);
if (added) {
......
......@@ -60,27 +60,19 @@ public class DilateCommand extends ArgumentReturnMathCommand{
private Method getDilateHelperMethod(){
Method method = new Method("dilateHelper", "void");
//parameter
//add parameters
Variable src = new Variable();
src.setName("src");
src.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
method.addParameter(src, "src", "CommonMatrix",MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable();
dst.setName("dst");
dst.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
Variable dilation_elem = new Variable();
dilation_elem.setName("erosion_elem");
dilation_elem.setVariableType(new VariableType("Integer", "int",""));
method.addParameter(dst, "dst", "CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());
Variable erosion_elem = new Variable();
method.addParameter(erosion_elem,"dilation_elem", "Integer", "int", "");
Variable iterations = new Variable();
iterations.setName("iterations");
iterations.setVariableType(new VariableType("Integer", "int", ""));
//add variable to method
method.addParameter(src);
method.addParameter(dst);
method.addParameter(dilation_elem);
method.addParameter(iterations);
method.addParameter(iterations, "iterations", "Integer","int", "");
//add an instruction to the method
method.addInstruction(methodBody());
return method;
}
......
......@@ -61,24 +61,15 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
private Method getErodeHelperMethod(){
Method method = new Method("erodeHelper", "void");
//parameters
//add parameters
Variable src = new Variable();
src.setName("src");
src.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
method.addParameter(src, "src", "CommonMatrix",MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable();
dst.setName("dst");
dst.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
method.addParameter(dst, "dst", "CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());
Variable erosion_elem = new Variable();
erosion_elem.setName("erosion_elem");
erosion_elem.setVariableType(new VariableType("Integer", "int",""));
method.addParameter(erosion_elem,"erosion_elem", "Integer", "int", "");
Variable iterations = new Variable();
iterations.setName("iterations");
iterations.setVariableType(new VariableType("Integer", "int", ""));
//add variable to method
method.addParameter(src);
method.addParameter(dst);
method.addParameter(erosion_elem);
method.addParameter(iterations);
method.addParameter(iterations, "iterations", "Integer","int", "");
//add an instruction to the method
method.addInstruction(methodBody());
......
......@@ -61,32 +61,20 @@ public class GaussianBlurCommand extends ArgumentReturnMathCommand{
private Method getGaussianBlurHelperMethod(){
Method method = new Method("gaussianBlurHelper", "void");
//parameters
//add parameters
Variable src = new Variable();
src.setName("src");
src.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
method.addParameter(src, "src", "CommonMatrix",MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable();
dst.setName("dst");
dst.setVariableType(new VariableType("CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName()));
method.addParameter(dst, "dst", "CommonMatrixType", MathConverter.curBackend.getMatrixTypeName(), MathConverter.curBackend.getIncludeHeaderName());
Variable sizeX = new Variable();
sizeX.setName("sizeX");
sizeX.setVariableType(new VariableType("Integer", "int",""));
method.addParameter(sizeX, "sizeX", "Integer", "int", "");
Variable sizeY = new Variable();
sizeY.setName("sizeY");
sizeY.setVariableType(new VariableType("Integer", "int",""));
method.addParameter(sizeY, "sizeY", "Integer", "int", "");
Variable sigmaX = new Variable();
sigmaX.setName("sigmaX");
sigmaX.setVariableType(new VariableType("Double", "double",""));
method.addParameter(sigmaX, "sigmaX", "Double", "double", "");
Variable sigmaY = new Variable();
sigmaY.setName("sigmaY");
sigmaY.setVariableType(new VariableType("Double", "double",""));
method.addParameter(src);
method.addParameter(dst);
method.addParameter(sizeX);
method.addParameter(sizeY);
method.addParameter(sigmaX);
method.addParameter(sigmaY);
method.addParameter(sigmaY, "sigmaY", "Double", "double", "");
//add an instruction to the method
method.addInstruction(methodBody());
return method;
......
......@@ -298,7 +298,7 @@ public class ComponentConverter {
if(v.isParameterVariable()){
method.addInstruction(new TargetCodeInstruction("this->" + MathInformationRegister.getVariableInitName(v, bluePrint) + "=" + MathInformationRegister.getVariableInitName(v, bluePrint) + ";\n"));
method.addParameter(v);
}else {//ToDo: inside getInitLine you can add your configuration for another represetation
}else {
Optional<String> initLine = MathConverter.getInitLine(v, bluePrint);
initLine.ifPresent(s -> method.addInstruction(new TargetCodeInstruction(s)));
}
......
......@@ -18,7 +18,7 @@ void init()
src=mat(n,m);
dst=mat(n,m);
}
void dilateHelper(mat src, mat dst, int erosion_elem, int iterations)
void dilateHelper(mat src, mat dst, int dilation_elem, int iterations)
{
int dilation_type = 0;
if( dilation_elem == 0 ){ dilation_type = MORPH_RECT; }
......
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