mirror of
https://github.com/irmen/prog8.git
synced 2024-11-03 13:07:54 +00:00
callgraph
This commit is contained in:
parent
75d5117a2d
commit
2f62271453
@ -200,13 +200,32 @@ class CallGraph(private val program: Program, private val asmFileLoader: (filena
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun unused(stmt: ISymbolStatement): Boolean {
|
fun unused(sub: Subroutine): Boolean {
|
||||||
if(stmt is Subroutine)
|
return calledBy[sub].isNullOrEmpty() // TODO also check inline assembly if it uses the subroutine
|
||||||
return calledBy[stmt].isNullOrEmpty() // TODO also check inline assembly if it uses the subroutine
|
}
|
||||||
|
|
||||||
// TODO implement algorithm to check usages of other things:
|
fun unused(block: Block): Boolean {
|
||||||
// stmt can be: Block, Label, VarDecl (including ParameterVarDecl), Subroutine, StructDecl.
|
return false // TODO implement unused check for Block, also check inline asm
|
||||||
// NOTE also check inline assembly blocks that may reference a name.
|
}
|
||||||
return false
|
|
||||||
|
fun unused(decl: VarDecl): Boolean {
|
||||||
|
return false // TODO implement unused check for vardecls, also check inline asm
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unused(struct: StructDecl): Boolean {
|
||||||
|
return false // TODO implement unused check for struct decls, also check inline asm
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun unused(label: Label) = false // just always output labels
|
||||||
|
|
||||||
|
fun unused(stmt: ISymbolStatement): Boolean {
|
||||||
|
return when(stmt) {
|
||||||
|
is Subroutine -> unused(stmt)
|
||||||
|
is Block -> unused(stmt)
|
||||||
|
is VarDecl -> unused(stmt)
|
||||||
|
is Label -> false // just always output labels
|
||||||
|
is StructDecl -> unused(stmt)
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user