[JS IR BE] support multimodule tests
This commit is contained in:
@@ -49,10 +49,11 @@ fun compile(
|
||||
files: List<KtFile>,
|
||||
configuration: CompilerConfiguration,
|
||||
export: FqName? = null,
|
||||
dependencies: List<Result> = listOf()
|
||||
dependencies: List<ModuleDescriptor> = listOf(),
|
||||
irDependencyModules: List<IrModuleFragment> = listOf()
|
||||
): Result {
|
||||
val analysisResult =
|
||||
TopDownAnalyzerFacadeForJS.analyzeFiles(files, project, configuration, dependencies.mapNotNull { it.moduleDescriptor as? ModuleDescriptorImpl }, emptyList())
|
||||
TopDownAnalyzerFacadeForJS.analyzeFiles(files, project, configuration, dependencies.mapNotNull { it as? ModuleDescriptorImpl }, emptyList())
|
||||
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
|
||||
@@ -61,8 +62,6 @@ fun compile(
|
||||
val psi2IrTranslator = Psi2IrTranslator(configuration.languageVersionSettings)
|
||||
val psi2IrContext = psi2IrTranslator.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext)
|
||||
|
||||
val irDependencyModules = dependencies.map { it.moduleFragment.deepCopyWithSymbols() }
|
||||
|
||||
irDependencyModules.forEach { psi2IrContext.symbolTable.loadModule(it)}
|
||||
|
||||
val moduleFragment = psi2IrTranslator.generateModuleFragment(psi2IrContext, files)
|
||||
|
||||
+1
-3
@@ -6,15 +6,13 @@
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.irCall
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
|
||||
+14
-7
@@ -37,22 +37,31 @@ class SecondaryCtorLowering(val context: JsIrBackendContext) {
|
||||
|
||||
fun getConstructorProcessorLowering() = object : DeclarationContainerLoweringPass {
|
||||
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
|
||||
irDeclarationContainer.declarations.transformFlat {
|
||||
if (it is IrClass) {
|
||||
listOf(it) + lowerClass(it)
|
||||
} else null
|
||||
}
|
||||
irDeclarationContainer.declarations.filterIsInstance<IrClass>().forEach { lowerClass(it) }
|
||||
}
|
||||
}::runOnFilePostfix
|
||||
|
||||
fun getConstructorRedirectorLowering() = object : DeclarationContainerLoweringPass {
|
||||
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
|
||||
if (irDeclarationContainer is IrClass) {
|
||||
updateConstructorDeclarations(irDeclarationContainer)
|
||||
}
|
||||
for (it in irDeclarationContainer.declarations) {
|
||||
it.accept(CallsiteRedirectionTransformer(), null)
|
||||
}
|
||||
}
|
||||
}::runOnFilePostfix
|
||||
|
||||
private fun updateConstructorDeclarations(irClass: IrClass) {
|
||||
irClass.declarations.transformFlat {
|
||||
if (it is IrConstructor) {
|
||||
oldCtorToNewMap[it.symbol]?.let { (newInit, newCreate) ->
|
||||
listOf(newInit.owner, newCreate.owner)
|
||||
}
|
||||
} else null
|
||||
}
|
||||
}
|
||||
|
||||
private fun lowerClass(irClass: IrClass): List<IrSimpleFunction> {
|
||||
val className = irClass.name.asString()
|
||||
val oldConstructors = mutableListOf<IrConstructor>()
|
||||
@@ -91,8 +100,6 @@ class SecondaryCtorLowering(val context: JsIrBackendContext) {
|
||||
}
|
||||
}
|
||||
|
||||
irClass.declarations.removeAll(oldConstructors)
|
||||
|
||||
return newConstructors
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !LANGUAGE: +ReleaseCoroutines
|
||||
// !API_VERSION: 1.3
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_COROUTINES
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_COROUTINES
|
||||
// WITH_RUNTIME
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_COROUTINES
|
||||
// WITH_RUNTIME
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_COROUTINES
|
||||
// WITH_RUNTIME
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_COROUTINES
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR, NATIVE
|
||||
// IGNORE_BACKEND: JVM_IR, NATIVE
|
||||
|
||||
inline class SnekDirection(val direction: Int) {
|
||||
companion object {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
class A {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
@PublishedApi
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user