Skip to content
Snippets Groups Projects
Commit f187fcc6 authored by Carlos Galindo's avatar Carlos Galindo
Browse files

add a cli flag to ignore constraints

parent c82bd528
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@ import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.lang.reflect.InvocationTargetException;
public class EKnife {
public enum Language {Java, Erlang, Php}
......@@ -157,6 +158,9 @@ public class EKnife {
case "--print-graph":
kArgs.setGraphFile(new File(args[argIndex + 1]));
break;
case "--ignore-constraints":
kArgs.algClass = AdaptedStandardAlgorithm.class;
break;
}
}
......@@ -176,6 +180,7 @@ public class EKnife {
help += " -n,--occurrence <num> The occurrence of the slicing criterion in that line\n";
help += " -G,--print-graph <file.dot> Exports the graph as a dot file\n";
help += " -G,--print-graph <file.pdf> Exports the graph as a PDF file\n";
help += " --ignore-constraints Generates constraints but ignores when slicing\n";
help += " --help Show this message.\n";
System.out.print(help);
......@@ -192,8 +197,7 @@ public class EKnife {
System.exit(1);
}
// final SlicingAlgorithm slicingAlgorithm = new AdaptedStandardAlgorithm(edg);
final SlicingAlgorithm slicingAlgorithm = new OnePassConstrainedAlgorithm(edg);
final SlicingAlgorithm slicingAlgorithm = a.getAlgorithm(edg);
final Set<Node> slice = slicingAlgorithm.slice(SC);
if (slice.isEmpty()) {
System.out.println("Warning: no files will be written, as the slice is empty.");
......@@ -599,6 +603,7 @@ public class EKnife {
int occurrence = 1;
File graphFile;
GraphFormat graphFormat;
Class<? extends SlicingAlgorithm> algClass = OnePassConstrainedAlgorithm.class;
void setGraphFile(File graphFile) {
......@@ -640,6 +645,14 @@ public class EKnife {
System.out.println(error);
return errors.isEmpty();
}
SlicingAlgorithm getAlgorithm(EDG edg) {
try {
return algClass.getConstructor(EDG.class).newInstance(edg);
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
public static class SlicingCriterionState{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment