Skip to content

Commit

Permalink
feat(spgroup#31): statements adjustes
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Sep 29, 2021
1 parent 2a8a243 commit bdcd506
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private boolean isInLeftStatementFlow(Statement.Type flowChangeTag) {
}

private boolean isInLeftAndRightStatementFlow(Statement.Type flowChangeTag) {
return flowChangeTag.equals(Statement.Type.BOTH);
return flowChangeTag.equals(Statement.Type.SOURCE_SINK);
}

// TODO add depth to InstanceFieldRef and StaticFieldRef...
Expand Down Expand Up @@ -374,7 +374,7 @@ private String getArrayRefName(ArrayRef arrayRef) {
private Statement getStatementAssociatedWithUnit(SootMethod sootMethod, Unit u, Statement.Type flowChangeTag) {
if (isLeftAndRightUnit(u) || isInLeftAndRightStatementFlow(flowChangeTag) || isBothUnitOrBothStatementFlow(u,
flowChangeTag)) {
return createStatement(sootMethod, u, Statement.Type.BOTH);
return createStatement(sootMethod, u, Statement.Type.SOURCE_SINK);
} else if (isLeftUnit(u)) {
return findLeftStatement(u);
} else if (isRightUnit(u)) {
Expand All @@ -388,7 +388,7 @@ private Statement getStatementAssociatedWithUnit(SootMethod sootMethod, Unit u,
}

private void setStackTraceInStmt(Statement stmt) {
stmt.setStacktrace(new ArrayList<TraversedLine>(this.stacktraceList));
stmt.setTraversedLine(new ArrayList<TraversedLine>(this.stacktraceList));
}

private void addStackTrace(TraversedLine traversedLine) {
Expand Down Expand Up @@ -445,6 +445,6 @@ private boolean isLeftStatement(Statement stmt) {
}

private boolean isLefAndRightStatement(Statement stmt) {
return stmt.getType().equals(Statement.Type.BOTH);
return stmt.getType().equals(Statement.Type.SOURCE_SINK);
}
}
4 changes: 2 additions & 2 deletions src/main/java/br/unb/cic/analysis/model/Conflict.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public Conflict(Statement source, Statement sink) {
this.sourceMethodName = source.getSootMethod().getName();
this.sourceLineNumber = source.getSourceCodeLineNumber();
this.sourceUnit = source.getUnit();
this.sourceTraversedLine = source.getStacktrace();
this.sourceTraversedLine = source.getTraversedLine();
this.sinkClassName = sink.getSootClass().getName();
this.sinkMethodName = sink.getSootMethod().getName();
this.sinkLineNumber = sink.getSourceCodeLineNumber();
this.sinkUnit = sink.getUnit();
this.sinkTraversedLine = sink.getStacktrace();
this.sinkTraversedLine = sink.getTraversedLine();
}

@Deprecated
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/br/unb/cic/analysis/model/Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import soot.SootMethod;
import soot.Unit;
import soot.ValueBox;
import soot.jimple.*;
import soot.jimple.AssignStmt;
import soot.jimple.InstanceInvokeExpr;
import soot.jimple.InvokeExpr;
import soot.jimple.InvokeStmt;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
Expand All @@ -31,18 +36,20 @@ public static StatementBuilder builder() {
return builder;
}

private SootClass sootClass;
private SootMethod sootMethod;
private Unit unit;
private SootClass sootClass;
private SootMethod sootMethod;
private Unit unit;
private Type type;
private Integer sourceCodeLineNumber;

private List<TraversedLine> traversedLine;

Statement(SootClass sootClass, SootMethod sootMethod, Unit unit, Type type, Integer sourceCodeLineNumber) {
this.sootClass = sootClass;
this.sootMethod = sootMethod;
this.unit = unit;
this.type = type;
this.sourceCodeLineNumber = sourceCodeLineNumber;
this.traversedLine = new ArrayList<>();
}

public SootClass getSootClass() {
Expand All @@ -65,6 +72,14 @@ public Integer getSourceCodeLineNumber() {
return sourceCodeLineNumber;
}

public List<TraversedLine> getTraversedLine() {
return traversedLine;
}

public void setTraversedLine(List<TraversedLine> traversedLine) {
this.traversedLine = traversedLine;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down

0 comments on commit bdcd506

Please sign in to comment.