Loading iacfg/src/main/java/es/upv/mist/slicing/graphs/icfg/ICFG.java +12 −9 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import org.jgrapht.graph.DefaultEdge; import org.jgrapht.traverse.DepthFirstIterator; import java.util.*; import java.util.stream.Collectors; import static es.upv.mist.slicing.util.SingletonCollector.toSingleton; Loading @@ -46,6 +47,15 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< protected final Map<CallableDeclaration<?>, CFG> cfgMap = ASTUtils.newIdentityHashMap(); protected boolean built = false; /** Map to associate ICFG nodes to correspondent Topological numbers */ protected final Map<GraphNode<?>, Set<Integer>> topologicalNumbersMap = new HashMap<>(); public String getTopologicalNumbersString(GraphNode<?> node) { return topologicalNumbersMap.get(node).stream() .map(String::valueOf) .collect(Collectors.joining(",")); } public ControlFlowArc addControlFlowArc(GraphNode<?> from, GraphNode<?> to) { ControlFlowArc a = new ControlFlowArc(); addEdge(from, to, a); Loading Loading @@ -90,16 +100,8 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< protected IntraSCRGraph intraSCRs; /** Non-Recursive interprocedural Arcs from {@link #intraSCRs} */ protected Set<Triple<GraphNode<?>, GraphNode<?>, ControlFlowArc>> interprocNonRecArcs = new HashSet<>(); /** A list of all {@link #intraSCRs} that have an callSite type in Nanda-Ramesh algorithm */ protected Set<IntraSCR> callSiteIntraSCRs = new HashSet<>(); /** A list of all {@link #intraSCRs} that have an returnSite type in Nanda-Ramesh algorithm */ protected Set<IntraSCR> returnSiteIntraSCRs = new HashSet<>(); /** A map to locate the correspondent call node from a return node */ protected final Map<IntraSCR, IntraSCR> returnToCorrespondentCallSiteMap = new HashMap<>(); /** A map to locate the {@link #intraSCRs} within a call*/ protected final Map<IntraSCR, Set<IntraSCR>> callNodeProcessMap = new HashMap<>(); /** A map to get the topological number associated to the {@link #intraSCRs} */ protected final Map<Integer, IntraSCR> topologicalNumbersMap = new HashMap<>(); /** counter for topologicalNumbers */ protected int topologicalNumber = 0; Loading Loading @@ -130,7 +132,8 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< private void setTopologicalNumbersIntoICFG() { for (IntraSCR intraSCR : intraSCRs.vertexSet()) { for (GraphNode<?> graphNode : intraSCR.vertexSet()) { graphNode.setTopologicalNumbers(intraSCR.getTopologicalNumberSet()); topologicalNumbersMap.computeIfAbsent(graphNode, k -> new HashSet<>()).addAll(intraSCR.getTopologicalNumberSet()); } } } Loading iacfg/src/test/java/es/upv/mist/slicing/graphs/icfg/ICFGLog.java +10 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package es.upv.mist.slicing.graphs.icfg; import es.upv.mist.slicing.arcs.Arc; import es.upv.mist.slicing.cli.DOTAttributes; import es.upv.mist.slicing.cli.GraphLog; import es.upv.mist.slicing.nodes.GraphNode; public class ICFGLog extends GraphLog<ICFG> { public ICFGLog() { Loading @@ -20,4 +21,13 @@ public class ICFGLog extends GraphLog<ICFG> { res.add("style", "dashed"); return res; } @Override protected DOTAttributes vertexAttributes(GraphNode<?> node) { DOTAttributes res = new DOTAttributes(); res.set("label", node.getLongLabel() + "\n" + this.graph.getTopologicalNumbersString(node)); if (node.isImplicitInstruction()) res.add("style", "dashed"); return res; } } Loading
iacfg/src/main/java/es/upv/mist/slicing/graphs/icfg/ICFG.java +12 −9 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import org.jgrapht.graph.DefaultEdge; import org.jgrapht.traverse.DepthFirstIterator; import java.util.*; import java.util.stream.Collectors; import static es.upv.mist.slicing.util.SingletonCollector.toSingleton; Loading @@ -46,6 +47,15 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< protected final Map<CallableDeclaration<?>, CFG> cfgMap = ASTUtils.newIdentityHashMap(); protected boolean built = false; /** Map to associate ICFG nodes to correspondent Topological numbers */ protected final Map<GraphNode<?>, Set<Integer>> topologicalNumbersMap = new HashMap<>(); public String getTopologicalNumbersString(GraphNode<?> node) { return topologicalNumbersMap.get(node).stream() .map(String::valueOf) .collect(Collectors.joining(",")); } public ControlFlowArc addControlFlowArc(GraphNode<?> from, GraphNode<?> to) { ControlFlowArc a = new ControlFlowArc(); addEdge(from, to, a); Loading Loading @@ -90,16 +100,8 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< protected IntraSCRGraph intraSCRs; /** Non-Recursive interprocedural Arcs from {@link #intraSCRs} */ protected Set<Triple<GraphNode<?>, GraphNode<?>, ControlFlowArc>> interprocNonRecArcs = new HashSet<>(); /** A list of all {@link #intraSCRs} that have an callSite type in Nanda-Ramesh algorithm */ protected Set<IntraSCR> callSiteIntraSCRs = new HashSet<>(); /** A list of all {@link #intraSCRs} that have an returnSite type in Nanda-Ramesh algorithm */ protected Set<IntraSCR> returnSiteIntraSCRs = new HashSet<>(); /** A map to locate the correspondent call node from a return node */ protected final Map<IntraSCR, IntraSCR> returnToCorrespondentCallSiteMap = new HashMap<>(); /** A map to locate the {@link #intraSCRs} within a call*/ protected final Map<IntraSCR, Set<IntraSCR>> callNodeProcessMap = new HashMap<>(); /** A map to get the topological number associated to the {@link #intraSCRs} */ protected final Map<Integer, IntraSCR> topologicalNumbersMap = new HashMap<>(); /** counter for topologicalNumbers */ protected int topologicalNumber = 0; Loading Loading @@ -130,7 +132,8 @@ public class ICFG extends es.upv.mist.slicing.graphs.Graph implements Buildable< private void setTopologicalNumbersIntoICFG() { for (IntraSCR intraSCR : intraSCRs.vertexSet()) { for (GraphNode<?> graphNode : intraSCR.vertexSet()) { graphNode.setTopologicalNumbers(intraSCR.getTopologicalNumberSet()); topologicalNumbersMap.computeIfAbsent(graphNode, k -> new HashSet<>()).addAll(intraSCR.getTopologicalNumberSet()); } } } Loading
iacfg/src/test/java/es/upv/mist/slicing/graphs/icfg/ICFGLog.java +10 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package es.upv.mist.slicing.graphs.icfg; import es.upv.mist.slicing.arcs.Arc; import es.upv.mist.slicing.cli.DOTAttributes; import es.upv.mist.slicing.cli.GraphLog; import es.upv.mist.slicing.nodes.GraphNode; public class ICFGLog extends GraphLog<ICFG> { public ICFGLog() { Loading @@ -20,4 +21,13 @@ public class ICFGLog extends GraphLog<ICFG> { res.add("style", "dashed"); return res; } @Override protected DOTAttributes vertexAttributes(GraphNode<?> node) { DOTAttributes res = new DOTAttributes(); res.set("label", node.getLongLabel() + "\n" + this.graph.getTopologicalNumbersString(node)); if (node.isImplicitInstruction()) res.add("style", "dashed"); return res; } }