[Native] Drop createField from IrUtils2

We can call `IrFieldImpl` directly, the same way it is done
for other IR declarations in `CBridgeGen` file.
This commit is contained in:
Ivan Kylchik
2023-08-15 15:12:01 +02:00
committed by Space Team
parent 7e71e778c9
commit 9e750e900d
2 changed files with 10 additions and 35 deletions
@@ -17,18 +17,12 @@ import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
import org.jetbrains.kotlin.ir.declarations.impl.*
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
import org.jetbrains.kotlin.ir.symbols.impl.*
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.konan.ForeignExceptionMode
@@ -1128,13 +1122,18 @@ private class ObjCBlockPointerValuePassing(
irClass.superTypes += stubs.irBuiltIns.anyType
irClass.superTypes += functionType.makeNotNull()
val blockHolderField = createField(
val blockHolderField = IrFieldImpl(
startOffset, endOffset,
OBJC_BLOCK_FUNCTION_IMPL,
stubs.irBuiltIns.anyType,
IrFieldSymbolImpl(),
Name.identifier("blockHolder"),
isMutable = false, owner = irClass
stubs.irBuiltIns.anyType,
DescriptorVisibilities.PRIVATE,
isFinal = true,
isStatic = false,
isExternal = false
)
irClass.addChild(blockHolderField)
val constructor = IrConstructorImpl(
startOffset, endOffset,
@@ -160,30 +160,6 @@ fun IrBuilderWithScope.irCatch(type: IrType) =
}
)
fun createField(
startOffset: Int,
endOffset: Int,
origin: IrDeclarationOrigin,
type: IrType,
name: Name,
isMutable: Boolean,
owner: IrClass
) =
IrFieldImpl(
startOffset, endOffset,
origin,
IrFieldSymbolImpl(),
name,
type,
DescriptorVisibilities.PRIVATE,
!isMutable,
false,
false,
).apply {
owner.declarations += this
parent = owner
}
fun IrValueParameter.copy(newDescriptor: ParameterDescriptor): IrValueParameter {
// Aggressive use of IrBasedDescriptors during deserialization
// makes these types different.