Rename thisType and receiverType to dispatch and extension ones

This commit is contained in:
Michael Bogdanov
2015-04-06 18:55:33 +03:00
parent a201cb3258
commit 31c4aaac4d
13 changed files with 29 additions and 29 deletions
@@ -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<Type>
public val argumentTypes: Array<Type>
public val parameterTypes: Array<Type>
public val returnType: Type
@@ -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<JvmMethodParameterSignature> {
return signature.getValueParameters()
@@ -51,7 +51,7 @@ public class CallableMethod(override val owner: Type, private val defaultImplOwn
return signature.getAsmMethod()
}
override val argumentTypes: Array<Type>
override val parameterTypes: Array<Type>
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 ("<init>".equals(method.getName())) {
v.aconst(null)
@@ -3595,7 +3595,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> 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,
@@ -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();
}
@@ -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)) {
@@ -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());
@@ -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)
}
@@ -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)
}
@@ -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)
}
}
@@ -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)
}
@@ -27,8 +27,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
public abstract class IntrinsicCallable(override val returnType: Type,
override val valueParameterTypes: List<Type>,
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<Type>
override val parameterTypes: Array<Type>
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)
@@ -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()
@@ -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)
}