Commit cf4214c0 authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Constructor Support

parent ed087875
......@@ -154,4 +154,12 @@ public class EMAMBluePrintCPP extends EMAMBluePrint {
public void addInstructionToMethod(Instruction instruction, String methodName) {
getMethod(methodName).get().addInstruction(instruction);
}
public void setConstructor(Method constructor) {
this.constructor = constructor;
}
public Method getConstructor() {
return constructor;
}
}
......@@ -185,6 +185,9 @@ public class LanguageUnitCPP extends LanguageUnit {
resultString += generateHeaderGenerateVariable(v);
}
if (bluePrint.getConstructor() != null)
resultString += generateConstructor(bluePrint.getConstructor(), bluePrint);
//generate methods
for (Method method : bluePrint.getMethods()) {
if(!method.isPublic()){
......@@ -204,6 +207,29 @@ public class LanguageUnitCPP extends LanguageUnit {
return resultString;
}
private String generateConstructor(Method constructor, EMAMBluePrintCPP bluePrint) {
int counter = 0;
String resultString = constructor.getName() + "(";
for (Variable param : constructor.getParameters()) {
if (counter == 0) {
++counter;
resultString += param.getVariableType().getTypeNameTargetLanguage() + " " + param.getNameTargetLanguageFormat();
} else {
resultString += ", " + param.getVariableType().getTypeNameTargetLanguage() + " " + param.getNameTargetLanguageFormat();
}
if (param.isArray())
resultString += "[" + param.getArraySize() + "]";
}
resultString += ") :\n";//TODO add semicolon when using source files
for (Instruction instruction : constructor.getInstructions())
resultString += instruction.getTargetLanguageInstruction();
resultString += "{}\n";
return resultString;
}
protected String generateHeaderGenerateVariable(Variable v){
if(v instanceof VariablePortValueChecker){
......
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