Proper file names for inlined code.
This commit is contained in:
committed by
Vasily Levchenko
parent
22d99d0bd8
commit
72af75f3a2
-6
@@ -28,7 +28,6 @@ class ModuleIndex(val module: IrModuleFragment) {
|
||||
* Contains all functions declared in [module]
|
||||
*/
|
||||
val functions = mutableMapOf<FunctionDescriptor, IrFunction>()
|
||||
val declarationToFile = mutableMapOf<DeclarationDescriptor, String>()
|
||||
|
||||
init {
|
||||
val map = mutableMapOf<ClassDescriptor, IrClass>()
|
||||
@@ -60,11 +59,6 @@ class ModuleIndex(val module: IrModuleFragment) {
|
||||
super.visitFunction(declaration)
|
||||
functions[declaration.descriptor] = declaration
|
||||
}
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration) {
|
||||
super.visitDeclaration(declaration)
|
||||
declarationToFile[declaration.descriptor] = currentFile!!.path
|
||||
}
|
||||
})
|
||||
|
||||
classes = map
|
||||
|
||||
+10
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.SourceManager
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
@@ -191,3 +192,12 @@ val IrDeclaration.isGetter get() = this is IrSimpleFunction && this == this.corr
|
||||
val IrDeclaration.isSetter get() = this is IrSimpleFunction && this == this.correspondingProperty?.setter
|
||||
|
||||
val IrDeclaration.isAccessor get() = this.isGetter || this.isSetter
|
||||
|
||||
val IrDeclaration.fileEntry: SourceManager.FileEntry get() = parent.let {
|
||||
when (it) {
|
||||
is IrFile -> it.fileEntry
|
||||
is IrPackageFragment -> TODO("Unknown file")
|
||||
is IrDeclaration -> it.fileEntry
|
||||
else -> TODO("Unexpected declaration parent")
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.backend.konan.descriptors.isFunctionInvoke
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.needsInlining
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
||||
import org.jetbrains.kotlin.backend.konan.irasdescriptors.constructedClass
|
||||
import org.jetbrains.kotlin.backend.konan.irasdescriptors.fileEntry
|
||||
import org.jetbrains.kotlin.backend.konan.irasdescriptors.isInlineParameter
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
@@ -148,7 +149,7 @@ internal class FunctionInlining(val context: Context) : IrElementTransformerVoid
|
||||
}
|
||||
}
|
||||
|
||||
val sourceFileName = context.ir.originalModuleIndex.declarationToFile[callee.descriptor.original] ?: ""
|
||||
val sourceFileName = callee.fileEntry.name
|
||||
|
||||
val transformer = ParameterSubstitutor()
|
||||
statements.transform { it.transform(transformer, data = null) }
|
||||
|
||||
-2
@@ -1111,8 +1111,6 @@ abstract class IrModuleDeserializer(
|
||||
|
||||
parent?.let { declaration.parent = it }
|
||||
|
||||
val sourceFileName = proto.fileName
|
||||
|
||||
val descriptor = declaration.descriptor
|
||||
|
||||
if (descriptor is WrappedDeclarationDescriptor<*>) {
|
||||
|
||||
-6
@@ -1039,12 +1039,6 @@ internal class IrModuleSerializer(
|
||||
|
||||
proto.setDeclarator(declarator)
|
||||
|
||||
// TODO disabled for now.
|
||||
//val fileName = context.ir.originalModuleIndex.declarationToFile[declaration.descriptor]
|
||||
//proto.fileName = fileName
|
||||
|
||||
proto.fileName = serializeString("some file name")
|
||||
|
||||
return proto.build()
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -616,7 +616,6 @@ message IrDeclaration {
|
||||
required Coordinates coordinates = 2;
|
||||
required Annotations annotations = 3;
|
||||
required IrDeclarator declarator = 4;
|
||||
required String file_name = 5; // TODO: files should be communicated some other way, I suppose.
|
||||
}
|
||||
|
||||
/* ------- IrStatements --------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user