diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java b/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java index 2969692..5f63542 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithms/TypeInference.java @@ -869,7 +869,7 @@ newJsonType = createNewJsonType(newMemberTypes, DataConstraintModel.typeJson); } } - if (jsonType != newJsonType && newJsonType != null) { + if (jsonType != newJsonType && newJsonType != null && !newJsonType.isAncestorOf(jsonType)) { // Update the type of the json term and record the updated expression. t.setType(newJsonType); jsonType = newJsonType; @@ -909,7 +909,7 @@ newJsonType = createNewJsonType(newMemberTypes, DataConstraintModel.typeJson); } } - if (jsonType != newJsonType && newJsonType != null) { + if (jsonType != newJsonType && newJsonType != null && !newJsonType.isAncestorOf(jsonType)) { // Update the type of the json argument and record the updated expression. if (jsonArg instanceof Variable) { ((Variable) jsonArg).setType(newJsonType); @@ -967,7 +967,7 @@ } } } - if (jsonType != newJsonType && newJsonType != null) { + if (jsonType != newJsonType && newJsonType != null && !newJsonType.isAncestorOf(jsonType)) { // Update the type of the json argument and record the updated expression. if (jsonArg instanceof Variable) { ((Variable) jsonArg).setType(newJsonType); diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java index 72f2358..85973e0 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGenerator.java @@ -256,8 +256,8 @@ orderedList.add(0, curResNode); } - protected void updateMainComponent(DataTransferModel model, TypeDeclaration mainType, MethodDeclaration mainConstructor, Node componentNode, - final List depends, ILanguageSpecific langSpec) { + protected void updateMainComponent(TypeDeclaration mainType, MethodDeclaration mainConstructor, Node componentNode, + MethodDeclaration constructor, ILanguageSpecific langSpec) { // Declare the field to refer to each object in the main type. ResourceNode resNode = null; String nodeName = null; @@ -273,24 +273,9 @@ } // Add a statement to instantiate each object to the main constructor. List parameters = new ArrayList<>(); - for (ResourceHierarchy res: depends) { - // For the callee objects (the destination resource of push transfer or the source resource of pull transfer). - parameters.add(res.getResourceName()); - } - // For the refs. - if (resNode != null) { - Set refs = new HashSet<>(); - for (Channel cg : model.getChannels()) { - DataTransferChannel ch = (DataTransferChannel) cg; - if (ch.getInputResources().contains(resNode.getOutSideResource())) { - for (ResourcePath resPath: ch.getReferenceResources()) { - if (!refs.contains(resPath) && !depends.contains(resPath.getResourceHierarchy())) { - refs.add(resPath); - String refResName = resPath.getResourceName(); - parameters.add(refResName); - } - } - } + if (constructor.getParameters() != null) { + for (VariableDeclaration var: constructor.getParameters()) { + parameters.add(var.getName()); } } diff --git a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java index cf3f036..0bd7352 100644 --- a/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java +++ b/AlgebraicDataflowArchitectureModel/src/generators/CodeGeneratorFromDataFlowGraph.java @@ -81,7 +81,7 @@ if (resourceNode.getResourceHierarchy().getParent() == null) { // For each root resource // Update the main component for this component. - updateMainComponent(model, mainComponent, mainConstructor, componentNode, depends, langSpec); + updateMainComponent(mainComponent, mainConstructor, componentNode, constructor, langSpec); } // Declare the fields to refer to reference resources. diff --git a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ModelExtension.java b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ModelExtension.java index d8aa4af..7d4ce1b 100644 --- a/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ModelExtension.java +++ b/AlgebraicDataflowArchitectureModel/src/models/dataFlowModel/ModelExtension.java @@ -57,7 +57,7 @@ merge.setGenerator(new Symbol.IImplGenerator() { @Override public String generate(Type type, String[] childrenImpl, String[] childrenSideEffects, String[] sideEffect) { - String implType = "Arrayist<>"; + String implType = "ArrayList<>"; String interfaceType = "List"; String compType = "Integer"; if (type != null) {