Skip to content

Commit c19c488

Browse files
authored
Merge pull request #2033 from MarcMil/deepclone
Deep clone edges
2 parents c46bde7 + 24d52cb commit c19c488

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/main/java/soot/jimple/toolkits/callgraph/VirtualEdgesSummaries.java

+35
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ public int getArgIndex() {
559559
return argIndex;
560560
}
561561

562+
public abstract VirtualEdgeTarget clone();
563+
564+
/**
565+
* Clones the edge, but with a potentially different arg index
566+
*
567+
* @param argIndex
568+
* the arg index to set in the clone
569+
* @return the clone
570+
*/
571+
public abstract VirtualEdgeTarget clone(int argIndex);
572+
562573
public MethodSubSignature getTargetMethod() {
563574
return targetMethod;
564575
}
@@ -629,6 +640,14 @@ public DirectTarget(RefType targetType, MethodSubSignature targetMethod) {
629640
super(targetType, targetMethod);
630641
}
631642

643+
public DirectTarget clone() {
644+
return new DirectTarget(targetType, targetMethod, argIndex);
645+
}
646+
647+
public DirectTarget clone(int argIndex) {
648+
return new DirectTarget(targetType, targetMethod, argIndex);
649+
}
650+
632651
@Override
633652
public String toString() {
634653
return String.format("Direct to %s%s on %s", targetType != null ? targetType.getClassName() + ": " : "",
@@ -699,6 +718,22 @@ public IndirectTarget(RefType targetType, MethodSubSignature targetMethod) {
699718
super(targetType, targetMethod);
700719
}
701720

721+
public IndirectTarget clone() {
722+
IndirectTarget d = new IndirectTarget(targetType, targetMethod, argIndex);
723+
for (VirtualEdgeTarget i : getTargets()) {
724+
d.addTarget(i.clone());
725+
}
726+
return d;
727+
}
728+
729+
public IndirectTarget clone(int argIndex) {
730+
IndirectTarget d = new IndirectTarget(targetType, targetMethod, argIndex);
731+
for (VirtualEdgeTarget i : getTargets()) {
732+
d.addTarget(i.clone());
733+
}
734+
return d;
735+
}
736+
702737
public void addTarget(VirtualEdgeTarget target) {
703738
if (!targets.contains(target)) {
704739
targets.add(target);

0 commit comments

Comments
 (0)