Commit 737ead94 authored by Javier Costa's avatar Javier Costa
Browse files

PDG Structure validation + begin with slicing

parent 7a8d9076
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ public class CFGLog extends GraphLog<CFGGraph, CFGVisitor> {
    }

    @Override
    void generatePNGs() throws IOException {
    public void generatePNGs() throws IOException {
        Graphviz.fromString(graph.toGraphvizRepresentation())
                .render(Format.PNG)
                .toFile(new File("./out/cfg.png"));
+12 −4
Original line number Diff line number Diff line
@@ -20,10 +20,18 @@ public abstract class GraphLog<G extends Graph<?>, V extends VoidVisitor<?>> {
    G graph;
    V visitor;

    abstract void visit(Node node);
    public GraphLog() {

    }

    public GraphLog(G graph) {
        this.graph = graph;
    }

    public abstract void visit(Node node);


    void log() throws IOException {
    public void log() throws IOException {
        Logger.log(
                "****************************\n" +
                "*           GRAPH          *\n" +
@@ -41,7 +49,7 @@ public abstract class GraphLog<G extends Graph<?>, V extends VoidVisitor<?>> {
        generatePNGs();
    }

    abstract void generatePNGs() throws IOException;
    public abstract void generatePNGs() throws IOException;

    abstract void openVisualRepresentation() throws IOException;
    public abstract void openVisualRepresentation() throws IOException;
}
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.body.MethodDeclaration;
import tfm.utils.Logger;
import tfm.utils.Utils;

import java.io.File;
import java.io.IOException;
@@ -13,7 +14,7 @@ import java.util.Optional;

public class Main {

    public static final String PROGRAM = "src/main/java/tfm/programs/pdg/Example1.java";
    public static final String PROGRAM = Utils.PROGRAMS_FOLDER + "pdg/Example2.java";
    public static final String METHOD = "";
    public static final String GRAPH = GraphLog.PDG;

+15 −7
Original line number Diff line number Diff line
@@ -16,8 +16,16 @@ import java.util.stream.Collectors;

public class PDGLog extends GraphLog<PDGGraph, PDGCFGVisitor> {

    public PDGLog() {
        super();
    }

    public PDGLog(PDGGraph pdgGraph) {
        super(pdgGraph);
    }

    @Override
    void visit(com.github.javaparser.ast.Node node) {
    public void visit(com.github.javaparser.ast.Node node) {
        this.graph = new PDGGraph();

        this.visitor = new PDGCFGVisitor(graph);
@@ -26,7 +34,7 @@ public class PDGLog extends GraphLog<PDGGraph, PDGCFGVisitor> {
    }

    @Override
    void log() throws IOException {
    public void log() throws IOException {
        super.log();

        Logger.log("Nodes with variable info");
@@ -44,10 +52,10 @@ public class PDGLog extends GraphLog<PDGGraph, PDGCFGVisitor> {
    }

    @Override
    void generatePNGs() throws IOException {
        Graphviz.fromString(visitor.getCfgGraph().toGraphvizRepresentation())
                .render(Format.PNG)
                .toFile(new File("./out/pdg-cfg.png"));
    public void generatePNGs() throws IOException {
//        Graphviz.fromString(visitor.getCfgGraph().toGraphvizRepresentation())
//                .render(Format.PNG)
//                .toFile(new File("./out/pdg-cfg.png"));

        Graphviz.fromString(graph.toGraphvizRepresentation())
                .render(Format.PNG)
@@ -55,7 +63,7 @@ public class PDGLog extends GraphLog<PDGGraph, PDGCFGVisitor> {
    }

    @Override
    void openVisualRepresentation() throws IOException {
    public void openVisualRepresentation() throws IOException {
        new ProcessBuilder(Arrays.asList("xdg-open", "./out/pdg-cfg.png")).start();
        new ProcessBuilder(Arrays.asList("xdg-open", "./out/pdg.png")).start();
    }
+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import java.io.IOException;
public class SDGLog extends GraphLog<SDGGraph, SDGVisitor> {

    @Override
    void visit(Node node) {
    public void visit(Node node) {
        SDGGraph sdgGraph = new SDGGraph();

        SDGVisitor sdgVisitor = new SDGVisitor(sdgGraph);
@@ -18,12 +18,12 @@ public class SDGLog extends GraphLog<SDGGraph, SDGVisitor> {
    }

    @Override
    void generatePNGs() throws IOException {
    public void generatePNGs() throws IOException {

    }

    @Override
    void openVisualRepresentation() throws IOException {
    public void openVisualRepresentation() throws IOException {

    }
}
Loading