Commit e7d95501 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

Mega commit: object trees and their connections.

* VariableAction stores pending connections between trees.
* Update JavaParser from 3.17.0 to 3.19.0
* Object trees in assignments and return statements are linked to the appropriate expressions.
* Return trees are linked interprocedurally.
* ReturnStmt variable actions are now all generated by VariableVisitor.
* CallNode.Return are now generated by VariableVisitor instead of the SDG after the interprocedural finders.
* Actual-in nodes are now generated based on the expressions used, and then linked to the actual-in generated by the InterproceduralUsageFinder.
* We now accept calls as scope or argument of another call.
* ClassGraph is now a singleton. ClassGraph#newInstance() generates a new one.
* ClassGraph can generate a complete ObjectTree for a given type.
* MemberNode's parent can now be any node, and can be set after creation.
* New slicing algorithm for the JSysDG.
* Added interprocedural object-flow arcs.
* Added ObjectFlow and Flow dependency arcs.
* Introduced test to guarantee that interprocedural arcs are either input xor output.
* Updated tests
parent e4127a91
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -34,12 +34,12 @@
        <dependency>
            <groupId>com.github.javaparser</groupId>
            <artifactId>javaparser-core</artifactId>
            <version>3.17.0</version>
            <version>3.19.0</version>
        </dependency>
        <dependency>
            <groupId>com.github.javaparser</groupId>
            <artifactId>javaparser-symbol-solver-core</artifactId>
            <version>3.17.0</version>
            <version>3.19.0</version>
        </dependency>
        <dependency>
            <groupId>org.jgrapht</groupId>
+4 −0
Original line number Diff line number Diff line
@@ -89,6 +89,10 @@ public abstract class Arc extends DefaultEdge {
        throw new UnsupportedOperationException("Not a DataDependencyArc");
    }

    public boolean isObjectFlow() {
        return false;
    }

    // =========================== SDG ===========================

    /** Whether or not this is an interprocedural arc that connects a call site to its declaration. */
+24 −0
Original line number Diff line number Diff line
package es.upv.mist.slicing.arcs.pdg;

import es.upv.mist.slicing.arcs.Arc;
import org.jgrapht.nio.Attribute;
import org.jgrapht.nio.DefaultAttribute;

import java.util.Map;

public class FlowDependencyArc extends Arc {
    public FlowDependencyArc() {
        super();
    }

    public FlowDependencyArc(String variable) {
        super(variable);
    }

    @Override
    public Map<String, Attribute> getDotAttributes() {
        Map<String, Attribute> map = super.getDotAttributes();
        map.put("color", DefaultAttribute.createAttribute("red"));
        return map;
    }
}
+26 −0
Original line number Diff line number Diff line
package es.upv.mist.slicing.arcs.pdg;

import es.upv.mist.slicing.arcs.Arc;
import org.jgrapht.nio.Attribute;
import org.jgrapht.nio.DefaultAttribute;

import java.util.Map;

public class ObjectFlowDependencyArc extends Arc {
    public ObjectFlowDependencyArc() {
        super();
    }

    @Override
    public boolean isObjectFlow() {
        return true;
    }

    @Override
    public Map<String, Attribute> getDotAttributes() {
        Map<String, Attribute> map = super.getDotAttributes();
        map.put("color", DefaultAttribute.createAttribute("red"));
        map.put("style", DefaultAttribute.createAttribute("dashed"));
        return map;
    }
}
+26 −4
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import es.upv.mist.slicing.nodes.io.ActualIONode;
import es.upv.mist.slicing.nodes.io.CallNode;
import es.upv.mist.slicing.nodes.io.FormalIONode;
import es.upv.mist.slicing.nodes.io.OutputNode;
import es.upv.mist.slicing.nodes.oo.MemberNode;
import org.jgrapht.nio.Attribute;
import org.jgrapht.nio.DefaultAttribute;

@@ -22,18 +23,39 @@ public class ParameterInOutArc extends InterproceduralArc {

    @Override
    public boolean isInterproceduralInputArc() {
        GraphNode<?> source = (GraphNode<?>) getSource();
        GraphNode<?> target = (GraphNode<?>) getTarget();
        GraphNode<?> source = getNodeCommon(getSource());
        GraphNode<?> target = getNodeCommon(getTarget());
        return source instanceof ActualIONode && ((ActualIONode) source).isInput() &&
                target instanceof FormalIONode && ((FormalIONode) target).isInput();
    }

    @Override
    public boolean isInterproceduralOutputArc() {
        GraphNode<?> source = (GraphNode<?>) getSource();
        GraphNode<?> target = (GraphNode<?>) getTarget();
        GraphNode<?> source = getNodeCommon(getSource());
        GraphNode<?> target = getNodeCommon(getTarget());
        return (source instanceof FormalIONode && ((FormalIONode) source).isOutput() &&
                target instanceof ActualIONode && ((ActualIONode) target).isOutput()) ||
                (source instanceof OutputNode && target instanceof CallNode.Return);
    }

    protected GraphNode<?> getNodeCommon(Object node) {
        GraphNode<?> graphNode = (GraphNode<?>) node;
        while (graphNode instanceof MemberNode)
            graphNode = ((MemberNode) graphNode).getParent();
        return graphNode;
    }

    public static class ObjectFlow extends ParameterInOutArc {
        @Override
        public boolean isObjectFlow() {
            return true;
        }

        @Override
        public Map<String, Attribute> getDotAttributes() {
            Map<String, Attribute> map = super.getDotAttributes();
            map.put("style", DefaultAttribute.createAttribute("dotted"));
            return map;
        }
    }
}
Loading