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

fix insertBefore #1130

Closed
wants to merge 1 commit into from
Closed
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 @@ -15,10 +15,13 @@
import sootup.core.jimple.common.expr.JNeExpr;
import sootup.core.jimple.common.ref.JCaughtExceptionRef;
import sootup.core.jimple.common.stmt.*;
import sootup.core.model.Body;
import sootup.core.signatures.MethodSignature;
import sootup.core.signatures.PackageName;
import sootup.core.types.ClassType;
import sootup.core.types.PrimitiveType;
import sootup.core.types.UnknownType;
import sootup.core.util.ImmutableUtils;

@Tag("Java8")
public class MutableBlockStmtGraphTest {
Expand Down Expand Up @@ -1148,4 +1151,33 @@ public void testGetEntrypoints() {
assertTrue(entrypoints.contains(handlerStmt1));
assertTrue(entrypoints.contains(handlerStmt2));
}

@Test
public void testInsertBefore1(){

MutableBlockStmtGraph graph = new MutableBlockStmtGraph();

Local l0 = new Local("l0", PrimitiveType.IntType.getInstance());
Local l1 = new Local("l1", PrimitiveType.IntType.getInstance());
Local l2 = new Local("l2", PrimitiveType.IntType.getInstance());
StmtPositionInfo noPosInfo = StmtPositionInfo.getNoStmtPositionInfo();

JAssignStmt assignl0e1 = new JAssignStmt(l0, IntConstant.getInstance(1), noPosInfo);
JAssignStmt assignl1e1 = new JAssignStmt(l1, IntConstant.getInstance(2), noPosInfo);
JAssignStmt assignl2e0 = new JAssignStmt(l2, IntConstant.getInstance(0), noPosInfo);
JGotoStmt gotoStmt = new JGotoStmt(noPosInfo);

JReturnStmt returnl2 = new JReturnStmt(l2, noPosInfo);

graph.setStartingStmt(assignl0e1);
graph.putEdge(assignl0e1, assignl1e1);
graph.putEdge(assignl1e1, gotoStmt);
graph.putEdge(gotoStmt,JGotoStmt.BRANCH_IDX, assignl2e0);
graph.putEdge(assignl2e0, returnl2);

FallsThroughStmt nop = new JNopStmt(StmtPositionInfo.getNoStmtPositionInfo());
FallsThroughStmt nop2 = new JNopStmt(StmtPositionInfo.getNoStmtPositionInfo());
graph.insertBefore(assignl2e0, Arrays.asList(nop, nop2), Collections.emptyMap());
System.out.println(graph);
}
}
Loading