Skip to content

Commit 61fa846

Browse files
author
Dominik Helm
committed
Move logic for handling methods without body out of ReachableMethodAnalysis
1 parent dee8a44 commit 61fa846

File tree

7 files changed

+35
-38
lines changed

7 files changed

+35
-38
lines changed

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/SystemPropertiesAnalysisScheduler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import org.opalj.fpcf.PropertyStore
2626
import org.opalj.fpcf.Results
2727
import org.opalj.fpcf.UBP
2828
import org.opalj.tac.cg.TypeIteratorKey
29-
import org.opalj.tac.fpcf.analyses.cg.DefinedBodyReachableMethodAnalysis
29+
import org.opalj.tac.fpcf.analyses.cg.ReachableMethodAnalysis
3030
import org.opalj.tac.fpcf.properties.TACAI
3131
import org.opalj.value.ValueInformation
3232

3333
class SystemPropertiesAnalysisScheduler private[analyses] (
3434
final val project: SomeProject
35-
) extends DefinedBodyReachableMethodAnalysis {
35+
) extends ReachableMethodAnalysis {
3636

3737
def processMethod(
3838
callContext: ContextType,

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/cg/CallGraphAnalysis.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package fpcf
55
package analyses
66
package cg
77

8+
import org.opalj.br.DeclaredMethod
89
import org.opalj.br.Method
910
import org.opalj.br.MethodDescriptor
1011
import org.opalj.br.ObjectType
@@ -28,6 +29,7 @@ import org.opalj.fpcf.InterimPartialResult
2829
import org.opalj.fpcf.InterimUBP
2930
import org.opalj.fpcf.ProperPropertyComputationResult
3031
import org.opalj.fpcf.PropertyBounds
32+
import org.opalj.fpcf.PropertyComputationResult
3133
import org.opalj.fpcf.PropertyKind
3234
import org.opalj.fpcf.PropertyStore
3335
import org.opalj.fpcf.Results
@@ -119,12 +121,16 @@ class CallGraphAnalysis private[cg] (
119121
}
120122
}
121123

124+
override final def processMethodWithoutBody(eOptP: EOptionP[DeclaredMethod, Callers]): PropertyComputationResult = {
125+
processMethodWithoutBody(eOptP, null)
126+
}
127+
122128
override final def processMethod(
123129
callContext: ContextType,
124-
tacEPOpt: EOptionP[Method, TACAI]
130+
tacEP: EPS[Method, TACAI]
125131
): ProperPropertyComputationResult = {
126-
if (tacEPOpt.hasUBP) {
127-
val state = new TACAIBasedCGState[ContextType](callContext, tacEPOpt)
132+
if (tacEP ne null) {
133+
val state = new TACAIBasedCGState[ContextType](callContext, tacEP)
128134
processMethod(state, new DirectCalls())
129135
} else {
130136
Results(new DirectCalls().partialResults(callContext, enforceCalleesResult = true))

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/cg/ReachableMethodAnalysis.scala

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.opalj.br.fpcf.FPCFAnalysis
1313
import org.opalj.br.fpcf.properties.cg.Callers
1414
import org.opalj.br.fpcf.properties.cg.NoCallers
1515
import org.opalj.fpcf.EOptionP
16-
import org.opalj.fpcf.EPK
1716
import org.opalj.fpcf.EPS
1817
import org.opalj.fpcf.InterimPartialResult
1918
import org.opalj.fpcf.NoResult
@@ -28,6 +27,8 @@ import org.opalj.tac.fpcf.properties.TACAI
2827
* Base trait for analyses that are executed for every method that is reachable.
2928
* The analysis is performed by `processMethod`.
3029
*
30+
* Note that methods without a body are not processed unless `processMethodWithoutBody` is overridden
31+
*
3132
* @author Florian Kuebler
3233
*/
3334
trait ReachableMethodAnalysis extends FPCFAnalysis with TypeConsumerAnalysis {
@@ -57,20 +58,27 @@ trait ReachableMethodAnalysis extends FPCFAnalysis with TypeConsumerAnalysis {
5758

5859
val tacEP = propertyStore(method, TACAI.key)
5960
if (tacEP.hasUBP && tacEP.ub.tac.isDefined) {
60-
processMethod(callersEOptP, NoCallers, tacEP)
61+
processMethod(callersEOptP, NoCallers, tacEP.asEPS)
6162
} else {
6263
InterimPartialResult(Set(tacEP), continuationForTAC(declaredMethod))
6364
}
6465
}
6566

6667
protected def processMethodWithoutBody(
6768
eOptP: EOptionP[DeclaredMethod, Callers]
68-
): PropertyComputationResult = processMethod(eOptP, NoCallers, EPK(eOptP.e.definedMethod, TACAI.key))
69+
): PropertyComputationResult = NoResult
70+
71+
protected def processMethodWithoutBody(
72+
eOptP: EOptionP[DeclaredMethod, Callers],
73+
tacEP: EPS[Method, TACAI]
74+
): ProperPropertyComputationResult = {
75+
processMethod(eOptP, NoCallers, tacEP)
76+
}
6977

70-
private[this] def processMethod(
78+
protected def processMethod(
7179
eOptP: EOptionP[DeclaredMethod, Callers],
7280
oldCallers: Callers,
73-
tacEOptP: EOptionP[Method, TACAI]
81+
tacEP: EPS[Method, TACAI]
7482
): ProperPropertyComputationResult = {
7583
val newCallers = if (eOptP.hasUBP) eOptP.ub else NoCallers
7684
var results: List[ProperPropertyComputationResult] = Nil
@@ -79,18 +87,18 @@ trait ReachableMethodAnalysis extends FPCFAnalysis with TypeConsumerAnalysis {
7987
val theCalleeContext =
8088
if (calleeContext.hasContext) calleeContext.asInstanceOf[ContextType]
8189
else typeIterator.newContext(eOptP.e)
82-
results ::= processMethod(theCalleeContext, tacEOptP)
90+
results ::= processMethod(theCalleeContext, tacEP)
8391
}
8492

8593
Results(
86-
InterimPartialResult(Set(eOptP), continuationForCallers(newCallers, tacEOptP)),
94+
InterimPartialResult(Set(eOptP), continuationForCallers(newCallers, tacEP)),
8795
results
8896
)
8997
}
9098

9199
def processMethod(
92100
callContext: ContextType,
93-
tacEOptP: EOptionP[Method, TACAI]
101+
tacEP: EPS[Method, TACAI]
94102
): ProperPropertyComputationResult
95103

96104
protected def continuationForTAC(
@@ -110,28 +118,11 @@ trait ReachableMethodAnalysis extends FPCFAnalysis with TypeConsumerAnalysis {
110118

111119
private[this] def continuationForCallers(
112120
oldCallers: Callers,
113-
tacEOptP: EOptionP[Method, TACAI]
121+
tacEP: EPS[Method, TACAI]
114122
)(
115123
update: SomeEPS
116124
): ProperPropertyComputationResult = {
117125
val newCallers = update.asInstanceOf[EPS[DeclaredMethod, Callers]]
118-
processMethod(newCallers, oldCallers, tacEOptP)
126+
processMethod(newCallers, oldCallers, tacEP)
119127
}
120128
}
121-
122-
trait DefinedBodyReachableMethodAnalysis extends ReachableMethodAnalysis {
123-
124-
override protected final def processMethodWithoutBody(
125-
eOptP: EOptionP[DeclaredMethod, Callers]
126-
): PropertyComputationResult = NoResult
127-
128-
override final def processMethod(
129-
callContext: ContextType,
130-
tacEPOpt: EOptionP[Method, TACAI]
131-
): ProperPropertyComputationResult = processMethod(callContext, tacEPOpt.asEPS)
132-
133-
def processMethod(
134-
callContext: ContextType,
135-
tacEP: EPS[Method, TACAI]
136-
): ProperPropertyComputationResult
137-
}

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/cg/xta/ArrayInstantiationsAnalysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import org.opalj.tac.fpcf.properties.TACAI
4343
final class ArrayInstantiationsAnalysis(
4444
val project: SomeProject,
4545
selectSetEntity: TypeSetEntitySelector
46-
) extends DefinedBodyReachableMethodAnalysis {
46+
) extends ReachableMethodAnalysis {
4747

4848
override def processMethod(
4949
callContext: ContextType,

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/cg/xta/TypePropagationAnalysis.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import org.opalj.tac.fpcf.properties.TACAI
5656
final class TypePropagationAnalysis private[analyses] (
5757
val project: SomeProject,
5858
selectTypeSetEntity: TypeSetEntitySelector
59-
) extends DefinedBodyReachableMethodAnalysis {
59+
) extends ReachableMethodAnalysis {
6060

6161
private[this] val debug = false
6262
private[this] val _trace: TypePropagationTrace = new TypePropagationTrace()

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/fieldaccess/FieldAccessInformationAnalysis.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import org.opalj.fpcf.Results
3737
import org.opalj.fpcf.SomeEPS
3838
import org.opalj.fpcf.UBP
3939
import org.opalj.tac.fpcf.analyses.cg.BaseAnalysisState
40-
import org.opalj.tac.fpcf.analyses.cg.DefinedBodyReachableMethodAnalysis
40+
import org.opalj.tac.fpcf.analyses.cg.ReachableMethodAnalysis
4141
import org.opalj.tac.fpcf.analyses.cg.persistentUVar
4242
import org.opalj.tac.fpcf.properties.TACAI
4343
import org.opalj.tac.fpcf.properties.TheTACAI
@@ -166,7 +166,7 @@ private[fieldaccess] class EagerTacBasedFieldAccessInformationAnalysis(
166166

167167
private[fieldaccess] class ReachableTacBasedFieldAccessInformationAnalysis(
168168
val project: SomeProject
169-
) extends FieldAccessInformationAnalysis with DefinedBodyReachableMethodAnalysis {
169+
) extends FieldAccessInformationAnalysis with ReachableMethodAnalysis {
170170

171171
override def processMethod(callContext: ContextType, tacEP: EPS[Method, TACAI]): ProperPropertyComputationResult = {
172172
implicit val state: State = new State(callContext, tacEP)

OPAL/tac/src/main/scala/org/opalj/tac/fpcf/analyses/pointsto/AbstractPointsToAnalysis.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import org.opalj.fpcf.UBP
5151
import org.opalj.log.OPALLogger.logOnce
5252
import org.opalj.log.Warn
5353
import org.opalj.tac.common.DefinitionSite
54-
import org.opalj.tac.fpcf.analyses.cg.DefinedBodyReachableMethodAnalysis
54+
import org.opalj.tac.fpcf.analyses.cg.ReachableMethodAnalysis
5555
import org.opalj.tac.fpcf.properties.TACAI
5656
import org.opalj.value.IsMultipleReferenceValue
5757
import org.opalj.value.IsReferenceValue
@@ -64,7 +64,7 @@ import org.opalj.value.ValueInformation
6464
*
6565
* @author Florian Kuebler
6666
*/
67-
trait AbstractPointsToAnalysis extends PointsToAnalysisBase with DefinedBodyReachableMethodAnalysis {
67+
trait AbstractPointsToAnalysis extends PointsToAnalysisBase with ReachableMethodAnalysis {
6868

6969
override def processMethod(
7070
callContext: ContextType,

0 commit comments

Comments
 (0)