Add StackValue.put(InstructionAdapter) for convenience

This commit is contained in:
Alexander Udalov
2018-11-22 15:13:48 +01:00
parent f9be21c935
commit dd0b087b92
10 changed files with 28 additions and 27 deletions
@@ -456,7 +456,7 @@ class ExpressionCodegen(
override fun visitGetField(expression: IrGetField, data: BlockInfo): StackValue {
expression.markLineNumber(startOffset = true)
val value = generateFieldValue(expression, data)
value.put(value.type, mv)
value.put(mv)
return onStack(value.type)
}
@@ -511,7 +511,7 @@ class ExpressionCodegen(
private fun generateLocal(symbol: IrSymbol, type: Type): StackValue {
val index = findLocalIndex(symbol)
StackValue.local(index, type).put(type, mv)
StackValue.local(index, type).put(mv)
return onStack(type)
}
@@ -549,7 +549,7 @@ class ExpressionCodegen(
expression.markLineNumber(startOffset = true)
val value = expression.value
val type = expression.asmType
StackValue.constant(value, type).put(type, mv)
StackValue.constant(value, type).put(mv)
return expression.onStack
}
@@ -643,7 +643,7 @@ class ExpressionCodegen(
val elementKotlinType = classCodegen.context.builtIns.getArrayElementType(outType.toKotlinType()!!)
for ((i, element) in expression.elements.withIndex()) {
mv.dup()
StackValue.constant(i).put(Type.INT_TYPE, mv)
StackValue.constant(i).put(mv)
val rightSide = gen(element, elementType, data)
StackValue
.arrayElement(
@@ -822,7 +822,7 @@ class ExpressionCodegen(
val type = boxType(asmType)
generateIsCheck(mv, expression.typeOperand.toKotlinType(), type, state.languageVersionSettings.isReleaseCoroutines())
if (IrTypeOperator.NOT_INSTANCEOF == expression.operator) {
StackValue.not(StackValue.onStack(Type.BOOLEAN_TYPE)).put(Type.BOOLEAN_TYPE, mv)
StackValue.not(StackValue.onStack(Type.BOOLEAN_TYPE)).put(mv)
}
}
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.codegen.AsmUtil.boxType
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
@@ -38,7 +37,7 @@ object JavaClassProperty : IntrinsicMethod() {
val type = value.type
when {
type == Type.VOID_TYPE -> {
StackValue.unit().put(AsmTypes.UNIT_TYPE, v)
StackValue.unit().put(v)
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false)
}
isPrimitive(type) -> {
@@ -17,8 +17,10 @@
package org.jetbrains.kotlin.backend.jvm.intrinsics
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
import org.jetbrains.kotlin.psi.KtPrefixExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
@@ -28,7 +30,7 @@ import org.jetbrains.org.objectweb.asm.Type
class Not : IntrinsicMethod() {
override fun toCallable(expression: IrMemberAccessExpression, signature: JvmMethodSignature, context: JvmBackendContext): IrIntrinsicFunction {
return IrIntrinsicFunction.create(expression, signature, context) {
StackValue.not(StackValue.onStack(Type.BOOLEAN_TYPE)).put(Type.BOOLEAN_TYPE, it)
StackValue.not(StackValue.onStack(Type.BOOLEAN_TYPE)).put(it)
}
}