From 16d17351f77ccae519a7f0263201056179e39d97 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 10 Jun 2016 17:37:57 -0400 Subject: [PATCH] don't use loadLocal, add new node to package-info --- .../painless/node/ECapturingFunctionRef.java | 9 +++++---- .../org/elasticsearch/painless/node/package-info.java | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ECapturingFunctionRef.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ECapturingFunctionRef.java index 4e125a55de6..3e35602a3a2 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ECapturingFunctionRef.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ECapturingFunctionRef.java @@ -26,6 +26,7 @@ import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.Locals; import org.elasticsearch.painless.Locals.Variable; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import static org.elasticsearch.painless.WriterConstants.DEF_BOOTSTRAP_HANDLE; @@ -77,19 +78,19 @@ public class ECapturingFunctionRef extends AExpression { if (defInterface && captured.type.sort == Definition.Sort.DEF) { // dynamic interface, dynamic implementation writer.push("D" + type + "." + call + ",1"); - writer.loadLocal(captured.slot); + writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.slot); } else if (defInterface) { // dynamic interface, typed implementation writer.push("S" + captured.type.name + "." + call + ",1"); - writer.loadLocal(captured.slot); + writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.slot); } else if (ref == null) { // typed interface, dynamic implementation - writer.loadLocal(captured.slot); + writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.slot); String descriptor = Type.getMethodType(expected.type, captured.type.type).getDescriptor(); writer.invokeDynamic(call, descriptor, DEF_BOOTSTRAP_HANDLE, (Object)DefBootstrap.REFERENCE, expected.name); } else { // typed interface, typed implementation - writer.loadLocal(captured.slot); + writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.slot); // convert MethodTypes to asm Type for the constant pool. String invokedType = ref.invokedType.toMethodDescriptorString(); Type samMethodType = Type.getMethodType(ref.samMethodType.toMethodDescriptorString()); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/package-info.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/package-info.java index 8ab69366f24..d98e5f68bcf 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/package-info.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/node/package-info.java @@ -35,6 +35,7 @@ * {@link org.elasticsearch.painless.node.EBinary} - Represents a binary math expression. * {@link org.elasticsearch.painless.node.EBool} - Represents a boolean expression. * {@link org.elasticsearch.painless.node.EBoolean} - Represents a boolean constant. + * {@link org.elasticsearch.painless.node.ECapturingFunctionRef} - Represents a function reference (capturing). * {@link org.elasticsearch.painless.node.ECast} - Represents an implicit cast in most cases. (Internal only.) * {@link org.elasticsearch.painless.node.EChain} - Represents the entirety of a variable/method chain for read/write operations. * {@link org.elasticsearch.painless.node.EComp} - Represents a comparison expression. @@ -42,7 +43,7 @@ * {@link org.elasticsearch.painless.node.EConstant} - Represents a constant. (Internal only.) * {@link org.elasticsearch.painless.node.EDecimal} - Represents a decimal constant. * {@link org.elasticsearch.painless.node.EExplicit} - Represents an explicit cast. - * {@link org.elasticsearch.painless.node.EFunctionRef} - Represents a function reference. + * {@link org.elasticsearch.painless.node.EFunctionRef} - Represents a function reference (non-capturing). * {@link org.elasticsearch.painless.node.ENull} - Represents a null constant. * {@link org.elasticsearch.painless.node.ENumeric} - Represents a non-decimal numeric constant. * {@link org.elasticsearch.painless.node.EUnary} - Represents a unary math expression.