Clean intr
This commit is contained in:
@@ -25,27 +25,19 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
|||||||
public class CompareTo : IntrinsicMethod() {
|
public class CompareTo : IntrinsicMethod() {
|
||||||
|
|
||||||
private fun genInvoke(type: Type?, v: InstructionAdapter) {
|
private fun genInvoke(type: Type?, v: InstructionAdapter) {
|
||||||
if (type == Type.INT_TYPE) {
|
when (type) {
|
||||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(II)I", false)
|
Type.INT_TYPE -> v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(II)I", false)
|
||||||
}
|
Type.LONG_TYPE -> v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(JJ)I", false)
|
||||||
else if (type == Type.LONG_TYPE) {
|
Type.FLOAT_TYPE -> v.invokestatic("java/lang/Float", "compare", "(FF)I", false)
|
||||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(JJ)I", false)
|
Type.DOUBLE_TYPE -> v.invokestatic("java/lang/Double", "compare", "(DD)I", false)
|
||||||
}
|
else -> throw UnsupportedOperationException()
|
||||||
else if (type == Type.FLOAT_TYPE) {
|
|
||||||
v.invokestatic("java/lang/Float", "compare", "(FF)I", false)
|
|
||||||
}
|
|
||||||
else if (type == Type.DOUBLE_TYPE) {
|
|
||||||
v.invokestatic("java/lang/Double", "compare", "(DD)I", false)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw UnsupportedOperationException()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toCallable(method: CallableMethod): Callable {
|
override fun toCallable(method: CallableMethod): Callable {
|
||||||
val argumentType = comparisonOperandType(method.thisType ?: method.receiverType, method.argumentTypes.first())
|
val parameterType = comparisonOperandType(method.thisType ?: method.receiverType, method.parameterTypes.single())
|
||||||
return binaryIntrinsic(method.returnType, argumentType, argumentType, null) {
|
return binaryIntrinsic(method.returnType, parameterType, parameterType, null) {
|
||||||
genInvoke(argumentType, it)
|
genInvoke(parameterType, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,36 +30,18 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
|||||||
|
|
||||||
public class IteratorNext : IntrinsicMethod() {
|
public class IteratorNext : IntrinsicMethod() {
|
||||||
|
|
||||||
protected fun getIteratorName(returnType: Type): String {
|
private fun getIteratorName(returnType: Type): String {
|
||||||
val name: String
|
return when (returnType) {
|
||||||
if (returnType == Type.CHAR_TYPE) {
|
Type.CHAR_TYPE -> "Char"
|
||||||
name = "Char"
|
Type.BOOLEAN_TYPE -> "Boolean"
|
||||||
|
Type.BYTE_TYPE -> "Byte"
|
||||||
|
Type.SHORT_TYPE -> "Short"
|
||||||
|
Type.INT_TYPE -> "Int"
|
||||||
|
Type.LONG_TYPE -> "Long"
|
||||||
|
Type.FLOAT_TYPE -> "Float"
|
||||||
|
Type.DOUBLE_TYPE -> "Double"
|
||||||
|
else -> throw UnsupportedOperationException("Can't get correct name for iterator from type: " + returnType)
|
||||||
}
|
}
|
||||||
else if (returnType == Type.BOOLEAN_TYPE) {
|
|
||||||
name = "Boolean"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.BYTE_TYPE) {
|
|
||||||
name = "Byte"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.SHORT_TYPE) {
|
|
||||||
name = "Short"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.INT_TYPE) {
|
|
||||||
name = "Int"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.LONG_TYPE) {
|
|
||||||
name = "Long"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.FLOAT_TYPE) {
|
|
||||||
name = "Float"
|
|
||||||
}
|
|
||||||
else if (returnType == Type.DOUBLE_TYPE) {
|
|
||||||
name = "Double"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw UnsupportedOperationException("Can't get correct name for iterator from type: " + returnType)
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.codegen.intrinsics
|
package org.jetbrains.kotlin.codegen.intrinsics
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codegen.Callable
|
import org.jetbrains.kotlin.codegen.Callable
|
||||||
|
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||||
import org.jetbrains.kotlin.codegen.StackValue
|
import org.jetbrains.kotlin.codegen.StackValue
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
@@ -40,8 +41,7 @@ public class RangeTo : IntrinsicMethod() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
override fun toCallable(method: CallableMethod): Callable {
|
||||||
val method = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
|
||||||
val argType = nameToPrimitive(method.returnType.getInternalName().substringAfter("kotlin/").substringBefore("Range"))
|
val argType = nameToPrimitive(method.returnType.getInternalName().substringAfter("kotlin/").substringBefore("Range"))
|
||||||
return object : IntrinsicCallable(method.returnType, method.valueParameterTypes.map { argType }, nullOr(method.thisType, argType), nullOr(method.receiverType, argType)) {
|
return object : IntrinsicCallable(method.returnType, method.valueParameterTypes.map { argType }, nullOr(method.thisType, argType), nullOr(method.receiverType, argType)) {
|
||||||
override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) {
|
override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) {
|
||||||
|
|||||||
Reference in New Issue
Block a user