a13756cfe9
To clearly distinguish this modules API from the Analysis API ^KT-66695 Fixed
Native Analysis Api based Klib reader
Tasks
Run Tests
./gradlew :native:analysis-api-klib-reader:check
Usage: Reading symbols from a given klib module
A set of top level KlibDeclarationAddress can be read from KtLibraryModule by
fun example(module: KtLibraryModule) {
val addresses = module.readKlibDeclarationAddresses()
}
Such addresses can be resolved to KtSymbols by
addresses.flatMap { address -> address.getSymbols() }
Note: getSymbols returns a sequence as multiple symbols can live under the same address.
Usage: Getting all library modules in a Standalone Analysis API session.
Example of creating a session
val session = buildStandaloneAnalysisAPISession {
buildKtModuleProvider {
// ...
addModule(buildKtLibraryModule {
addBinaryRoot(pathToKlib)
// ..
})
}
}
Example analyzing libraries within the session
session.getAllLibraryModules().forEach { module ->
analyze(module) {
module.readKlibDeclarationAddresses()
.flatMap { address -> address.getSymbols() }
}
}
Test Strategy
Black Box Test:
We are building a klib from the testProject.
This klib will be used to read the addresses. Those addresses will be rendered and compared to
!testProject.addresses