[JS IR] expose currentStage via the stageController

Otherwise the signatures for the declarations, created in lowerings,
will be miscalculated.
This commit is contained in:
Anton Bannykh
2021-11-12 13:53:22 +03:00
committed by TeamCityServer
parent f413d7fd75
commit f9e62f8ffa
2 changed files with 18 additions and 2 deletions
@@ -804,7 +804,7 @@ private val jsSuspendArityStorePhase = makeDeclarationTransformerPhase(
description = "Store arity for suspend functions to not remove it during DCE"
)
private val loweringList = listOf<Lowering>(
val loweringList = listOf<Lowering>(
scriptRemoveReceiverLowering,
validateIrBeforeLowering,
annotationInstantiationLowering,
@@ -5,7 +5,9 @@
package org.jetbrains.kotlin.ir.backend.js
import org.jetbrains.kotlin.backend.common.lower
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.common.phaser.PhaserState
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
@@ -87,7 +89,7 @@ fun compileWithIC(
generateJsTests(context, mainModule)
jsPhases.invokeToplevel(PhaseConfig(jsPhases), context, allModules)
lowerPreservingTags(allModules, context, PhaseConfig(jsPhases), symbolTable.irFactory.stageController as WholeWorldStageController)
val transformer = IrModuleToJsTransformerTmp(
context,
@@ -107,6 +109,20 @@ fun compileWithIC(
ast.entries.forEach { (path, bytes) -> cacheConsumer.commitBinaryAst(path, bytes) }
}
fun lowerPreservingTags(modules: Iterable<IrModuleFragment>, context: JsIrBackendContext, phaseConfig: PhaseConfig, controller: WholeWorldStageController) {
// Lower all the things
controller.currentStage = 0
val phaserState = PhaserState<Iterable<IrModuleFragment>>()
loweringList.forEachIndexed { i, lowering ->
controller.currentStage = i + 1
lowering.modulePhase.invoke(phaseConfig, phaserState, context, modules)
}
controller.currentStage = pirLowerings.size + 1
}
@Suppress("UNUSED_PARAMETER")
fun generateJsFromAst(