Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added changes to avoid nullpointerexception while generation BCJCA tests #15

Open
wants to merge 1 commit into
base: evaluation
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.security.SecureRandom;
import java.util.AbstractMap.SimpleEntry;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -82,6 +83,10 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry<String, String> para
}
}
String secureInt = "";
//TODO: need to understand what is secureInt
if(value == 0) {
secureInt = "0";
}else {
switch (comp.getOperator()) {
case g:
case ge:
Expand All @@ -103,7 +108,7 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry<String, String> para
case eq:
default:
break;
}
}}
return secureInt;
}
} else if (constraint instanceof CrySLPredicate && "instanceOf".equals(((CrySLPredicate) constraint).getPredName())) {
Expand All @@ -116,8 +121,18 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry<String, String> para
LogOps operator = crySLConstraint.getOperator();
ISLConstraint left = crySLConstraint.getLeft();
ISLConstraint right = crySLConstraint.getRight();
Entry<String, String> leftAlternative = new SimpleEntry<String, String>(left.getInvolvedVarNames().iterator().next(), parameter.getValue());
Entry<String, String> rightAlternative = new SimpleEntry<String, String>(right.getInvolvedVarNames().iterator().next(), parameter.getValue());
Iterator<String> leftAltiterator = left.getInvolvedVarNames().iterator();
Entry<String, String> leftAlternative = null;
if(leftAltiterator.hasNext()) {
leftAlternative = new SimpleEntry<String, String>(leftAltiterator.next(), parameter.getValue());
}
// new SimpleEntry<String, String>(leftAltiterator.next(), parameter.getValue())
Iterator<String> rightAltiterator = right.getInvolvedVarNames().iterator();

Entry<String, String> rightAlternative = null;
if (rightAltiterator.hasNext()) {
rightAlternative = new SimpleEntry<String, String>(rightAltiterator.next(), parameter.getValue());
}

if (operator == LogOps.and) {
if (left.getInvolvedVarNames().contains(parVarName)) {
Expand Down Expand Up @@ -156,13 +171,19 @@ private String resolveCrySLConstraint(CrySLRule rule, Entry<String, String> para
if (!leftResult.isEmpty()) {
return leftResult;
} else {
return resolveCrySLConstraint(rule, rightAlternative, right, onlyEval);
if (rightAlternative != null) {
return resolveCrySLConstraint(rule, rightAlternative, right, onlyEval);
}

}
}
} else if (operator == LogOps.implies) {
if (!right.getInvolvedVarNames().contains(parVarName) || resolveCrySLConstraint(rule, leftAlternative, left, true).isEmpty()) {
return "";
if (leftAlternative != null) {
if (!right.getInvolvedVarNames().contains(parVarName) || resolveCrySLConstraint(rule, leftAlternative, left, true).isEmpty()) {
return "";
}
}

return resolveCrySLConstraint(rule, parameter, right);
} else {
return ""; // invalid operator
Expand Down