forked from JavaTX/JavaCompilerCore
Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into targetBytecode
This commit is contained in:
commit
df852ef36e
13
resources/bytecode/javFiles/Chain.jav
Normal file
13
resources/bytecode/javFiles/Chain.jav
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class Chain {
|
||||||
|
x = 5;
|
||||||
|
|
||||||
|
chain() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
m() {
|
||||||
|
return this.chain().chain().chain().x;
|
||||||
|
}
|
||||||
|
}
|
15
resources/bytecode/javFiles/FunctionalInterface.jav
Normal file
15
resources/bytecode/javFiles/FunctionalInterface.jav
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class FunctionalInterface {
|
||||||
|
Integer accept(Function<Integer, Integer> f) {
|
||||||
|
return f.apply(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer m() {
|
||||||
|
var v = accept(i -> {
|
||||||
|
return i * 10;
|
||||||
|
});
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
package de.dhbwstuttgart.target.tree.expression;
|
package de.dhbwstuttgart.target.tree.expression;
|
||||||
|
|
||||||
import de.dhbwstuttgart.target.tree.type.TargetType;
|
|
||||||
|
|
||||||
public record TargetForEach(TargetExpression vardecl, TargetExpression list) implements TargetExpression {
|
public record TargetForEach(TargetExpression vardecl, TargetExpression list) implements TargetExpression {
|
||||||
}
|
}
|
||||||
|
@ -745,4 +745,22 @@ public class TestComplete {
|
|||||||
//var m = clazz.getDeclaredMethod("m", Integer.class);
|
//var m = clazz.getDeclaredMethod("m", Integer.class);
|
||||||
//assertEquals(m.invoke(instance, 10), 60);
|
//assertEquals(m.invoke(instance, 10), 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFunctionalInterface() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "FunctionalInterface.jav");
|
||||||
|
var clazz = classFiles.get("FunctionalInterface");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
var m = clazz.getDeclaredMethod("m", Integer.class);
|
||||||
|
assertEquals(m.invoke(instance, 20), 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChain() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Chain.jav");
|
||||||
|
var clazz = classFiles.get("Chain");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
var m = clazz.getDeclaredMethod("m");
|
||||||
|
assertEquals(m.invoke(instance), 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user