Fix complex funcs
This commit is contained in:
parent
20956c52fd
commit
9c75f37409
4 changed files with 9 additions and 7 deletions
|
@ -86,7 +86,7 @@ class CFunction(
|
|||
if (index > 0) { // 按理来说肯定成立,加个检查防止意外
|
||||
var i = 0
|
||||
var left = cParser.sentenceList[index - 1].left
|
||||
while (left == "-" && index - i >= 0) {
|
||||
while (left !in cParser.defineList && index - i >= 0) {
|
||||
left = cParser.sentenceList[index - i].left
|
||||
i++
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package core
|
||||
|
||||
import kotlin.math.abs
|
||||
|
||||
data class Relation(val from: String, val to: String)
|
||||
|
||||
fun generateGraph(relations: Map<String, List<Relation>>, crossLabelPaths: List<String>? = null): String {
|
||||
|
|
|
@ -160,8 +160,7 @@ fun main() {
|
|||
relations.putAll(parseRelation(it.name,it.getTraceTree().getStringRepr()))
|
||||
}
|
||||
println(funcs.getInvokeTree("main").getFuncRepr("main"))
|
||||
println(sourceFile.getDef())
|
||||
println(sourceFile.getUse())
|
||||
|
||||
println(generateGraph(relations))
|
||||
println(funcs.getInvokeGraph("main"))
|
||||
|
||||
|
|
|
@ -49,10 +49,15 @@ fun List<TraceTree>.getStringRepr(): String {
|
|||
|
||||
fun Map<String, List<TraceTree>>.getFuncRepr(func: String): String {
|
||||
val result = StringBuilder()
|
||||
var fName = ""
|
||||
this.forEach { (name, list) ->
|
||||
result.append("$name:")
|
||||
fName = name
|
||||
val listRepr = list.getStringRepr()
|
||||
result.append(listRepr.split('\n').filter { it.startsWith(func) }.joinToString("\n"))
|
||||
}
|
||||
return result.toString()
|
||||
val fixedResult = StringBuilder()
|
||||
result.lines().forEach { line ->
|
||||
fixedResult.append("$fName:$line\n")
|
||||
}
|
||||
return fixedResult.toString()
|
||||
}
|
Loading…
Reference in a new issue