Clean intr
This commit is contained in:
@@ -25,27 +25,19 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
public class CompareTo : IntrinsicMethod() {
|
||||
|
||||
private fun genInvoke(type: Type?, v: InstructionAdapter) {
|
||||
if (type == Type.INT_TYPE) {
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(II)I", false)
|
||||
}
|
||||
else if (type == Type.LONG_TYPE) {
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "compare", "(JJ)I", false)
|
||||
}
|
||||
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()
|
||||
when (type) {
|
||||
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)
|
||||
Type.FLOAT_TYPE -> v.invokestatic("java/lang/Float", "compare", "(FF)I", false)
|
||||
Type.DOUBLE_TYPE -> v.invokestatic("java/lang/Double", "compare", "(DD)I", false)
|
||||
else -> throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val argumentType = comparisonOperandType(method.thisType ?: method.receiverType, method.argumentTypes.first())
|
||||
return binaryIntrinsic(method.returnType, argumentType, argumentType, null) {
|
||||
genInvoke(argumentType, it)
|
||||
val parameterType = comparisonOperandType(method.thisType ?: method.receiverType, method.parameterTypes.single())
|
||||
return binaryIntrinsic(method.returnType, parameterType, parameterType, null) {
|
||||
genInvoke(parameterType, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,36 +30,18 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
public class IteratorNext : IntrinsicMethod() {
|
||||
|
||||
protected fun getIteratorName(returnType: Type): String {
|
||||
val name: String
|
||||
if (returnType == Type.CHAR_TYPE) {
|
||||
name = "Char"
|
||||
private fun getIteratorName(returnType: Type): String {
|
||||
return when (returnType) {
|
||||
Type.CHAR_TYPE -> "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
|
||||
|
||||
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.descriptors.FunctionDescriptor
|
||||
@@ -40,8 +41,7 @@ public class RangeTo : IntrinsicMethod() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val method = codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext())
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
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)) {
|
||||
override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) {
|
||||
|
||||
Reference in New Issue
Block a user