Loading sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysCFG.java +18 −18 Original line number Diff line number Diff line Loading @@ -25,22 +25,20 @@ import java.util.Set; * polymorphism and other features. */ public class JSysCFG extends ESCFG { /** ClassGraph associated to the Method represented by the CFG */ protected ClassGraph classGraph; /** Set of constructors that must be built with implicit nodes. */ protected Set<ConstructorDeclaration> implicitConstructors; public JSysCFG(ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { super(); this.classGraph = classGraph; this.implicitConstructors = implicitConstructors; @Override public void build(CallableDeclaration<?> declaration) { throw new UnsupportedOperationException("Use build(CallableDeclaration, ClassGraph, Set<ConstructorDeclaration>)"); } @Override public void buildRootNode(CallableDeclaration<?> rootNodeAst) { super.buildRootNode(rootNodeAst); if (implicitConstructors.contains(rootNodeAst)) rootNode.markAsImplicit(); public void build(CallableDeclaration<?> declaration, ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { Builder builder = (Builder) newCFGBuilder(); builder.classGraph = classGraph; builder.implicitDeclaration = implicitConstructors.contains(declaration); declaration.accept(builder, null); // Verify that it has been built exitNode = vertexSet().stream().filter(MethodExitNode.class::isInstance).findFirst() .orElseThrow(() -> new IllegalStateException("Built graph has no exit node!")); built = true; } @Override Loading @@ -49,6 +47,8 @@ public class JSysCFG extends ESCFG { } public class Builder extends ESCFG.Builder { /** ClassGraph associated to the Method represented by the CFG */ protected ClassGraph classGraph; /** List of implicit instructions inserted explicitly in this CFG. * They should be included in the graph as ImplicitNodes. */ protected List<Node> methodInsertedInstructions = new LinkedList<>(); Loading Loading @@ -93,8 +93,6 @@ public class JSysCFG extends ESCFG { @Override public void visit(ConstructorDeclaration n, Void arg) { if (implicitConstructors.contains(n)) implicitDeclaration = true; // Insert call to super() if it is implicit. if (!ASTUtils.constructorHasExplicitConstructorInvocation(n)){ var superCall = new ExplicitConstructorInvocationStmt(null, null, false, null, new NodeList<>()); Loading @@ -106,11 +104,13 @@ public class JSysCFG extends ESCFG { } // Perform the same task as previous graphs. super.visit(n, arg); // Convert the exit nodes to implicit if appropriate if (implicitDeclaration) // Convert enter/exit nodes to implicit if appropriate if (implicitDeclaration) { getRootNode().markAsImplicit(); vertexSet().stream() .filter(MethodExitNode.class::isInstance) .forEach(GraphNode::markAsImplicit); } } } } sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysDG.java +7 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package es.upv.mist.slicing.graphs.jsysdg; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.CallableDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ConstructorDeclaration; import com.github.javaparser.ast.visitor.ModifierVisitor; Loading Loading @@ -45,9 +46,14 @@ public class JSysDG extends ESSDG { }, null); } @Override protected void buildCFG(CallableDeclaration<?> declaration, CFG cfg) { ((JSysCFG) cfg).build(declaration, classGraph, newlyInsertedConstructors); } @Override protected CFG createCFG() { return new JSysCFG(classGraph, newlyInsertedConstructors); return new JSysCFG(); } @Override Loading sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysPDG.java +2 −6 Original line number Diff line number Diff line package es.upv.mist.slicing.graphs.jsysdg; import com.github.javaparser.ast.body.ConstructorDeclaration; import es.upv.mist.slicing.graphs.ClassGraph; import es.upv.mist.slicing.graphs.exceptionsensitive.ESPDG; import java.util.Set; public class JSysPDG extends ESPDG { public JSysPDG(ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { this(new JSysCFG(classGraph, implicitConstructors)); public JSysPDG() { this(new JSysCFG()); } public JSysPDG(JSysCFG cfg) { Loading sdg-core/src/main/java/es/upv/mist/slicing/graphs/sdg/SDG.java +7 −2 Original line number Diff line number Diff line Loading @@ -129,19 +129,24 @@ public class SDG extends Graph implements Sliceable, Buildable<NodeList<Compilat @Override public void visit(MethodDeclaration n, Void arg) { CFG cfg = createCFG(); cfg.build(n); buildCFG(n, cfg); cfgMap.put(n, cfg); } @Override public void visit(ConstructorDeclaration n, Void arg) { CFG cfg = createCFG(); cfg.build(n); buildCFG(n, cfg); cfgMap.put(n, cfg); } }, null); } /** Given a single empty CFG and a declaration, build the CFG. */ protected void buildCFG(CallableDeclaration<?> declaration, CFG cfg) { cfg.build(declaration); } /** Create call graph from the list of compilation units. */ protected CallGraph createCallGraph(NodeList<CompilationUnit> nodeList) { CallGraph callGraph = new CallGraph(cfgMap, classGraph); Loading Loading
sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysCFG.java +18 −18 Original line number Diff line number Diff line Loading @@ -25,22 +25,20 @@ import java.util.Set; * polymorphism and other features. */ public class JSysCFG extends ESCFG { /** ClassGraph associated to the Method represented by the CFG */ protected ClassGraph classGraph; /** Set of constructors that must be built with implicit nodes. */ protected Set<ConstructorDeclaration> implicitConstructors; public JSysCFG(ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { super(); this.classGraph = classGraph; this.implicitConstructors = implicitConstructors; @Override public void build(CallableDeclaration<?> declaration) { throw new UnsupportedOperationException("Use build(CallableDeclaration, ClassGraph, Set<ConstructorDeclaration>)"); } @Override public void buildRootNode(CallableDeclaration<?> rootNodeAst) { super.buildRootNode(rootNodeAst); if (implicitConstructors.contains(rootNodeAst)) rootNode.markAsImplicit(); public void build(CallableDeclaration<?> declaration, ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { Builder builder = (Builder) newCFGBuilder(); builder.classGraph = classGraph; builder.implicitDeclaration = implicitConstructors.contains(declaration); declaration.accept(builder, null); // Verify that it has been built exitNode = vertexSet().stream().filter(MethodExitNode.class::isInstance).findFirst() .orElseThrow(() -> new IllegalStateException("Built graph has no exit node!")); built = true; } @Override Loading @@ -49,6 +47,8 @@ public class JSysCFG extends ESCFG { } public class Builder extends ESCFG.Builder { /** ClassGraph associated to the Method represented by the CFG */ protected ClassGraph classGraph; /** List of implicit instructions inserted explicitly in this CFG. * They should be included in the graph as ImplicitNodes. */ protected List<Node> methodInsertedInstructions = new LinkedList<>(); Loading Loading @@ -93,8 +93,6 @@ public class JSysCFG extends ESCFG { @Override public void visit(ConstructorDeclaration n, Void arg) { if (implicitConstructors.contains(n)) implicitDeclaration = true; // Insert call to super() if it is implicit. if (!ASTUtils.constructorHasExplicitConstructorInvocation(n)){ var superCall = new ExplicitConstructorInvocationStmt(null, null, false, null, new NodeList<>()); Loading @@ -106,11 +104,13 @@ public class JSysCFG extends ESCFG { } // Perform the same task as previous graphs. super.visit(n, arg); // Convert the exit nodes to implicit if appropriate if (implicitDeclaration) // Convert enter/exit nodes to implicit if appropriate if (implicitDeclaration) { getRootNode().markAsImplicit(); vertexSet().stream() .filter(MethodExitNode.class::isInstance) .forEach(GraphNode::markAsImplicit); } } } }
sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysDG.java +7 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package es.upv.mist.slicing.graphs.jsysdg; import com.github.javaparser.ast.CompilationUnit; import com.github.javaparser.ast.Modifier; import com.github.javaparser.ast.NodeList; import com.github.javaparser.ast.body.CallableDeclaration; import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; import com.github.javaparser.ast.body.ConstructorDeclaration; import com.github.javaparser.ast.visitor.ModifierVisitor; Loading Loading @@ -45,9 +46,14 @@ public class JSysDG extends ESSDG { }, null); } @Override protected void buildCFG(CallableDeclaration<?> declaration, CFG cfg) { ((JSysCFG) cfg).build(declaration, classGraph, newlyInsertedConstructors); } @Override protected CFG createCFG() { return new JSysCFG(classGraph, newlyInsertedConstructors); return new JSysCFG(); } @Override Loading
sdg-core/src/main/java/es/upv/mist/slicing/graphs/jsysdg/JSysPDG.java +2 −6 Original line number Diff line number Diff line package es.upv.mist.slicing.graphs.jsysdg; import com.github.javaparser.ast.body.ConstructorDeclaration; import es.upv.mist.slicing.graphs.ClassGraph; import es.upv.mist.slicing.graphs.exceptionsensitive.ESPDG; import java.util.Set; public class JSysPDG extends ESPDG { public JSysPDG(ClassGraph classGraph, Set<ConstructorDeclaration> implicitConstructors) { this(new JSysCFG(classGraph, implicitConstructors)); public JSysPDG() { this(new JSysCFG()); } public JSysPDG(JSysCFG cfg) { Loading
sdg-core/src/main/java/es/upv/mist/slicing/graphs/sdg/SDG.java +7 −2 Original line number Diff line number Diff line Loading @@ -129,19 +129,24 @@ public class SDG extends Graph implements Sliceable, Buildable<NodeList<Compilat @Override public void visit(MethodDeclaration n, Void arg) { CFG cfg = createCFG(); cfg.build(n); buildCFG(n, cfg); cfgMap.put(n, cfg); } @Override public void visit(ConstructorDeclaration n, Void arg) { CFG cfg = createCFG(); cfg.build(n); buildCFG(n, cfg); cfgMap.put(n, cfg); } }, null); } /** Given a single empty CFG and a declaration, build the CFG. */ protected void buildCFG(CallableDeclaration<?> declaration, CFG cfg) { cfg.build(declaration); } /** Create call graph from the list of compilation units. */ protected CallGraph createCallGraph(NodeList<CompilationUnit> nodeList) { CallGraph callGraph = new CallGraph(cfgMap, classGraph); Loading