Skip to content

Commit

Permalink
refactor(spgroup#31): replace for with forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Dec 22, 2020
1 parent 3a811de commit e864cdb
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void runAnalyzeWithBaseUnit(SootMethod sm, List<SootMethod> traversed, S
private void runAnalyze(SootMethod sm, List<SootMethod> traversed, Statement.Type changeTag, Unit unit, boolean tagged) {
if (unit instanceof AssignStmt) {
/* TODO Does AssignStmt check contain objects, arrays or other types?
Yes, sssignStmt handles assignments and they can be of any type as long as they follow the structure: variable = value
Yes, AssignStmt handles assignments and they can be of any type as long as they follow the structure: variable = value
*/
AssignStmt assignStmt = (AssignStmt) unit;

Expand Down Expand Up @@ -159,9 +159,9 @@ private void gen(Statement stmt) {
}

private void kill(Unit unit) {
for (DataFlowAbstraction dataFlowAbstraction : res) {
res.forEach(dataFlowAbstraction -> {
removeAll(unit.getDefBoxes(), dataFlowAbstraction);
}
});
}

private void removeAll(List<ValueBox> defBoxes, DataFlowAbstraction dataFlowAbstraction) {
Expand Down Expand Up @@ -204,15 +204,15 @@ private void detectConflict(Unit u, Statement.Type changeTag, SootMethod sm) {
* Checks if there is a conflict and if so adds it to the conflict list.
*/
private void checkConflicts(Unit unit, List<DataFlowAbstraction> potentialConflictingAssignments, Statement.Type changeTag, SootMethod sm) {
for (DataFlowAbstraction dataFlowAbstraction : potentialConflictingAssignments) {
for (ValueBox valueBox : unit.getDefBoxes()) {
potentialConflictingAssignments.forEach(dataFlowAbstraction -> {
unit.getDefBoxes().forEach(valueBox -> {
if (isSameVariable(valueBox, dataFlowAbstraction)) {
Conflict c = new Conflict(getStatementAssociatedWithUnit(sm, unit, changeTag), dataFlowAbstraction.getStmt());
conflicts.add(c);
System.out.println(c);
}
}
}
});
});
}

// TODO need to treat other cases (Arrays...)
Expand All @@ -228,7 +228,6 @@ private boolean isSameVariable(ValueBox valueBox, DataFlowAbstraction dataFlowAb
return false;
}


/*
* Returns the Statement changeTag
*/
Expand Down

0 comments on commit e864cdb

Please sign in to comment.