JS IR: apply forLoopsLowering
Replaced createTemporaryVariable usages with createTmpVariables. The latter doesn't rely on KotlinType's. Using KotlinType with JS_IR backend causes runtime excpetions, as some expected descriptor API is not implemented, because it avoids descriptors as much as possible.
This commit is contained in:
+5
-5
@@ -132,9 +132,9 @@ internal class UntilHandler(private val context: CommonBackendContext, private v
|
||||
var additionalVariables = emptyList<IrVariable>()
|
||||
if (untilArg.canHaveSideEffects) {
|
||||
if (receiverValue.canHaveSideEffects) {
|
||||
receiverValueVar = scope.createTemporaryVariable(receiverValue, nameHint = "untilReceiverValue")
|
||||
receiverValueVar = scope.createTmpVariable(receiverValue, nameHint = "untilReceiverValue")
|
||||
}
|
||||
untilArgVar = scope.createTemporaryVariable(untilArgCasted, nameHint = "untilArg")
|
||||
untilArgVar = scope.createTmpVariable(untilArgCasted, nameHint = "untilArg")
|
||||
additionalVariables = listOfNotNull(receiverValueVar, untilArgVar)
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ internal class DefaultProgressionHandler(private val context: CommonBackendConte
|
||||
override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? =
|
||||
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
|
||||
// Directly use the `first/last/step` properties of the progression.
|
||||
val progression = scope.createTemporaryVariable(expression, nameHint = "progression")
|
||||
val progression = scope.createTmpVariable(expression, nameHint = "progression")
|
||||
val progressionClass = progression.type.getClass()!!
|
||||
val first = irCall(progressionClass.symbol.getPropertyGetter("first")!!).apply {
|
||||
dispatchReceiver = irGet(progression)
|
||||
@@ -616,7 +616,7 @@ internal abstract class IndexedGetIterationHandler(
|
||||
//
|
||||
// This also ensures that the semantics of re-assignment of array variables used in the loop is consistent with the semantics
|
||||
// proposed in https://youtrack.jetbrains.com/issue/KT-21354.
|
||||
val objectVariable = scope.createTemporaryVariable(
|
||||
val objectVariable = scope.createTmpVariable(
|
||||
expression, nameHint = "indexedObject"
|
||||
)
|
||||
|
||||
@@ -747,7 +747,7 @@ internal class DefaultIterableHandler(private val context: CommonBackendContext)
|
||||
dispatchReceiver = expression
|
||||
}
|
||||
IterableHeaderInfo(
|
||||
scope.createTemporaryVariable(iterator, nameHint = "iterator")
|
||||
scope.createTmpVariable(iterator, nameHint = "iterator")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.backend.common.lower.loops
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
|
||||
import org.jetbrains.kotlin.ir.builders.createTmpVariable
|
||||
import org.jetbrains.kotlin.ir.builders.irGet
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||
@@ -89,7 +90,7 @@ internal val IrExpression.constLongValue: Long?
|
||||
*/
|
||||
internal fun DeclarationIrBuilder.createTemporaryVariableIfNecessary(expression: IrExpression, nameHint: String? = null) =
|
||||
if (expression.canHaveSideEffects) {
|
||||
scope.createTemporaryVariable(expression, nameHint = nameHint).let { Pair(it, irGet(it)) }
|
||||
scope.createTmpVariable(expression, nameHint = nameHint).let { Pair(it, irGet(it)) }
|
||||
} else {
|
||||
Pair(null, expression)
|
||||
}
|
||||
Reference in New Issue
Block a user