Unverified Commit b2c98ba9 authored by Javier Costa's avatar Javier Costa Committed by GitHub
Browse files

Merge pull request #16 from jacosro/more_graphs

Add more graphs and generalize CFG and control dependence creation
parents 3b669889 70348bc6
Loading
Loading
Loading
Loading

.gitmodules

0 → 100644
+3 −0
Original line number Diff line number Diff line
[submodule "src/test/res/java-slicing-benchmarks"]
	path = src/test/res/java-slicing-benchmarks
	url = kaz:repos/java-slicing-benchmarks.git
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.5.2</version>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
+9 −4
Original line number Diff line number Diff line
@@ -12,10 +12,7 @@ import java.util.Map;
import java.util.Objects;

public abstract class Arc extends DefaultEdge {
    public Arc() {

    }

    /** @see tfm.arcs.cfg.ControlFlowArc */
    public final boolean isControlFlowArc() {
        return this instanceof ControlFlowArc;
    }
@@ -26,6 +23,13 @@ public abstract class Arc extends DefaultEdge {
        throw new UnsupportedOperationException("Not a ControlFlowArc");
    }

    /** @see tfm.arcs.cfg.ControlFlowArc.NonExecutable */
    public final boolean isExecutableControlFlowArc() {
        return this instanceof ControlFlowArc &&
                !(this instanceof ControlFlowArc.NonExecutable);
    }

    /** @see tfm.arcs.pdg.ControlDependencyArc */
    public final boolean isControlDependencyArc() {
        return this instanceof ControlDependencyArc;
    }
@@ -36,6 +40,7 @@ public abstract class Arc extends DefaultEdge {
        throw new UnsupportedOperationException("Not a ControlDependencyArc");
    }

    /** @see tfm.arcs.pdg.DataDependencyArc */
    public final boolean isDataDependencyArc() {
        return this instanceof DataDependencyArc;
    }
+26 −1
Original line number Diff line number Diff line
package tfm.arcs.cfg;

import org.jgrapht.io.Attribute;
import org.jgrapht.io.DefaultAttribute;
import tfm.arcs.Arc;
import tfm.graphs.augmented.ACFG;
import tfm.graphs.cfg.CFG;

import java.util.Map;

/**
 * An edge of the {@link CFG}, representing the direct
 * flow of control. It connects two instructions if, when the source
 * is executed, one of the possible next instructions is the destination.
 */
public class ControlFlowArc extends Arc {
    public ControlFlowArc() {
    /**
     * Represents a non-executable control flow arc, used within the {@link ACFG ACFG}.
     * Initially it had the following meaning: connecting a statement with
     * the following one as if the source was a {@code nop} command (no operation).
     * <br/>
     * It is used to improve control dependence, and it should be skipped when
     * computing data dependence and other analyses.
     */
    public static final class NonExecutable extends ControlFlowArc {
        @Override
        public Map<String, Attribute> getDotAttributes() {
            Map<String, Attribute> map = super.getDotAttributes();
            map.put("style", DefaultAttribute.createAttribute("dashed"));
            return map;
        }
    }
}
+8 −2
Original line number Diff line number Diff line
package tfm.arcs.pdg;

import tfm.arcs.Arc;
import tfm.graphs.pdg.PDG;
import tfm.graphs.sdg.SDG;

/**
 * An arc used in the {@link PDG} and {@link SDG}
 * used to represent control dependence between two nodes. The traditional definition of
 * control dependence is: a node {@code a} is <it>control dependent</it> on node
 * {@code b} if and only if {@code b} alters the number of times {@code a} is executed.
 */
public class ControlDependencyArc extends Arc {
    public ControlDependencyArc() {
    }
}
Loading