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) { // 按理来说肯定成立,加个检查防止意外
|
if (index > 0) { // 按理来说肯定成立,加个检查防止意外
|
||||||
var i = 0
|
var i = 0
|
||||||
var left = cParser.sentenceList[index - 1].left
|
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
|
left = cParser.sentenceList[index - i].left
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import kotlin.math.abs
|
|
||||||
|
|
||||||
data class Relation(val from: String, val to: String)
|
data class Relation(val from: String, val to: String)
|
||||||
|
|
||||||
fun generateGraph(relations: Map<String, List<Relation>>, crossLabelPaths: List<String>? = null): 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()))
|
relations.putAll(parseRelation(it.name,it.getTraceTree().getStringRepr()))
|
||||||
}
|
}
|
||||||
println(funcs.getInvokeTree("main").getFuncRepr("main"))
|
println(funcs.getInvokeTree("main").getFuncRepr("main"))
|
||||||
println(sourceFile.getDef())
|
|
||||||
println(sourceFile.getUse())
|
|
||||||
println(generateGraph(relations))
|
println(generateGraph(relations))
|
||||||
println(funcs.getInvokeGraph("main"))
|
println(funcs.getInvokeGraph("main"))
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,15 @@ fun List<TraceTree>.getStringRepr(): String {
|
||||||
|
|
||||||
fun Map<String, List<TraceTree>>.getFuncRepr(func: String): String {
|
fun Map<String, List<TraceTree>>.getFuncRepr(func: String): String {
|
||||||
val result = StringBuilder()
|
val result = StringBuilder()
|
||||||
|
var fName = ""
|
||||||
this.forEach { (name, list) ->
|
this.forEach { (name, list) ->
|
||||||
result.append("$name:")
|
fName = name
|
||||||
val listRepr = list.getStringRepr()
|
val listRepr = list.getStringRepr()
|
||||||
result.append(listRepr.split('\n').filter { it.startsWith(func) }.joinToString("\n"))
|
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