Search in sources :

Example 6 with FieldInsnNode

use of org.jetbrains.org.objectweb.asm.tree.FieldInsnNode in project kotlin by JetBrains.

the class RegeneratedLambdaFieldRemapper method getFieldForInline.

@Nullable
@Override
public StackValue getFieldForInline(@NotNull FieldInsnNode node, @Nullable StackValue prefix) {
    assert node.name.startsWith("$$$") : "Captured field template should start with $$$ prefix";
    if (node.name.equals("$$$" + InlineCodegenUtil.THIS)) {
        assert oldOwnerType.equals(node.owner) : "Can't unfold '$$$THIS' parameter";
        return StackValue.LOCAL_0;
    }
    FieldInsnNode fin = new FieldInsnNode(node.getOpcode(), node.owner, node.name.substring(3), node.desc);
    CapturedParamInfo field = findFieldInMyCaptured(fin);
    boolean searchInParent = false;
    if (field == null) {
        field = findFieldInMyCaptured(new FieldInsnNode(Opcodes.GETSTATIC, oldOwnerType, InlineCodegenUtil.THIS$0, Type.getObjectType(parent.getLambdaInternalName()).getDescriptor()));
        searchInParent = true;
        if (field == null) {
            throw new IllegalStateException("Couldn't find captured this " + getLambdaInternalName() + " for " + node.name);
        }
    }
    StackValue result = StackValue.field(field.isSkipped ? Type.getObjectType(parent.parent.getNewLambdaInternalName()) : field.getType(), Type.getObjectType(getNewLambdaInternalName()), /*TODO owner type*/
    field.getNewFieldName(), false, prefix == null ? StackValue.LOCAL_0 : prefix);
    return searchInParent ? parent.getFieldForInline(node, result) : result;
}
Also used : StackValue(org.jetbrains.kotlin.codegen.StackValue) FieldInsnNode(org.jetbrains.org.objectweb.asm.tree.FieldInsnNode) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FieldInsnNode (org.jetbrains.org.objectweb.asm.tree.FieldInsnNode)6 AbstractInsnNode (org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode)3 Nullable (org.jetbrains.annotations.Nullable)2 StackValue (org.jetbrains.kotlin.codegen.StackValue)2 NotNull (org.jetbrains.annotations.NotNull)1 Method (org.jetbrains.org.objectweb.asm.commons.Method)1 AnnotationNode (org.jetbrains.org.objectweb.asm.tree.AnnotationNode)1 FieldNode (org.jetbrains.org.objectweb.asm.tree.FieldNode)1 FrameNode (org.jetbrains.org.objectweb.asm.tree.FrameNode)1 IntInsnNode (org.jetbrains.org.objectweb.asm.tree.IntInsnNode)1 LabelNode (org.jetbrains.org.objectweb.asm.tree.LabelNode)1 LdcInsnNode (org.jetbrains.org.objectweb.asm.tree.LdcInsnNode)1 LineNumberNode (org.jetbrains.org.objectweb.asm.tree.LineNumberNode)1 MethodInsnNode (org.jetbrains.org.objectweb.asm.tree.MethodInsnNode)1 TypeInsnNode (org.jetbrains.org.objectweb.asm.tree.TypeInsnNode)1