Review fix: unify irTemporary variants

This commit is contained in:
Georgy Bronnikov
2020-10-21 13:24:23 +03:00
parent 8e331c8afe
commit b7a07fdf03
7 changed files with 14 additions and 41 deletions
@@ -271,7 +271,7 @@ class IrSparseArrayParcelSerializer(
) : IrParcelSerializer {
override fun AndroidIrBuilder.readParcel(parcel: IrValueDeclaration): IrExpression =
irBlock {
val remainingSizeTemporary = irTemporaryVar(parcelReadInt(irGet(parcel)))
val remainingSizeTemporary = irTemporary(parcelReadInt(irGet(parcel)), isMutable = true)
val sparseArrayConstructor = sparseArrayClass.constructors.first { irConstructor ->
irConstructor.valueParameters.size == 1 && irConstructor.valueParameters.single().type.isInt()
@@ -125,7 +125,7 @@ fun IrClass.isSubclassOfFqName(fqName: String): Boolean =
fqNameWhenAvailable?.asString() == fqName || superTypes.any { it.erasedUpperBound.isSubclassOfFqName(fqName) }
inline fun IrBlockBuilder.forUntil(upperBound: IrExpression, loopBody: IrBlockBuilder.(IrValueDeclaration) -> Unit) {
val indexTemporary = irTemporaryVar(irInt(0))
val indexTemporary = irTemporary(irInt(0), isMutable = true)
+irWhile().apply {
condition = irNotEquals(irGet(indexTemporary), upperBound)
body = irBlock {
@@ -367,23 +367,19 @@ open class SerializerIrGenerator(
val localSerialDesc = irTemporary(irGet(descriptorGetterSymbol.owner.returnType, irThis(), descriptorGetterSymbol), "desc")
// workaround due to unavailability of labels (KT-25386)
val flagVar = irTemporaryVar(irBoolean(true), "flag")
val flagVar = irTemporary(irBoolean(true), "flag", isMutable = true)
val indexVar = irTemporaryVar(irInt(0), "index")
val indexVar = irTemporary(irInt(0), "index", isMutable = true)
// calculating bit mask vars
val blocksCnt = serializableProperties.bitMaskSlotCount()
// var bitMask0 = 0, bitMask1 = 0...
val bitMasks = (0 until blocksCnt).map { irTemporaryVar(irInt(0), "bitMask$it") }
val bitMasks = (0 until blocksCnt).map { irTemporary(irInt(0), "bitMask$it", isMutable = true) }
// var local0 = null, local1 = null ...
val localProps = serializableProperties.mapIndexed { i, prop ->
val (expr, type) = defaultValueAndType(prop)
irTemporaryVar(
expr,
"local$i",
type
)
irTemporary(expr, "local$i", type, isMutable = true)
}
//input = input.beginStructure(...)
@@ -292,7 +292,7 @@ class IrSparseArrayParcelSerializer(
) : IrParcelSerializer {
override fun AndroidIrBuilder.readParcel(parcel: IrValueDeclaration): IrExpression {
return irBlock {
val remainingSizeTemporary = irTemporaryVar(parcelReadInt(irGet(parcel)))
val remainingSizeTemporary = irTemporary(parcelReadInt(irGet(parcel)), isMutable = true)
val sparseArrayConstructor = sparseArrayClass.constructors.first { irConstructor ->
irConstructor.valueParameters.size == 1 && irConstructor.valueParameters.single().type.isInt()
@@ -134,7 +134,7 @@ fun IrClass.isSubclassOfFqName(fqName: String): Boolean {
}
inline fun IrBlockBuilder.forUntil(upperBound: IrExpression, loopBody: IrBlockBuilder.(IrValueDeclaration) -> Unit) {
val indexTemporary = irTemporaryVar(irInt(0))
val indexTemporary = irTemporary(irInt(0), isMutable = true)
+irWhile().apply {
condition = irNotEquals(irGet(indexTemporary), upperBound)
body = irBlock {