diff --git a/AlgebraicDataflowArchitectureModel/src/algorithms/FinalDecisionOfStoringResourceStates.java b/AlgebraicDataflowArchitectureModel/src/algorithms/FinalDecisionOfStoringResourceStates.java index 999e9c1..715fdd2 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithms/FinalDecisionOfStoringResourceStates.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithms/FinalDecisionOfStoringResourceStates.java @@ -9,10 +9,10 @@ import models.dataFlowModel.*; public class FinalDecisionOfStoringResourceStates { - static private HashSet arrivedNode = new HashSet<>(); + static private HashSet reachableNodes = new HashSet<>(); static public void doDecide(ResourceDependencyGraph graph) { - arrivedNode.clear(); + reachableNodes.clear(); for (Node n : graph.getNodes()) { ResourceNode resource = (ResourceNode) n; trackNode(resource); @@ -20,27 +20,26 @@ } static private void trackNode(ResourceNode resource) { - if (arrivedNode.contains(resource)) + if (reachableNodes.contains(resource)) return; - arrivedNode.add(resource); - boolean flag = false; + reachableNodes.add(resource); + boolean flag = true; for (Edge e : resource.getInEdges()) { - if (((PushPullAttribute) e.getAttribute()).getOptions().get(0) == PushPullValue.PUSH) { + if (((PushPullAttribute) e.getAttribute()).getOptions().get(0) != PushPullValue.PUSH) { + // Traverse pull edges only. trackNode((ResourceNode) e.getSource()); - flag = true; + flag = false; } } - if (resource.getInEdges().size() == 0) - flag = true; +// if (resource.getInEdges().size() == 0) +// flag = true; ((StoreAttribute) resource.getAttribute()).setStored(flag); if (resource.getIdentifierTemplate().getResourceStateType() == null) { for (Edge e : resource.getInEdges()) { for (ChannelMember cm : ((ResourceDependency) e).getChannelGenerator().getChannelMembers()) { - if (((PushPullAttribute) ((ResourceDependency) e).getAttribute()).getOptions() - .get(0) == PushPullValue.PUSH + if (((PushPullAttribute) ((ResourceDependency) e).getAttribute()).getOptions().get(0) == PushPullValue.PUSH && cm.getStateTransition().getNextStateExpression().getClass() == Term.class) { - if (((Term) cm.getStateTransition().getNextStateExpression()).getSymbol().getName() - .equals("cons")) { + if (((Term) cm.getStateTransition().getNextStateExpression()).getSymbol().getName().equals("cons")) { resource.getIdentifierTemplate().setResourceStateType(DataConstraintModel.typeList); } } @@ -49,11 +48,9 @@ } for (Edge e : resource.getOutEdges()) { for (ChannelMember cm : ((ResourceDependency) e).getChannelGenerator().getChannelMembers()) { - if (((PushPullAttribute) ((ResourceDependency) e).getAttribute()).getOptions() - .get(0) != PushPullValue.PUSH + if (((PushPullAttribute) ((ResourceDependency) e).getAttribute()).getOptions().get(0) != PushPullValue.PUSH && cm.getStateTransition().getNextStateExpression().getClass() == Term.class) { - if (((Term) cm.getStateTransition().getNextStateExpression()).getSymbol().getName() - .equals("cons")) { + if (((Term) cm.getStateTransition().getNextStateExpression()).getSymbol().getName().equals("cons")) { resource.getIdentifierTemplate().setResourceStateType(DataConstraintModel.typeList); } }