diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index 85f5327f..39a5e8eb 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.ArrayList; +import java.util.List; import org.apache.bcel.Const; import org.apache.bcel.Constants; @@ -214,6 +215,16 @@ public class LambdaExpression extends Expr{ return ret; } + /* + private List crawlVariables(SyntaxTreeNode inStatements){ + List ret = new ArrayList<>(); + for(SyntaxTreeNode child : inStatements.getChildren()){ + ret.addAll(crawlVariables(child)); + } + return ret; + } + */ + @Override public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) { DHBWConstantPoolGen cp = cg.getConstantPool(); @@ -296,7 +307,7 @@ public class LambdaExpression extends Expr{ String interfaceMethodName = "apply"; //Das ist ein Hack, funktioniert momentan, da nur FunN Interfaces für LambdaAusdrücke funktionieren //String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(lambdaType.getBytecodeType(cg, rs), additionalParameters); - String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(new org.apache.bcel.generic.ObjectType("Fun0"), additionalParameters); + String invokeDynamicType = org.apache.bcel.generic.Type.getMethodSignature(new org.apache.bcel.generic.ObjectType(lambdaType.get_Name()), additionalParameters); il.append(cg.getInstructionFactory().createInvokeDynamic(interfaceMethodName,invokeDynamicType, bMethod)); return il; diff --git a/test/bytecode/LambdaExpr.jav b/test/bytecode/LambdaExpr.jav index 882f8f9e..3339ec0e 100644 --- a/test/bytecode/LambdaExpr.jav +++ b/test/bytecode/LambdaExpr.jav @@ -1,9 +1,9 @@ class LambdaExpr { - void method() { + method() { lambda; - lambda = () -> 1; - + lambda = (Integer a) -> a; + return lambda; } } \ No newline at end of file