Get rid of cli dependencies from ir

This commit is contained in:
Mikhael Bogdanov
2017-11-15 15:45:37 +01:00
parent 28e34ac39b
commit cbfcb74b58
4 changed files with 4 additions and 19 deletions
-1
View File
@@ -9,7 +9,6 @@ dependencies {
compile(project(":compiler:util")) compile(project(":compiler:util"))
compile(project(":compiler:frontend")) compile(project(":compiler:frontend"))
compile(project(":compiler:ir.tree")) compile(project(":compiler:ir.tree"))
compile(project(":compiler:cli-common"))
} }
sourceSets { sourceSets {
@@ -2,13 +2,13 @@ package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.backend.common.ir.Ir import org.jetbrains.kotlin.backend.common.ir.Ir
import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.scopes.MemberScope import org.jetbrains.kotlin.resolve.scopes.MemberScope
@@ -35,7 +35,7 @@ interface CommonBackendContext : BackendContext {
fun log(message: () -> String) fun log(message: () -> String)
val messageCollector: MessageCollector fun report(element: IrElement?, irFile: IrFile?, message: String, isError: Boolean)
} }
class ReflectionTypes(module: ModuleDescriptor, internalPackage: FqName) { class ReflectionTypes(module: ModuleDescriptor, internalPackage: FqName) {
@@ -16,14 +16,11 @@
package org.jetbrains.kotlin.backend.common package org.jetbrains.kotlin.backend.common
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.util.getCompilerMessageLocation
fun CommonBackendContext.reportWarning(message: String, irFile: IrFile, irElement: IrElement) { fun CommonBackendContext.reportWarning(message: String, irFile: IrFile, irElement: IrElement) {
val location = irElement.getCompilerMessageLocation(irFile) report(irElement, irFile, message, false)
messageCollector.report(CompilerMessageSeverity.WARNING, message, location)
} }
fun <E> MutableList<E>.push(element: E) = this.add(element) fun <E> MutableList<E>.push(element: E) = this.add(element)
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.ir.util package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.backend.common.atMostOne import org.jetbrains.kotlin.backend.common.atMostOne
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
@@ -122,16 +121,6 @@ fun IrExpression.isNullConst() = this is IrConst<*> && this.kind == IrConstKind.
fun IrCall.usesDefaultArguments(): Boolean = fun IrCall.usesDefaultArguments(): Boolean =
this.descriptor.valueParameters.any { this.getValueArgument(it) == null } this.descriptor.valueParameters.any { this.getValueArgument(it) == null }
fun IrElement.getCompilerMessageLocation(containingFile: IrFile): CompilerMessageLocation? {
val sourceRangeInfo = containingFile.fileEntry.getSourceRangeInfo(this.startOffset, this.endOffset)
return CompilerMessageLocation.create(
path = sourceRangeInfo.filePath,
line = sourceRangeInfo.startLineNumber,
column = sourceRangeInfo.startColumnNumber,
lineContent = null // TODO: retrieve the line content.
)
}
fun IrFunction.createParameterDeclarations() { fun IrFunction.createParameterDeclarations() {
fun ParameterDescriptor.irValueParameter() = IrValueParameterImpl( fun ParameterDescriptor.irValueParameter() = IrValueParameterImpl(
innerStartOffset(this), innerEndOffset(this), innerStartOffset(this), innerEndOffset(this),