diff --git a/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageNecessity.java b/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageNecessity.java index cfd38d0..0625664 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageNecessity.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithm/DataStorageNecessity.java @@ -7,27 +7,30 @@ public class DataStorageNecessity { static public ResourceDependencyGraph run(DataFlowModel model) { + ResourceDependencyGraph graph = model.getResourceDependencyGraph(); DataConstraintModel dcmodel = (DataConstraintModel) model; for (ChannelGenerator generator : dcmodel.getChannelGenerators()) { - for (ChannelMember member : ((DataflowChannelGenerator)generator).getOutputChannelMembers()) { + for (ChannelMember member : ((DataflowChannelGenerator) generator).getOutputChannelMembers()) { Expression curexp = member.getStateTransition().getCurStateExpression(); Expression nextexp = member.getStateTransition().getNextStateExpression(); - for (Position pos : nextexp.getVariables().keySet()) { + boolean flag = false; + for (Position pos : curexp.getVariables().keySet()) { System.out.println(curexp); System.out.println(nextexp.getVariables().containsKey(pos)); System.out.println(nextexp); - if(nextexp.getVariables().get(pos).contains(curexp)) { - for(Node node:model.getResourceDependencyGraph().getNodes()) { - if(((ResourceNode)node).getIdentifierTemplate().equals(member.getIdentifierTemplate())){ - StoreAttribute store = new StoreAttribute(); - store.setNeeded(true); - ((ResourceNode)node).setAttribute(store); - } - } + if (nextexp.contains(curexp.getVariables().get(pos))) { + flag = true; + } + } + for (Node node : graph.getNodes()) { + if (((ResourceNode) node).getIdentifierTemplate().equals(member.getIdentifierTemplate())) { + StoreAttribute store = new StoreAttribute(); + store.setNeeded(flag); + ((ResourceNode) node).setAttribute(store); } } } } - return model.getResourceDependencyGraph(); + return graph; } }