Commit 6bcaeab3 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

All algorithms: improved lastEdgeType storing logic.

Now last edge is only remembered as Control if the node is a Generator. Also moved store lastEdgeType logic to interface.
parent 0a6a570c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ public class AdaptedStandardAlgorithm implements SlicingAlgorithm {
    private record State(Node node, Edge.Type lastEdgeType) {
        private State(Node node, Edge.Type lastEdgeType) {
            this.node = node;
            if (lastEdgeType == Edge.Type.Structural || lastEdgeType == Edge.Type.Control)
            if (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
+2 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class ConstrainedTabularAlgorithm implements SlicingAlgorithm {
    protected final Map<State, Set<Work>> current2worksMap = new HashMap<>();

    protected ConstrainedTabularAlgorithm(EDG edg, Collection<Work> workList) {
        assert sliceDirection == LAST.Direction.Backwards;
        assert !Config.summaries : "ConstrainedTabularAlgorithm requires no generation of summaries in the graph, apart from external ones.";
        this.edg = edg;
        this.workList = workList;
@@ -140,7 +141,7 @@ public class ConstrainedTabularAlgorithm implements SlicingAlgorithm {
            List<Constraints> resolvedList = edgeCons.resolve(Phase.Tabular, edg, edge, (Constraints) work.current.stack.clone(), topConstraint, 0);

            for (Constraints resolved : resolvedList)
                if (edge.getType() == Edge.Type.Structural || edge.getType() == Edge.Type.Control)
                if (SlicingAlgorithm.shouldTypeBeStored(nextNode, edge.getType()))
                    propagate(new Work(work, new State(nextNode, resolved), edge.getType()));
                else // no need to store the type, type only matters for structural and control.
                    propagate(new Work(work, new State(nextNode, resolved)));
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class OnePassStandardAlgorithm implements SlicingAlgorithm {
    private record State(Node node, Edge.Type lastEdgeType) {
        private State(Node node, Edge.Type lastEdgeType) {
            this.node = node;
            if (lastEdgeType == Edge.Type.Structural || lastEdgeType == Edge.Type.Control)
            if (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
+5 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ public interface SlicingAlgorithm {
                && !(lastEdgeType == Edge.Type.Structural && edge.getType() != Edge.Type.Structural);
    }

    static boolean shouldTypeBeStored(Node node, Edge.Type edgeType) {
        return edgeType == Edge.Type.Structural
                || (node.getType() == Node.Type.Generator && edgeType == Edge.Type.Control);
    }

    /**
     * Checks whether a given node is a pseudo-predicate (by type).
     */
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class StandardAlgorithm implements SlicingAlgorithm {
    private record State(Node node, Edge.Type lastEdgeType) {
        private State(Node node, Edge.Type lastEdgeType) {
            this.node = node;
            if (lastEdgeType == Edge.Type.Control || lastEdgeType == Edge.Type.Structural)
            if (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
Loading