[LL API] Minor, prettify naming in 'LLFirBodyLazyResolver'

This commit is contained in:
Yan Zhulanow
2023-05-16 20:22:53 +09:00
committed by Space Team
parent 2aaf589ef2
commit d386dd1f7b
@@ -91,9 +91,9 @@ private class LLFirBodyTargetResolver(
if (target.resolvePhase >= resolverPhase) return true if (target.resolvePhase >= resolverPhase) return true
// resolve class CFG graph here, to do this we need to have property & init blocks resoled // resolve class CFG graph here, to do this we need to have property & init blocks resoled
resolveMemberProperties(target) resolveMembersForControlFlowGraph(target)
performCustomResolveUnderLock(target) { performCustomResolveUnderLock(target) {
calculateCFG(target) calculateControlFlowGraph(target)
} }
return true return true
@@ -103,10 +103,10 @@ private class LLFirBodyTargetResolver(
return false return false
} }
private fun calculateCFG(target: FirRegularClass) { private fun calculateControlFlowGraph(target: FirRegularClass) {
checkWithAttachmentBuilder( checkWithAttachmentBuilder(
target.controlFlowGraphReference == null, target.controlFlowGraphReference == null,
{ "controlFlowGraphReference should be null if class phase < $resolverPhase)" }, { "'controlFlowGraphReference' should be 'null' if the class phase < $resolverPhase)" },
) { ) {
withFirEntry("firClass", target) withFirEntry("firClass", target)
} }
@@ -114,22 +114,22 @@ private class LLFirBodyTargetResolver(
val dataFlowAnalyzer = transformer.declarationsTransformer.dataFlowAnalyzer val dataFlowAnalyzer = transformer.declarationsTransformer.dataFlowAnalyzer
dataFlowAnalyzer.enterClass(target, buildGraph = true) dataFlowAnalyzer.enterClass(target, buildGraph = true)
val controlFlowGraph = dataFlowAnalyzer.exitClass() val controlFlowGraph = dataFlowAnalyzer.exitClass()
?: buildErrorWithAttachment("CFG should not be null as buildGraph is specified") { ?: buildErrorWithAttachment("CFG should not be 'null' as 'buildGraph' is specified") {
withFirEntry("firClass", target) withFirEntry("firClass", target)
} }
target.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(controlFlowGraph)) target.replaceControlFlowGraphReference(FirControlFlowGraphReferenceImpl(controlFlowGraph))
} }
private fun resolveMemberProperties(target: FirRegularClass) { private fun resolveMembersForControlFlowGraph(target: FirRegularClass) {
withRegularClass(target) { withRegularClass(target) {
transformer.firTowerDataContextCollector?.addDeclarationContext(target, transformer.context.towerDataContext) transformer.firTowerDataContextCollector?.addDeclarationContext(target, transformer.context.towerDataContext)
for (member in target.declarations) { for (member in target.declarations) {
if (member is FirCallableDeclaration || member is FirAnonymousInitializer) { if (member is FirCallableDeclaration || member is FirAnonymousInitializer) {
/* TODO we should resolve only properties and init blocks here but due to the recent changes in the compiler, we also have to do this for all callable members // TODO: Ideally, only properties and init blocks should be resolved here.
we should avoid doing it as it leads to additional work and also can might to problems with incremental analysis // However, dues to changes in the compiler resolution, we temporarily have to resolve all callable members.
*/ // Such additional work might affect incremental analysis performance.
member.lazyResolveToPhase(resolverPhase.previous) member.lazyResolveToPhase(resolverPhase.previous)
performResolve(member) performResolve(member)
} }