diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/JavaPrototypeGenerateAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/JavaPrototypeGenerateAction.java index 90bbd0e..92b552b 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/actions/JavaPrototypeGenerateAction.java +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/JavaPrototypeGenerateAction.java @@ -13,9 +13,12 @@ import algorithms.*; import application.editor.Editor; import code.ast.*; +import generators.CodeGenerator; import generators.DataTransferMethodAnalyzer; import generators.JavaCodeGenerator; import generators.JavaMethodBodyGenerator; +import generators.JavaSpecific; +import models.controlFlowModel.ControlFlowGraph; import models.dataConstraintModel.IdentifierTemplate; import models.dataFlowModel.DataTransferModel; import models.dataFlowModel.ModelExtension; @@ -35,16 +38,16 @@ @Override public void actionPerformed(ActionEvent e) { - DataFlowGraph graph = editor.getDataFlowGraph(); - if (graph == null) { + DataFlowGraph dataFlowgraph = editor.getDataFlowGraph(); + if (dataFlowgraph == null) { editor.changeStage(Editor.STAGE_PUSH_PULL_SELECTION); - graph = editor.getDataFlowGraph(); + dataFlowgraph = editor.getDataFlowGraph(); } - if (graph != null) { + if (dataFlowgraph != null) { DataTransferModel model = editor.getModel(); ModelExtension.extendModel(model); TypeInference.infer(model); - DataTransferMethodAnalyzer.decideToStoreResourceStates(graph); + DataTransferMethodAnalyzer.decideToStoreResourceStates(dataFlowgraph); String fileName = editor.getCurFileName(); if (fileName == null) fileName = "Main"; String mainTypeName = fileName.split("\\.")[0]; @@ -56,11 +59,16 @@ } } if (!exist) { - JavaCodeGenerator.setMainTypeName(mainTypeName); // use model's file name as the main type's name. + CodeGenerator.setMainTypeName(mainTypeName); // use model's file name as the main type's name. } else { - JavaCodeGenerator.resetMainTypeName(); // use the default main type's name. + CodeGenerator.resetMainTypeName(); // use the default main type's name. } - editor.setCodes(JavaMethodBodyGenerator.doGenerate(graph, model, JavaCodeGenerator.doGenerate(graph, model))); + ControlFlowGraph controlFlowGraph = editor.getControlFlowGraph(); + if (controlFlowGraph != null) { + editor.setCodes(CodeGenerator.doGenerate(model, controlFlowGraph, new JavaSpecific())); + } else { + editor.setCodes(CodeGenerator.doGenerate(model, dataFlowgraph, new JavaSpecific())); + } ModelExtension.recoverModel(model); for (CompilationUnit file : editor.getCodes()) { System.out.println(file);