private fun preAnalyzeMethods(): Set<DefUseCoverageTestFitness>? { val r: MutableSet<DefUseCoverageTestFitness> = HashSet<DefUseCoverageTestFitness>() val toAnalyze: LinkedList<ClassCallNode> = LinkedList<ClassCallNode>() toAnalyze.addAll(getInitialPreAnalyzeableMethods()) while (!toAnalyze.isEmpty()) { val currentMethod: ClassCallNode = toAnalyze.poll() val analyzeableEntry: CCFGMethodEntryNode = ccfg.getMethodEntryNodeForClassCallNode(currentMethod) if (analyzedMethods.contains(analyzeableEntry)) continue r.addAll(determineIntraInterMethodPairs(analyzeableEntry)) val parents: Set<ClassCallNode> = ccfg.getCcg().getParents(currentMethod) for (parent in parents) { if (toAnalyze.contains(parent)) continue if (analyzedMethods.contains(ccfg.getMethodEntryNodeForClassCallNode(parent))) continue val parentsChildren: Set<ClassCallNode> = ccfg.getCcg().getChildren(parent) var canAnalyzeNow = true for (parentsChild in parentsChildren) { if (parentsChild == null) continue if (!parentsChild.equals(parent) && !(toAnalyze.contains(parentsChild) || analyzedMethods.contains( ccfg.getMethodEntryNodeForClassCallNode(parentsChild) )) ) { canAnalyzeNow = false break } } if (canAnalyzeNow) { toAnalyze.offer(parent) } } } return r }
Checks if there are methods in the CCG that dont call any other methods except for maybe itself . For these we can predetermine free uses and activeDefs prior to looking for inter_method_pairs . After that we can even repeat this process for methods we now have determined free uses and activeDefs ! that way you can save a lot of computation . Map activeDefs and freeUses according to the variable so you can easily determine which defs will be active and which uses are free once you encounter a methodCall to that method without looking at its part of the CCFG