Commit 53fdb7db authored by Sergio Pérez's avatar Sergio Pérez
Browse files

Add prefix to VariableActions names when necessary and reorder sequence of assign VariableActions

parent f81411ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class JSysDG extends ESSDG {
            // See creation strategy at http://kaz2.dsic.upv.es:3000/Fzg46cQvT1GzHQG9hFnP1g#Using-data-flow-in-the-SDG
            classGraph = createClassGraph(nodeList);
            buildCFGs(nodeList);                             // 1
            CallGraph callGraph = createCallGraph(nodeList); // 2
            CallGraph callGraph = createCallGraph(nodeList, classGraph); // 2
            dataFlowAnalysis(callGraph);                     // 3
            buildAndCopyPDGs();                              // 4
            connectCalls(callGraph);                         // 5
+8 −4
Original line number Diff line number Diff line
@@ -89,8 +89,6 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act

    @Override
    public void visit(NameExpr n, Action action) {
        String prefix = this.getNamePrefix(n); // Add a prefix to the name ("this." or "CLASS.this.")
        n.setName(new SimpleName(prefix + n.getNameAsString()));
        acceptAction(n, action);
    }

@@ -117,6 +115,11 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act
    }

    protected void acceptAction(Expression n, Action action) {
        if (n instanceof NameExpr) { // Add a prefix to the name ("this." or "CLASS.this.") when "n" is a NameExpr
            NameExpr en = (NameExpr) n;
            String prefix = this.getNamePrefix(en); // Add a prefix to the name ("this." or "CLASS.this.")
            en.setName(new SimpleName(prefix + en.getNameAsString()));
        }
        switch (action) {
            case DECLARATION:
                declConsumer.accept(graphNode, n);
@@ -177,11 +180,12 @@ public class VariableVisitor extends GraphNodeContentVisitor<VariableVisitor.Act

    @Override
    public void visit(AssignExpr n, Action action) {
        // Value is always visited first since uses occur before definitions
        n.getValue().accept(this, action);
        // Target will be used if operator is not '='
        if (n.getOperator() != AssignExpr.Operator.ASSIGN)
            n.getTarget().accept(this, action);
        visitAsDefinition(n.getTarget(), n.getValue(), action);
        n.getValue().accept(this, action);
    }

    @Override