GoSub no longer inherits from Jump node, fixes subtle ast/codegen bugs related to jsrs

This commit is contained in:
Irmen de Jong
2021-12-28 01:55:13 +01:00
parent 98d25fc4e9
commit 6e11b8ada1
13 changed files with 122 additions and 58 deletions

View File

@@ -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)!!
}