[Wasm] Copy property reference lowering from K/N
This commit is contained in:
@@ -179,6 +179,12 @@ private val sharedVariablesLoweringPhase = makeWasmModulePhase(
|
||||
description = "Box captured mutable variables"
|
||||
)
|
||||
|
||||
private val propertyReferenceLowering = makeWasmModulePhase(
|
||||
::WasmPropertyReferenceLowering,
|
||||
name = "WasmPropertyReferenceLowering",
|
||||
description = "Lower property references"
|
||||
)
|
||||
|
||||
private val callableReferencePhase = makeWasmModulePhase(
|
||||
::WasmCallableReferenceLowering,
|
||||
name = "WasmCallableReferenceLowering",
|
||||
@@ -454,6 +460,7 @@ val wasmPhases = NamedCompilerPhase(
|
||||
enumClassConstructorBodyLoweringPhase then
|
||||
|
||||
sharedVariablesLoweringPhase then
|
||||
propertyReferenceLowering then
|
||||
callableReferencePhase then
|
||||
localDelegatedPropertiesLoweringPhase then
|
||||
localDeclarationsLoweringPhase then
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.defaultType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.typeWith
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -146,6 +148,21 @@ class WasmSymbols(
|
||||
val exportString = getInternalFunction("exportString")
|
||||
val unsafeGetScratchRawMemory = getInternalFunction("unsafeGetScratchRawMemory")
|
||||
|
||||
// KProperty implementations
|
||||
val kLocalDelegatedPropertyImpl: IrClassSymbol = this.getInternalClass("KLocalDelegatedPropertyImpl")
|
||||
val kLocalDelegatedMutablePropertyImpl: IrClassSymbol = this.getInternalClass("KLocalDelegatedMutablePropertyImpl")
|
||||
val kProperty0Impl: IrClassSymbol = this.getInternalClass("KProperty0Impl")
|
||||
val kProperty1Impl: IrClassSymbol = this.getInternalClass("KProperty1Impl")
|
||||
val kProperty2Impl: IrClassSymbol = this.getInternalClass("KProperty2Impl")
|
||||
val kMutableProperty0Impl: IrClassSymbol = this.getInternalClass("KMutableProperty0Impl")
|
||||
val kMutableProperty1Impl: IrClassSymbol = this.getInternalClass("KMutableProperty1Impl")
|
||||
val kMutableProperty2Impl: IrClassSymbol = this.getInternalClass("KMutableProperty2Impl")
|
||||
val kMutableProperty0: IrClassSymbol = getIrClass(FqName("kotlin.reflect.KMutableProperty0"))
|
||||
val kMutableProperty1: IrClassSymbol = getIrClass(FqName("kotlin.reflect.KMutableProperty1"))
|
||||
val kMutableProperty2: IrClassSymbol = getIrClass(FqName("kotlin.reflect.KMutableProperty2"))
|
||||
|
||||
val kTypeStub = getInternalFunction("kTypeStub")
|
||||
|
||||
private val functionNInterfaces = (0..22).map { arity ->
|
||||
getIrClass(FqName("kotlin.wasm.internal.Function$arity"))
|
||||
}
|
||||
@@ -187,4 +204,8 @@ class WasmSymbols(
|
||||
private fun getInternalFunction(name: String) = getFunction(name, wasmInternalPackage)
|
||||
|
||||
private fun getIrClass(fqName: FqName): IrClassSymbol = symbolTable.referenceClass(getClass(fqName))
|
||||
private fun getInternalClass(name: String): IrClassSymbol = getIrClass(FqName("kotlin.wasm.internal.$name"))
|
||||
fun getKFunctionType(type: IrType, list: List<IrType>): IrType {
|
||||
return irBuiltIns.functionN(list.size).typeWith(list + type)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user