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

PDGConnections: only mark as applied if arcs have been added.

parent aa31dca9
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -41,10 +41,8 @@ class ObjectTreeConnection implements VariableAction.PDGConnection {

    @Override
    public void apply(JSysPDG graph) {
        if (!applied) {
        if (!applied)
            connectTrees(graph, FlowDependencyArc::new, ObjectFlowDependencyArc::new);
            applied = true;
        }
    }

    protected void connectTrees(Graph graph, Supplier<Arc> flowSupplier, Supplier<Arc> objFlowSupplier) {
@@ -67,9 +65,12 @@ class ObjectTreeConnection implements VariableAction.PDGConnection {
    private void connectOT(ObjectTree source, ObjectTree target, GraphNode<?> rootSrc, GraphNode<?> rootTgt,
                           Graph graph, Supplier<Arc> flowSupplier, Supplier<Arc> objFlowSupplier) {
        if (source == null || target == null) {
            if (!rootSrc.equals(rootTgt))
            if (!rootSrc.equals(rootTgt)) {
                graph.addEdge(rootSrc, rootTgt, flowSupplier.get());
                applied = true;
            }
        } else {
            applied = true;
            graph.addEdge(rootSrc, rootTgt, objFlowSupplier.get());
            graph.addEdge(rootSrc, rootTgt, flowSupplier.get());
            for (String treeMember : target.nameIterable()) {
+8 −1
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ public class ValueConnection implements VariableAction.PDGConnection {
    protected final VariableAction action;
    protected final String member;

    protected boolean applied = false;

    public ValueConnection(VariableAction action, String member) {
        this.action = action;
        this.member = member.isEmpty() ? ROOT_NAME : ROOT_NAME + "." + member;
@@ -19,13 +21,18 @@ public class ValueConnection implements VariableAction.PDGConnection {

    @Override
    public void apply(JSysPDG graph) {
        if (applied)
            return;
        GraphNode<?> statementNode;
        if (action instanceof VariableAction.Movable)
            statementNode = ((VariableAction.Movable) action).getRealNode();
        else
            statementNode = action.getGraphNode();
        if (action.hasPolyTreeMember(member))
            for (MemberNode source : action.getObjectTree().getNodesForPoly(member))
            for (MemberNode source : action.getObjectTree().getNodesForPoly(member)) {
                graph.addEdge(source, statementNode, new FlowDependencyArc());
                applied = true;
            }

    }
}