[JS IR BE] Create temporary variables with wrapped descriptors.
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@ class NullableFieldsDeclarationLowering(val backendContext: CommonBackendContext
|
||||
getter.body = IrBlockBodyImpl(startOffset, endOffset) {
|
||||
val irBuilder = backendContext.createIrBuilder(getter.symbol, startOffset, endOffset)
|
||||
irBuilder.run {
|
||||
val resultVar = scope.createTemporaryVariable(
|
||||
val resultVar = scope.createTmpVariable(
|
||||
irGetField(getter.dispatchReceiverParameter?.let { irGet(it) }, backingField)
|
||||
)
|
||||
resultVar.parent = getter
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ class ReturnableBlockTransformer(val context: CommonBackendContext, val containe
|
||||
val scopeSymbol = currentScope?.scope?.scopeOwnerSymbol ?: containerSymbol
|
||||
val builder = context.createIrBuilder(scopeSymbol!!)
|
||||
val variable by lazy {
|
||||
builder.scope.createTemporaryVariableDeclaration(expression.type, "tmp\$ret\$${labelCnt++}", true)
|
||||
builder.scope.createTmpVariable(expression.type, "tmp\$ret\$${labelCnt++}", true)
|
||||
}
|
||||
|
||||
val loop by lazy {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.ir.builders
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||
@@ -56,6 +57,34 @@ fun <T : IrElement> IrStatementsBuilder<T>.createTmpVariable(
|
||||
return variable
|
||||
}
|
||||
|
||||
fun Scope.createTmpVariable(
|
||||
irType: IrType,
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false,
|
||||
initializer: IrExpression? = null,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
|
||||
startOffset: Int = UNDEFINED_OFFSET,
|
||||
endOffset: Int = UNDEFINED_OFFSET
|
||||
): IrVariable {
|
||||
val descriptor = WrappedVariableDescriptor()
|
||||
val symbol = IrVariableSymbolImpl(descriptor)
|
||||
return IrVariableImpl(
|
||||
startOffset,
|
||||
endOffset,
|
||||
origin,
|
||||
symbol,
|
||||
Name.identifier(nameHint ?: "tmp"),
|
||||
irType,
|
||||
isMutable,
|
||||
isConst = false,
|
||||
isLateinit = false
|
||||
).apply {
|
||||
this.initializer = initializer
|
||||
parent = getLocalDeclarationParent()
|
||||
descriptor.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun Scope.createTmpVariable(
|
||||
irExpression: IrExpression,
|
||||
nameHint: String? = null,
|
||||
|
||||
Reference in New Issue
Block a user