diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/MethodBodyGenerator.java b/AlgebraicDataflowArchitectureModel/src/algorithms/MethodBodyGenerator.java index c27b6b3..2cef2f4 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithms/MethodBodyGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithms/MethodBodyGenerator.java @@ -42,7 +42,7 @@ // Create a map from type names (lower case) to their types. Map typeMap = new HashMap<>(); for (TypeDeclaration type: types) { - typeMap.put(type.getTypeName().toLowerCase(), type); + typeMap.put(type.getTypeName().substring(0,1).toLowerCase() + type.getTypeName().substring(1), type); } // Generate the body of each update or getter method. @@ -62,17 +62,24 @@ // push MethodDeclaration update = getUpdateMethod(dstType); String curState = d.getChannelGenerator().deriveUpdateExpressionOf(out, CodeGenerator.pushAccessor).toImplementation(); - update.addFirstStatement(dstResourceName + " = " + curState + ";"); + String updateStatement = dstResourceName + " = " + curState + ";"; + if (update.getBody() == null || !update.getBody().getStatements().contains(updateStatement)) { + update.addFirstStatement(updateStatement); + } MethodDeclaration getter = getGetterMethod(dstType); - getter.addStatement("return " + dstResourceName + ";"); + if (getter.getBody() == null || getter.getBody().getStatements().size() == 0) { + getter.addStatement("return " + dstResourceName + ";"); + } // src side MethodDeclaration srcUpdate = getUpdateMethod(srcType); if (srcUpdate != null) srcUpdate.addStatement(dstResourceName + ".update(" + srcResourceName + ");"); } else { // pull or push/pull MethodDeclaration getter = getGetterMethod(dstType); - String curState = d.getChannelGenerator().deriveUpdateExpressionOf(out, CodeGenerator.pullAccessor).toImplementation(); - getter.addStatement("return " + curState + ";"); + if (getter.getBody() == null || getter.getBody().getStatements().size() == 0) { + String curState = d.getChannelGenerator().deriveUpdateExpressionOf(out, CodeGenerator.pullAccessor).toImplementation(); + getter.addStatement("return " + curState + ";"); + } } } }