Skip to content

Commit

Permalink
[Java-frontend] Add functionLinenumberEnd to methods (#1618)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
  • Loading branch information
arthurscchan authored Jun 20, 2024
1 parent af239a4 commit 3ba9f22
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@
import soot.SootField;
import soot.SootMethod;
import soot.Type;
import soot.Unit;

public class FunctionElement {
private String functionName;
private String functionSourceFile;
private String linkageType;
private Integer functionLinenumber;
private Integer functionLinenumberEnd;
private Integer functionDepth;
private String returnType;
private Integer argCount;
Expand Down Expand Up @@ -59,6 +61,7 @@ public FunctionElement() {
this.returnType = "";

this.functionLinenumber = -1;
this.functionLinenumberEnd = -1;
this.functionDepth = 0;
this.argCount = 0;
this.BBCount = 0;
Expand Down Expand Up @@ -102,6 +105,14 @@ public void setFunctionLinenumber(Integer functionLinenumber) {
this.functionLinenumber = functionLinenumber;
}

public Integer getFunctionLinenumberEnd() {
return functionLinenumberEnd;
}

public void setFunctionLinenumberEnd(Integer functionLinenumberEnd) {
this.functionLinenumberEnd = functionLinenumberEnd;
}

public Integer getFunctionDepth() {
return functionDepth;
}
Expand Down Expand Up @@ -314,13 +325,29 @@ public void setBaseInformation(SootMethod m) {
SootClass c = m.getDeclaringClass();

this.setFunctionSourceFile(c.getFilePath());
this.setFunctionLinenumber(m.getJavaSourceStartLineNumber());
this.setReturnType(m.getReturnType().toString());
this.setFunctionDepth(0);
this.setArgCount(m.getParameterCount());
for (Type type : m.getParameterTypes()) {
this.addArgType(type.toString());
}

Integer startLine = m.getJavaSourceStartLineNumber();
Integer endLine = -1;
if ((startLine > 0) && (m.hasActiveBody())) {
for (Unit u : m.getActiveBody().getUnits()) {
Integer line = u.getJavaSourceStartLineNumber();
if (line > endLine) {
endLine = line;
}
}
if (endLine > 0) {
endLine++;
}
}

this.setFunctionLinenumber(startLine);
this.setFunctionLinenumberEnd(endLine);
}

public void setCountInformation(Integer bbCount, Integer iCount, Integer complexity) {
Expand Down

0 comments on commit 3ba9f22

Please sign in to comment.