|
|
@ -42,18 +42,20 @@ abstract class DataFlowAnalyzer<T>(owner: String, private val method: MethodNode |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun analyze() { |
|
|
|
fun analyze() { |
|
|
|
for (node in graph.vertexSet()) { |
|
|
|
val initialSet = createInitialSet() |
|
|
|
outSets[node] = createInitialSet() |
|
|
|
|
|
|
|
} |
|
|
|
val workList = LinkedHashSet<Int>() |
|
|
|
|
|
|
|
workList += graph.vertexSet().filter { vertex -> graph.inDegreeOf(vertex) == 0 } |
|
|
|
|
|
|
|
|
|
|
|
val workList = LinkedHashSet<Int>(graph.vertexSet()) |
|
|
|
|
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
val node = workList.removeFirstOrNull() ?: break |
|
|
|
val node = workList.removeFirstOrNull() ?: break |
|
|
|
|
|
|
|
|
|
|
|
val predecessors = graph.incomingEdgesOf(node).map { edge -> outSets[graph.getEdgeSource(edge)]!! } |
|
|
|
val predecessors = graph.incomingEdgesOf(node).map { edge -> |
|
|
|
|
|
|
|
outSets[graph.getEdgeSource(edge)] ?: initialSet |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val inSet = if (predecessors.isEmpty()) { |
|
|
|
val inSet = if (predecessors.isEmpty()) { |
|
|
|
createInitialSet() |
|
|
|
initialSet |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
predecessors.reduce(this::join) |
|
|
|
predecessors.reduce(this::join) |
|
|
|
} |
|
|
|
} |
|
|
|