Loading EDG/src/main/java/edg/EDGFactory.java +26 −7 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import edg.graph.LAST; public class EDGFactory { private final LAST last; private EDG edg; private boolean interproceduralGraph = false; public EDGFactory(LAST last) { Loading Loading @@ -75,15 +75,34 @@ public class EDGFactory { } } private void generateDependencies() { long initialControl = System.nanoTime(); new ControlEdgeGenerator(edg).generate(); long finalControl = System.nanoTime(); edg.getGenerationTime().setControlTime((finalControl-initialControl) / 1000000.0); // WE ARE NOT GENERATING INTERPROCEDURAL EDGES if (interproceduralGraph) { if (isOOLanguage) new InterproceduralEdgeGenerator(edg).generate(); // Specially Generated for OOPrograms else else { long initialInputOutput = System.nanoTime(); new InterproceduralEdgeGenerator(edg).generateErlang(); // // new FlowEdgeGenerator(edg).generate(); // TODO: Testear varios escenarios del POST-IT long finalInputOutput = System.nanoTime(); edg.getGenerationTime().setInterproceduralTime((finalInputOutput-initialInputOutput) / 1000000.0); } } long initialFlow = System.nanoTime(); new FlowEdgeGenerator(edg).generate(); long finalFlow = System.nanoTime(); edg.getGenerationTime().setFlowTime((finalFlow-initialFlow) / 1000000.0); // WE ARE NOT GENERATING SUMMARIES if (interproceduralGraph) new SummaryEdgeGenerator(edg).generate(); else new SummaryEdgeGenerator(edg).generateAsExternal(); // new ExceptionEdgeGenerator(edg).generate(); } Loading EDG/src/main/java/edg/edge/SummaryEdgeGenerator.java +29 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,35 @@ public class SummaryEdgeGenerator extends EdgeGenerator this.generateInternalSummaryEdges(); } public void generateAsExternal(){ this.generateSummaryEdgesAsExternal(); } private void generateSummaryEdgesAsExternal() { final List<Node> calls = edg.getNodes(Node.Type.Call); for (Node call : calls) { final Node callee = edg.getChild(call, Node.Type.Callee); if (isKnownModuleFunction(callee)) { buildSummaryEdges(call, callee); continue; } final Node callResult = edg.getResFromNode(call); final Node argumentsNode = edg.getChild(call, Node.Type.Arguments); final List<Node> arguments = edg.getChildren(argumentsNode); arguments.removeIf(n -> n.getType() == Node.Type.Result); for (Node argument : arguments) { final Node argumentResult = edg.getResFromNode(argument); this.edg.addEdge(argumentResult, callResult, new Edge(Edge.Type.Summary, AsteriskConstraint.getConstraint())); } } } /* ********************************** */ /* ************ External ************ */ /* ********************************** */ Loading EDG/src/main/java/edg/graph/EDG.java +22 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ public class EDG extends LAST { this.rootNode = last.rootNode; this.nextId = last.nextId; this.fictitiousId = last.fictitiousId; this.getGenerationTime().setStructureTime(last.getStructuralTime()); this.getGenerationTime().setControlFlowTime(last.getControlFlowTime()); this.getGenerationTime().setValueTime(last.getValueTime()); this.getGenerationTime().setCompositeTime(last.getCompositeStructureTime()); } // ================================================= // Loading Loading @@ -80,12 +84,14 @@ public class EDG extends LAST { public static class GraphGeneratorTimer { // MILISECONDS (1*10^(-3)) private double structureTime; private double controlFlowTime; private double controlTime; private double interproceduralTime; private double flowTime; private double valueTime; private double compositeTime; private double summaryTime; private double exceptionTime; Loading @@ -93,46 +99,50 @@ public class EDG extends LAST { { this.structureTime = structureTime; } public void setControlFlowTime(double controlFlowTime) { this.controlFlowTime = controlFlowTime; } public void setControlTime(double controlTime) { this.controlTime = controlTime; } public void setControlTime(double controlTime) { this.controlTime = controlTime; } public void setInterproceduralTime(double interproceduralTime) { this.interproceduralTime = interproceduralTime; } public void setFlowTime(double flowTime) { this.flowTime = flowTime; } public void setValueTime(double valueTime) { this.valueTime = valueTime; } public void setCompositeTime(double compositeTime) { this.compositeTime = compositeTime; } public void setSummaryTime(double summaryTime) { this.summaryTime = summaryTime; } public void setExceptionTime(double exceptionTime) { this.exceptionTime = exceptionTime; } public double getStructureTime() { return this.structureTime; } public double getControlFlowTime() { return this.controlFlowTime; } public double getValueTime() { return this.valueTime; } public double getCompositeTime() { return this.compositeTime; } public double getControlTime() { return this.controlTime; } public double getFlowTime() { return this.flowTime; } public double getGenerationEDGTime() { return structureTime + controlFlowTime + controlTime + interproceduralTime + flowTime + valueTime + summaryTime + exceptionTime; } public double getGenerationIntraproceduralEDGTime() { return structureTime + controlFlowTime + controlTime + flowTime + valueTime ; } } } EDG/src/main/java/edg/graph/LAST.java +14 −0 Original line number Diff line number Diff line Loading @@ -929,4 +929,18 @@ public class LAST extends GraphWithRoot { return false; return true; } private double structuralGenerationTime = 0; private double controlFlowGenerationTime = 0; private double valueGenerationTime = 0; private double compositeStructureTime = 0; public void setStructuralTime(double time) { structuralGenerationTime = time; } public void setControlFlowTime(double time) { controlFlowGenerationTime = time; } public void setValueTime(double time) { valueGenerationTime = time; } public void setCompositeStructureEdges(double time) { compositeStructureTime = time; } public double getStructuralTime() { return structuralGenerationTime; } public double getControlFlowTime() { return controlFlowGenerationTime; } public double getValueTime() { return valueGenerationTime; } public double getCompositeStructureTime() { return compositeStructureTime; } } EDG/src/main/java/edg/slicing/AdaptedStandardAlgorithm.java 0 → 100644 +92 −0 Original line number Diff line number Diff line package edg.slicing; import edg.graph.EDG; import edg.graph.Edge; import edg.graph.LAST; import edg.graph.Node; import java.util.*; public class AdaptedStandardAlgorithm extends StandardAlgorithm{ public AdaptedStandardAlgorithm(EDG edg) { super(edg); } public Set<Node> slice(Node slicingCriterion) { final Set<Node> slice = new HashSet<>(); if (slicingCriterion == null) return slice; slice.add(slicingCriterion); this.traverse(slicingCriterion, slice); return slice; } protected void traverse(Node slicingCriterion, Set<Node> slice, Edge.Type... ignoreEdgeTypes) { final Deque<Node> pendingNodes = new LinkedList<>(slice); final Set<Edge.Type> ignoreEdgeTypesSet = new HashSet<>(Arrays.asList(ignoreEdgeTypes)); while (!pendingNodes.isEmpty()) { final Node pendingNode = pendingNodes.removeFirst(); final Set<Edge> nextEdges = edg.getEdges(pendingNode, sliceDirection); nextEdges.removeIf(e -> ignoreEdgeTypesSet.contains(e.getType())); nextEdges.removeIf(Edge::isControlFlowEdge); nextEdges.removeIf(e -> !e.isTraversable()); for (Edge nextEdge : nextEdges) { final Node nextNode = sliceDirection == LAST.Direction.Backwards ? edg.getEdgeSource(nextEdge): edg.getEdgeTarget(nextEdge); if (!slice.contains(nextNode)) { Node outerStructureNode = this.getOuterCompositeNode(nextNode); if (outerStructureNode != null) { List<Node> nextNodes = edg.getDescendants(outerStructureNode); nextNodes.add(outerStructureNode); if (nextNodes.contains(slicingCriterion)) nextNodes.removeIf(n -> n.getType() == Node.Type.Result); nextNodes.add(edg.getResFromNode(nextNode)); for (Node next : nextNodes) { pendingNodes.addLast(next); slice.add(next); } } else { pendingNodes.addLast(nextNode); slice.add(nextNode); } } } } } public Node getOuterCompositeNode(Node node) { Node lastDataContainerParent = null; Node nextParent = edg.getParent(node); while (nextParent != null && isPossibleDataContainer(nextParent)){ if (nextParent.getType() == Node.Type.List || nextParent.getType() == Node.Type.DataConstructor) lastDataContainerParent = nextParent; nextParent = edg.getParent(nextParent); } return lastDataContainerParent; } public boolean isPossibleDataContainer(Node parent) { switch (parent.getType()){ case Equality: case Arguments: case Call: case Operation: case List: case DataConstructor: return true; default: return false; } } } Loading
EDG/src/main/java/edg/EDGFactory.java +26 −7 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ import edg.graph.LAST; public class EDGFactory { private final LAST last; private EDG edg; private boolean interproceduralGraph = false; public EDGFactory(LAST last) { Loading Loading @@ -75,15 +75,34 @@ public class EDGFactory { } } private void generateDependencies() { long initialControl = System.nanoTime(); new ControlEdgeGenerator(edg).generate(); long finalControl = System.nanoTime(); edg.getGenerationTime().setControlTime((finalControl-initialControl) / 1000000.0); // WE ARE NOT GENERATING INTERPROCEDURAL EDGES if (interproceduralGraph) { if (isOOLanguage) new InterproceduralEdgeGenerator(edg).generate(); // Specially Generated for OOPrograms else else { long initialInputOutput = System.nanoTime(); new InterproceduralEdgeGenerator(edg).generateErlang(); // // new FlowEdgeGenerator(edg).generate(); // TODO: Testear varios escenarios del POST-IT long finalInputOutput = System.nanoTime(); edg.getGenerationTime().setInterproceduralTime((finalInputOutput-initialInputOutput) / 1000000.0); } } long initialFlow = System.nanoTime(); new FlowEdgeGenerator(edg).generate(); long finalFlow = System.nanoTime(); edg.getGenerationTime().setFlowTime((finalFlow-initialFlow) / 1000000.0); // WE ARE NOT GENERATING SUMMARIES if (interproceduralGraph) new SummaryEdgeGenerator(edg).generate(); else new SummaryEdgeGenerator(edg).generateAsExternal(); // new ExceptionEdgeGenerator(edg).generate(); } Loading
EDG/src/main/java/edg/edge/SummaryEdgeGenerator.java +29 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,35 @@ public class SummaryEdgeGenerator extends EdgeGenerator this.generateInternalSummaryEdges(); } public void generateAsExternal(){ this.generateSummaryEdgesAsExternal(); } private void generateSummaryEdgesAsExternal() { final List<Node> calls = edg.getNodes(Node.Type.Call); for (Node call : calls) { final Node callee = edg.getChild(call, Node.Type.Callee); if (isKnownModuleFunction(callee)) { buildSummaryEdges(call, callee); continue; } final Node callResult = edg.getResFromNode(call); final Node argumentsNode = edg.getChild(call, Node.Type.Arguments); final List<Node> arguments = edg.getChildren(argumentsNode); arguments.removeIf(n -> n.getType() == Node.Type.Result); for (Node argument : arguments) { final Node argumentResult = edg.getResFromNode(argument); this.edg.addEdge(argumentResult, callResult, new Edge(Edge.Type.Summary, AsteriskConstraint.getConstraint())); } } } /* ********************************** */ /* ************ External ************ */ /* ********************************** */ Loading
EDG/src/main/java/edg/graph/EDG.java +22 −12 Original line number Diff line number Diff line Loading @@ -23,6 +23,10 @@ public class EDG extends LAST { this.rootNode = last.rootNode; this.nextId = last.nextId; this.fictitiousId = last.fictitiousId; this.getGenerationTime().setStructureTime(last.getStructuralTime()); this.getGenerationTime().setControlFlowTime(last.getControlFlowTime()); this.getGenerationTime().setValueTime(last.getValueTime()); this.getGenerationTime().setCompositeTime(last.getCompositeStructureTime()); } // ================================================= // Loading Loading @@ -80,12 +84,14 @@ public class EDG extends LAST { public static class GraphGeneratorTimer { // MILISECONDS (1*10^(-3)) private double structureTime; private double controlFlowTime; private double controlTime; private double interproceduralTime; private double flowTime; private double valueTime; private double compositeTime; private double summaryTime; private double exceptionTime; Loading @@ -93,46 +99,50 @@ public class EDG extends LAST { { this.structureTime = structureTime; } public void setControlFlowTime(double controlFlowTime) { this.controlFlowTime = controlFlowTime; } public void setControlTime(double controlTime) { this.controlTime = controlTime; } public void setControlTime(double controlTime) { this.controlTime = controlTime; } public void setInterproceduralTime(double interproceduralTime) { this.interproceduralTime = interproceduralTime; } public void setFlowTime(double flowTime) { this.flowTime = flowTime; } public void setValueTime(double valueTime) { this.valueTime = valueTime; } public void setCompositeTime(double compositeTime) { this.compositeTime = compositeTime; } public void setSummaryTime(double summaryTime) { this.summaryTime = summaryTime; } public void setExceptionTime(double exceptionTime) { this.exceptionTime = exceptionTime; } public double getStructureTime() { return this.structureTime; } public double getControlFlowTime() { return this.controlFlowTime; } public double getValueTime() { return this.valueTime; } public double getCompositeTime() { return this.compositeTime; } public double getControlTime() { return this.controlTime; } public double getFlowTime() { return this.flowTime; } public double getGenerationEDGTime() { return structureTime + controlFlowTime + controlTime + interproceduralTime + flowTime + valueTime + summaryTime + exceptionTime; } public double getGenerationIntraproceduralEDGTime() { return structureTime + controlFlowTime + controlTime + flowTime + valueTime ; } } }
EDG/src/main/java/edg/graph/LAST.java +14 −0 Original line number Diff line number Diff line Loading @@ -929,4 +929,18 @@ public class LAST extends GraphWithRoot { return false; return true; } private double structuralGenerationTime = 0; private double controlFlowGenerationTime = 0; private double valueGenerationTime = 0; private double compositeStructureTime = 0; public void setStructuralTime(double time) { structuralGenerationTime = time; } public void setControlFlowTime(double time) { controlFlowGenerationTime = time; } public void setValueTime(double time) { valueGenerationTime = time; } public void setCompositeStructureEdges(double time) { compositeStructureTime = time; } public double getStructuralTime() { return structuralGenerationTime; } public double getControlFlowTime() { return controlFlowGenerationTime; } public double getValueTime() { return valueGenerationTime; } public double getCompositeStructureTime() { return compositeStructureTime; } }
EDG/src/main/java/edg/slicing/AdaptedStandardAlgorithm.java 0 → 100644 +92 −0 Original line number Diff line number Diff line package edg.slicing; import edg.graph.EDG; import edg.graph.Edge; import edg.graph.LAST; import edg.graph.Node; import java.util.*; public class AdaptedStandardAlgorithm extends StandardAlgorithm{ public AdaptedStandardAlgorithm(EDG edg) { super(edg); } public Set<Node> slice(Node slicingCriterion) { final Set<Node> slice = new HashSet<>(); if (slicingCriterion == null) return slice; slice.add(slicingCriterion); this.traverse(slicingCriterion, slice); return slice; } protected void traverse(Node slicingCriterion, Set<Node> slice, Edge.Type... ignoreEdgeTypes) { final Deque<Node> pendingNodes = new LinkedList<>(slice); final Set<Edge.Type> ignoreEdgeTypesSet = new HashSet<>(Arrays.asList(ignoreEdgeTypes)); while (!pendingNodes.isEmpty()) { final Node pendingNode = pendingNodes.removeFirst(); final Set<Edge> nextEdges = edg.getEdges(pendingNode, sliceDirection); nextEdges.removeIf(e -> ignoreEdgeTypesSet.contains(e.getType())); nextEdges.removeIf(Edge::isControlFlowEdge); nextEdges.removeIf(e -> !e.isTraversable()); for (Edge nextEdge : nextEdges) { final Node nextNode = sliceDirection == LAST.Direction.Backwards ? edg.getEdgeSource(nextEdge): edg.getEdgeTarget(nextEdge); if (!slice.contains(nextNode)) { Node outerStructureNode = this.getOuterCompositeNode(nextNode); if (outerStructureNode != null) { List<Node> nextNodes = edg.getDescendants(outerStructureNode); nextNodes.add(outerStructureNode); if (nextNodes.contains(slicingCriterion)) nextNodes.removeIf(n -> n.getType() == Node.Type.Result); nextNodes.add(edg.getResFromNode(nextNode)); for (Node next : nextNodes) { pendingNodes.addLast(next); slice.add(next); } } else { pendingNodes.addLast(nextNode); slice.add(nextNode); } } } } } public Node getOuterCompositeNode(Node node) { Node lastDataContainerParent = null; Node nextParent = edg.getParent(node); while (nextParent != null && isPossibleDataContainer(nextParent)){ if (nextParent.getType() == Node.Type.List || nextParent.getType() == Node.Type.DataConstructor) lastDataContainerParent = nextParent; nextParent = edg.getParent(nextParent); } return lastDataContainerParent; } public boolean isPossibleDataContainer(Node parent) { switch (parent.getType()){ case Equality: case Arguments: case Call: case Operation: case List: case DataConstructor: return true; default: return false; } } }