Fix VerifyError on android with 'inv' operation on Byte and Short

This commit is contained in:
Mikhael Bogdanov
2016-11-15 12:20:07 +01:00
parent 5b44343d15
commit 63fed20249
@@ -19,19 +19,21 @@ package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType
import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.org.objectweb.asm.Type
class Inv : IntrinsicMethod() {
override fun toCallable(method: CallableMethod): Callable {
val type = numberFunctionOperandType(method.returnType)
return createUnaryIntrinsicCallable(method, newThisType = type) {
val intermediateResultType = numberFunctionOperandType(method.returnType)
return createUnaryIntrinsicCallable(method) {
if (returnType == Type.LONG_TYPE) {
it.lconst(-1)
}
else {
it.iconst(-1)
}
it.xor(returnType)
it.xor(intermediateResultType)
StackValue.coerce(intermediateResultType, returnType, it)
}
}
}