Skip to content

Commit

Permalink
Add a strategy tailored for PurityAnalysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKoelzer committed Feb 1, 2019
1 parent 6409782 commit e1b4d59
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.net.URL

import com.phaller.rasync.cell._
import com.phaller.rasync.lattice.Updater
import com.phaller.rasync.pool.HandlerPool
import com.phaller.rasync.pool.{ HandlerPool, SchedulingStrategy }

import scala.concurrent.Await
import scala.concurrent.duration._
Expand Down Expand Up @@ -51,6 +51,19 @@ import org.opalj.bytecode.JRELibraryFolder

import scala.util.Try

// A strategy tailored to PurityAnalysis
object PurityStrategy extends SchedulingStrategy {
override def calcPriority[Purity](dependentCell: Cell[Purity], other: Cell[Purity], value: Try[ValueOutcome[Purity]]): Int = value match {
case scala.util.Success(FinalOutcome(Impure)) => -1
case _ => 1
}

override def calcPriority[Purity](dependentCell: Cell[Purity], value: Try[Purity]): Int = value match {
case scala.util.Success(Pure) => 0
case _ => -1
}
}

object PurityAnalysis extends DefaultOneStepAnalysis {

override def main(args: Array[String]): Unit = {
Expand All @@ -70,7 +83,7 @@ object PurityAnalysis extends DefaultOneStepAnalysis {

val startTime = System.currentTimeMillis // Used for measuring execution time
// 1. Initialization of key data structures (one cell(completer) per method)
implicit val pool: HandlerPool[Purity] = new HandlerPool(PurityKey)
implicit val pool: HandlerPool[Purity] = new HandlerPool(key = PurityKey, schedulingStrategy = PurityStrategy)
var methodToCell = Map.empty[Method, Cell[Purity]]
for {
classFile <- project.allProjectClassFiles
Expand Down

0 comments on commit e1b4d59

Please sign in to comment.