Remove unnecessary dependency of 'fir2ir' on 'ir.backend.common'
Move some lookup utilities which are used in `OperatorExpressionGenerator`, to 'ir.tree'.
This commit is contained in:
@@ -1,8 +1,3 @@
|
|||||||
/*
|
|
||||||
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
id("jps-compatible")
|
id("jps-compatible")
|
||||||
@@ -15,7 +10,6 @@ dependencies {
|
|||||||
compileOnly(project(":compiler:fir:tree"))
|
compileOnly(project(":compiler:fir:tree"))
|
||||||
compileOnly(project(":compiler:ir.tree"))
|
compileOnly(project(":compiler:ir.tree"))
|
||||||
compileOnly(project(":compiler:ir.psi2ir"))
|
compileOnly(project(":compiler:ir.psi2ir"))
|
||||||
compileOnly(project(":compiler:ir.backend.common"))
|
|
||||||
|
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
|
||||||
@@ -48,4 +42,4 @@ projectTest(parallel = true) {
|
|||||||
workingDir = rootDir
|
workingDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
testsJar()
|
testsJar()
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.ir.util
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
|
||||||
|
|
||||||
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
|
||||||
val properties = declarations.filterIsInstance<IrProperty>().filter { it.name.asString() == name }
|
|
||||||
if (properties.size > 1) {
|
|
||||||
error(
|
|
||||||
"More than one property with name $name in class $fqNameWhenAvailable:\n" +
|
|
||||||
properties.joinToString("\n", transform = IrProperty::render)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return properties.firstOrNull()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun IrClass.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
|
|
||||||
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
|
||||||
|
|
||||||
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
|
||||||
getPropertyDeclaration(name)?.getter?.symbol
|
|
||||||
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
|
||||||
|
|
||||||
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
|
||||||
getPropertyDeclaration(name)?.setter?.symbol
|
|
||||||
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
|
||||||
|
|
||||||
fun IrClassSymbol.getSimpleFunction(name: String): IrSimpleFunctionSymbol? = owner.getSimpleFunction(name)
|
|
||||||
fun IrClassSymbol.getPropertyGetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertyGetter(name)
|
|
||||||
fun IrClassSymbol.getPropertySetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertySetter(name)
|
|
||||||
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.ir.SourceRangeInfo
|
|||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
@@ -217,3 +219,29 @@ class NaiveSourceBasedFileEntryImpl(override val name: String, val lineStartOffs
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrClass.getPropertyDeclaration(name: String): IrProperty? {
|
||||||
|
val properties = declarations.filterIsInstance<IrProperty>().filter { it.name.asString() == name }
|
||||||
|
if (properties.size > 1) {
|
||||||
|
error(
|
||||||
|
"More than one property with name $name in class $fqNameWhenAvailable:\n" +
|
||||||
|
properties.joinToString("\n", transform = IrProperty::render)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return properties.firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun IrClass.getSimpleFunction(name: String): IrSimpleFunctionSymbol? =
|
||||||
|
findDeclaration<IrSimpleFunction> { it.name.asString() == name }?.symbol
|
||||||
|
|
||||||
|
fun IrClass.getPropertyGetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
|
getPropertyDeclaration(name)?.getter?.symbol
|
||||||
|
?: getSimpleFunction("<get-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|
||||||
|
fun IrClass.getPropertySetter(name: String): IrSimpleFunctionSymbol? =
|
||||||
|
getPropertyDeclaration(name)?.setter?.symbol
|
||||||
|
?: getSimpleFunction("<set-$name>").also { assert(it?.owner?.correspondingPropertySymbol?.owner?.name?.asString() == name) }
|
||||||
|
|
||||||
|
fun IrClassSymbol.getSimpleFunction(name: String): IrSimpleFunctionSymbol? = owner.getSimpleFunction(name)
|
||||||
|
fun IrClassSymbol.getPropertyGetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertyGetter(name)
|
||||||
|
fun IrClassSymbol.getPropertySetter(name: String): IrSimpleFunctionSymbol? = owner.getPropertySetter(name)
|
||||||
|
|||||||
Reference in New Issue
Block a user