IR: use IrFactory in IR builders
This commit is contained in:
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.ir.backend.js.utils.Namer
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addFunction
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addTypeParameter
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
@@ -326,9 +327,11 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
private fun getInternalClassWithoutPackage(fqName: String) =
|
||||
context.symbolTable.referenceClass(context.getClass(FqName(fqName)))
|
||||
|
||||
private val irFactory: IrFactory get() = context.irFactory
|
||||
|
||||
// TODO: unify how we create intrinsic symbols
|
||||
private fun defineObjectCreateIntrinsic(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("Object\$create")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
}.apply {
|
||||
@@ -337,7 +340,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineCreateSharedBox(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("\$sharedBox\$create")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
returnType = context.dynamicType
|
||||
@@ -356,7 +359,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineReadSharedBox(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("\$sharedBox\$read")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
}.apply {
|
||||
@@ -375,7 +378,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineWriteSharedBox(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("\$sharedBox\$write")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
returnType = irBuiltIns.unitType
|
||||
@@ -399,7 +402,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineEs6DefaultTypeIntrinsic(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("DefaultType")
|
||||
}.apply {
|
||||
returnType = addTypeParameter("T", irBuiltIns.anyType).defaultType
|
||||
@@ -407,7 +410,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineJsBindIntrinsic(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("\$jsBind\$")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
returnType = irBuiltIns.anyNType
|
||||
@@ -417,7 +420,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineJsSliceIntrinsic(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier("slice")
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
}.apply {
|
||||
@@ -428,7 +431,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
||||
}
|
||||
|
||||
private fun defineUnreachableIntrinsic(): IrSimpleFunction {
|
||||
return externalPackageFragment.addFunction {
|
||||
return irFactory.addFunction(externalPackageFragment) {
|
||||
name = Name.identifier(Namer.UNREACHABLE_NAME)
|
||||
origin = JsLoweredDeclarationOrigin.JS_INTRINSICS_STUB
|
||||
returnType = irBuiltIns.nothingType
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.jetbrains.kotlin.ir.backend.js.ir.JsIrDeclarationBuilder
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.JsInnerClassesSupport
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
@@ -56,7 +56,7 @@ class JsIrBackendContext(
|
||||
override var inVerbosePhase: Boolean = false
|
||||
|
||||
override val irFactory: IrFactory = IrFactoryImpl
|
||||
override val jsIrDeclarationBuilder: JsIrDeclarationBuilder = JsIrDeclarationBuilder()
|
||||
override val jsIrDeclarationBuilder: JsIrDeclarationBuilder = JsIrDeclarationBuilder(irFactory)
|
||||
|
||||
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
|
||||
|
||||
@@ -139,7 +139,7 @@ class JsIrBackendContext(
|
||||
get() = testContainerFuns
|
||||
|
||||
override val mapping = JsMapping()
|
||||
val innerClassesSupport = JsInnerClassesSupport(mapping)
|
||||
val innerClassesSupport = JsInnerClassesSupport(mapping, irFactory)
|
||||
|
||||
companion object {
|
||||
val KOTLIN_PACKAGE_FQN = FqName.fromSegments(listOf("kotlin"))
|
||||
|
||||
+4
-7
@@ -10,17 +10,14 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
// This is a temporary class for migration to IrFactory. Usages should be refactored to use the factory directly once possible,
|
||||
// since it doesn't add sufficient value on its own.
|
||||
class JsIrDeclarationBuilder {
|
||||
fun buildValueParameter(parent: IrDeclarationParent, name: String, index: Int, type: IrType): IrValueParameter =
|
||||
class JsIrDeclarationBuilder(private val irFactory: IrFactory) {
|
||||
fun buildValueParameter(parent: IrFunction, name: String, index: Int, type: IrType): IrValueParameter =
|
||||
buildValueParameter(parent) {
|
||||
this.origin = JsIrBuilder.SYNTHESIZED_DECLARATION
|
||||
this.name = Name.identifier(name)
|
||||
@@ -64,7 +61,7 @@ class JsIrDeclarationBuilder {
|
||||
isInfix: Boolean = false,
|
||||
isFakeOverride: Boolean = false,
|
||||
origin: IrDeclarationOrigin = JsIrBuilder.SYNTHESIZED_DECLARATION,
|
||||
): IrSimpleFunction = buildFun {
|
||||
): IrSimpleFunction = irFactory.buildFun {
|
||||
this.origin = origin
|
||||
this.name = name
|
||||
this.visibility = visibility
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ class CallableReferenceLowering(private val context: CommonBackendContext) : Bod
|
||||
private val isKReference = superFunctionInterface.name.identifier[0] == 'K'
|
||||
|
||||
private fun buildReferenceClass(): IrClass {
|
||||
return buildClass {
|
||||
return context.irFactory.buildClass {
|
||||
setSourceRange(reference)
|
||||
visibility = Visibilities.LOCAL
|
||||
// A callable reference results in a synthetic class, while a lambda is not synthetic.
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ class CreateScriptFunctionsPhase(val context: CommonBackendContext) : FileLoweri
|
||||
}
|
||||
|
||||
private fun createFunction(irScript: IrScript, name: String, returnType: IrType): IrSimpleFunction =
|
||||
buildFun {
|
||||
context.irFactory.buildFun {
|
||||
val (startOffset, endOffset) = getFunctionBodyOffsets(irScript)
|
||||
this.startOffset = startOffset
|
||||
this.endOffset = endOffset
|
||||
|
||||
+4
-4
@@ -62,7 +62,7 @@ class EnumUsageLowering(val context: JsIrBackendContext) : BodyLoweringPass {
|
||||
}
|
||||
|
||||
private fun createFieldForEntry(entry: IrEnumEntry, irClass: IrClass): IrField =
|
||||
buildField {
|
||||
context.irFactory.buildField {
|
||||
startOffset = entry.startOffset
|
||||
endOffset = entry.endOffset
|
||||
origin = entry.origin
|
||||
@@ -117,7 +117,7 @@ class EnumClassConstructorLowering(val context: JsCommonBackendContext) : Declar
|
||||
}
|
||||
|
||||
private fun transformEnumConstructor(enumConstructor: IrConstructor, enumClass: IrClass): IrConstructor {
|
||||
return buildConstructor {
|
||||
return context.irFactory.buildConstructor {
|
||||
updateFrom(enumConstructor)
|
||||
returnType = enumConstructor.returnType
|
||||
}.apply {
|
||||
@@ -321,7 +321,7 @@ class EnumEntryInstancesLowering(val context: JsIrBackendContext) : DeclarationT
|
||||
private fun createEnumEntryInstanceVariable(irClass: IrClass, enumEntry: IrEnumEntry): IrField {
|
||||
val enumName = irClass.name.identifier
|
||||
|
||||
val result = buildField {
|
||||
val result = context.irFactory.buildField {
|
||||
name = Name.identifier("${enumName}_${enumEntry.name.identifier}_instance")
|
||||
type = enumEntry.getType(irClass).makeNullable()
|
||||
isStatic = true
|
||||
@@ -389,7 +389,7 @@ class EnumClassCreateInitializerLowering(val context: JsIrBackendContext) : Decl
|
||||
return null
|
||||
}
|
||||
|
||||
private fun createEntryInstancesInitializedVar(irClass: IrClass): IrField = buildField {
|
||||
private fun createEntryInstancesInitializedVar(irClass: IrClass): IrField = context.irFactory.buildField {
|
||||
val enumName = irClass.name.identifier
|
||||
name = Name.identifier("${enumName}_entriesInitialized")
|
||||
type = context.irBuiltIns.booleanType
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
|
||||
val superInvokeFun = invokeFun.overriddenSymbols.single { it.owner.isSuspend == invokeFun.isSuspend }.owner
|
||||
val lambdaName = Name.identifier("${lambdaClass.name.asString()}\$lambda")
|
||||
|
||||
val lambdaDeclaration = buildFun {
|
||||
val lambdaDeclaration = context.irFactory.buildFun {
|
||||
startOffset = invokeFun.startOffset
|
||||
endOffset = invokeFun.endOffset
|
||||
// Since box/unbox is done on declaration side in case of suspend function use the specified type
|
||||
@@ -200,7 +200,7 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
|
||||
|
||||
val factoryName = Name.identifier("${lambdaClass.name.asString()}\$factory")
|
||||
|
||||
val factoryDeclaration = buildFun {
|
||||
val factoryDeclaration = context.irFactory.buildFun {
|
||||
startOffset = expression.startOffset
|
||||
endOffset = expression.endOffset
|
||||
visibility = lambdaClass.visibility
|
||||
|
||||
+5
-4
@@ -6,9 +6,9 @@
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.getOrPut
|
||||
import org.jetbrains.kotlin.backend.common.lower.InnerClassesSupport
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
||||
import org.jetbrains.kotlin.backend.common.lower.InnerClassesSupport
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsMapping
|
||||
@@ -19,12 +19,13 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.util.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.dump
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class JsInnerClassesSupport(mapping: JsMapping) : InnerClassesSupport {
|
||||
class JsInnerClassesSupport(mapping: JsMapping, private val irFactory: IrFactory) : InnerClassesSupport {
|
||||
private val outerThisFieldSymbols = mapping.outerThisFieldSymbols
|
||||
private val innerClassConstructors = mapping.innerClassConstructors
|
||||
private val originalInnerClassPrimaryConstructorByClass = mapping.originalInnerClassPrimaryConstructorByClass
|
||||
@@ -36,7 +37,7 @@ class JsInnerClassesSupport(mapping: JsMapping) : InnerClassesSupport {
|
||||
val outerClass = innerClass.parent as? IrClass
|
||||
?: throw AssertionError("No containing class for inner class ${innerClass.dump()}")
|
||||
|
||||
buildField {
|
||||
irFactory.buildField {
|
||||
origin = InnerClassesSupport.FIELD_FOR_OUTER_THIS
|
||||
name = Name.identifier("\$this")
|
||||
type = outerClass.defaultType
|
||||
@@ -74,7 +75,7 @@ class JsInnerClassesSupport(mapping: JsMapping) : InnerClassesSupport {
|
||||
val irClass = oldConstructor.parent as IrClass
|
||||
val outerThisType = (irClass.parent as IrClass).defaultType
|
||||
|
||||
val newConstructor = buildConstructor(oldConstructor.descriptor) {
|
||||
val newConstructor = irFactory.buildConstructor(oldConstructor.descriptor) {
|
||||
updateFrom(oldConstructor)
|
||||
returnType = oldConstructor.returnType
|
||||
}.also {
|
||||
|
||||
+5
-3
@@ -12,14 +12,16 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.lower.irBlockBody
|
||||
import org.jetbrains.kotlin.backend.common.lower.irIfThen
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsCommonBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.buildField
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.types.makeNullable
|
||||
@@ -41,7 +43,7 @@ class ObjectDeclarationLowering(
|
||||
|
||||
val getInstanceFun = context.getOrCreateGetInstanceFunction(declaration)
|
||||
|
||||
val instanceField = buildField {
|
||||
val instanceField = context.irFactory.buildField {
|
||||
name = Name.identifier(declaration.name.asString() + "_instance")
|
||||
type = declaration.defaultType.makeNullable()
|
||||
isStatic = true
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : DeclarationTrans
|
||||
|
||||
if (function.visibility != Visibilities.PRIVATE || function.dispatchReceiverParameter == null) return null
|
||||
|
||||
val staticFunction = buildFun {
|
||||
val staticFunction = context.irFactory.buildFun {
|
||||
updateFrom(function)
|
||||
name = function.name
|
||||
returnType = function.returnType
|
||||
|
||||
+4
-4
@@ -58,7 +58,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
|
||||
private fun buildFactoryFunction(reference: IrPropertyReference): IrSimpleFunction {
|
||||
val property = reference.symbol.owner
|
||||
|
||||
val factoryDeclaration = buildFun {
|
||||
val factoryDeclaration = context.irFactory.buildFun {
|
||||
startOffset = reference.startOffset
|
||||
endOffset = reference.endOffset
|
||||
returnType = reference.type
|
||||
@@ -126,7 +126,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
|
||||
val supperAccessor =
|
||||
classifier.owner.declarations.filterIsInstance<IrSimpleFunction>().single { it.name.asString() == superName }
|
||||
|
||||
val function = buildFun {
|
||||
val function = context.irFactory.buildFun {
|
||||
startOffset = reference.startOffset
|
||||
endOffset = reference.endOffset
|
||||
returnType = supperAccessor.returnType
|
||||
@@ -239,7 +239,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
|
||||
|
||||
private fun buildLocalDelegateLambda(expression: IrLocalDelegatedPropertyReference): IrExpression {
|
||||
val delegatedVar = expression.delegate.owner
|
||||
val function = buildFun {
|
||||
val function = context.irFactory.buildFun {
|
||||
startOffset = expression.startOffset
|
||||
endOffset = expression.endOffset
|
||||
returnType = context.irBuiltIns.nothingType
|
||||
@@ -259,4 +259,4 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -220,7 +220,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
}
|
||||
|
||||
private fun buildNewCoroutineClass(function: IrSimpleFunction): IrClass =
|
||||
buildClass {
|
||||
context.irFactory.buildClass {
|
||||
startOffset = function.startOffset
|
||||
endOffset = function.endOffset
|
||||
origin = DECLARATION_ORIGIN_COROUTINE_IMPL
|
||||
@@ -242,7 +242,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
}
|
||||
}
|
||||
|
||||
return buildConstructor {
|
||||
return context.irFactory.buildConstructor {
|
||||
startOffset = function.startOffset
|
||||
endOffset = function.endOffset
|
||||
origin = DECLARATION_ORIGIN_COROUTINE_IMPL
|
||||
@@ -285,7 +285,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
}
|
||||
|
||||
private fun buildInvokeSuspendMethod(stateMachineFunction: IrSimpleFunction): IrSimpleFunction {
|
||||
val smFunction = buildFun {
|
||||
val smFunction = context.irFactory.buildFun {
|
||||
startOffset = function.startOffset
|
||||
endOffset = function.endOffset
|
||||
origin = DECLARATION_ORIGIN_COROUTINE_IMPL
|
||||
@@ -328,7 +328,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
// i.sn = pn
|
||||
// return i
|
||||
private fun buildCreateMethod(superCreateFunction: IrSimpleFunction?, constructor: IrConstructor): IrSimpleFunction =
|
||||
buildFun {
|
||||
context.irFactory.buildFun {
|
||||
startOffset = function.startOffset
|
||||
endOffset = function.endOffset
|
||||
origin = DECLARATION_ORIGIN_COROUTINE_IMPL
|
||||
@@ -515,7 +515,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
|
||||
fun IrClass.addField(name: Name, type: IrType, isMutable: Boolean): IrField {
|
||||
val klass = this
|
||||
return buildField {
|
||||
return factory.buildField {
|
||||
this.startOffset = klass.startOffset
|
||||
this.endOffset = klass.endOffset
|
||||
this.origin = DECLARATION_ORIGIN_COROUTINE_IMPL
|
||||
|
||||
+3
-3
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.util.constructedClass
|
||||
import org.jetbrains.kotlin.ir.util.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.JsName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface CrossModuleReferenceInfo {
|
||||
@@ -127,7 +127,7 @@ fun breakCrossModuleFieldAccess(
|
||||
fun IrField.getter(): IrSimpleFunction {
|
||||
return fieldToGetter.getOrPut(this) {
|
||||
val fieldName = name
|
||||
val getter = buildFun {
|
||||
val getter = context.irFactory.buildFun {
|
||||
name = Name.identifier("get-$fieldName")
|
||||
returnType = type
|
||||
}
|
||||
@@ -151,7 +151,7 @@ fun breakCrossModuleFieldAccess(
|
||||
fun IrField.setter(): IrSimpleFunction {
|
||||
return fieldToSetter.getOrPut(this) {
|
||||
val fieldName = name
|
||||
val setter = buildFun {
|
||||
val setter = context.irFactory.buildFun {
|
||||
name = Name.identifier("set-$fieldName")
|
||||
returnType = context.irBuiltIns.unitType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user