diff --git a/build.gradle.kts b/build.gradle.kts index 958a133d872..91a22ccc2d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -218,6 +218,7 @@ extra["compilerModules"] = arrayOf( ":compiler:ir.tree", ":compiler:ir.psi2ir", ":compiler:ir.backend.common", + ":compiler:backend.jvm", ":compiler:backend.js", ":compiler:backend-common", ":compiler:backend", diff --git a/compiler/backend/build.gradle.kts b/compiler/backend/build.gradle.kts index 6f87ebe6030..98d4f3698d0 100644 --- a/compiler/backend/build.gradle.kts +++ b/compiler/backend/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -12,9 +11,6 @@ dependencies { compile(project(":compiler:backend-common")) compile(project(":compiler:frontend")) compile(project(":compiler:frontend.java")) - compile(project(":compiler:ir.tree")) - compile(project(":compiler:ir.psi2ir")) - compile(project(":compiler:ir.backend.common")) compile(project(":compiler:serialization")) compileOnly(intellijCoreDep()) { includeJars("intellij-core", "annotations", "asm-all", rootProject = rootProject) } } @@ -22,8 +18,6 @@ dependencies { sourceSets { "main" { projectDefault() - java.srcDir("../ir/backend.jvm/src") } "test" {} } - diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/IrExpressionLambda.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/IrExpressionLambda.kt new file mode 100644 index 00000000000..3bb6175443a --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/IrExpressionLambda.kt @@ -0,0 +1,10 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.codegen + +interface IrExpressionLambda { + val isExtensionLambda: Boolean +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt index edaae3f0824..f655b1f95b8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.codegen.inline -import org.jetbrains.kotlin.backend.jvm.codegen.IrExpressionLambda import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.ClosureCodegen +import org.jetbrains.kotlin.codegen.IrExpressionLambda import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.kotlin.codegen.coroutines.continuationAsmType import org.jetbrains.kotlin.codegen.coroutines.getOrCreateJvmSuspendFunctionView diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 0ce0a7cd7af..b8ce8b67f38 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -14,6 +13,7 @@ dependencies { compile(project(":compiler:frontend.script")) compile(project(":compiler:backend-common")) compile(project(":compiler:backend")) + compile(project(":compiler:backend.jvm")) compile(project(":compiler:light-classes")) compile(project(":compiler:serialization")) compile(project(":compiler:plugin-api")) @@ -54,4 +54,4 @@ testsJar {} projectTest { workingDir = rootDir -} \ No newline at end of file +} diff --git a/compiler/ir/backend.jvm/build.gradle.kts b/compiler/ir/backend.jvm/build.gradle.kts new file mode 100644 index 00000000000..0a7394c7f83 --- /dev/null +++ b/compiler/ir/backend.jvm/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + compile(project(":kotlin-annotations-jvm")) + compile(project(":compiler:backend")) + compile(project(":compiler:ir.tree")) + compile(project(":compiler:ir.psi2ir")) + compile(project(":compiler:ir.backend.common")) + compileOnly(intellijCoreDep()) { includeJars("intellij-core", "annotations", "asm-all", rootProject = rootProject) } +} + +sourceSets { + "main" { + projectDefault() + } + "test" {} +} diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt index 6675450518b..12130e3a21d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.backend.jvm.codegen import org.jetbrains.kotlin.builtins.isExtensionFunctionType -import org.jetbrains.kotlin.codegen.Callable -import org.jetbrains.kotlin.codegen.JvmKotlinType -import org.jetbrains.kotlin.codegen.StackValue -import org.jetbrains.kotlin.codegen.ValueKind +import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.inline.* import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper @@ -32,7 +29,7 @@ class IrInlineCodegen( ) : InlineCodegen(codegen, state, function, typeParameterMappings, sourceCompiler), IrCallGenerator { override fun putClosureParametersOnStack(next: LambdaInfo, functionReferenceReceiver: StackValue?) { - val lambdaInfo = next as IrExpressionLambda + val lambdaInfo = next as IrExpressionLambdaImpl activeLambda = lambdaInfo lambdaInfo.reference.getArguments().forEachIndexed { index, (_, ir) -> @@ -52,7 +49,7 @@ class IrInlineCodegen( if (valueParameterDescriptor?.let { isInlineParameter(it) } == true && isInlineIrExpression(argumentExpression)) { val irReference: IrFunctionReference = (argumentExpression as IrBlock).statements.filterIsInstance().single() - rememberClosure(irReference, parameterType, valueParameterDescriptor) as IrExpressionLambda + rememberClosure(irReference, parameterType, valueParameterDescriptor) as IrExpressionLambdaImpl } else { putValueOnStack(argumentExpression, parameterType, valueParameterDescriptor?.index ?: -1) } @@ -94,7 +91,7 @@ class IrInlineCodegen( private fun rememberClosure(irReference: IrFunctionReference, type: Type, parameter: ValueParameterDescriptor): LambdaInfo { //assert(InlineUtil.isInlinableParameterExpression(ktLambda)) { "Couldn't find inline expression in ${expression.text}" } val expression = irReference.symbol.owner as IrFunction - return IrExpressionLambda( + return IrExpressionLambdaImpl( irReference, expression, typeMapper, parameter.isCrossinline, false/*TODO*/, parameter.type.isExtensionFunctionType ).also { lambda -> @@ -105,14 +102,14 @@ class IrInlineCodegen( } } -class IrExpressionLambda( +class IrExpressionLambdaImpl( val reference: IrFunctionReference, val function: IrFunction, typeMapper: KotlinTypeMapper, isCrossInline: Boolean, override val isBoundCallableReference: Boolean, - val isExtensionLambda: Boolean -) : ExpressionLambda(typeMapper, isCrossInline) { + override val isExtensionLambda: Boolean +) : ExpressionLambda(typeMapper, isCrossInline), IrExpressionLambda { override fun isMyLabel(name: String): Boolean { //TODO("not implemented") @@ -151,4 +148,4 @@ class IrExpressionLambda( } fun isInlineIrExpression(argumentExpression: IrExpression) = - argumentExpression is IrBlock && argumentExpression.origin == IrStatementOrigin.LAMBDA \ No newline at end of file + argumentExpression is IrBlock && argumentExpression.origin == IrStatementOrigin.LAMBDA diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt index f265de15656..f6fa2c74de2 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrSourceCompilerForInline.kt @@ -69,7 +69,7 @@ class IrSourceCompilerForInline( get() = codegen.classCodegen.getOrCreateSourceMapper() override fun generateLambdaBody(adapter: MethodVisitor, jvmMethodSignature: JvmMethodSignature, lambdaInfo: ExpressionLambda): SMAP { - lambdaInfo as? IrExpressionLambda ?: error("Expecting ir lambda, but $lambdaInfo") + lambdaInfo as? IrExpressionLambdaImpl ?: error("Expecting ir lambda, but $lambdaInfo") val functionCodegen = object : FunctionCodegen(lambdaInfo.function, codegen.classCodegen) { override fun createMethod(flags: Int, signature: JvmMethodGenericSignature): MethodVisitor { diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/build.gradle.kts b/plugins/kotlin-serialization/kotlin-serialization-compiler/build.gradle.kts index 88f2237991b..9c1f05b7383 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/build.gradle.kts +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/build.gradle.kts @@ -1,4 +1,3 @@ - description = "Kotlin Serialization Compiler Plugin" plugins { @@ -14,6 +13,7 @@ dependencies { compile(project(":compiler:plugin-api")) compile(project(":compiler:frontend")) compile(project(":compiler:backend")) + compile(project(":compiler:ir.backend.common")) compile(project(":js:js.frontend")) compile(project(":js:js.translator")) diff --git a/prepare/idea-plugin/build.gradle.kts b/prepare/idea-plugin/build.gradle.kts index 372a57a299d..1f163d9ed8a 100644 --- a/prepare/idea-plugin/build.gradle.kts +++ b/prepare/idea-plugin/build.gradle.kts @@ -16,6 +16,7 @@ val projectsToShadow by extra(listOf( ":plugins:annotation-based-compiler-plugins-ide-support", ":compiler:backend", ":compiler:backend-common", + ":compiler:backend.jvm", ":compiler:ir.backend.common", ":kotlin-build-common", ":compiler:cli-common", diff --git a/settings.gradle b/settings.gradle index 729707c6b40..e4b88372b45 100644 --- a/settings.gradle +++ b/settings.gradle @@ -45,6 +45,7 @@ include ":kotlin-build-common", ":compiler:ir.ir2cfg", ":compiler:ir.backend.common", ":compiler:backend.js", + ":compiler:backend.jvm", ":compiler:backend-common", ":compiler:backend", ":compiler:plugin-api", @@ -273,6 +274,7 @@ project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File project(':compiler:ir.backend.common').projectDir = "$rootDir/compiler/ir/backend.common" as File project(':compiler:backend.js').projectDir = "$rootDir/compiler/ir/backend.js" as File +project(':compiler:backend.jvm').projectDir = "$rootDir/compiler/ir/backend.jvm" as File project(':kotlin-native:kotlin-native-utils').projectDir = "$rootDir/konan/utils" as File project(':kotlin-native:kotlin-native-library-reader').projectDir = "$rootDir/konan/library-reader" as File project(':kotlin-jps-plugin').projectDir = "$rootDir/prepare/jps-plugin" as File