mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 05:29:38 +00:00
also track subroutines in the callgraph that only get their address taken
This commit is contained in:
parent
5540482888
commit
4aca8bb8df
@ -7,6 +7,7 @@ import prog8.ast.Program
|
|||||||
import prog8.ast.base.DataType
|
import prog8.ast.base.DataType
|
||||||
import prog8.ast.base.ParentSentinel
|
import prog8.ast.base.ParentSentinel
|
||||||
import prog8.ast.base.Position
|
import prog8.ast.base.Position
|
||||||
|
import prog8.ast.expressions.AddressOf
|
||||||
import prog8.ast.expressions.FunctionCall
|
import prog8.ast.expressions.FunctionCall
|
||||||
import prog8.ast.expressions.IdentifierReference
|
import prog8.ast.expressions.IdentifierReference
|
||||||
import prog8.ast.statements.*
|
import prog8.ast.statements.*
|
||||||
@ -150,6 +151,17 @@ class CallGraph(private val program: Program, private val asmFileLoader: (filena
|
|||||||
super.visit(functionCallStatement)
|
super.visit(functionCallStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visit(addressOf: AddressOf) {
|
||||||
|
val otherSub = addressOf.identifier.targetSubroutine(program)
|
||||||
|
if(otherSub!=null) {
|
||||||
|
addressOf.definingSubroutine()?.let { thisSub ->
|
||||||
|
calls[thisSub] = calls.getValue(thisSub).plus(otherSub)
|
||||||
|
calledBy[otherSub] = calledBy.getValue(otherSub).plus(thisSub)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.visit(addressOf)
|
||||||
|
}
|
||||||
|
|
||||||
override fun visit(jump: Jump) {
|
override fun visit(jump: Jump) {
|
||||||
val otherSub = jump.identifier?.targetSubroutine(program)
|
val otherSub = jump.identifier?.targetSubroutine(program)
|
||||||
if (otherSub != null) {
|
if (otherSub != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user