Merge branch 'targetBytecode' of ssh://gitea.hb.dhbw-stuttgart.de:2221/JavaTX/JavaCompilerCore into targetBytecode
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 5m39s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 5m39s
This commit is contained in:
commit
9801f8a5ae
@ -2,41 +2,21 @@ import java.lang.Integer;
|
|||||||
|
|
||||||
public class Y {
|
public class Y {
|
||||||
y;
|
y;
|
||||||
//factorial;
|
|
||||||
|
|
||||||
public Y() {
|
public Y() {
|
||||||
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
||||||
//factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
class fac1 {
|
|
||||||
factorial;
|
|
||||||
|
|
||||||
fac1() {
|
|
||||||
var y;
|
|
||||||
y = new Y<Integer,Integer,Integer,Integer,Integer>().getY();
|
|
||||||
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ergibt Parse-Error
|
public class Fac1 {
|
||||||
class fac1 {
|
public factorial;
|
||||||
factorial;
|
public Fac1() {
|
||||||
|
|
||||||
fac1() {
|
|
||||||
var y;
|
var y;
|
||||||
y = new Y<>().y;
|
var tmp = new Y<>(); // TODO Having new Y<>().y on one line doesn't work, see FIXME in StatementGenerator
|
||||||
|
y = tmp.y;
|
||||||
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
|
||||||
}
|
}
|
||||||
public static void main(String args[]) {
|
|
||||||
System.out.println(new fac1().factorial.apply(3));
|
public fac(v) {
|
||||||
|
return factorial.apply(v);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
*/
|
|
@ -697,6 +697,7 @@ public class StatementGenerator {
|
|||||||
if (!Objects.isNull(expr.methodCall())) {
|
if (!Objects.isNull(expr.methodCall())) {
|
||||||
return convert(expr.methodCall(), expr.expression(), offset);
|
return convert(expr.methodCall(), expr.expression(), offset);
|
||||||
} else if (!Objects.isNull(expr.identifier())) {
|
} else if (!Objects.isNull(expr.identifier())) {
|
||||||
|
// FIXME This is not the right way of handling any of this
|
||||||
return generateLocalOrFieldVarOrClassName(expr.getText(), offset);
|
return generateLocalOrFieldVarOrClassName(expr.getText(), offset);
|
||||||
} else {
|
} else {
|
||||||
// Für alle anderen Optionen, wie Feldzugriff, Aufrufe von super oder explizite
|
// Für alle anderen Optionen, wie Feldzugriff, Aufrufe von super oder explizite
|
||||||
@ -779,6 +780,7 @@ public class StatementGenerator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Expression generateLocalOrFieldVarOrClassName(String expression, Token offset) {
|
private Expression generateLocalOrFieldVarOrClassName(String expression, Token offset) {
|
||||||
|
// FIXME Why does this take a String argument???
|
||||||
String[] parts = expression.split("\\.");
|
String[] parts = expression.split("\\.");
|
||||||
if (parts.length < 2) {
|
if (parts.length < 2) {
|
||||||
// Check for localVar:
|
// Check for localVar:
|
||||||
|
@ -188,9 +188,8 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (!(o instanceof ClassOrInterface other)) return false;
|
||||||
ClassOrInterface that = (ClassOrInterface) o;
|
return Objects.equals(name, other.name);
|
||||||
return Objects.equals(name, that.name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -602,7 +602,11 @@ public class TestComplete {
|
|||||||
@Test
|
@Test
|
||||||
public void yTest() throws Exception {
|
public void yTest() throws Exception {
|
||||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Y.jav");
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Y.jav");
|
||||||
var instance = classFiles.get("Y").getDeclaredConstructor().newInstance();
|
|
||||||
|
var fac1 = classFiles.get("Fac1");
|
||||||
|
var instance = fac1.getDeclaredConstructor().newInstance();
|
||||||
|
var fac = fac1.getDeclaredMethod("fac", Integer.class);
|
||||||
|
assertEquals(fac.invoke(instance, 10), 3628800);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user