Commit 05a959c4 authored by Javier Costa's avatar Javier Costa
Browse files

generic astNode instead of statement + sdg

parent a9151bc3
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ import java.util.Comparator;
import java.util.function.Function;
import java.util.stream.Collectors;

public abstract class CFGGraph extends Graph<CFGNode> {
public class CFGGraph extends Graph<CFGNode> {

    public CFGGraph() {
        super();
@@ -28,7 +28,9 @@ public abstract class CFGGraph extends Graph<CFGNode> {
        return vertex;
    }

    protected abstract String getRootNodeData();
    protected String getRootNodeData() {
        return "Start";
    }

    @SuppressWarnings("unchecked")
    public void addControlFlowEdge(CFGNode from, CFGNode to) {
+2 −2
Original line number Diff line number Diff line
@@ -87,9 +87,9 @@ public abstract class Graph<NodeType extends Node> extends edg.graphlib.Graph<St

    public abstract NodeType addNode(String instruction, Statement statement);

    public Optional<NodeType> findNodeByStatement(Statement statement) {
    public <ASTNode extends com.github.javaparser.ast.Node> Optional<NodeType> findNodeByASTNode(ASTNode astNode) {
        return getNodes().stream()
                .filter(node -> Objects.equals(node.getStatement(), statement))
                .filter(node -> Objects.equals(node.getAstNode(), astNode))
                .findFirst();
    }

+4 −2
Original line number Diff line number Diff line
@@ -20,13 +20,15 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public abstract class PDGGraph extends Graph<PDGNode> {
public class PDGGraph extends Graph<PDGNode> {

    public PDGGraph() {
        setRootVertex(new PDGNode(getNextVertexId(), getRootNodeData(), new EmptyStmt()));
    }

    protected abstract String getRootNodeData();
    protected String getRootNodeData() {
        return "Entry";
    }

    public <N extends Node> PDGNode addNode(N node) {
        PDGNode vertex = new PDGNode(getNextVertexId(), node);
+17 −0
Original line number Diff line number Diff line
package tfm.graphs;

import com.github.javaparser.ast.stmt.Statement;
import tfm.nodes.SDGNode;

public class SDGGraph extends Graph<SDGNode> {

    @Override
    public SDGNode addNode(String instruction, Statement statement) {
        return null;
    }

    @Override
    public String toGraphvizRepresentation() {
        return null;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import tfm.graphs.Graph;
import java.util.stream.Collectors;


public class CFGNode extends Node {
public class CFGNode extends Node<Statement> {

    public <N extends Node> CFGNode(N node) {
        super(node);
Loading