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

Tabular algorithms: enable traversal of summaries

- Config.summaries must be false, to disallow generation of internal summary edges with grammars.
parent 8b40a41d
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
/*
 * EDG, a library to generate and slice Expression Dependence Graphs.
 * Copyright (c) 2021-2023. David Insa, Carlos Galindo, Sergio Pérez, Josep Silva, Salvador Tamarit.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package edg.slicing;

import edg.config.Config;
@@ -40,6 +58,7 @@ public class ConstrainedTabularAlgorithm implements SlicingAlgorithm {
    protected final Map<State, Set<Work>> current2worksMap = new HashMap<>();

    public ConstrainedTabularAlgorithm(EDG edg) {
        assert !Config.summaries : "ConstrainedTabularAlgorithm requires no generation of summaries in the graph, apart from external ones.";
        this.edg = edg;
    }

@@ -104,7 +123,6 @@ public class ConstrainedTabularAlgorithm implements SlicingAlgorithm {
        for (Edge edge : edg.getEdges(node, LAST.Direction.Backwards)) {
            // Edge-skipping rules
            if (edge.isControlFlowEdge() // Control Flow is not deleted from the graph, but is unnecessary
                    || edge.getType() == Edge.Type.Summary // Always ignore in-graph summary edges (those are built with grammars and are inaccurate)
                    || !filter.test(edge) // Apply the caller-specified filter
                    || !edge.isTraversable() // Skip non-traversable edges (structural)
                    || (node.getType() == Node.Type.Generator && leType != Edge.Type.Control && edge.getType() == Edge.Type.Value)
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

package edg.slicing;

import edg.config.Config;
import edg.graph.EDG;
import edg.graph.Edge;
import edg.graph.LAST;
@@ -43,6 +44,7 @@ public class TabularAlgorithm implements SlicingAlgorithm {
    protected final Map<Node, Set<Work>> current2worksMap = new HashMap<>();

    public TabularAlgorithm(EDG edg) {
        assert !Config.summaries : "TabularAlgorithm requires no generation of summaries in the graph, apart from external ones.";
        this.edg = edg;
    }

@@ -101,7 +103,6 @@ public class TabularAlgorithm implements SlicingAlgorithm {
    protected void traverseEdges(Work work, Predicate<Edge> filter) {
        for (Edge e : edg.getEdges(work.current, LAST.Direction.Backwards))
            if (!e.isControlFlowEdge()
                    && e.getType() != Edge.Type.Summary
                    && e.isTraversable()
                    && filter.test(e)
                    && !(work.current.getType() == Node.Type.Generator && work.lastEdge != Edge.Type.Control && e.getType() == Edge.Type.Value)