Browse Source

Some small changes on Generated Lambdas

The interfaces now are annotated with FunctionalInterface
CapturedParameters might work now
kindlich 6 years ago
parent
commit
bcceba4543
No known key found for this signature in database

+ 1
- 0
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/CompilerUtils.java View File

151
 
151
 
152
     private static void createLambdaInterface(FunctionHeader header, String name) {
152
     private static void createLambdaInterface(FunctionHeader header, String name) {
153
         ClassWriter ifaceWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
153
         ClassWriter ifaceWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
154
+        ifaceWriter.visitAnnotation("java/lang/FunctionalInterface", true).visitEnd();
154
         ifaceWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT, name, null, "java/lang/Object", null);
155
         ifaceWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT, name, null, "java/lang/Object", null);
155
 
156
 
156
         ifaceWriter.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, "accept", calcDesc(header, false), calcSign(header, false), null).visitEnd();
157
         ifaceWriter.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, "accept", calcDesc(header, false), calcSign(header, false), null).visitEnd();

+ 1
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaCapturedExpressionVisitor.java View File

17
 
17
 
18
     @Override
18
     @Override
19
     public Void visitCapturedParameter(CapturedParameterExpression expression) {
19
     public Void visitCapturedParameter(CapturedParameterExpression expression) {
20
-        return null;
20
+        return new GetFunctionParameterExpression(expression.position, expression.parameter).accept(expressionVisitor);
21
     }
21
     }
22
 
22
 
23
     @Override
23
     @Override

Loading…
Cancel
Save