forked from JavaTX/JavaCompilerCore
Merge branch 'bytecode2' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify-test
Conflicts: src/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java
This commit is contained in:
commit
134496129a
@ -111,7 +111,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
public BytecodeGenMethod(LambdaExpression lambdaExpression, ResultSet resultSet, MethodVisitor mv,
|
public BytecodeGenMethod(LambdaExpression lambdaExpression, ResultSet resultSet, MethodVisitor mv,
|
||||||
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter,SourceFile sf) {
|
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter,SourceFile sf) {
|
||||||
|
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
this.mv = mv;
|
this.mv = mv;
|
||||||
this.isInterface = isInterface;
|
this.isInterface = isInterface;
|
||||||
@ -379,6 +378,12 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
case BIGGEREQUAL:
|
case BIGGEREQUAL:
|
||||||
mv.visitJumpInsn(Opcodes.IF_ICMPLT, branchLabel);
|
mv.visitJumpInsn(Opcodes.IF_ICMPLT, branchLabel);
|
||||||
break;
|
break;
|
||||||
|
case EQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IF_ICMPNE, branchLabel);
|
||||||
|
break;
|
||||||
|
case NOTEQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFEQ, branchLabel);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -404,6 +409,12 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
case BIGGEREQUAL:
|
case BIGGEREQUAL:
|
||||||
mv.visitJumpInsn(Opcodes.IFLT, branchLabel);
|
mv.visitJumpInsn(Opcodes.IFLT, branchLabel);
|
||||||
break;
|
break;
|
||||||
|
case EQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFNE, branchLabel);
|
||||||
|
break;
|
||||||
|
case NOTEQUAL:
|
||||||
|
mv.visitJumpInsn(Opcodes.IFEQ, branchLabel);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -569,7 +580,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
new BytecodeGenMethod(lambdaExpression, this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
new BytecodeGenMethod(lambdaExpression, this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
||||||
classFiles,this.path, lamCounter,sf);
|
classFiles,this.path, lamCounter,sf);
|
||||||
|
|
||||||
mvLambdaBody.visitMaxs(0, 0);
|
mvLambdaBody.visitMaxs(0, 0);
|
||||||
mvLambdaBody.visitEnd();
|
mvLambdaBody.visitEnd();
|
||||||
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
|
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
|
||||||
@ -851,11 +861,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
// methCallType = "L"+methCallType+";";
|
// methCallType = "L"+methCallType+";";
|
||||||
// }
|
// }
|
||||||
for(java.lang.reflect.Method m : methods) {
|
for(java.lang.reflect.Method m : methods) {
|
||||||
if(name.equals(m.getName()) && i == m.getParameterCount() && methCallType.equals(m.getReturnType().getName().replace(".", "/"))) {
|
if(name.equals(m.getName()) && i == m.getParameterCount() &&
|
||||||
|
(methCallType.equals(m.getReturnType().getName().replace(".", "/")) ||
|
||||||
|
m.getReturnType().getName().replace(".", "/").equals(Type.getInternalName(Object.class)))) {
|
||||||
boolean typesEqual = true;
|
boolean typesEqual = true;
|
||||||
Class<?>[] pTypes = m.getParameterTypes();
|
Class<?>[] pTypes = m.getParameterTypes();
|
||||||
for(int j = 0; j<typesOfParams.length; ++j) {
|
for(int j = 0; j<typesOfParams.length; ++j) {
|
||||||
if(!typesOfParams[j].equals(pTypes[j])) {
|
if(!typesOfParams[j].equals(pTypes[j].getName().replaceAll(".", "/")) && !pTypes[j].getName().replace(".", "/").equals(Type.getInternalName(Object.class))) {
|
||||||
typesEqual = false;
|
typesEqual = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,12 @@ public class FacultyTest {
|
|||||||
//
|
//
|
||||||
// // Damit man auf die Methode zugreifen kann
|
// // Damit man auf die Methode zugreifen kann
|
||||||
apply.setAccessible(true);
|
apply.setAccessible(true);
|
||||||
|
// Field value
|
||||||
|
Object fieldVal = fact.get(instanceOfClass);
|
||||||
Integer i = 3;
|
Integer i = 3;
|
||||||
|
Method applyFromField = fieldVal.getClass().getDeclaredMethod("apply", Object.class);
|
||||||
Integer result = (Integer) apply.invoke(instanceOfClass, i);
|
applyFromField.setAccessible(true);
|
||||||
|
Integer result = (Integer) applyFromField.invoke(instanceOfClass, i);
|
||||||
// Integer result = (Integer) m.invoke(instanceOfClass,i);
|
// Integer result = (Integer) m.invoke(instanceOfClass,i);
|
||||||
|
|
||||||
assertEquals(6, result);
|
assertEquals(6, result);
|
||||||
|
@ -4,15 +4,13 @@ public class Faculty {
|
|||||||
public fact;
|
public fact;
|
||||||
Faculty() {
|
Faculty() {
|
||||||
fact = (x) -> {
|
fact = (x) -> {
|
||||||
if(x<0) {
|
if (x == 1) {
|
||||||
return 0;
|
return 1;
|
||||||
}else if (x < 1) {
|
}
|
||||||
return x;
|
else {
|
||||||
}
|
return x * (fact.apply(x-1));
|
||||||
else {
|
}
|
||||||
return x * (fact.apply(x-1));
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// m (x) {
|
// m (x) {
|
||||||
|
Loading…
Reference in New Issue
Block a user