Merge branch 'targetBytecode' into patternMatching
This commit is contained in:
commit
3be557a32b
2
resources/bytecode/javFiles/Bug343.jav
Normal file
2
resources/bytecode/javFiles/Bug343.jav
Normal file
@ -0,0 +1,2 @@
|
||||
public record Bug343() {
|
||||
}
|
@ -2,41 +2,21 @@ import java.lang.Integer;
|
||||
|
||||
public class Y {
|
||||
y;
|
||||
//factorial;
|
||||
|
||||
public Y() {
|
||||
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); });
|
||||
y = f -> t -> f.apply(y.apply(f)).apply(t);
|
||||
}
|
||||
}
|
||||
|
||||
ergibt Parse-Error
|
||||
class fac1 {
|
||||
factorial;
|
||||
|
||||
fac1() {
|
||||
public class Fac1 {
|
||||
public factorial;
|
||||
public Fac1() {
|
||||
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); });
|
||||
}
|
||||
public static void main(String args[]) {
|
||||
System.out.println(new fac1().factorial.apply(3));
|
||||
}
|
||||
|
||||
public fac(v) {
|
||||
return factorial.apply(v);
|
||||
}
|
||||
}
|
||||
*/
|
@ -698,6 +698,7 @@ public class StatementGenerator {
|
||||
if (!Objects.isNull(expr.methodCall())) {
|
||||
return convert(expr.methodCall(), expr.expression(), offset);
|
||||
} else if (!Objects.isNull(expr.identifier())) {
|
||||
// FIXME This is not the right way of handling any of this
|
||||
return generateLocalOrFieldVarOrClassName(expr.getText(), offset);
|
||||
} else {
|
||||
// Für alle anderen Optionen, wie Feldzugriff, Aufrufe von super oder explizite
|
||||
@ -780,6 +781,7 @@ public class StatementGenerator {
|
||||
* @return
|
||||
*/
|
||||
private Expression generateLocalOrFieldVarOrClassName(String expression, Token offset) {
|
||||
// FIXME Why does this take a String argument???
|
||||
String[] parts = expression.split("\\.");
|
||||
if (parts.length < 2) {
|
||||
// Check for localVar:
|
||||
|
@ -254,7 +254,10 @@ public class SyntaxTreeGenerator {
|
||||
List<RefType> implementedInterfaces = new ArrayList<>();
|
||||
List<Pattern> constructorParameters = new ArrayList<>();
|
||||
List<Statement> constructorStatements = new ArrayList<>();
|
||||
for (RecordComponentContext component : recordDeclaration.recordHeader().recordComponentList().recordComponent()) {
|
||||
|
||||
List<Java17Parser.RecordComponentContext> components = recordDeclaration.recordHeader().recordComponentList() != null ?
|
||||
recordDeclaration.recordHeader().recordComponentList().recordComponent(): List.of();
|
||||
for (RecordComponentContext component : components) {
|
||||
int fieldmodifiers = allmodifiers.get("private") + allmodifiers.get("final");
|
||||
String fieldname = component.identifier().getText();
|
||||
Token fieldoffset = component.getStart();
|
||||
|
@ -605,7 +605,11 @@ public class TestComplete {
|
||||
@Test
|
||||
public void yTest() throws Exception {
|
||||
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
|
||||
@ -1192,4 +1196,11 @@ public class TestComplete {
|
||||
var clazz = classFiles.get("Bug338");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug343() throws Exception {
|
||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug343.jav");
|
||||
var clazz = classFiles.get("Bug343");
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user