Search in sources :

Example 6 with Variable

use of org.elasticsearch.painless.Locals.Variable in project elasticsearch by elastic.

the class ELambda method write.

@Override
void write(MethodWriter writer, Globals globals) {
    writer.writeDebugInfo(location);
    if (ref != null) {
        writer.writeDebugInfo(location);
        // load captures
        for (Variable capture : captures) {
            writer.visitVarInsn(capture.type.type.getOpcode(Opcodes.ILOAD), capture.getSlot());
        }
        // convert MethodTypes to asm Type for the constant pool.
        String invokedType = ref.invokedType.toMethodDescriptorString();
        org.objectweb.asm.Type samMethodType = org.objectweb.asm.Type.getMethodType(ref.samMethodType.toMethodDescriptorString());
        org.objectweb.asm.Type interfaceType = org.objectweb.asm.Type.getMethodType(ref.interfaceMethodType.toMethodDescriptorString());
        if (ref.needsBridges()) {
            writer.invokeDynamic(ref.invokedName, invokedType, LAMBDA_BOOTSTRAP_HANDLE, samMethodType, ref.implMethodASM, samMethodType, LambdaMetafactory.FLAG_BRIDGES, 1, interfaceType);
        } else {
            writer.invokeDynamic(ref.invokedName, invokedType, LAMBDA_BOOTSTRAP_HANDLE, samMethodType, ref.implMethodASM, samMethodType, 0);
        }
    } else {
        // placeholder
        writer.push((String) null);
        // load captures
        for (Variable capture : captures) {
            writer.visitVarInsn(capture.type.type.getOpcode(Opcodes.ILOAD), capture.getSlot());
        }
    }
    // add synthetic method to the queue to be written
    globals.addSyntheticMethod(desugared);
}
Also used : Variable(org.elasticsearch.painless.Locals.Variable)

Aggregations

Variable (org.elasticsearch.painless.Locals.Variable)6 Type (org.elasticsearch.painless.Definition.Type)2 Location (org.elasticsearch.painless.Location)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Method (org.elasticsearch.painless.Definition.Method)1 FunctionRef (org.elasticsearch.painless.FunctionRef)1 Label (org.objectweb.asm.Label)1