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

Mark -output- as totally defined every time it is defined.

parent e66f4818
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -207,8 +207,7 @@ public class JSysCFG extends ESCFG {
                // Insert tree into GraphNode<ReturnStmt> nodes, the last action is always DEF(-output-)
                vertexSet().stream()
                        .filter(gn -> gn.getAstNode() instanceof ReturnStmt)
                        .map(GraphNode::getVariableActions)
                        .map(list -> list.get(list.size() - 1))
                        .map(GraphNode::getLastVariableAction)
                        .map(VariableAction::getObjectTree)
                        .forEach(tree -> tree.addAll(fields.get()));
            }
+1 −2
Original line number Diff line number Diff line
@@ -42,10 +42,9 @@ public class JSysCallConnector extends ExceptionSensitiveCallConnector {
    }

    protected void connectObjectActualIn(GraphNode<?> actualIn, GraphNode<?> formalIn) {
        List<VariableAction> actualList = actualIn.getVariableActions();
        List<VariableAction> formalList = formalIn.getVariableActions();
        assert formalList.size() == 1;
        VariableAction actualVar = actualList.get(actualList.size() - 1);
        VariableAction actualVar = actualIn.getLastVariableAction();
        VariableAction formalVar = formalList.get(0);
        actualVar.applySDGTreeConnection((JSysDG) sdg, formalVar);
    }
+6 −0
Original line number Diff line number Diff line
@@ -81,6 +81,12 @@ public class GraphNode<N extends Node> implements Comparable<GraphNode<?>> {
        return Collections.unmodifiableList(variableActions);
    }

    public VariableAction getLastVariableAction() {
        if (variableActions.isEmpty())
            throw new IllegalStateException("There are no variable actions in this node");
        return variableActions.get(variableActions.size() - 1);
    }

    /** The node's label. It represents the portion of the node that
     *  is covered by this node, in the case of block statements. */
    public String getLabel() {
+4 −1
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act
            definitionStack.push(n.getExpression().get());
            acceptAction(SYNTHETIC, VARIABLE_NAME_OUTPUT, DEFINITION);
            definitionStack.pop();
            graphNode.getLastVariableAction().asDefinition()
                    .setTotallyDefinedMember("-root-");
        }
    }

@@ -382,7 +384,7 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act
        List<VariableAction> vaList = graphNode.getVariableActions();
        if (vaList.size() >= 5) { // call-super, DEC(this), USE(-output-), ret-super, DEF(this)
            VariableAction useOutput = vaList.get(vaList.size() - 3);
            VariableAction defThis = vaList.get(vaList.size() - 1);
            VariableAction defThis = graphNode.getLastVariableAction();
            assert useOutput.isUsage() && useOutput.getName().equals(VARIABLE_NAME_OUTPUT);
            assert defThis.isDefinition() && defThis.getName().equals("this");
            defThis.asDefinition().setTotallyDefinedMember("this");
@@ -444,6 +446,7 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act
            def = new VariableAction.Definition(SYNTHETIC, VARIABLE_NAME_OUTPUT, graphNode, (ObjectTree) fields.get().clone());
        else
            def = new VariableAction.Definition(SYNTHETIC, VARIABLE_NAME_OUTPUT, graphNode);
        def.setTotallyDefinedMember("-root-");
        var defMov = new VariableAction.Movable(def, CallNode.Return.create(call));
        graphNode.addVariableAction(defMov);
        // The container of the call uses -output-, unless the call is wrapped in an ExpressionStmt