Fix for generics invocation
This commit is contained in:
@@ -16,11 +16,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.asm;
|
package org.jetbrains.jet.codegen.asm;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.asm4.MethodVisitor;
|
import org.jetbrains.asm4.MethodVisitor;
|
||||||
import org.jetbrains.asm4.Opcodes;
|
import org.jetbrains.asm4.Opcodes;
|
||||||
import org.jetbrains.asm4.Type;
|
|
||||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||||
import org.jetbrains.asm4.tree.FieldInsnNode;
|
|
||||||
import org.jetbrains.jet.codegen.StackValue;
|
import org.jetbrains.jet.codegen.StackValue;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public abstract class VarRemapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue doRemap(int index) {
|
public RemapInfo doRemap(int index) {
|
||||||
int remappedIndex;
|
int remappedIndex;
|
||||||
|
|
||||||
if (index < allParamsSize) {
|
if (index < allParamsSize) {
|
||||||
@@ -69,7 +69,7 @@ public abstract class VarRemapper {
|
|||||||
throw new RuntimeException("Trying to access skipped parameter: " + info.type + " at " +index);
|
throw new RuntimeException("Trying to access skipped parameter: " + info.type + " at " +index);
|
||||||
}
|
}
|
||||||
if (info.isRemapped()) {
|
if (info.isRemapped()) {
|
||||||
return remapped;
|
return new RemapInfo(remapped, info);
|
||||||
} else {
|
} else {
|
||||||
remappedIndex = ((StackValue.Local)remapped).index;
|
remappedIndex = ((StackValue.Local)remapped).index;
|
||||||
}
|
}
|
||||||
@@ -77,33 +77,47 @@ public abstract class VarRemapper {
|
|||||||
remappedIndex = actualParamsSize - params.totalSize() + index; //captured params not used directly in this inlined method, they used in closure
|
remappedIndex = actualParamsSize - params.totalSize() + index; //captured params not used directly in this inlined method, they used in closure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new RemapInfo(StackValue.local(remappedIndex + additionalShift, AsmTypeConstants.OBJECT_TYPE), null);
|
||||||
return StackValue.local(remappedIndex + additionalShift, AsmTypeConstants.OBJECT_TYPE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackValue remap(int index) {
|
public RemapInfo remap(int index) {
|
||||||
return doRemap(index);
|
return doRemap(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitIincInsn(int var, int increment, MethodVisitor mv) {
|
public void visitIincInsn(int var, int increment, MethodVisitor mv) {
|
||||||
StackValue remap = remap(var);
|
RemapInfo remap = remap(var);
|
||||||
assert remap instanceof StackValue.Local;
|
assert remap.value instanceof StackValue.Local;
|
||||||
mv.visitIincInsn(((StackValue.Local) remap).index, increment);
|
mv.visitIincInsn(((StackValue.Local) remap.value).index, increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitVarInsn(int opcode, int var, InstructionAdapter mv) {
|
public void visitVarInsn(int opcode, int var, InstructionAdapter mv) {
|
||||||
StackValue remap = remap(var);
|
RemapInfo remapInfo = remap(var);
|
||||||
if (remap instanceof StackValue.Local) {
|
StackValue value = remapInfo.value;
|
||||||
mv.visitVarInsn(opcode, ((StackValue.Local) remap).index);
|
if (value instanceof StackValue.Local) {
|
||||||
|
if (remapInfo.parameterInfo != null) {
|
||||||
|
opcode = value.type.getOpcode(Opcodes.ILOAD);
|
||||||
|
}
|
||||||
|
mv.visitVarInsn(opcode, ((StackValue.Local) value).index);
|
||||||
|
if (remapInfo.parameterInfo != null) {
|
||||||
|
value.coerce(value.type, remapInfo.parameterInfo.type, mv);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//Type stub = Type.getObjectType("STUB");
|
value.put(remapInfo.parameterInfo.type, mv);
|
||||||
//String descriptor = stub.getDescriptor();
|
|
||||||
//
|
|
||||||
//mv.visitFieldInsn(Opcodes.GETSTATIC, stub.getInternalName(), "$$$this$skip", descriptor);
|
|
||||||
remap.put(remap.type, mv);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public StackValue doRemap(int index);
|
abstract public RemapInfo doRemap(int index);
|
||||||
|
|
||||||
|
public static class RemapInfo {
|
||||||
|
|
||||||
|
public final StackValue value;
|
||||||
|
|
||||||
|
public final ParameterInfo parameterInfo;
|
||||||
|
|
||||||
|
public RemapInfo(@NotNull StackValue value, @Nullable ParameterInfo info) {
|
||||||
|
this.value = value;
|
||||||
|
parameterInfo = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user