Commit aa71a7c3 authored by Javier Costa's avatar Javier Costa
Browse files

Refactor GraphNode

parent 29f4eeb1
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
package tfm.arcs;

import tfm.arcs.data.ArcData;
import tfm.nodes.Node;
import tfm.nodes.GraphNode;

import java.util.Objects;

public abstract class Arc<D extends ArcData> extends edg.graphlib.Arrow<String, D> {

    @SuppressWarnings("unchecked")
    public Arc(Node from, Node to) {
    public Arc(GraphNode from, GraphNode to) {
        super((edg.graphlib.Vertex<String, D>) from, (edg.graphlib.Vertex<String, D>) to);
    }

@@ -28,8 +28,8 @@ public abstract class Arc<D extends ArcData> extends edg.graphlib.Arrow<String,
    }

    public String toGraphvizRepresentation() {
        Node from = (Node) getFrom();
        Node to = (Node) getTo();
        GraphNode from = (GraphNode) getFrom();
        GraphNode to = (GraphNode) getTo();

        return String.format("%s -> %s",
                from.getId(),
@@ -37,12 +37,12 @@ public abstract class Arc<D extends ArcData> extends edg.graphlib.Arrow<String,
        );
    }

    public Node getFromNode() {
        return (Node) super.getFrom();
    public GraphNode getFromNode() {
        return (GraphNode) super.getFrom();
    }

    public Node getToNode() {
        return (Node) super.getTo();
    public GraphNode getToNode() {
        return (GraphNode) super.getTo();
    }

    @Override
@@ -60,10 +60,10 @@ public abstract class Arc<D extends ArcData> extends edg.graphlib.Arrow<String,

        Arc arc = (Arc) o;

        Node from = (Node) arc.getFrom();
        Node from2 = (Node) getFrom();
        Node to = (Node) getTo();
        Node to2 = (Node) arc.getTo();
        GraphNode from = (GraphNode) arc.getFrom();
        GraphNode from2 = (GraphNode) getFrom();
        GraphNode to = (GraphNode) getTo();
        GraphNode to2 = (GraphNode) arc.getTo();

        return Objects.equals(arc.getData(), getData()) &&
                Objects.equals(from.getId(), from2.getId()) &&
+2 −2
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ package tfm.arcs.cfg;

import tfm.arcs.Arc;
import tfm.arcs.data.VoidArcData;
import tfm.nodes.Node;
import tfm.nodes.GraphNode;

public class ControlFlowArc extends Arc<VoidArcData> {

    public ControlFlowArc(Node from, Node to) {
    public ControlFlowArc(GraphNode from, GraphNode to) {
        super(from, to);
    }

+4 −4
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ package tfm.arcs.pdg;

import tfm.arcs.Arc;
import tfm.arcs.data.ArcData;
import tfm.nodes.Node;
import tfm.nodes.GraphNode;

public class ControlDependencyArc extends Arc<ArcData> {

    public ControlDependencyArc(Node from, Node to) {
    public ControlDependencyArc(GraphNode from, GraphNode to) {
        super(from, to);
    }

@@ -28,8 +28,8 @@ public class ControlDependencyArc extends Arc<ArcData> {
    @Override
    public String toString() {
        return String.format("ControlDependencyArc{%s -> %s}",
                ((Node) getFrom()).getId(),
                ((Node) getTo()).getId()
                ((GraphNode) getFrom()).getId(),
                ((GraphNode) getTo()).getId()
        );
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ package tfm.arcs.pdg;

import tfm.arcs.Arc;
import tfm.arcs.data.VariableArcData;
import tfm.nodes.Node;
import tfm.nodes.GraphNode;

import java.util.ArrayList;
import java.util.Arrays;
@@ -10,7 +10,7 @@ import java.util.List;

public class DataDependencyArc extends Arc<VariableArcData> {

    public DataDependencyArc(Node from, Node to, String variable, String... variables) {
    public DataDependencyArc(GraphNode from, GraphNode to, String variable, String... variables) {
        super(from, to);

        List<String> variablesList = new ArrayList<>(variables.length + 1);
+2 −2
Original line number Diff line number Diff line
@@ -13,9 +13,9 @@ import java.util.Optional;

public class Main {

    public static final String PROGRAM = Utils.PROGRAMS_FOLDER + "sdg/Example1.java";
    public static final String PROGRAM = Utils.PROGRAMS_FOLDER + "cfg/Eval_1.java";
    public static final String METHOD = "";
    public static final String GRAPH = GraphLog.SDG;
    public static final String GRAPH = GraphLog.CFG;

    public static void main(String[] args) throws IOException {
        JavaParser.getStaticConfiguration().setAttributeComments(false);
Loading