Added methods for reporting call graph sizes.

This commit is contained in:
Achim D. Brucker 2016-08-31 08:24:29 +01:00
parent 68548a78c4
commit 4a80527a0b
1 changed files with 14 additions and 1 deletions

View File

@ -32,8 +32,11 @@ import eu.aniketos.dasca.crosslanguage.builder.ReplacePluginDefinesAndRequires
import eu.aniketos.dasca.crosslanguage.builder.FilterJSFrameworks
import eu.aniketos.dasca.crosslanguage.builder.PreciseJS
import eu.aniketos.dasca.crosslanguage.builder.RunBuildersInParallel
import eu.aniketos.dasca.crosslanguage.builder.MergedCallGraph
class AppTest {
private var cg = null:MergedCallGraph;
private var js2JavaHits = -1;
private var js2JavaMisses = -1;
private var js2JavaTotal = -1;
@ -95,11 +98,21 @@ class AppTest {
def getFalsePositives() = {
falsePositives
}
def getCallGraphSize() = cg.getNumberOfNodes
def getJSCallGraphSize() = cg.jsCG.getNumberOfNodes
def getJavaCallGraphSize() = cg.javaCG.getNumberOfNodes
private var cgSize = -1
def analyze(apk:String, options:List[CrossBuilderOption], expectedConnections:Set[(SourceLocation, SourceLocation)]):Boolean = {
val builder = CordovaCGBuilder(new File(getClass.getResource("/"+apk).getFile));
builder.setOptions(options:_*)
val crossTargets = builder.createCallGraph.getAllCrossTargets
cg = builder.createCallGraph
val crossTargets = cg.getAllCrossTargets
val convertedCrossTargets = convertToSourceLocationPairs(crossTargets)
val (javaPairs, jsPairs) = convertedCrossTargets.partition({case (origin, target) => origin.isInstanceOf[JavaSourceLocation]})
java2JSTotal = javaPairs.size