Compare commits

..

No commits in common. "ebd6a00a3917581fd3fa01d2a8bc3bda0e740777" and "e3548384916e8a8e0d5013034b844c63afcd8d4b" have entirely different histories.

66 changed files with 148 additions and 203 deletions

View File

@ -69,7 +69,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
<trimStackTrace>true</trimStackTrace> <trimStackTrace>true</trimStackTrace>
<excludes> <excludes>
<exclude>**/JavaTXCompilerTest.java</exclude> <exclude>**/JavaTXCompilerTest.java</exclude>
<exclude>**/AllgemeinTest.java</exclude>
<exclude>**/syntaxtreegenerator/*.java</exclude> <exclude>**/syntaxtreegenerator/*.java</exclude>
</excludes> </excludes>
</configuration> </configuration>

View File

@ -2,7 +2,7 @@ import java.lang.Integer;
import java.lang.String; import java.lang.String;
public class AA { public class AA {
public m(Integer i) { return "AA"; } m(Integer i) { return "AA"; }
public m2(AA x) { return "AA"; } m2(AA x) { return "AA"; }
} }

View File

@ -1,4 +1,3 @@
import java.lang.Integer; import java.lang.Integer;
import AA;
public class BB extends AA { } public class BB extends AA { }

View File

@ -3,15 +3,15 @@ import java.lang.Double;
public class BinaryInMeth { public class BinaryInMeth {
public m(a){ m(a){
return ++a; return ++a;
} }
public m2(a,b){ m2(a,b){
return m(a+b); return m(a+b);
} }
public m3(a) { m3(a) {
return m(++a); return m(++a);
} }
} }

View File

@ -1,5 +1,5 @@
public class Bug112 { public class Bug112 {
public m(x) { m(x) {
var y; var y;
x = y; x = y;
return y; return y;

View File

@ -1,8 +1,8 @@
import java.lang.Integer; import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
public class Bug122 { class Bug122 {
public void main() { void main() {
if (true) { if (true) {
for (Integer i = 0; i < 10; i++) { for (Integer i = 0; i < 10; i++) {

View File

@ -1,12 +1,12 @@
import java.lang.Boolean; import java.lang.Boolean;
import java.lang.Integer; import java.lang.Integer;
public class Bug123 { class Bug123 {
public Boolean works(){ Boolean works(){
if(true) return true; if(true) return true;
else return false; else return false;
} }
public void fails(){ void fails(){
Boolean a = true; Boolean a = true;
if(true) a = false; if(true) a = false;
} }

View File

@ -5,11 +5,11 @@ import java.util.List;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.ArrayList; import java.util.ArrayList;
public class Bug125 { class Bug125 {
static ArrayList<String> works = new ArrayList<>(); static ArrayList<String> works = new ArrayList<>();
static List<String> fails = new ArrayList<>(); static List<String> fails = new ArrayList<>();
public void main() { void main() {
works.toString(); works.toString();
fails.toString(); fails.toString();
} }

View File

@ -1,14 +1,14 @@
import java.util.Optional; import java.util.Optional;
import java.lang.Integer; import java.lang.Integer;
public class StaticClass { class StaticClass {
public static StaticClass barbar() { static StaticClass barbar() {
return new StaticClass(); return new StaticClass();
} }
} }
public class Bug285 { public class Bug285 {
public void foo() { void foo() {
Optional<Integer> opt = Optional.empty(); Optional<Integer> opt = Optional.empty();
StaticClass b = StaticClass.barbar(); StaticClass b = StaticClass.barbar();
} }

View File

@ -1,7 +0,0 @@
import Bug290B;
public class Bug290A {
public void m() {
new Bug290B();
}
}

View File

@ -1,11 +0,0 @@
import java.lang.String;
import java.lang.Integer;
public class Bug290B {
String name;
public Bug290B() {
Integer i = 0;
name = i.toString() + "$$";
}
}

View File

@ -4,7 +4,7 @@ import java.lang.String;
public class Bug98 { public class Bug98 {
public m(x, y ,z) { m(x, y ,z) {
x = new Vector<Integer>(); x = new Vector<Integer>();
y = new Vector<String>(); y = new Vector<String>();
x.add(1); x.add(1);

View File

@ -1,11 +1,11 @@
import java.lang.Integer; import java.lang.Integer;
import java.lang.String; import java.lang.String;
import BB;
public class CC extends BB { public class CC extends BB {
public m(Integer i) { m(Integer i) {
return "CC"; return "CC";
} }
public m2(CC x) { return "CC"; } m2(CC x) { return "CC"; }
} }

View File

@ -7,7 +7,7 @@ public class Chain {
return this; return this;
} }
public m() { m() {
return this.chain().chain().chain().x; return this.chain().chain().chain().x;
} }
} }

View File

@ -1,5 +1,5 @@
public class Cycle { class Cycle {
public m(x, y) { m(x, y) {
y = x; y = x;
x = y; x = y;
} }

View File

@ -1,5 +1,4 @@
import java.lang.Integer; import java.lang.Integer;
import CC;
public class DD extends CC { } public class DD extends CC { }

View File

@ -2,7 +2,7 @@ import java.lang.String;
import java.lang.RuntimeException; import java.lang.RuntimeException;
public class Exceptions { public class Exceptions {
public m() { m() {
throw new RuntimeException("Some Exception"); throw new RuntimeException("Some Exception");
} }
} }

View File

@ -1,14 +1,14 @@
import java.lang.String; import java.lang.String;
public class FieldTph2 { public class FieldTph2 {
public a; a;
public m(b){ m(b){
b = a; b = a;
return b; return b;
} }
public m2(c){ m2(c){
a = c; a = c;
} }
} }

View File

@ -1,20 +1,20 @@
public class FieldTphConsMeth { public class FieldTphConsMeth {
public a; a;
public FieldTphConsMeth(c) { public FieldTphConsMeth(c) {
a = id(c); a = id(c);
} }
public id(b) { id(b) {
return b; return b;
} }
public setA(x) { setA(x) {
a = x; a = x;
return a; return a;
} }
public m(x,y) { m(x,y) {
x = id(y); x = id(y);
} }

View File

@ -1,13 +1,13 @@
import java.lang.Boolean; import java.lang.Boolean;
public class FieldTphMMeth { public class FieldTphMMeth {
public a; a;
public FieldTphMMeth(c,d,e) { public FieldTphMMeth(c,d,e) {
a = m(c,d,e); a = m(c,d,e);
} }
public m(b,d,e) { m(b,d,e) {
if(e) { if(e) {
return m3(b); return m3(b);
} else{ } else{
@ -16,11 +16,11 @@ public class FieldTphMMeth {
} }
public m2(b) { m2(b) {
a = m3(b); a = m3(b);
} }
public m3(b){ m3(b){
return b; return b;
} }

View File

@ -1,8 +1,8 @@
import java.lang.Integer; import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
public class For{ class For{
public Integer m(Integer x){ Integer m(Integer x){
var c = x + 2; var c = x + 2;
Boolean b = true; Boolean b = true;
c = 5; c = 5;

View File

@ -6,7 +6,7 @@ public class FunctionalInterface {
return f.apply(20); return f.apply(20);
} }
public Integer m() { Integer m() {
var v = accept(i -> { var v = accept(i -> {
return i * 10; return i * 10;
}); });

View File

@ -1,8 +1,8 @@
import java.lang.String; import java.lang.String;
import java.lang.Integer; import java.lang.Integer;
public class Generics2<B extends String>{ class Generics2<B extends String>{
public <X extends Integer> X m1(X b){ <B extends Integer> B m1(B b){
return b; return b;
} }

View File

@ -3,7 +3,7 @@ import java.lang.String;
import java.io.PrintStream; import java.io.PrintStream;
public class HelloWorld { public class HelloWorld {
public static hello() { static hello() {
System.out.println("Hello World!"); System.out.println("Hello World!");
} }
} }

View File

@ -2,18 +2,15 @@ import java.util.Vector;
import java.lang.Integer; import java.lang.Integer;
import java.lang.String; import java.lang.String;
import AA;
import BB;
import CC;
import DD;
public class Inherit { public class Inherit {
public main(d, i) { main(d, i) {
return d.m(i); return d.m(i);
} }
public main(v, i) { main(v, i) {
var aa = v.elementAt(0); var aa = v.elementAt(0);
return aa.m(i); return aa.m(i);
} }

View File

@ -2,18 +2,15 @@ import java.util.Vector;
import java.lang.Integer; import java.lang.Integer;
import java.lang.String; import java.lang.String;
import AA;
import BB;
import CC;
import DD;
public class Inherit2 { public class Inherit2 {
public main(d) { main(d) {
return d.m2(d); return d.m2(d);
} }
public main(v) { main(v) {
var aa = v.elementAt(0); var aa = v.elementAt(0);
return aa.m2(aa); return aa.m2(aa);
} }

View File

@ -12,7 +12,7 @@ class Test2 {
public class InstanceOf { public class InstanceOf {
a = new Test(); a = new Test();
public test1() { return this.a instanceof Test; } test1() { return this.a instanceof Test; }
public test2() { return this.a instanceof Interface; } test2() { return this.a instanceof Interface; }
public test3() { return this.a instanceof Integer; } test3() { return this.a instanceof Integer; }
} }

View File

@ -2,7 +2,7 @@ import java.lang.Integer;
public class Lambda { public class Lambda {
public m() { m () {
var lam1 = (x) -> { var lam1 = (x) -> {
return x; return x;
}; };

View File

@ -4,52 +4,52 @@ import java.lang.Float;
import java.lang.Double; import java.lang.Double;
public class LessEqual { public class LessEqual {
public lessEqual(Integer a, Integer b){ lessEqual(Integer a, Integer b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Long a, Long b){ lessEqual(Long a, Long b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Float a, Float b){ lessEqual(Float a, Float b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Double a, Double b){ lessEqual(Double a, Double b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Long a, Integer b){ lessEqual(Long a, Integer b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Float a, Integer b){ lessEqual(Float a, Integer b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Double a, Integer b){ lessEqual(Double a, Integer b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Float a, Long b){ lessEqual(Float a, Long b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Double a, Long b){ lessEqual(Double a, Long b){
var c = a<=b; var c = a<=b;
return c; return c;
} }
public lessEqual(Double a, Float b){ lessEqual(Double a, Float b){
var c = a<=b; var c = a<=b;
return c; return c;
} }

View File

@ -5,52 +5,52 @@ import java.lang.Double;
public class LessThan { public class LessThan {
public lessThan(Integer a, Integer b){ lessThan(Integer a, Integer b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Long a, Long b){ lessThan(Long a, Long b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Float a, Float b){ lessThan(Float a, Float b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Double a, Double b){ lessThan(Double a, Double b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Long a, Integer b){ lessThan(Long a, Integer b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Float a, Integer b){ lessThan(Float a, Integer b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Double a, Integer b){ lessThan(Double a, Integer b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Float a, Long b){ lessThan(Float a, Long b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Double a, Long b){ lessThan(Double a, Long b){
var c = a<b; var c = a<b;
return c; return c;
} }
public lessThan(Double a, Float b){ lessThan(Double a, Float b){
var c = a<b; var c = a<b;
return c; return c;
} }

View File

@ -1,6 +1,6 @@
import java.lang.Character; import java.lang.Character;
public class Literal { public class Literal {
public m() { return null; } m() { return null; }
public m2() { return 'C'; } m2() { return 'C'; }
} }

View File

@ -9,7 +9,7 @@ public class Matrix extends Vector<Vector<Integer>> {
Matrix () { Matrix () {
} }
public Matrix(vv) { Matrix(vv) {
Integer i; Integer i;
i = 0; i = 0;
while(i < vv.size()) { while(i < vv.size()) {
@ -19,7 +19,7 @@ public class Matrix extends Vector<Vector<Integer>> {
} }
} }
public mul(m) { mul(m) {
var ret = new Matrix(); var ret = new Matrix();
var i = 0; var i = 0;
while(i < size()) { while(i < size()) {

View File

@ -8,7 +8,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
MatrixOP () { MatrixOP () {
} }
public MatrixOP(vv) { MatrixOP(vv) {
Integer i; Integer i;
i = 0; i = 0;
while(i < vv.size()) { while(i < vv.size()) {

View File

@ -2,16 +2,16 @@ import java.util.List;
import java.lang.Integer; import java.lang.Integer;
//import java.util.Collection; //import java.util.Collection;
public class Merge { class Merge {
public merge(a, b) { merge(a, b) {
a.addAll(b); a.addAll(b);
return a; return a;
} }
public sort(in){ sort(in){
var firstHalf = in.subList(1,2); var firstHalf = in.subList(1,2);
var secondHalf = in.subList(1,2); var secondHalf = in.subList(1,2);
return merge(sort(firstHalf), sort(secondHalf)); return merge(sort(firstHalf), sort(secondHalf));

View File

@ -1,14 +1,13 @@
import java.lang.Double; import java.lang.Double;
import java.lang.String; import java.lang.String;
import java.lang.Long; import java.lang.Long;
import java.lang.Integer;
public class OL { class OL {
public m (x) { return x + x; } m (x) { return x + x; }
} }
public class OLMain { class OLMain {
public main(x) { main(x) {
var ol; var ol;
ol = new OL(); ol = new OL();
return ol.m(x); return ol.m(x);

View File

@ -10,8 +10,8 @@ public class Parent {
public Parent() {} public Parent() {}
} }
public class Child extends Parent { class Child extends Parent {
public Child() { Child() {
super(3); super(3);
} }
} }

View File

@ -3,9 +3,9 @@ import java.lang.Double;
import java.lang.String; import java.lang.String;
public class Op2 { public class Op2 {
public m(){ m(){
var x = ""; //var x = "";
var a = 5+x; //var a = 5+x;
Integer x = 10; Integer x = 10;
Double y = 10.5; Double y = 10.5;

View File

@ -5,15 +5,15 @@ import java.lang.Float;
record Point(Number x, Number y) {} record Point(Number x, Number y) {}
public class OverloadPattern { public class OverloadPattern {
public m(Point(Integer x, Integer y)) { m(Point(Integer x, Integer y)) {
return x + y; return x + y;
} }
public m(Point(Float x, Float y)) { m(Point(Float x, Float y)) {
return x * y; return x * y;
} }
public m(Integer x) { m(Integer x) {
return x; return x;
} }
} }

View File

@ -2,17 +2,17 @@ import java.lang.String;
public class Overloading{ public class Overloading{
public test(x){ test(x){
return x.methode(); return x.methode();
} }
public methode(){ methode(){
return "Overloading"; return "Overloading";
} }
} }
public class Overloading2{ public class Overloading2{
public methode(){ methode(){
return "Overloading2"; return "Overloading2";
} }
} }

View File

@ -3,15 +3,15 @@ import java.lang.Boolean;
import java.lang.Object; import java.lang.Object;
public class Pair<T, U> { class Pair<T, U> {
T x; T x;
U y; U y;
public fst() { fst () {
return x; return x;
} }
public snd() { snd () {
return y; return y;
} }
} }

View File

@ -3,7 +3,7 @@ import java.lang.String;
public class Plus { public class Plus {
public m(a,b) { m(a,b) {
return a+b; return a+b;
} }
} }

View File

@ -1,25 +1,25 @@
import java.lang.Integer; import java.lang.Integer;
public class PostIncDec { public class PostIncDec {
public m() { m() {
var i = 0; var i = 0;
i++; i++;
return i; return i;
} }
public m2() { m2() {
var i = 0; var i = 0;
var j = i++; var j = i++;
return j; return j;
} }
public d() { d() {
var i = 0; var i = 0;
i--; i--;
return i; return i;
} }
public d2() { d2() {
var i = 0; var i = 0;
var j = i--; var j = i--;
return j; return j;

View File

@ -1,25 +1,25 @@
import java.lang.Integer; import java.lang.Integer;
public class PreInc { public class PreInc {
public m() { m() {
var i = 0; var i = 0;
++i; ++i;
return i; return i;
} }
public m2() { m2() {
var i = 0; var i = 0;
var j = ++i; var j = ++i;
return j; return j;
} }
public d() { d() {
var i = 0; var i = 0;
--i; --i;
return i; return i;
} }
public d2() { d2() {
var i = 0; var i = 0;
var j = --i; var j = --i;
return j; return j;

View File

@ -3,16 +3,16 @@ import java.util.Stack;
public class Put { public class Put {
public putElement(ele, v) { putElement(ele, v) {
v.addElement(ele); v.addElement(ele);
} }
public putElement(ele, s) { putElement(ele, s) {
s.push(ele); s.push(ele);
} }
public main(ele, x) { main(ele, x) {
putElement(ele, x); putElement(ele, x);
} }

View File

@ -15,8 +15,8 @@ public class RecordTest {
b = new Rec(10, 20); b = new Rec(10, 20);
c = new Rec(20, 40); c = new Rec(20, 40);
public doesEqual() { return a.equals(b); } doesEqual() { return a.equals(b); }
public doesNotEqual() { return b.equals(c); } doesNotEqual() { return b.equals(c); }
public hashCode() { return a.hashCode(); } hashCode() { return a.hashCode(); }
public toString() { return a.toString(); } toString() { return a.toString(); }
} }

View File

@ -2,7 +2,7 @@ import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
public class RelOps { public class RelOps {
public m(a,b){ m(a,b){
return a<b; return a<b;
} }
} }

View File

@ -6,7 +6,7 @@ import java.lang.Float;
public class Scalar extends Vector<Integer> { public class Scalar extends Vector<Integer> {
public Scalar(v) { Scalar(v) {
Integer i; Integer i;
i = 0; i = 0;
while(i < v.size()) { while(i < v.size()) {
@ -15,7 +15,7 @@ public class Scalar extends Vector<Integer> {
} }
} }
public mul(v) { mul(v) {
var ret = 0; var ret = 0;
var i = 0; var i = 0;
while(i < size()) { while(i < size()) {

View File

@ -12,7 +12,7 @@ public class Static {
i = x; i = x;
} }
public static m() { static m() {
return i + Other.field; return i + Other.field;
} }
} }

View File

@ -2,10 +2,10 @@ import java.lang.Integer;
import java.lang.Object; import java.lang.Object;
import java.lang.Float; import java.lang.Float;
public record Rec(Integer a, Object b) {} record Rec(Integer a, Object b) {}
public class Switch { public class Switch {
public main(o) { main(o) {
return switch (o) { return switch (o) {
case Rec(Integer a, Integer b) -> a + b; case Rec(Integer a, Integer b) -> a + b;
case Rec(Integer a, Float b) -> a + 10; case Rec(Integer a, Float b) -> a + 10;

View File

@ -3,7 +3,7 @@ import java.lang.String;
import java.lang.Object; import java.lang.Object;
public class SwitchString { public class SwitchString {
public main(o) { main(o) {
return switch (o) { return switch (o) {
case "AaAaAa" -> 1; // These two have the same hash code! case "AaAaAa" -> 1; // These two have the same hash code!
case "AaAaBB" -> 2; case "AaAaBB" -> 2;

View File

@ -1,10 +1,10 @@
import java.lang.String; import java.lang.String;
public class TXGenerics { class TXGenerics {
a; a;
b; b;
public test() { test() {
var c = new Cycle(); var c = new Cycle();
c.m(a, b); c.m(a, b);
} }

View File

@ -1,11 +1,11 @@
public class Tph { public class Tph {
public m(a,b){ m(a,b){
var c = m2(b); var c = m2(b);
return a; return a;
} }
public m2(b){ m2(b){
return b; return b;
} }
} }

View File

@ -3,7 +3,7 @@ import java.lang.Long;
import java.lang.Double; import java.lang.Double;
public class While { public class While {
public m(x) { m(x) {
while(x < 2) { while(x < 2) {
x = x+1; x = x+1;
} }

View File

@ -1,10 +1,10 @@
import java.lang.Integer; import java.lang.Integer;
public class Y { class Y {
y; y;
//factorial; //factorial;
public Y() { 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); }); //factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
} }

View File

@ -3,7 +3,7 @@ class Apply { }
public class applyLambda { public class applyLambda {
public m () { m () {
var lam1 = (x) -> { var lam1 = (x) -> {
return x; return x;
}; };

View File

@ -1435,8 +1435,6 @@ public class Codegen {
var access = method.access(); var access = method.access();
if (method.block() == null) if (method.block() == null)
access |= ACC_ABSTRACT; access |= ACC_ABSTRACT;
if (clazz instanceof TargetInterface)
access |= ACC_PUBLIC;
// TODO The older codegen has set ACC_PUBLIC for all methods, good for testing but bad for everything else // TODO The older codegen has set ACC_PUBLIC for all methods, good for testing but bad for everything else
MethodVisitor mv = cw.visitMethod(access, method.name(), method.getDescriptor(), method.getSignature(), null); MethodVisitor mv = cw.visitMethod(access, method.name(), method.getDescriptor(), method.getSignature(), null);

View File

@ -57,7 +57,6 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.sql.Array;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.function.Function; import java.util.function.Function;
@ -129,11 +128,11 @@ public class JavaTXCompiler {
} }
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException, IOException { public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException, IOException {
Set<ClassOrInterface> allClasses = new HashSet<>();// environment.getAllAvailableClasses(); List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
List<ClassOrInterface> importedClasses = new ArrayList<>();
ClassOrInterface objectClass = ASTFactory.createClass(classLoader.loadClass(new JavaClassName("java.lang.Object").toString())); ClassOrInterface objectClass = ASTFactory.createClass(classLoader.loadClass(new JavaClassName("java.lang.Object").toString()));
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC // Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for (Entry<File, SourceFile> source : sourceFiles.entrySet()) { for (Entry<File, SourceFile> source : sourceFiles.entrySet()) {
var importedClasses = new ArrayList<ClassOrInterface>();
for (JavaClassName name : source.getValue().getImports()) { for (JavaClassName name : source.getValue().getImports()) {
importedClasses.addAll(getAvailableClasses(name)); importedClasses.addAll(getAvailableClasses(name));
} }
@ -141,17 +140,18 @@ public class JavaTXCompiler {
ClassOrInterface importedClass = ASTFactory.createClass(c); ClassOrInterface importedClass = ASTFactory.createClass(c);
importedClasses.add(importedClass); importedClasses.add(importedClass);
} }
source.getValue().availableClasses.addAll(importedClasses);
} }
for (File f : this.sourceFiles.keySet()) { for (File f : this.sourceFiles.keySet()) {
SourceFile sf = sourceFiles.get(f); SourceFile sf = sourceFiles.get(f);
SourceFile sf_new = new SourceFile(sf.getPkgName(), sf.KlassenVektor.stream().map(cl -> new ClassOrInterface(cl)).collect(Collectors.toCollection(ArrayList::new)), sf.imports); sf = new SourceFile(sf.getPkgName(), sf.KlassenVektor.stream().map(cl -> new ClassOrInterface(cl)).collect(Collectors.toCollection(ArrayList::new)), sf.imports);
// sf enthaelt neues Source-File, neue Klassen-Objekte und neue // sf enthaelt neues Source-File, neue Klassen-Objekte und neue
// ArrayListen-Objekte fuer Fields, Construktoren und Methoden // ArrayListen-Objekte fuer Fields, Construktoren und Methoden
// Alle anderen Objekte werden nur kopiert. // Alle anderen Objekte werden nur kopiert.
sf_new.KlassenVektor.forEach(cl -> addMethods(sf_new, cl, sf.availableClasses, objectClass)); SourceFile sf_new = sf;
allClasses.addAll(sf_new.getClasses()); sf.KlassenVektor.forEach(cl -> addMethods(sf_new, cl, importedClasses, objectClass));
allClasses.addAll(sf.getClasses());
} }
allClasses.addAll(importedClasses);
TYPE ty = new TYPE(sourceFiles.values(), allClasses); TYPE ty = new TYPE(sourceFiles.values(), allClasses);
return ty.getConstraints(); return ty.getConstraints();
} }

View File

@ -143,8 +143,7 @@ public class SyntaxTreeGenerator {
if (srcfile.packageDeclaration() != null) if (srcfile.packageDeclaration() != null)
this.pkgName = convert(srcfile.packageDeclaration()); this.pkgName = convert(srcfile.packageDeclaration());
Map<String, Integer> imports = GatherNames.getImports(srcfile, packageCrawler, compiler); Map<String, Integer> imports = GatherNames.getImports(srcfile, packageCrawler, compiler);
this.imports.addAll(imports.keySet().stream().map(name -> reg.getName(name)).collect(Collectors.toSet())); this.imports = imports.keySet().stream().map(name -> reg.getName(name)).collect(Collectors.toSet());
for (Java17Parser.ClassOrInterfaceContext type : srcfile.classOrInterface()) { for (Java17Parser.ClassOrInterfaceContext type : srcfile.classOrInterface()) {
ClassorinterfacedeclContext clsoif; ClassorinterfacedeclContext clsoif;
if (type instanceof NoclassorinterfaceContext) { if (type instanceof NoclassorinterfaceContext) {

View File

@ -15,8 +15,6 @@ public class SourceFile extends SyntaxTreeNode {
public final List<ClassOrInterface> KlassenVektor; public final List<ClassOrInterface> KlassenVektor;
public final Set<JavaClassName> imports; public final Set<JavaClassName> imports;
public List<ClassOrInterface> availableClasses = new ArrayList<>();
/** /**
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei. * Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar. * SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.

View File

@ -293,8 +293,7 @@ public class ASTToTargetAST {
for (var method : overloadedMethods) { for (var method : overloadedMethods) {
var newMethod = new Method( var newMethod = new Method(
method.modifier, method.modifier,
method.name, encodeName(method.name, method.getParameterList()),
//encodeName(method.name, method.getParameterList()),
method.getReturnType(), method.getReturnType(),
method.getParameterList(), method.getParameterList(),
method.block, method.block,
@ -304,8 +303,7 @@ public class ASTToTargetAST {
res.add(newMethod); res.add(newMethod);
} }
// TODO Record overloading var template = overloadedMethods.get(0);
/*var template = overloadedMethods.get(0);
var pParams = new ArrayList<Pattern>(); var pParams = new ArrayList<Pattern>();
var i = 0; var i = 0;
@ -323,7 +321,7 @@ public class ASTToTargetAST {
var block = new Block(statements, new NullToken()); var block = new Block(statements, new NullToken());
var entryPoint = new Method(template.modifier, template.name, template.getReturnType(), params, block, template.getGenerics(), new NullToken()); var entryPoint = new Method(template.modifier, template.name, template.getReturnType(), params, block, template.getGenerics(), new NullToken());
res.add(entryPoint); // TODO*/ res.add(entryPoint); // TODO
return res.stream().map(this::convert).flatMap(List::stream).toList(); return res.stream().map(this::convert).flatMap(List::stream).toList();
} }

View File

@ -16,23 +16,19 @@ import java.util.*;
public class TYPE { public class TYPE {
private final Collection<SourceFile> sfs; private final Collection<SourceFile> sfs;
private final Set<ClassOrInterface> allAvailableClasses; private final TypeInferenceInformation typeInferenceInformation;
public TYPE(Collection<SourceFile> sourceFiles, Set<ClassOrInterface> allAvailableClasses){ public TYPE(Collection<SourceFile> sourceFiles, Collection<ClassOrInterface> allAvailableClasses){
sfs = sourceFiles; sfs = sourceFiles;
this.allAvailableClasses = allAvailableClasses; this.typeInferenceInformation = new TypeInferenceInformation(allAvailableClasses);
} }
public ConstraintSet getConstraints() { public ConstraintSet getConstraints() {
ConstraintSet ret = new ConstraintSet(); ConstraintSet ret = new ConstraintSet();
for(SourceFile sf : sfs) for(SourceFile sf : sfs)
for (ClassOrInterface cl : sf.KlassenVektor) { for (ClassOrInterface cl : sf.KlassenVektor) {
System.out.println(sf.availableClasses); ret.addAll(getConstraintsClass(cl ,typeInferenceInformation));
var allClasses = new HashSet<ClassOrInterface>(); }
allClasses.addAll(allAvailableClasses);
allClasses.addAll(sf.availableClasses);
ret.addAll(getConstraintsClass(cl, new TypeInferenceInformation(allClasses)));
}
return ret; return ret;
} }

View File

@ -670,7 +670,6 @@ public class TestComplete {
assertEquals(swtch.invoke(instance, "Some string"), 0); assertEquals(swtch.invoke(instance, "Some string"), 0);
} }
@Ignore("Not implemented")
@Test @Test
public void testSwitch2() throws Exception { public void testSwitch2() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch2.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch2.jav");
@ -699,7 +698,6 @@ public class TestComplete {
var instance = clazz.getDeclaredConstructor().newInstance(); var instance = clazz.getDeclaredConstructor().newInstance();
} }
@Ignore("Not implemented")
@Test @Test
public void testOverloadPattern() throws Exception { public void testOverloadPattern() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav");
@ -835,7 +833,6 @@ public class TestComplete {
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3); assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
} }
@Ignore("Not implemented")
@Test @Test
public void testStringConcat() throws Exception { public void testStringConcat() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav");
@ -926,11 +923,4 @@ public class TestComplete {
var clazz = classFiles.get("Bug285"); var clazz = classFiles.get("Bug285");
var instance = clazz.getDeclaredConstructor().newInstance(); var instance = clazz.getDeclaredConstructor().newInstance();
} }
@Test
public void testBug290() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug290A.jav");
var clazz = classFiles.get("Bug290A");
var instance = clazz.getDeclaredConstructor().newInstance();
}
} }

View File

@ -1,5 +1,4 @@
import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.core.JavaTXCompiler;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.io.File; import java.io.File;
@ -22,7 +21,6 @@ public class TestPackages {
cmp.generateBytecode(bytecodeDirectory); cmp.generateBytecode(bytecodeDirectory);
} }
@Ignore("FIXME")
@Test @Test
public void testPackagesCircular() throws Exception { public void testPackagesCircular() throws Exception {
var cmp = new JavaTXCompiler( var cmp = new JavaTXCompiler(

View File

@ -35,7 +35,7 @@ public class ASTToTypedTargetAST {
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Overloading.jav").toFile(); var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Overloading.jav").toFile();
var compiler = new JavaTXCompiler(file); var compiler = new JavaTXCompiler(file);
var resultSet = compiler.typeInference(); var resultSet = compiler.typeInference();
var converter = new ASTToTargetAST(compiler, resultSet); var converter = new ASTToTargetAST(resultSet);
var classes = compiler.sourceFiles.get(file).getClasses(); var classes = compiler.sourceFiles.get(file).getClasses();
var classLoader = new ByteArrayClassLoader(); var classLoader = new ByteArrayClassLoader();
@ -106,7 +106,7 @@ public class ASTToTypedTargetAST {
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics.jav").toFile(); var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics.jav").toFile();
var compiler = new JavaTXCompiler(file); var compiler = new JavaTXCompiler(file);
var resultSet = compiler.typeInference(); var resultSet = compiler.typeInference();
var converter = new ASTToTargetAST(compiler, resultSet); var converter = new ASTToTargetAST(resultSet);
var classes = compiler.sourceFiles.get(file).getClasses(); var classes = compiler.sourceFiles.get(file).getClasses();
var generics = TestCodegen.generateClass(converter.convert(classes.get(0)), new ByteArrayClassLoader()); var generics = TestCodegen.generateClass(converter.convert(classes.get(0)), new ByteArrayClassLoader());
@ -151,7 +151,7 @@ public class ASTToTypedTargetAST {
var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics4.jav").toFile(); var file = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Generics4.jav").toFile();
var compiler = new JavaTXCompiler(file); var compiler = new JavaTXCompiler(file);
var resultSet = compiler.typeInference(); var resultSet = compiler.typeInference();
var converter = new ASTToTargetAST(compiler, resultSet); var converter = new ASTToTargetAST(resultSet);
var classes = compiler.sourceFiles.get(file).getClasses(); var classes = compiler.sourceFiles.get(file).getClasses();
var generics4 = TestCodegen.generateClass(converter.convert(classes.get(0)), new ByteArrayClassLoader()); var generics4 = TestCodegen.generateClass(converter.convert(classes.get(0)), new ByteArrayClassLoader());

View File

@ -2,7 +2,6 @@ package targetast;
import de.dhbwstuttgart.environment.ByteArrayClassLoader; import de.dhbwstuttgart.environment.ByteArrayClassLoader;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -10,7 +9,6 @@ import java.util.Vector;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@Ignore("FIXME")
public class InheritTest2 { public class InheritTest2 {
private static Class<?> classToTest, classToTestAA, classToTestBB, classToTestCC, classToTestDD; private static Class<?> classToTest, classToTestAA, classToTestBB, classToTestCC, classToTestDD;
private static Object instanceOfClass, instanceOfClassAA, instanceOfClassBB, instanceOfClassCC, instanceOfClassDD; private static Object instanceOfClass, instanceOfClassAA, instanceOfClassBB, instanceOfClassCC, instanceOfClassDD;

View File

@ -12,7 +12,6 @@ import de.dhbwstuttgart.target.generate.Bound;
import static de.dhbwstuttgart.target.generate.Bound.*; import static de.dhbwstuttgart.target.generate.Bound.*;
import de.dhbwstuttgart.target.generate.BoundsList; import de.dhbwstuttgart.target.generate.BoundsList;
import de.dhbwstuttgart.target.generate.GenericsResult; import de.dhbwstuttgart.target.generate.GenericsResult;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -22,7 +21,6 @@ import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Ignore("TODO: Rewrite with the new algorithm")
public class TestGenerics { public class TestGenerics {
private static final String rootDirectory = System.getProperty("user.dir") + "/resources/insertGenerics/javFiles/"; private static final String rootDirectory = System.getProperty("user.dir") + "/resources/insertGenerics/javFiles/";
private static final String bytecodeDirectory = System.getProperty("user.dir") + "targetTest"; private static final String bytecodeDirectory = System.getProperty("user.dir") + "targetTest";