From 31c4aaac4d1ac23166eb2098bc71672f77e8f4e0 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Mon, 6 Apr 2015 18:55:33 +0300 Subject: [PATCH] Rename thisType and receiverType to dispatch and extension ones --- .../src/org/jetbrains/kotlin/codegen/Callable.kt | 6 +++--- .../org/jetbrains/kotlin/codegen/CallableMethod.kt | 6 +++--- .../jetbrains/kotlin/codegen/ExpressionCodegen.java | 2 +- .../kotlin/codegen/ImplementationBodyCodegen.java | 2 +- .../src/org/jetbrains/kotlin/codegen/StackValue.java | 6 +++--- .../kotlin/codegen/TailRecursionCodegen.java | 10 +++++----- .../jetbrains/kotlin/codegen/intrinsics/ArraySet.kt | 4 ++-- .../jetbrains/kotlin/codegen/intrinsics/CompareTo.kt | 2 +- .../jetbrains/kotlin/codegen/intrinsics/Equals.kt | 2 +- .../jetbrains/kotlin/codegen/intrinsics/HashCode.kt | 2 +- .../kotlin/codegen/intrinsics/IntrinsicCallable.kt | 12 ++++++------ .../jetbrains/kotlin/codegen/intrinsics/RangeTo.kt | 2 +- .../jetbrains/kotlin/codegen/intrinsics/ToString.kt | 2 +- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt index 0dc7b2629c1..2642240360b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/Callable.kt @@ -28,15 +28,15 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; public trait Callable { public val owner: Type - public val thisType: Type? + public val dispatchReceiverType: Type? - public val receiverType: Type? + public val extensionReceiverType: Type? public val generateCalleeType: Type? public val valueParameterTypes: List - public val argumentTypes: Array + public val parameterTypes: Array public val returnType: Type diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt index a1223770960..71170f11140 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallableMethod.kt @@ -38,7 +38,7 @@ import org.jetbrains.org.objectweb.asm.util.Printer; import java.util.ArrayList; -public class CallableMethod(override val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, override val thisType: Type?, override val receiverType: Type?, override val generateCalleeType: Type?) : Callable { +public class CallableMethod(override val owner: Type, private val defaultImplOwner: Type?, private val defaultImplParam: Type?, private val signature: JvmMethodSignature, private val invokeOpcode: Int, override val dispatchReceiverType: Type?, override val extensionReceiverType: Type?, override val generateCalleeType: Type?) : Callable { public fun getValueParameters(): List { return signature.getValueParameters() @@ -51,7 +51,7 @@ public class CallableMethod(override val owner: Type, private val defaultImplOwn return signature.getAsmMethod() } - override val argumentTypes: Array + override val parameterTypes: Array get() = getAsmMethod().getArgumentTypes() @@ -72,7 +72,7 @@ public class CallableMethod(override val owner: Type, private val defaultImplOwn val method = getAsmMethod(); val desc = JetTypeMapper.getDefaultDescriptor(method, if (invokeOpcode == INVOKESTATIC) null else defaultImplParam.getDescriptor(), - receiverType != null); + extensionReceiverType != null); if ("".equals(method.getName())) { v.aconst(null) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 82e18e8381a..88c704db0f6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3595,7 +3595,7 @@ public class ExpressionCodegen extends JetVisitor implem Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall); Callable callableMethod = resolveToCallableMethod(operationDescriptor, false, context); - Type[] argumentTypes = callableMethod.getArgumentTypes(); + Type[] argumentTypes = callableMethod.getParameterTypes(); StackValue collectionElementReceiver = createCollectionElementReceiver(expression, receiver, array, arrayType, operationDescriptor, isGetter, resolvedGetCall, resolvedSetCall, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 808d5bf3688..3c9b703d0af 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -954,7 +954,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { } } - for (Type argType : callableMethod.getArgumentTypes()) { + for (Type argType : callableMethod.getParameterTypes()) { iv.load(reg, argType); reg += argType.getSize(); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index c7d49f9b755..2dc6fda9d0d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -952,7 +952,7 @@ public abstract class StackValue { throw new UnsupportedOperationException("no setter specified"); } - Type[] argumentTypes = setter.getArgumentTypes(); + Type[] argumentTypes = setter.getParameterTypes(); coerce(topOfStackType, argumentTypes[argumentTypes.length - 1], v); setter.invokeWithNotNullAssertion(v, state, resolvedSetCall); Type returnType = setter.getReturnType(); @@ -1282,14 +1282,14 @@ public abstract class StackValue { ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter(); if (extensionReceiver != null) { - return callableMethod != null ? callableMethod.getReceiverType() : typeMapper.mapType(extensionReceiver.getType()); + return callableMethod != null ? callableMethod.getExtensionReceiverType() : typeMapper.mapType(extensionReceiver.getType()); } else if (dispatchReceiver != null) { if (AnnotationsPackage.isPlatformStaticInObjectOrClass(descriptor)) { return Type.VOID_TYPE; } else { - return callableMethod != null ? callableMethod.getThisType() : typeMapper.mapType(dispatchReceiver.getType()); + return callableMethod != null ? callableMethod.getDispatchReceiverType() : typeMapper.mapType(dispatchReceiver.getType()); } } else if (isLocalFunCall(callableMethod)) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java index f8877650b17..323085f0c95 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/TailRecursionCodegen.java @@ -74,18 +74,18 @@ public class TailRecursionCodegen { throw new IllegalStateException("Failed to arrange value arguments by index: " + fd); } assignParameterValues(fd, callable, arguments); - if (callable.getReceiverType() != null) { + if (callable.getExtensionReceiverType() != null) { if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) { StackValue expression = context.getReceiverExpression(codegen.typeMapper); - expression.store(StackValue.onStack(callable.getReceiverType()), v, true); + expression.store(StackValue.onStack(callable.getExtensionReceiverType()), v, true); } else { - AsmUtil.pop(v, callable.getReceiverType()); + AsmUtil.pop(v, callable.getExtensionReceiverType()); } } - if (callable.getThisType() != null) { - AsmUtil.pop(v, callable.getThisType()); + if (callable.getDispatchReceiverType() != null) { + AsmUtil.pop(v, callable.getDispatchReceiverType()); } v.goTo(context.getMethodStartLabel()); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt index c45642b411e..10e1e379bf1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ArraySet.kt @@ -25,8 +25,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter public class ArraySet : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - val type = correctElementType(method.thisType) - return object: IntrinsicCallable(Type.VOID_TYPE, listOf(Type.INT_TYPE, type), method.thisType, method.receiverType) { + val type = correctElementType(method.dispatchReceiverType) + return object: IntrinsicCallable(Type.VOID_TYPE, listOf(Type.INT_TYPE, type), method.dispatchReceiverType, method.extensionReceiverType) { override fun invokeIntrinsic(v: InstructionAdapter) { v.astore(type) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt index 94cd9ba4d02..90e246d6194 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/CompareTo.kt @@ -35,7 +35,7 @@ public class CompareTo : IntrinsicMethod() { } override fun toCallable(method: CallableMethod): Callable { - val parameterType = comparisonOperandType(method.thisType ?: method.receiverType, method.argumentTypes.single()) + val parameterType = comparisonOperandType(method.dispatchReceiverType ?: method.extensionReceiverType, method.parameterTypes.single()) return createBinaryIntrinsicCallable(method.returnType, parameterType, parameterType, null) { genInvoke(parameterType, it) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt index 38744a7739e..46275f5665e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/Equals.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE public class Equals : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - return createBinaryIntrinsicCallable(method.returnType, OBJECT_TYPE, nullOrObject(method.thisType), nullOrObject(method.receiverType)) { + return createBinaryIntrinsicCallable(method.returnType, OBJECT_TYPE, nullOrObject(method.dispatchReceiverType), nullOrObject(method.extensionReceiverType)) { AsmUtil.genAreEqualCall(it) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt index c39aad3d3c9..650f0884d94 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/HashCode.kt @@ -25,7 +25,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter public class HashCode : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - return object: IntrinsicCallable(Type.INT_TYPE, emptyList(), nullOrObject(method.thisType), nullOrObject(method.receiverType)) { + return object: IntrinsicCallable(Type.INT_TYPE, emptyList(), nullOrObject(method.dispatchReceiverType), nullOrObject(method.extensionReceiverType)) { override fun invokeIntrinsic(v: InstructionAdapter) { v.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "hashCode", "()I", false) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt index 62ddce21b44..551aa20076d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicCallable.kt @@ -27,8 +27,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter public abstract class IntrinsicCallable(override val returnType: Type, override val valueParameterTypes: List, - override val thisType: Type?, - override val receiverType: Type?) : Callable { + override val dispatchReceiverType: Type?, + override val extensionReceiverType: Type?) : Callable { override fun invokeWithoutAssertions(v: InstructionAdapter) { invokeIntrinsic(v) @@ -40,7 +40,7 @@ public abstract class IntrinsicCallable(override val returnType: Type, public abstract fun invokeIntrinsic(v: InstructionAdapter); - override val argumentTypes: Array + override val parameterTypes: Array get() { throw UnsupportedOperationException() } @@ -60,7 +60,7 @@ public abstract class IntrinsicCallable(override val returnType: Type, } public fun calcReceiverType(): Type? { - return receiverType ?: thisType + return extensionReceiverType ?: dispatchReceiverType } } @@ -80,7 +80,7 @@ public class UnaryIntrinsic( needPrimitiveCheck: Boolean = true, newThisType: Type? = null, private val invoke: UnaryIntrinsic.(v: InstructionAdapter) -> Unit -) : IntrinsicCallable(newReturnType ?: callable.returnType, callable.valueParameterTypes, newThisType ?: callable.thisType, callable.receiverType) { +) : IntrinsicCallable(newReturnType ?: callable.returnType, callable.valueParameterTypes, newThisType ?: callable.dispatchReceiverType, callable.extensionReceiverType) { init { if (needPrimitiveCheck) { @@ -105,7 +105,7 @@ public fun createUnaryIntrinsicCallable( } public open class MappedCallable(val callable: CallableMethod, val invoke: IntrinsicCallable.(v: InstructionAdapter) -> Unit = {}) : - IntrinsicCallable(callable.returnType, callable.valueParameterTypes, callable.thisType, callable.receiverType) { + IntrinsicCallable(callable.returnType, callable.valueParameterTypes, callable.dispatchReceiverType, callable.extensionReceiverType) { override fun invokeIntrinsic(v: InstructionAdapter) { invoke(v) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt index 1ab1a0058c7..1f8aaaa80db 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/RangeTo.kt @@ -43,7 +43,7 @@ public class RangeTo : IntrinsicMethod() { 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)) { + return object : IntrinsicCallable(method.returnType, method.valueParameterTypes.map { argType }, nullOr(method.dispatchReceiverType, argType), nullOr(method.extensionReceiverType, argType)) { override fun beforeParameterGeneration(v: InstructionAdapter, value: StackValue?) { v.anew(returnType) v.dup() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt index 339e18552cf..b21df6bcc7d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/ToString.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.CallableMethod public class ToString : IntrinsicMethod() { override fun toCallable(method: CallableMethod): Callable { - val type = AsmUtil.stringValueOfType(method.thisType ?: method.receiverType) + val type = AsmUtil.stringValueOfType(method.dispatchReceiverType ?: method.extensionReceiverType) return createUnaryIntrinsicCallable(method, newThisType = type) { it.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false) }