Fix type of increment/decrement for array element.
Minor cleanup.
This commit is contained in:
committed by
Dmitry Petrov
parent
64d630faa3
commit
2b6171057e
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.IrVariableValue
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.IrVariableLValue
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.IrValue
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.createRematerializableValue
|
||||
import org.jetbrains.kotlin.psi2ir.toExpectedType
|
||||
@@ -51,7 +51,7 @@ class IrCallGenerator(val irStatementGenerator: IrStatementGenerator) : IrGenera
|
||||
}
|
||||
|
||||
val irTmpVar = temporaryVariableFactory.createTemporaryVariable(irExpression, nameHint)
|
||||
putValue(ktExpression, IrVariableValue(irTmpVar))
|
||||
putValue(ktExpression, IrVariableLValue(irTmpVar))
|
||||
return irTmpVar
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class IrCallGenerator(val irStatementGenerator: IrStatementGenerator) : IrGenera
|
||||
}
|
||||
|
||||
val irTmpVar = temporaryVariableFactory.createTemporaryVariable(irExpression, valueParameterDescriptor.name.asString())
|
||||
putValue(valueParameterDescriptor, IrVariableValue(irTmpVar))
|
||||
putValue(valueParameterDescriptor, IrVariableLValue(irTmpVar))
|
||||
return irTmpVar
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -223,10 +223,10 @@ class IrOperatorExpressionGenerator(val irStatementGenerator: IrStatementGenerat
|
||||
if (descriptor.isDelegated)
|
||||
TODO("Delegated local variable")
|
||||
else
|
||||
IrVariableValue(ktLeft.startOffset, ktLeft.endOffset, descriptor, irOperator)
|
||||
IrVariableLValue(ktLeft.startOffset, ktLeft.endOffset, descriptor, irOperator)
|
||||
is PropertyDescriptor ->
|
||||
IrCallGenerator(irStatementGenerator).run {
|
||||
IrPropertyLValueValue(
|
||||
IrPropertyLValue(
|
||||
ktLeft, irOperator, descriptor,
|
||||
generateReceiver(ktLeft, resolvedCall.dispatchReceiver, descriptor.dispatchReceiverParameter),
|
||||
generateReceiver(ktLeft, resolvedCall.extensionReceiver, descriptor.extensionReceiverParameter),
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.psi2ir.deparenthesize
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.IrVariableValue
|
||||
import org.jetbrains.kotlin.psi2ir.generators.values.IrVariableLValue
|
||||
import org.jetbrains.kotlin.psi2ir.toExpectedType
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
@@ -78,7 +78,7 @@ class IrStatementGenerator(
|
||||
irBlock.addStatement(irTmpInitializer)
|
||||
|
||||
val irCallGenerator = IrCallGenerator(this)
|
||||
irCallGenerator.putValue(ktInitializer, IrVariableValue(irTmpInitializer))
|
||||
irCallGenerator.putValue(ktInitializer, IrVariableLValue(irTmpInitializer))
|
||||
|
||||
for ((index, ktEntry) in multiDeclaration.entries.withIndex()) {
|
||||
val componentResolvedCall = getOrFail(BindingContext.COMPONENT_RESOLVED_CALL, ktEntry)
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ class IrIndexedLValue(
|
||||
irBlock.addStatement(irTmp)
|
||||
|
||||
callGenerator.putValue(indexedSetCall.resultingDescriptor.valueParameters.last(),
|
||||
IrVariableValue(irTmp))
|
||||
IrVariableLValue(irTmp))
|
||||
|
||||
irBlock.addStatement(callGenerator.generateCall(ktArrayAccessExpression, indexedSetCall, irOperator))
|
||||
|
||||
@@ -120,7 +120,7 @@ class IrIndexedLValue(
|
||||
|
||||
private fun createDesugaredBlock(call: ResolvedCall<*>, hasResult: Boolean, operator: IrOperator?): IrBlockExpressionImpl {
|
||||
return IrBlockExpressionImpl(ktArrayAccessExpression.startOffset, ktArrayAccessExpression.endOffset,
|
||||
call.resultingDescriptor.returnType,
|
||||
if (hasResult) type else call.resultingDescriptor.returnType,
|
||||
hasResult, operator)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.psi2ir.toExpectedType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrPropertyLValueValue(
|
||||
class IrPropertyLValue(
|
||||
val ktElement: KtElement,
|
||||
val irOperator: IrOperator?,
|
||||
val descriptor: PropertyDescriptor,
|
||||
@@ -37,8 +37,8 @@ class IrPropertyLValueValue(
|
||||
|
||||
private fun IrPropertyAccessExpression.setReceivers() =
|
||||
apply {
|
||||
dispatchReceiver = this@IrPropertyLValueValue.dispatchReceiver
|
||||
extensionReceiver = this@IrPropertyLValueValue.extensionReceiver
|
||||
dispatchReceiver = this@IrPropertyLValue.dispatchReceiver
|
||||
extensionReceiver = this@IrPropertyLValue.extensionReceiver
|
||||
}
|
||||
|
||||
override fun load(): IrExpression =
|
||||
+1
-1
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.ir.expressions.IrSetVariableExpressionImpl
|
||||
import org.jetbrains.kotlin.psi2ir.toExpectedType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
class IrVariableValue(
|
||||
class IrVariableLValue(
|
||||
val startOffset: Int,
|
||||
val endOffset: Int,
|
||||
val descriptor: VariableDescriptor,
|
||||
+26
-28
@@ -50,32 +50,30 @@ IrFile /incrementDecrement.kt
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false operator=null
|
||||
VAR val a1: kotlin.Int
|
||||
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Int
|
||||
BLOCK type=kotlin.Unit hasResult=true operator=PREFIX_INCR
|
||||
VAR val tmp0_array: kotlin.IntArray
|
||||
GET_PROPERTY .arr type=kotlin.IntArray operator=null
|
||||
VAR val tmp1: kotlin.Int
|
||||
CALL .inc type=kotlin.Int operator=PREFIX_INCR
|
||||
$this: CALL .get type=kotlin.Int operator=PREFIX_INCR
|
||||
$this: GET_VAR tmp0_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=PREFIX_INCR
|
||||
$this: GET_VAR tmp0_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
value: GET_VAR tmp1 type=kotlin.Int operator=null
|
||||
GET_VAR tmp1 type=kotlin.Int operator=null
|
||||
BLOCK type=kotlin.Int hasResult=true operator=PREFIX_INCR
|
||||
VAR val tmp0_array: kotlin.IntArray
|
||||
GET_PROPERTY .arr type=kotlin.IntArray operator=null
|
||||
VAR val tmp1: kotlin.Int
|
||||
CALL .inc type=kotlin.Int operator=PREFIX_INCR
|
||||
$this: CALL .get type=kotlin.Int operator=PREFIX_INCR
|
||||
$this: GET_VAR tmp0_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=PREFIX_INCR
|
||||
$this: GET_VAR tmp0_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
value: GET_VAR tmp1 type=kotlin.Int operator=null
|
||||
GET_VAR tmp1 type=kotlin.Int operator=null
|
||||
VAR val a2: kotlin.Int
|
||||
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Int
|
||||
BLOCK type=kotlin.Unit hasResult=true operator=PREFIX_DECR
|
||||
VAR val tmp2_array: kotlin.IntArray
|
||||
GET_PROPERTY .arr type=kotlin.IntArray operator=null
|
||||
VAR val tmp3: kotlin.Int
|
||||
CALL .dec type=kotlin.Int operator=PREFIX_DECR
|
||||
$this: CALL .get type=kotlin.Int operator=PREFIX_DECR
|
||||
$this: GET_VAR tmp2_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=PREFIX_DECR
|
||||
$this: GET_VAR tmp2_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
value: GET_VAR tmp3 type=kotlin.Int operator=null
|
||||
GET_VAR tmp3 type=kotlin.Int operator=null
|
||||
BLOCK type=kotlin.Int hasResult=true operator=PREFIX_DECR
|
||||
VAR val tmp2_array: kotlin.IntArray
|
||||
GET_PROPERTY .arr type=kotlin.IntArray operator=null
|
||||
VAR val tmp3: kotlin.Int
|
||||
CALL .dec type=kotlin.Int operator=PREFIX_DECR
|
||||
$this: CALL .get type=kotlin.Int operator=PREFIX_DECR
|
||||
$this: GET_VAR tmp2_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
CALL .set type=kotlin.Unit operator=PREFIX_DECR
|
||||
$this: GET_VAR tmp2_array type=kotlin.IntArray operator=null
|
||||
index: LITERAL Int type=kotlin.Int value='0'
|
||||
value: GET_VAR tmp3 type=kotlin.Int operator=null
|
||||
GET_VAR tmp3 type=kotlin.Int operator=null
|
||||
|
||||
Reference in New Issue
Block a user