Move declaration origins to IrDeclarationOrigin.kt

This commit is contained in:
Georgy Bronnikov
2018-12-18 14:35:13 +03:00
parent bccb451afd
commit 7df0cffac9
5 changed files with 13 additions and 14 deletions
@@ -25,6 +25,7 @@ interface JvmLoweredDeclarationOrigin : IrDeclarationOrigin {
object CLASS_STATIC_INITIALIZER : IrDeclarationOriginImpl("CLASS_STATIC_INITIALIZER")
object DEFAULT_IMPLS : IrDeclarationOriginImpl("DEFAULT_IMPL")
object FIELD_FOR_OUTER_THIS : IrDeclarationOriginImpl("FIELD_FOR_OUTER_THIS")
object FUNCTION_REFERENCE_IMPL : IrDeclarationOriginImpl("FUNCTION_REFERENCE_IMPL")
object SYNTHETIC_ACCESSOR : IrDeclarationOriginImpl("SYNTHETIC_ACCESSOR", isSynthetic = true)
object TO_ARRAY : IrDeclarationOriginImpl("TO_ARRAY")
object JVM_STATIC_WRAPPER : IrDeclarationOriginImpl("JVM_STATIC_WRAPPER")
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.backend.jvm.codegen
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.descriptors.JvmDescriptorWithExtraFlags
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES
import org.jetbrains.kotlin.codegen.*
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.backend.common.ir.copyTo
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
import org.jetbrains.kotlin.backend.common.lower.*
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineIrExpression
import org.jetbrains.kotlin.codegen.PropertyReferenceCodegen
import org.jetbrains.kotlin.descriptors.*
@@ -53,8 +54,6 @@ class CrIrType(val type: Type) : IrType {
//Originally was copied from K/Native
class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPass {
object DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL : IrDeclarationOriginImpl("FUNCTION_REFERENCE_IMPL")
private var functionReferenceCount = 0
private val inlineLambdaReferences = mutableSetOf<IrFunctionReference>()
@@ -218,7 +217,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val functionReferenceClassDescriptor = WrappedClassDescriptor()
functionReferenceClass = IrClassImpl(
startOffset, endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrClassSymbolImpl(functionReferenceClassDescriptor),
name = "${callee.name}\$${functionReferenceCount++}".synthesizedName,
kind = ClassKind.CLASS,
@@ -274,7 +273,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val descriptor = WrappedClassConstructorDescriptor()
return IrConstructorImpl(
irFunctionReference.startOffset, irFunctionReference.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrConstructorSymbolImpl(descriptor),
name = Name.special("<init>"),
visibility = Visibilities.PUBLIC,
@@ -341,7 +340,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val descriptor = WrappedSimpleFunctionDescriptor()
return IrFunctionImpl(
irFunctionReference.startOffset, irFunctionReference.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrSimpleFunctionSymbolImpl(descriptor),
Name.identifier("invoke"),
Visibilities.PUBLIC,
@@ -450,7 +449,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val field = IrFieldImpl(
irFunctionReference.startOffset,
irFunctionReference.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrFieldSymbolImpl(descriptor),
name,
type,
@@ -470,7 +469,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val descriptor = WrappedSimpleFunctionDescriptor()
return IrFunctionImpl(
irFunctionReference.startOffset, irFunctionReference.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrSimpleFunctionSymbolImpl(descriptor),
Name.identifier("getSignature"),
superFunction.visibility,
@@ -506,7 +505,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val descriptor = WrappedSimpleFunctionDescriptor()
return IrFunctionImpl(
irFunctionReference.startOffset, irFunctionReference.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrSimpleFunctionSymbolImpl(descriptor),
Name.identifier("getName"),
superGetter.visibility,
@@ -536,7 +535,7 @@ class CallableReferenceLowering(val context: JvmBackendContext) : FileLoweringPa
val descriptor = WrappedSimpleFunctionDescriptor()
return IrFunctionImpl(
functionReferenceClass.startOffset, functionReferenceClass.endOffset,
DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
IrSimpleFunctionSymbolImpl(descriptor),
Name.identifier("getOwner"),
superFunction.visibility,
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDesc
import org.jetbrains.kotlin.backend.common.descriptors.WrappedValueParameterDescriptor
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irIfThen
import org.jetbrains.kotlin.backend.common.makePhase
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
@@ -52,7 +52,7 @@ class FunctionNVarargInvokeLowering(var context: JvmBackendContext) : ClassLower
val descriptor = WrappedSimpleFunctionDescriptor()
return IrFunctionImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
origin = CallableReferenceLowering.DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
symbol = IrSimpleFunctionSymbolImpl(descriptor),
name = Name.identifier("invoke"),
visibility = Visibilities.PUBLIC,
@@ -68,7 +68,7 @@ class FunctionNVarargInvokeLowering(var context: JvmBackendContext) : ClassLower
val varargParameterDescriptor = WrappedValueParameterDescriptor()
val varargParam = IrValueParameterImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
origin = CallableReferenceLowering.DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL,
origin = JvmLoweredDeclarationOrigin.FUNCTION_REFERENCE_IMPL,
symbol = IrValueParameterSymbolImpl(varargParameterDescriptor),
name = Name.identifier("args"),
index = 0,
@@ -28,7 +28,7 @@ interface IrDeclarationOrigin {
object DELEGATED_PROPERTY_ACCESSOR : IrDeclarationOriginImpl("DELEGATED_PROPERTY_ACCESSOR")
object DELEGATED_MEMBER : IrDeclarationOriginImpl("DELEGATED_MEMBER")
object ENUM_CLASS_SPECIAL_MEMBER : IrDeclarationOriginImpl("ENUM_CLASS_SPECIAL_MEMBER")
object FUNCTION_FOR_DEFAULT_PARAMETER : IrDeclarationOriginImpl("FUNCTION_FOR_DEFAULT_PARAMETER")
object FUNCTION_FOR_DEFAULT_PARAMETER : IrDeclarationOriginImpl("FUNCTION_FOR_DEFAULT_PARAMETER", isSynthetic = true)
object FILE_CLASS : IrDeclarationOriginImpl("FILE_CLASS")
object GENERATED_DATA_CLASS_MEMBER : IrDeclarationOriginImpl("GENERATED_DATA_CLASS_MEMBER")
object GENERATED_INLINE_CLASS_MEMBER : IrDeclarationOriginImpl("GENERATED_INLINE_CLASS_MEMBER")