Skip to content

Commit 4313278

Browse files
committed
feat: A6
1 parent 3f3c478 commit 4313278

File tree

7 files changed

+215
-19
lines changed

7 files changed

+215
-19
lines changed

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_1CallSelector.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package pascal.taie.analysis.pta.core.cs.selector;
2424

25+
import org.apache.logging.log4j.core.layout.internal.ListChecker;
2526
import pascal.taie.analysis.pta.core.cs.context.Context;
2627
import pascal.taie.analysis.pta.core.cs.context.ListContext;
2728
import pascal.taie.analysis.pta.core.cs.element.CSCallSite;
@@ -43,18 +44,18 @@ public Context getEmptyContext() {
4344
@Override
4445
public Context selectContext(CSCallSite callSite, JMethod callee) {
4546
// TODO - finish me
46-
return null;
47+
return ListContext.make(callSite.getCallSite());
4748
}
4849

4950
@Override
5051
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5152
// TODO - finish me
52-
return null;
53+
return ListContext.make(callSite.getCallSite());
5354
}
5455

5556
@Override
5657
public Context selectHeapContext(CSMethod method, Obj obj) {
5758
// TODO - finish me
58-
return null;
59+
return this.getEmptyContext();
5960
}
6061
}

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_1ObjSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ public Context getEmptyContext() {
4343
@Override
4444
public Context selectContext(CSCallSite callSite, JMethod callee) {
4545
// TODO - finish me
46-
return null;
46+
return callSite.getContext();
4747
}
4848

4949
@Override
5050
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5151
// TODO - finish me
52-
return null;
52+
return ListContext.make(recv.getObject());
5353
}
5454

5555
@Override
5656
public Context selectHeapContext(CSMethod method, Obj obj) {
5757
// TODO - finish me
58-
return null;
58+
return this.getEmptyContext();
5959
}
6060
}

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_1TypeSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ public Context getEmptyContext() {
4343
@Override
4444
public Context selectContext(CSCallSite callSite, JMethod callee) {
4545
// TODO - finish me
46-
return null;
46+
return callSite.getContext();
4747
}
4848

4949
@Override
5050
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5151
// TODO - finish me
52-
return null;
52+
return ListContext.make(recv.getObject().getContainerType());
5353
}
5454

5555
@Override
5656
public Context selectHeapContext(CSMethod method, Obj obj) {
5757
// TODO - finish me
58-
return null;
58+
return this.getEmptyContext();
5959
}
6060
}

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_2CallSelector.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import pascal.taie.ir.stmt.Invoke;
3232
import pascal.taie.language.classes.JMethod;
3333

34+
import java.util.List;
35+
3436
/**
3537
* Implementation of 2-call-site sensitivity.
3638
*/
@@ -44,18 +46,36 @@ public Context getEmptyContext() {
4446
@Override
4547
public Context selectContext(CSCallSite callSite, JMethod callee) {
4648
// TODO - finish me
47-
return null;
49+
Context context = callSite.getContext();
50+
int contextLength = context.getLength();
51+
if (contextLength > 0) {
52+
return ListContext.make(context.getElementAt(contextLength - 1), callSite.getCallSite());
53+
} else {
54+
return ListContext.make(callSite.getCallSite());
55+
}
4856
}
4957

5058
@Override
5159
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5260
// TODO - finish me
53-
return null;
61+
Context context = callSite.getContext();
62+
int contextLength = context.getLength();
63+
if (contextLength > 0) {
64+
return ListContext.make(context.getElementAt(contextLength - 1), callSite.getCallSite());
65+
} else {
66+
return ListContext.make(callSite.getCallSite());
67+
}
5468
}
5569

5670
@Override
5771
public Context selectHeapContext(CSMethod method, Obj obj) {
5872
// TODO - finish me
59-
return null;
73+
Context context = method.getContext();
74+
int contextLength = context.getLength();
75+
if (contextLength > 0) {
76+
return ListContext.make(context.getElementAt(contextLength - 1));
77+
} else {
78+
return method.getContext();
79+
}
6080
}
6181
}

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_2ObjSelector.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,30 @@ public Context getEmptyContext() {
4343
@Override
4444
public Context selectContext(CSCallSite callSite, JMethod callee) {
4545
// TODO - finish me
46-
return null;
46+
return callSite.getContext();
4747
}
4848

4949
@Override
5050
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5151
// TODO - finish me
52-
return null;
52+
Context context = recv.getContext();
53+
int contextLength = context.getLength();
54+
if (contextLength > 0) {
55+
return ListContext.make(context.getElementAt(contextLength - 1), recv.getObject());
56+
} else {
57+
return ListContext.make(recv.getObject());
58+
}
5359
}
5460

5561
@Override
5662
public Context selectHeapContext(CSMethod method, Obj obj) {
5763
// TODO - finish me
58-
return null;
64+
Context context = method.getContext();
65+
int contextLength = context.getLength();
66+
if (contextLength > 0) {
67+
return ListContext.make(context.getElementAt(contextLength - 1));
68+
} else {
69+
return method.getContext();
70+
}
5971
}
6072
}

A6/tai-e/src/main/java/pascal/taie/analysis/pta/core/cs/selector/_2TypeSelector.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import pascal.taie.analysis.pta.core.cs.element.CSMethod;
2929
import pascal.taie.analysis.pta.core.cs.element.CSObj;
3030
import pascal.taie.analysis.pta.core.heap.Obj;
31+
import pascal.taie.language.classes.JClass;
3132
import pascal.taie.language.classes.JMethod;
3233
import pascal.taie.language.type.Type;
3334

@@ -44,18 +45,30 @@ public Context getEmptyContext() {
4445
@Override
4546
public Context selectContext(CSCallSite callSite, JMethod callee) {
4647
// TODO - finish me
47-
return null;
48+
return callSite.getContext();
4849
}
4950

5051
@Override
5152
public Context selectContext(CSCallSite callSite, CSObj recv, JMethod callee) {
5253
// TODO - finish me
53-
return null;
54+
Context context = recv.getContext();
55+
int contextLength = context.getLength();
56+
if (contextLength > 0) {
57+
return ListContext.make(context.getElementAt(contextLength - 1), recv.getObject().getContainerType());
58+
} else {
59+
return ListContext.make(recv.getObject().getContainerType());
60+
}
5461
}
5562

5663
@Override
5764
public Context selectHeapContext(CSMethod method, Obj obj) {
5865
// TODO - finish me
59-
return null;
66+
Context context = method.getContext();
67+
int contextLength = context.getLength();
68+
if (contextLength > 0) {
69+
return ListContext.make(context.getElementAt(contextLength - 1));
70+
} else {
71+
return method.getContext();
72+
}
6073
}
6174
}

0 commit comments

Comments
 (0)