mirror of
https://github.com/irmen/prog8.git
synced 2025-10-13 19:18:33 +00:00
Merge branch 'master' into c128target
# Conflicts: # examples/test.p8
This commit is contained in:
@@ -6,7 +6,7 @@ import prog8.ast.Program
|
||||
import prog8.ast.base.Position
|
||||
import prog8.ast.base.VarDeclType
|
||||
import prog8.ast.expressions.AddressOf
|
||||
import prog8.ast.expressions.FunctionCall
|
||||
import prog8.ast.expressions.FunctionCallExpr
|
||||
import prog8.ast.expressions.IdentifierReference
|
||||
import prog8.ast.statements.*
|
||||
import prog8.ast.walk.IAstVisitor
|
||||
@@ -59,15 +59,15 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
super.visit(directive)
|
||||
}
|
||||
|
||||
override fun visit(functionCall: FunctionCall) {
|
||||
val otherSub = functionCall.target.targetSubroutine(program)
|
||||
override fun visit(functionCallExpr: FunctionCallExpr) {
|
||||
val otherSub = functionCallExpr.target.targetSubroutine(program)
|
||||
if (otherSub != null) {
|
||||
functionCall.definingSubroutine?.let { thisSub ->
|
||||
functionCallExpr.definingSubroutine?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + functionCall
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + functionCallExpr
|
||||
}
|
||||
}
|
||||
super.visit(functionCall)
|
||||
super.visit(functionCallExpr)
|
||||
}
|
||||
|
||||
override fun visit(functionCallStatement: FunctionCallStatement) {
|
||||
@@ -103,6 +103,17 @@ class CallGraph(private val program: Program) : IAstVisitor {
|
||||
super.visit(jump)
|
||||
}
|
||||
|
||||
override fun visit(gosub: GoSub) {
|
||||
val otherSub = gosub.identifier?.targetSubroutine(program)
|
||||
if (otherSub != null) {
|
||||
gosub.definingSubroutine?.let { thisSub ->
|
||||
calls[thisSub] = calls.getValue(thisSub) + otherSub
|
||||
calledBy[otherSub] = calledBy.getValue(otherSub) + gosub
|
||||
}
|
||||
}
|
||||
super.visit(gosub)
|
||||
}
|
||||
|
||||
override fun visit(identifier: IdentifierReference) {
|
||||
allIdentifiersAndTargets[Pair(identifier, identifier.position)] = identifier.targetStatement(program)!!
|
||||
}
|
||||
|
Reference in New Issue
Block a user