Loading pom.xml +6 −0 Original line number Diff line number Diff line Loading @@ -41,5 +41,11 @@ <version>1.3.0</version> </dependency> <dependency> <groupId>org.jgrapht</groupId> <artifactId>jgrapht-io</artifactId> <version>1.3.0</version> </dependency> </dependencies> </project> No newline at end of file src/main/java/tfm/arcs/Arc.java +7 −7 Original line number Diff line number Diff line package tfm.arcs; import org.jgrapht.graph.DefaultEdge;; import org.jgrapht.graph.DefaultEdge; import tfm.nodes.GraphNode; import java.util.Objects; Loading Loading @@ -30,6 +30,10 @@ public abstract class Arc extends DefaultEdge { @Override public String toString() { return toGraphvizRepresentation(); } public String toGraphvizRepresentation() { GraphNode<?> from = (GraphNode<?>) getSource(); GraphNode<?> to = (GraphNode<?>) getTarget(); Loading @@ -39,14 +43,10 @@ public abstract class Arc extends DefaultEdge { ); } public String toGraphvizRepresentation() { return toString(); } @Override public boolean equals(Object o) { if (this != o) { return false; if (this == o) { return true; } return Objects.equals(variable, ((Arc) o).variable); Loading src/main/java/tfm/arcs/cfg/ControlFlowArc.java +0 −2 Original line number Diff line number Diff line package tfm.arcs.cfg; import tfm.arcs.Arc; import tfm.arcs.data.VoidArcData; import tfm.nodes.GraphNode; public class ControlFlowArc extends Arc { Loading src/main/java/tfm/arcs/pdg/ControlDependencyArc.java +0 −2 Original line number Diff line number Diff line package tfm.arcs.pdg; import tfm.arcs.Arc; import tfm.arcs.data.ArcData; import tfm.nodes.GraphNode; public class ControlDependencyArc extends Arc { Loading src/main/java/tfm/exec/GraphLog.java +22 −2 Original line number Diff line number Diff line package tfm.exec; import com.github.javaparser.ast.Node; import org.jgrapht.io.ComponentNameProvider; import org.jgrapht.io.DOTExporter; import org.jgrapht.io.ExportException; import org.jgrapht.io.GraphExporter; import tfm.arcs.Arc; import tfm.graphs.Graph; import tfm.nodes.GraphNode; import tfm.utils.FileUtil; import tfm.utils.Logger; import java.io.*; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; public abstract class GraphLog<G extends Graph> { public enum Format { Loading Loading @@ -73,8 +82,19 @@ public abstract class GraphLog<G extends Graph> { generated = true; File tmpDot = File.createTempFile("graph-source-", ".dot"); tmpDot.deleteOnExit(); try (Writer w = new FileWriter(tmpDot)) { w.write(graph.toGraphvizRepresentation()); // w.write(graph.toGraphvizRepresentation()); // JGraphT DOT export GraphExporter<GraphNode<?>, Arc> exporter = new DOTExporter<>( component -> String.valueOf(component.getId()), GraphNode::getInstruction, component -> component.getVariable().orElse("")); exporter.exportGraph(graph, w); } catch (ExportException e) { e.printStackTrace(); } ProcessBuilder pb = new ProcessBuilder("dot", tmpDot.getAbsolutePath(), "-T" + format.getExt(), Loading Loading
pom.xml +6 −0 Original line number Diff line number Diff line Loading @@ -41,5 +41,11 @@ <version>1.3.0</version> </dependency> <dependency> <groupId>org.jgrapht</groupId> <artifactId>jgrapht-io</artifactId> <version>1.3.0</version> </dependency> </dependencies> </project> No newline at end of file
src/main/java/tfm/arcs/Arc.java +7 −7 Original line number Diff line number Diff line package tfm.arcs; import org.jgrapht.graph.DefaultEdge;; import org.jgrapht.graph.DefaultEdge; import tfm.nodes.GraphNode; import java.util.Objects; Loading Loading @@ -30,6 +30,10 @@ public abstract class Arc extends DefaultEdge { @Override public String toString() { return toGraphvizRepresentation(); } public String toGraphvizRepresentation() { GraphNode<?> from = (GraphNode<?>) getSource(); GraphNode<?> to = (GraphNode<?>) getTarget(); Loading @@ -39,14 +43,10 @@ public abstract class Arc extends DefaultEdge { ); } public String toGraphvizRepresentation() { return toString(); } @Override public boolean equals(Object o) { if (this != o) { return false; if (this == o) { return true; } return Objects.equals(variable, ((Arc) o).variable); Loading
src/main/java/tfm/arcs/cfg/ControlFlowArc.java +0 −2 Original line number Diff line number Diff line package tfm.arcs.cfg; import tfm.arcs.Arc; import tfm.arcs.data.VoidArcData; import tfm.nodes.GraphNode; public class ControlFlowArc extends Arc { Loading
src/main/java/tfm/arcs/pdg/ControlDependencyArc.java +0 −2 Original line number Diff line number Diff line package tfm.arcs.pdg; import tfm.arcs.Arc; import tfm.arcs.data.ArcData; import tfm.nodes.GraphNode; public class ControlDependencyArc extends Arc { Loading
src/main/java/tfm/exec/GraphLog.java +22 −2 Original line number Diff line number Diff line package tfm.exec; import com.github.javaparser.ast.Node; import org.jgrapht.io.ComponentNameProvider; import org.jgrapht.io.DOTExporter; import org.jgrapht.io.ExportException; import org.jgrapht.io.GraphExporter; import tfm.arcs.Arc; import tfm.graphs.Graph; import tfm.nodes.GraphNode; import tfm.utils.FileUtil; import tfm.utils.Logger; import java.io.*; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; public abstract class GraphLog<G extends Graph> { public enum Format { Loading Loading @@ -73,8 +82,19 @@ public abstract class GraphLog<G extends Graph> { generated = true; File tmpDot = File.createTempFile("graph-source-", ".dot"); tmpDot.deleteOnExit(); try (Writer w = new FileWriter(tmpDot)) { w.write(graph.toGraphvizRepresentation()); // w.write(graph.toGraphvizRepresentation()); // JGraphT DOT export GraphExporter<GraphNode<?>, Arc> exporter = new DOTExporter<>( component -> String.valueOf(component.getId()), GraphNode::getInstruction, component -> component.getVariable().orElse("")); exporter.exportGraph(graph, w); } catch (ExportException e) { e.printStackTrace(); } ProcessBuilder pb = new ProcessBuilder("dot", tmpDot.getAbsolutePath(), "-T" + format.getExt(), Loading