Skip to content

Commit

Permalink
refactor(spgroup#31): extract to runAnalyze method and parameterized …
Browse files Browse the repository at this point in the history
…tagged and base execution
  • Loading branch information
barbosamaatheus committed Dec 22, 2020
1 parent b03c518 commit 0e74b7a
Showing 1 changed file with 37 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,48 @@ private void traverse(SootMethod sm, List<SootMethod> traversed, Statement.Type
detectConflict(res, unit, changeTag, sm);

if (isTagged(changeTag, unit)) {
// TODO mover if e else para metodos diferentes
if (unit instanceof AssignStmt) {
// TODO Verificar AssignStmt contem objetos, arrays ou outros tipos?
AssignStmt assignStmt = (AssignStmt) unit;

// TODO Verificar caso: x = foo() + foo()
if (assignStmt.containsInvokeExpr()) {
traverse(assignStmt.getInvokeExpr().getMethod(), traversed, changeTag);
}

// TODO renomear Statement. (UnitWithExtraInformations)
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);
gen(stmt);

// TODO Verificar tratamento em caso de for
} else if (unit instanceof InvokeStmt) {
InvokeStmt invokeStmt = (InvokeStmt) unit;
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);
// TODO trocar stmt.getType() por changeTag
traverse(invokeStmt.getInvokeExpr().getMethod(), traversed, stmt.getType());
}
runAnalyzeWithTaggedUnit(sm, traversed, changeTag, unit);

} else {
// TODO parametrizar
if (unit instanceof AssignStmt) {
AssignStmt assignStmt = (AssignStmt) unit;
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);
runAnalyzeWithBaseUnit(sm, traversed, changeTag, unit);
}
});
}

if (assignStmt.containsInvokeExpr()) {
traverse(assignStmt.getInvokeExpr().getMethod(), traversed, stmt.getType());
}
private void runAnalyzeWithTaggedUnit(SootMethod sm, List<SootMethod> traversed, Statement.Type changeTag, Unit unit) {
runAnalyze(sm, traversed, changeTag, unit, true);
}

kill(unit);
private void runAnalyzeWithBaseUnit(SootMethod sm, List<SootMethod> traversed, Statement.Type changeTag, Unit unit) {
runAnalyze(sm, traversed, changeTag, unit, false);
}

} else if (unit instanceof InvokeStmt) {
InvokeStmt invokeStmt = (InvokeStmt) unit;
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);
traverse(invokeStmt.getInvokeExpr().getMethod(), traversed, stmt.getType());
}
private void runAnalyze(SootMethod sm, List<SootMethod> traversed, Statement.Type changeTag, Unit unit, boolean tagged) {
if (unit instanceof AssignStmt) {
// TODO Verificar AssignStmt contem objetos, arrays ou outros tipos?
AssignStmt assignStmt = (AssignStmt) unit;

// TODO Verificar caso: x = foo() + foo()
if (assignStmt.containsInvokeExpr()) {
traverse(assignStmt.getInvokeExpr().getMethod(), traversed, changeTag);
}
});

// TODO renomear Statement. (UnitWithExtraInformations)
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);

if (tagged) {
gen(stmt);
} else {
kill(unit);
}

// TODO Verificar tratamento em caso de for
} else if (unit instanceof InvokeStmt) {
InvokeStmt invokeStmt = (InvokeStmt) unit;
Statement stmt = getStatementAssociatedWithUnit(sm, unit, changeTag);
// TODO trocar stmt.getType() por changeTag
traverse(invokeStmt.getInvokeExpr().getMethod(), traversed, stmt.getType());
}
}

private boolean isTagged(Statement.Type changeTag, Unit unit) {
Expand Down

0 comments on commit 0e74b7a

Please sign in to comment.