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

Partially revert: All algorithms: improved lastEdgeType storing logic

Commit partially reverted: 6bcaeab3
parent ba5dc266
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 (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
            if (SlicingAlgorithm.shouldTypeBeStored(lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
+1 −1
Original line number Diff line number Diff line
@@ -141,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 (SlicingAlgorithm.shouldTypeBeStored(nextNode, edge.getType()))
                if (SlicingAlgorithm.shouldTypeBeStored(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 (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
            if (SlicingAlgorithm.shouldTypeBeStored(lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
+2 −3
Original line number Diff line number Diff line
@@ -70,9 +70,8 @@ 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);
    static boolean shouldTypeBeStored(Edge.Type edgeType) {
        return edgeType == Edge.Type.Structural || edgeType == Edge.Type.Control;
    }

    /**
+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 (SlicingAlgorithm.shouldTypeBeStored(node, lastEdgeType))
            if (SlicingAlgorithm.shouldTypeBeStored(lastEdgeType))
                this.lastEdgeType = lastEdgeType;
            else
                this.lastEdgeType = null;
Loading