19
19
20
20
public class nCFAContextWithReceiversSelector extends nCFAContextSelector {
21
21
22
- /**
23
- * The N to use if the instance implements BaseStream.
24
- */
25
- public static final int CONTEXT_LENGTH_FOR_STREAMS = 2 ;
26
-
27
22
protected class CallStringTriple {
28
23
24
+ CGNode node ;
25
+
26
+ CallSiteReference site ;
27
+ IMethod target ;
28
+
29
29
public CallStringTriple (CGNode node , CallSiteReference site , IMethod target ) {
30
30
this .node = node ;
31
31
this .site = site ;
32
32
this .target = target ;
33
33
}
34
34
35
- CGNode node ;
36
- CallSiteReference site ;
37
- IMethod target ;
35
+ @ Override
36
+ public boolean equals (Object obj ) {
37
+ if (obj instanceof CallStringTriple ) {
38
+ CallStringTriple rhs = (CallStringTriple ) obj ;
39
+ return this .node .equals (rhs .node ) && this .site .equals (rhs .site ) && this .target .equals (rhs .target );
40
+ } else
41
+ return false ;
42
+ }
38
43
39
44
@ Override
40
45
public int hashCode () {
@@ -46,17 +51,13 @@ public int hashCode() {
46
51
47
52
return builder .toString ().hashCode ();
48
53
}
49
-
50
- @ Override
51
- public boolean equals (Object obj ) {
52
- if (obj instanceof CallStringTriple ) {
53
- CallStringTriple rhs = (CallStringTriple ) obj ;
54
- return this .node .equals (rhs .node ) && this .site .equals (rhs .site ) && this .target .equals (rhs .target );
55
- } else
56
- return false ;
57
- }
58
54
}
59
55
56
+ /**
57
+ * The N to use if the instance implements BaseStream.
58
+ */
59
+ public static final int CONTEXT_LENGTH_FOR_STREAMS = 2 ;
60
+
60
61
protected Map <CallStringTriple , CallStringWithReceivers > callStringWithReceiversMap = new HashMap <>();
61
62
62
63
public nCFAContextWithReceiversSelector (int n , ContextSelector base ) {
@@ -66,15 +67,14 @@ public nCFAContextWithReceiversSelector(int n, ContextSelector base) {
66
67
@ Override
67
68
public Context getCalleeTarget (CGNode caller , CallSiteReference site , IMethod callee ,
68
69
InstanceKey [] actualParameters ) {
69
- Context baseContext = base .getCalleeTarget (caller , site , callee , actualParameters );
70
- CallStringWithReceivers cs = getCallString (caller , site , callee , actualParameters );
71
- if (cs == null ) {
70
+ Context baseContext = this . base .getCalleeTarget (caller , site , callee , actualParameters );
71
+ CallStringWithReceivers cs = this . getCallString (caller , site , callee , actualParameters );
72
+ if (cs == null )
72
73
return baseContext ;
73
- } else if (baseContext == Everywhere .EVERYWHERE ) {
74
+ else if (baseContext == Everywhere .EVERYWHERE )
74
75
return new CallStringContext (cs );
75
- } else {
76
+ else
76
77
return new CallStringContextPair (cs , baseContext );
77
- }
78
78
}
79
79
80
80
protected CallStringWithReceivers getCallString (CGNode caller , CallSiteReference site , IMethod target ,
@@ -94,17 +94,15 @@ protected CallStringWithReceivers getCallString(CGNode caller, CallSiteReference
94
94
// not found. Compute it.
95
95
CallStringWithReceivers ret = null ;
96
96
97
- int length = getLength (caller , site , target );
97
+ int length = this . getLength (caller , site , target );
98
98
if (length > 0 ) {
99
- if (caller .getContext ().get (CALL_STRING ) != null ) {
99
+ if (caller .getContext ().get (CALL_STRING ) != null )
100
100
ret = new CallStringWithReceivers (site , caller .getMethod (), length ,
101
101
(CallString ) caller .getContext ().get (CALL_STRING ));
102
- } else {
102
+ else
103
103
ret = new CallStringWithReceivers (site , caller .getMethod ());
104
- }
105
- } else {
104
+ } else
106
105
ret = null ;
107
- }
108
106
109
107
// if we have a receiver.
110
108
if (ret != null && actualParameters != null && actualParameters .length > 0 )
@@ -117,14 +115,14 @@ protected CallStringWithReceivers getCallString(CGNode caller, CallSiteReference
117
115
}
118
116
119
117
protected Map <CallStringTriple , CallStringWithReceivers > getCallStringWithReceiversMap () {
120
- return callStringWithReceiversMap ;
118
+ return this . callStringWithReceiversMap ;
121
119
}
122
120
123
121
/**
124
122
* {@inheritDoc}
125
- *
126
- * @return CONTEXT_LENGTH_FOR_STREAMS if the target's return type implements {@link BaseStream},
127
- * otherwise, return the original value.
123
+ *
124
+ * @return CONTEXT_LENGTH_FOR_STREAMS if the target's return type implements
125
+ * {@link BaseStream}, otherwise, return the original value.
128
126
*/
129
127
@ Override
130
128
protected int getLength (CGNode caller , CallSiteReference site , IMethod target ) {
0 commit comments