Compare commits
5 Commits
ed1be59546
...
KPS2025
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c519d0746 | ||
|
|
db040d590e | ||
|
|
f496ff13b8 | ||
|
|
642ecc9a50 | ||
|
|
a0e59eebe8 |
@@ -18,7 +18,7 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
java-version: '24'
|
||||
cache: 'maven'
|
||||
- name: Compile project
|
||||
run: |
|
||||
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
java-version: '24'
|
||||
cache: 'maven'
|
||||
- name: Compile project
|
||||
run: |
|
||||
|
||||
10
pom.xml
10
pom.xml
@@ -44,11 +44,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<artifactId>asm</artifactId>
|
||||
<version>9.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>9.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -77,8 +72,9 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.14.0</version>
|
||||
<configuration>
|
||||
<source>25</source>
|
||||
<target>25</target>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
<source>24</source>
|
||||
<target>24</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
7
resources/AllgemeinTest/Uncurrier.jav
Normal file
7
resources/AllgemeinTest/Uncurrier.jav
Normal file
@@ -0,0 +1,7 @@
|
||||
public class Uncurrier{
|
||||
uncurry (f){
|
||||
return x -> f.apply(x);}
|
||||
uncurry (f){
|
||||
return (x, y) -> f.apply(x).apply(y);
|
||||
}
|
||||
}
|
||||
9
resources/AllgemeinTest/UncurrierMain.jav
Normal file
9
resources/AllgemeinTest/UncurrierMain.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
import Uncurrier;
|
||||
import java.lang.Integer;
|
||||
|
||||
class UncurrierMain {
|
||||
meth(y) {
|
||||
var uc = new Uncurrier() ;
|
||||
uc.uncurry(x -> x+1);
|
||||
}
|
||||
}
|
||||
9
resources/KPSPresentation/AddEle.jav
Normal file
9
resources/KPSPresentation/AddEle.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
import java.util.Vector;
|
||||
import java.util.Collection;
|
||||
|
||||
class AddEle {
|
||||
addEle(x, y) {
|
||||
x.add(y);
|
||||
return x;
|
||||
}
|
||||
}
|
||||
15
resources/KPSPresentation/Fac.jav
Normal file
15
resources/KPSPresentation/Fac.jav
Normal file
@@ -0,0 +1,15 @@
|
||||
import java.lang.Double;
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Fac {
|
||||
|
||||
getFac(n){
|
||||
var res = 1;
|
||||
var i = 1;
|
||||
while(i<=n) {
|
||||
res = res * i;
|
||||
i++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
25
resources/KPSPresentation/Faculty.jav
Normal file
25
resources/KPSPresentation/Faculty.jav
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Faculty {
|
||||
public Fun1$$<Double, Double> fact = (x) -> {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return x * (fact.apply(x-1.0));
|
||||
}
|
||||
};
|
||||
|
||||
public getFact(x) {
|
||||
return fact.apply(x);
|
||||
}
|
||||
|
||||
public static void main(x) {
|
||||
var f = new Faculty();
|
||||
var intRes = f.getFact(3.0);
|
||||
System.out.println(intRes);
|
||||
}
|
||||
}
|
||||
18
resources/KPSPresentation/FacultyBug.jav
Normal file
18
resources/KPSPresentation/FacultyBug.jav
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Float;
|
||||
|
||||
public class FacultyBug {
|
||||
public Fun1$$<Float, Float> fact = (x) -> {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return x * (fact.apply(x-1));
|
||||
}
|
||||
};
|
||||
|
||||
public getFact(x) {
|
||||
return fact.apply(x);
|
||||
}
|
||||
|
||||
}
|
||||
11
resources/KPSPresentation/Id.jav
Normal file
11
resources/KPSPresentation/Id.jav
Normal file
@@ -0,0 +1,11 @@
|
||||
class Id {
|
||||
id2 = x -> x;
|
||||
|
||||
id(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
id3(x) {
|
||||
return id(x);
|
||||
}
|
||||
}
|
||||
11
resources/KPSPresentation/Lambda.jav
Normal file
11
resources/KPSPresentation/Lambda.jav
Normal file
@@ -0,0 +1,11 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Lambda {
|
||||
|
||||
m () {
|
||||
var lam1 = (x) -> {
|
||||
return x * x;
|
||||
};
|
||||
return lam1;
|
||||
}
|
||||
}
|
||||
106
resources/KPSPresentation/Main.jav
Normal file
106
resources/KPSPresentation/Main.jav
Normal file
@@ -0,0 +1,106 @@
|
||||
import java.lang.String ;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Character;
|
||||
import java.lang.Object;
|
||||
import java.lang.Integer;
|
||||
import fst;
|
||||
import Id;
|
||||
import OLMain;
|
||||
import Fac;
|
||||
import Faculty;
|
||||
import applyLambda;
|
||||
import java.util.Vector;
|
||||
import Matrix;
|
||||
import MatrixOP;
|
||||
|
||||
public class Main {
|
||||
public static main(x) {
|
||||
/*
|
||||
new fst().main(5);
|
||||
System.out.println(new fst().main(5));
|
||||
|
||||
//Id.jav: the identity-function
|
||||
//applied to an integer
|
||||
System.out.println(new Id().id(1));
|
||||
//applied to a string
|
||||
System.out.println(new Id().id("hallo"));
|
||||
//lamda-Expr
|
||||
//System.out.println(new Id().id2.apply(1));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
|
||||
//OL.jav: Overloading
|
||||
OLMain ol = new OLMain();
|
||||
|
||||
//the function main is applied to an integer
|
||||
System.out.println(ol.main(2));
|
||||
//the main is applied to a double
|
||||
System.out.println(ol.main(2.0));
|
||||
System.out.println(ol.main("Hallo"));
|
||||
//Fac.jav
|
||||
System.out.println(new Fac().getFac(6));
|
||||
|
||||
|
||||
//Faculty.jav
|
||||
//System.out.println(new Faculty().fact.apply(6));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
System.out.println(new Faculty().getFact(3));
|
||||
|
||||
//Lambda.jav: An lambda expression applied by the method apply
|
||||
//System.out.println(new Lambda().m().apply(77));
|
||||
//Bug: https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/issues/378
|
||||
|
||||
//applyLambda.jav: A defined lambda expression is applied
|
||||
System.out.println(new applyLambda().m());
|
||||
*/
|
||||
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||
Vector<Integer> v1 = new Vector<Integer> ();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
Vector<Integer> v2 = new Vector<Integer> ();
|
||||
v2.addElement(3);
|
||||
v2.addElement(3);
|
||||
Matrix m1 = new Matrix();
|
||||
m1.addElement(v1);
|
||||
m1.addElement(v2);
|
||||
//vv.addElement(v1);
|
||||
//vv.addElement(v2);
|
||||
//Matrix m1 = new Matrix(vv);
|
||||
|
||||
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
||||
Vector<Integer> v3 = new Vector<Integer> ();
|
||||
v3.addElement(2);
|
||||
v3.addElement(2);
|
||||
Vector<Integer> v4 = new Vector<Integer> ();
|
||||
v4.addElement(3);
|
||||
v4.addElement(3);
|
||||
Matrix m2 = new Matrix();
|
||||
m2.addElement(v3);
|
||||
m2.addElement(v4);
|
||||
//vv1.addElement(v3);
|
||||
//vv1.addElement(v4);
|
||||
//Matrix m2 = new Matrix(vv1);
|
||||
|
||||
|
||||
//Matrix m3 = m1.mul(vv1);
|
||||
Matrix m3 = m1.mul(m2);
|
||||
System.out.println(m1.toString() + " * " + m2.toString() + " = " + m3.toString());
|
||||
|
||||
//MatrixOP
|
||||
MatrixOP mOp1 = new MatrixOP();
|
||||
mOp1.addElement(v1);
|
||||
mOp1.addElement(v2);
|
||||
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
|
||||
System.out.println(m1.toString() + " * " + m2.toString() + " = " + mOp2.toString());
|
||||
}
|
||||
}
|
||||
/*
|
||||
public class MainBug {
|
||||
public static main(x) {
|
||||
System.out.println(new fst().main(5));
|
||||
//System.out.println(new FacultyBug().getFact(3));
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
11
resources/KPSPresentation/MainFaculty.jav
Normal file
11
resources/KPSPresentation/MainFaculty.jav
Normal file
@@ -0,0 +1,11 @@
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import Faculty;
|
||||
|
||||
public class MainFaculty {
|
||||
public static void main(x) {
|
||||
//var f = new Faculty();
|
||||
//var intRes = f.getFact(3);
|
||||
//System.out.println(intRes);
|
||||
}
|
||||
}
|
||||
20
resources/KPSPresentation/MainOL.jav
Normal file
20
resources/KPSPresentation/MainOL.jav
Normal file
@@ -0,0 +1,20 @@
|
||||
import java.lang.String ;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Float;
|
||||
import OL2;
|
||||
|
||||
class MainOL {
|
||||
public static main(x) {
|
||||
var ol = new OL2();
|
||||
|
||||
//the function main is applied to an integer
|
||||
//var res1 = ol.m2(2);
|
||||
//the main is applied to a double
|
||||
//System.out.println(ol.m2(2.0));
|
||||
//System.out.println(ol.m2("Hallo").toString());
|
||||
var res2 = ol.m2("Hallo").toString();
|
||||
System.out.println(res2);
|
||||
|
||||
}
|
||||
}
|
||||
41
resources/KPSPresentation/Matrix.jav
Normal file
41
resources/KPSPresentation/Matrix.jav
Normal file
@@ -0,0 +1,41 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
|
||||
public Matrix () {
|
||||
}
|
||||
|
||||
public Matrix(vv) {
|
||||
var i = 0;
|
||||
while(i < vv.size()) {
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mul(m) {
|
||||
var ret = new Matrix();
|
||||
var i = 0;
|
||||
while(i < size()) {
|
||||
var v1 = this.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
64
resources/KPSPresentation/MatrixOP.jav
Normal file
64
resources/KPSPresentation/MatrixOP.jav
Normal file
@@ -0,0 +1,64 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
|
||||
public MatrixOP () {
|
||||
}
|
||||
|
||||
public MatrixOP(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
mul = (m1, m2) -> {
|
||||
var ret = new MatrixOP();
|
||||
var i = 0;
|
||||
while(i < m1.size()) {
|
||||
var v1 = m1.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m2.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
// v2.addElement(new Integer(erg));
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
public static main(x) {
|
||||
var vv = new Vector<Vector<Integer>>();
|
||||
var v1 = new Vector<Integer> ();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
var v2 = new Vector<Integer> ();
|
||||
v2.addElement(3);
|
||||
v2.addElement(3);
|
||||
|
||||
//MatrixOP
|
||||
MatrixOP mOp1 = new MatrixOP();
|
||||
mOp1.addElement(v1);
|
||||
mOp1.addElement(v2);
|
||||
MatrixOP mOp2 = mOp1.mul.apply(mOp1, mOp1);
|
||||
System.out.print(mOp1); System.out.print(" * "); System.out.print(mOp1); System.out.print(" = "); System.out.println(mOp2);
|
||||
//System.out.print(mOp1 + " * " + mOp1 + " = " + mOp2);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
resources/KPSPresentation/OL.jav
Normal file
33
resources/KPSPresentation/OL.jav
Normal file
@@ -0,0 +1,33 @@
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Object;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
|
||||
|
||||
|
||||
public class OL1 {
|
||||
|
||||
m1( x) { return x + x; }
|
||||
|
||||
|
||||
m1(x) { return x || x; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class OL2 {
|
||||
|
||||
m2(x) {
|
||||
var ol;
|
||||
ol = new OL1();
|
||||
return ol.m1(x);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
resources/KPSPresentation/OLFun.jav
Normal file
20
resources/KPSPresentation/OLFun.jav
Normal file
@@ -0,0 +1,20 @@
|
||||
import java.lang.String;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.util.Vector;
|
||||
import java.lang.Boolean;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class OLFun {
|
||||
x;
|
||||
|
||||
|
||||
m(f, y) {
|
||||
y = f.apply(x+x);
|
||||
return x;
|
||||
}
|
||||
|
||||
}
|
||||
12
resources/KPSPresentation/Pair.jav
Normal file
12
resources/KPSPresentation/Pair.jav
Normal file
@@ -0,0 +1,12 @@
|
||||
class Pair {
|
||||
fst;
|
||||
snd;
|
||||
|
||||
Pair(fst, snd) { this.fst=fst; this.snd=snd; }
|
||||
|
||||
getfst() { return this.fst; }
|
||||
|
||||
swap() {
|
||||
return new Pair<>(this.snd, this.fst);
|
||||
}
|
||||
}
|
||||
9
resources/KPSPresentation/Plus.jav
Normal file
9
resources/KPSPresentation/Plus.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
|
||||
public class Plus {
|
||||
|
||||
m(a, b) {
|
||||
return a+b;
|
||||
}
|
||||
}
|
||||
25
resources/KPSPresentation/Sorting.jav
Normal file
25
resources/KPSPresentation/Sorting.jav
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.String;
|
||||
|
||||
public class Sorting{
|
||||
merge(a, b){
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
sort(in){
|
||||
var firstHalf = in;
|
||||
var secondHalf = in;
|
||||
return merge(sort(firstHalf), sort(secondHalf));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void sort(a){
|
||||
a = merge(a,a);
|
||||
}
|
||||
*/
|
||||
}
|
||||
20
resources/KPSPresentation/Swap.jav
Normal file
20
resources/KPSPresentation/Swap.jav
Normal file
@@ -0,0 +1,20 @@
|
||||
import java.lang.String;
|
||||
import java.lang.Object;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Character;
|
||||
|
||||
public class Swap{
|
||||
<ZDP, ZEA, ZDO, YZP, ZCY, ZDZ> Fun1$$<ZCY, Fun1$$<ZDZ, ZEA>> swap(f){
|
||||
return x->y->f.apply(y).apply(x);
|
||||
}
|
||||
|
||||
Fun1$$<String, Fun1$$<String, Fun1$$<String, String>>> swap(f){
|
||||
return x -> y -> z -> f.apply(z).apply(x).apply(y);
|
||||
}
|
||||
|
||||
public static main (y) {
|
||||
var func = x -> y -> z -> x + y + z;
|
||||
var res = new Swap().swap(func).apply("A").apply("B").apply("C");
|
||||
System.out.println(res);}
|
||||
}
|
||||
6
resources/KPSPresentation/TPHMethod.jav
Normal file
6
resources/KPSPresentation/TPHMethod.jav
Normal file
@@ -0,0 +1,6 @@
|
||||
class TPHMethod {
|
||||
void m(a, b) {
|
||||
a = b;
|
||||
b=a;
|
||||
}
|
||||
}
|
||||
16
resources/KPSPresentation/Test.jav
Normal file
16
resources/KPSPresentation/Test.jav
Normal file
@@ -0,0 +1,16 @@
|
||||
class Test{
|
||||
void m( op, a, b ){
|
||||
op.myapply(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
class Atype{}
|
||||
class Btype{}
|
||||
|
||||
class Operator1{
|
||||
void myapply(Atype p1, Atype p2){...}
|
||||
}
|
||||
|
||||
class Operator2{
|
||||
void myapply(Btype p1, Btype p2){...}
|
||||
}
|
||||
7
resources/KPSPresentation/Uncurrier.jav
Normal file
7
resources/KPSPresentation/Uncurrier.jav
Normal file
@@ -0,0 +1,7 @@
|
||||
public class Uncurrier{
|
||||
uncurry (f){
|
||||
return x -> f.apply(x);}
|
||||
uncurry (f){
|
||||
return (x, y) -> f.apply(x).apply(y);
|
||||
}
|
||||
}
|
||||
7
resources/KPSPresentation/UncurrierMain.jav
Normal file
7
resources/KPSPresentation/UncurrierMain.jav
Normal file
@@ -0,0 +1,7 @@
|
||||
import Uncurrier;
|
||||
|
||||
class UncurrierMain {
|
||||
public static main(x) {
|
||||
var uc = new Uncurrier() ;
|
||||
}
|
||||
}
|
||||
16
resources/KPSPresentation/VectorAdd.jav
Normal file
16
resources/KPSPresentation/VectorAdd.jav
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.util.Vector;
|
||||
|
||||
class VectorAdd {
|
||||
vectorAdd(v1, v2) {
|
||||
var i = 0;
|
||||
var erg = new Vector<>();
|
||||
while (i < v1.size()) {
|
||||
erg.addElement(v1.elementAt(i) + v2.elementAt(i));
|
||||
i++;
|
||||
}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
16
resources/KPSPresentation/applyLambda.jav
Normal file
16
resources/KPSPresentation/applyLambda.jav
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.util.Vector;
|
||||
class Apply { }
|
||||
|
||||
public class applyLambda {
|
||||
|
||||
public m () {
|
||||
var lam1 = (x) -> {
|
||||
return x;
|
||||
};
|
||||
|
||||
return lam1.apply(new Apply());
|
||||
//return lam1;
|
||||
//return new Vector();
|
||||
}
|
||||
}
|
||||
|
||||
7
resources/KPSPresentation/fst.jav
Normal file
7
resources/KPSPresentation/fst.jav
Normal file
@@ -0,0 +1,7 @@
|
||||
//import java.lang.Integer;
|
||||
|
||||
class fst {
|
||||
main(x) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
8
resources/KPSPresentation/genVector.jav
Normal file
8
resources/KPSPresentation/genVector.jav
Normal file
@@ -0,0 +1,8 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class genVector {
|
||||
|
||||
m(v) {
|
||||
return v.elementAt(0);
|
||||
}
|
||||
}
|
||||
8
resources/KPSPresentation/idTest.jav
Normal file
8
resources/KPSPresentation/idTest.jav
Normal file
@@ -0,0 +1,8 @@
|
||||
import java.lang.Integer;
|
||||
import Id;
|
||||
|
||||
class Test {
|
||||
m() {
|
||||
Integer o1 = new Id<Integer,Integer>().id2.apply(1);
|
||||
}
|
||||
}
|
||||
9
resources/KPSPresentation/lambdaId.jav
Normal file
9
resources/KPSPresentation/lambdaId.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
public class lambdaId {
|
||||
lambdaId = x -> x;
|
||||
|
||||
/*
|
||||
id3 (x) {
|
||||
return lambdaId.apply(x);
|
||||
}
|
||||
*/
|
||||
}
|
||||
9
resources/KPSPresentation/mathStruc.jav
Normal file
9
resources/KPSPresentation/mathStruc.jav
Normal file
@@ -0,0 +1,9 @@
|
||||
class mathStruc {
|
||||
model;
|
||||
|
||||
innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model));
|
||||
|
||||
mathStruc(m) {
|
||||
model =m;
|
||||
}
|
||||
}
|
||||
18
resources/KPSPresentation/mathStrucInteger.jav
Normal file
18
resources/KPSPresentation/mathStrucInteger.jav
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.lang.Integer;
|
||||
|
||||
class mathStruc {
|
||||
model;
|
||||
|
||||
innerOp = (o) -> (ms) -> new mathStruc<>(o.apply(model,ms.model));
|
||||
|
||||
mathStruc(m) {
|
||||
model =m;
|
||||
}
|
||||
}
|
||||
|
||||
class mathStrucIntegerUse {
|
||||
main() {
|
||||
var ms = new mathStruc<>(2);
|
||||
return ms.innerOp.apply((x,y) -> x+y).apply(ms);
|
||||
}
|
||||
}
|
||||
90
resources/KPSPresentation/mathStrucMatrixOP.jav
Normal file
90
resources/KPSPresentation/mathStrucMatrixOP.jav
Normal file
@@ -0,0 +1,90 @@
|
||||
import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Boolean;
|
||||
|
||||
public class mathStrucMatrixOP {
|
||||
model;
|
||||
|
||||
innerOp = (o) -> (ms) -> new mathStrucMatrixOP<>(o.apply(model,ms.model));
|
||||
|
||||
public mathStrucMatrixOP(m) {
|
||||
model =m;
|
||||
}
|
||||
}
|
||||
|
||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
|
||||
MatrixOP () {
|
||||
}
|
||||
|
||||
MatrixOP(vv) {
|
||||
Integer i;
|
||||
i = 0;
|
||||
while(i < vv.size()) {
|
||||
// Boolean a = this.add(vv.elementAt(i));
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
|
||||
public mul = (m1, m2) -> {
|
||||
var ret = new MatrixOP();
|
||||
var i = 0;
|
||||
while(i < m1.size()) {
|
||||
var v1 = m1.elementAt(i);
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
while(k < v1.size()) {
|
||||
erg = erg + v1.elementAt(k)
|
||||
* m2.elementAt(k).elementAt(j);
|
||||
k++; }
|
||||
// v2.addElement(new Integer(erg));
|
||||
v2.addElement(erg);
|
||||
j++; }
|
||||
ret.addElement(v2);
|
||||
i++;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
class mathStrucUseMatrixOP {
|
||||
|
||||
main() {
|
||||
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||
Vector<Integer> v1 = new Vector<Integer>();
|
||||
v1.addElement(2);
|
||||
v1.addElement(2);
|
||||
Vector<Integer> v2 = new Vector<Integer>();
|
||||
v2.addElement(3);
|
||||
v2.addElement(3);
|
||||
vv.addElement(v1);
|
||||
vv.addElement(v2);
|
||||
|
||||
MatrixOP m1 = new MatrixOP(vv);
|
||||
|
||||
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
||||
Vector<Integer> v3 = new Vector<Integer>();
|
||||
v3.addElement(2);
|
||||
v3.addElement(2);
|
||||
Vector<Integer> v4 = new Vector<Integer>();
|
||||
v4.addElement(3);
|
||||
v4.addElement(3);
|
||||
vv1.addElement(v3);
|
||||
vv1.addElement(v4);
|
||||
|
||||
MatrixOP m2 = new MatrixOP(vv1);
|
||||
|
||||
var mms;
|
||||
mms = new mathStrucMatrixOP<>(m1);
|
||||
var mms2;
|
||||
mms2 = new mathStrucMatrixOP<>(m2);
|
||||
var mms3;
|
||||
mms3 = mms.innerOp.apply(m1.mul).apply(mms2);
|
||||
return mms3;
|
||||
}
|
||||
}
|
||||
14
resources/KPSPresentation/test1.jav
Normal file
14
resources/KPSPresentation/test1.jav
Normal file
@@ -0,0 +1,14 @@
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Integer;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class testclass{
|
||||
|
||||
public testMethod(ele){
|
||||
if(ele){
|
||||
return 1;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class Bug378Id {
|
||||
id2 = x -> x;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import Bug378Id;
|
||||
import java.lang.Integer;
|
||||
|
||||
public class Bug378Main {
|
||||
public static main(args) {
|
||||
var hallo = (new Bug378Id<Integer>().id2).apply(1);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Bug379 {
|
||||
public Fun1$$<Double, Double> fact = (x) -> {
|
||||
if (x == 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return x * (fact.apply(x-1));
|
||||
}
|
||||
};
|
||||
|
||||
public getFact(x) {
|
||||
return fact.apply(x);
|
||||
}
|
||||
|
||||
public static void main(x) {
|
||||
var f = new Bug379();
|
||||
var intRes = f.getFact(3);
|
||||
System.out.println(intRes);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
sealed interface List<T> permits Cons, Empty {}
|
||||
record Cons<T>(T a , List<T> l ) implements List <T> {}
|
||||
record Empty<T>() implements List <T> {}
|
||||
|
||||
public class Bug380 {
|
||||
public <T> List<T> append(l1, List<T> l2) {
|
||||
return switch ( l1 ) {
|
||||
case Cons(e, rest) -> new Cons<>(e, append(rest, l2)); //::Typ TPH A
|
||||
case Empty() -> l2;//::TPH B
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import java.lang.Runnable;
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Thread;
|
||||
|
||||
public class Bug382 {
|
||||
public static main(a) {
|
||||
var f = () -> System.out.println("Hallo Welt!");
|
||||
new Thread(f).run();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import java.lang.String;
|
||||
import java.lang.System;
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Bug383 {
|
||||
public static main(a) {
|
||||
var f = () -> System.out.println("Hello from Thread!");
|
||||
f.apply();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import java.util.Vector;
|
||||
import java.lang.Integer;
|
||||
//import java.lang.Byte;
|
||||
import java.lang.Boolean;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import java.lang.Integer;
|
||||
import java.lang.Double;
|
||||
import java.lang.Number;
|
||||
import java.lang.String;
|
||||
|
||||
public record R(String n) {}
|
||||
public record R(Number n) {}
|
||||
|
||||
public class SwitchOverload {
|
||||
|
||||
f() { return 10; }
|
||||
g() { return 20; }
|
||||
public f(){}
|
||||
|
||||
public m(r) {
|
||||
return switch(r) {
|
||||
case R("test") -> f();
|
||||
case R("foo") -> g();
|
||||
case R r -> 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,7 @@ import de.dhbwstuttgart.target.tree.*;
|
||||
import de.dhbwstuttgart.target.tree.expression.*;
|
||||
import de.dhbwstuttgart.target.tree.type.*;
|
||||
import org.objectweb.asm.*;
|
||||
import org.objectweb.asm.tree.analysis.AnalyzerException;
|
||||
import org.objectweb.asm.util.CheckClassAdapter;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.invoke.*;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
@@ -128,7 +125,7 @@ public class Codegen {
|
||||
}
|
||||
|
||||
private void popValue(State state, TargetType type) {
|
||||
if (type.equals(TargetType.double_) || type.equals(TargetType.long_))
|
||||
if (type.equals(TargetType.Double) || type.equals(TargetType.Long))
|
||||
state.mv.visitInsn(POP2);
|
||||
else
|
||||
state.mv.visitInsn(POP);
|
||||
@@ -137,21 +134,21 @@ public class Codegen {
|
||||
private void boxPrimitive(State state, TargetType type) {
|
||||
if (type instanceof TargetExtendsWildcard ew) type = ew.innerType();
|
||||
var mv = state.mv;
|
||||
if (type.equals(TargetType.boolean_)) {
|
||||
if (type.equals(TargetType.Boolean) || type.equals(TargetType.boolean_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;", false);
|
||||
} else if (type.equals(TargetType.byte_)) {
|
||||
} else if (type.equals(TargetType.Byte) || type.equals(TargetType.byte_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
} else if (type.equals(TargetType.Double) || type.equals(TargetType.double_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
|
||||
} else if (type.equals(TargetType.long_)) {
|
||||
} else if (type.equals(TargetType.Long) || type.equals(TargetType.long_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
|
||||
} else if (type.equals(TargetType.int_)) {
|
||||
} else if (type.equals(TargetType.Integer) || type.equals(TargetType.int_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
} else if (type.equals(TargetType.Float) || type.equals(TargetType.float_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
|
||||
} else if (type.equals(TargetType.short_)) {
|
||||
} else if (type.equals(TargetType.Short) || type.equals(TargetType.short_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
|
||||
} else if (type.equals(TargetType.char_)) {
|
||||
} else if (type.equals(TargetType.Char) || type.equals(TargetType.char_)) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;", false);
|
||||
}
|
||||
}
|
||||
@@ -188,11 +185,9 @@ public class Codegen {
|
||||
convertTo(state, op.right().type(), type);
|
||||
mv.visitJumpInsn(code, if_true);
|
||||
mv.visitInsn(ICONST_0);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(GOTO, end);
|
||||
mv.visitLabel(if_true);
|
||||
mv.visitInsn(ICONST_1);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitLabel(end);
|
||||
}
|
||||
|
||||
@@ -207,11 +202,9 @@ public class Codegen {
|
||||
mv.visitInsn(cmp);
|
||||
mv.visitJumpInsn(code, if_true);
|
||||
mv.visitInsn(ICONST_0);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(GOTO, end);
|
||||
mv.visitLabel(if_true);
|
||||
mv.visitInsn(ICONST_1);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitLabel(end);
|
||||
}
|
||||
|
||||
@@ -240,85 +233,65 @@ public class Codegen {
|
||||
if (source instanceof TargetExtendsWildcard ew) source = ew.innerType();
|
||||
if (dest instanceof TargetExtendsWildcard ew) dest = ew.innerType();
|
||||
|
||||
var mv = state.mv;
|
||||
if (source.equals(dest))
|
||||
return;
|
||||
|
||||
if (isFunctionalInterface(source) && isFunctionalInterface(dest) &&
|
||||
if (source.equals(TargetType.Long)) {
|
||||
if (dest.equals(TargetType.Integer))
|
||||
mv.visitInsn(L2I);
|
||||
else if (dest.equals(TargetType.Float))
|
||||
mv.visitInsn(L2F);
|
||||
else if (dest.equals(TargetType.Double))
|
||||
mv.visitInsn(L2D);
|
||||
else if (dest.equals(TargetType.Byte) || dest.equals(TargetType.Char) || dest.equals(TargetType.Short)) {
|
||||
mv.visitInsn(L2I);
|
||||
convertTo(state, TargetType.Integer, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.Float)) {
|
||||
if (dest.equals(TargetType.Integer))
|
||||
mv.visitInsn(F2I);
|
||||
else if (dest.equals(TargetType.Double))
|
||||
mv.visitInsn(F2D);
|
||||
else if (dest.equals(TargetType.Long))
|
||||
mv.visitInsn(F2L);
|
||||
else if (dest.equals(TargetType.Byte) || dest.equals(TargetType.Char) || dest.equals(TargetType.Short)) {
|
||||
mv.visitInsn(F2I);
|
||||
convertTo(state, TargetType.Integer, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.Double)) {
|
||||
if (dest.equals(TargetType.Integer))
|
||||
mv.visitInsn(D2I);
|
||||
else if (dest.equals(TargetType.Float))
|
||||
mv.visitInsn(D2F);
|
||||
else if (dest.equals(TargetType.Long))
|
||||
mv.visitInsn(D2L);
|
||||
else if (dest.equals(TargetType.Byte) || dest.equals(TargetType.Char) || dest.equals(TargetType.Short)) {
|
||||
mv.visitInsn(D2I);
|
||||
convertTo(state, TargetType.Integer, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.Byte) || source.equals(TargetType.Char) || source.equals(TargetType.Short) || source.equals(TargetType.Integer)) {
|
||||
if (dest.equals(TargetType.Byte))
|
||||
mv.visitInsn(I2B);
|
||||
else if (dest.equals(TargetType.Char))
|
||||
mv.visitInsn(I2C);
|
||||
else if (dest.equals(TargetType.Short))
|
||||
mv.visitInsn(I2S);
|
||||
else if (dest.equals(TargetType.Long))
|
||||
mv.visitInsn(I2L);
|
||||
else if (dest.equals(TargetType.Float))
|
||||
mv.visitInsn(I2F);
|
||||
else if (dest.equals(TargetType.Double))
|
||||
mv.visitInsn(I2D);
|
||||
} else if (source.equals(TargetType.Boolean)) {
|
||||
unboxPrimitive(state, dest);
|
||||
} else if (isFunctionalInterface(source) && isFunctionalInterface(dest) &&
|
||||
!(source instanceof TargetFunNType && dest instanceof TargetFunNType)) {
|
||||
boxFunctionalInterface(state, source, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
var mv = state.mv;
|
||||
if ((source instanceof TargetRefType || source instanceof TargetGenericType) &&
|
||||
(dest instanceof TargetRefType || dest instanceof TargetGenericType)) {
|
||||
if (dest instanceof TargetGenericType) return;
|
||||
} else if (!(dest instanceof TargetGenericType)) {
|
||||
//boxPrimitive(state, source);
|
||||
mv.visitTypeInsn(CHECKCAST, dest.getInternalName());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(source instanceof TargetPrimitiveType)) {
|
||||
unboxPrimitive(state, source);
|
||||
source = TargetType.toPrimitive(source);
|
||||
}
|
||||
|
||||
var origDest = dest;
|
||||
dest = TargetType.toPrimitive(dest);
|
||||
if (source.equals(TargetType.long_)) {
|
||||
if (dest.equals(TargetType.int_))
|
||||
mv.visitInsn(L2I);
|
||||
else if (dest.equals(TargetType.float_))
|
||||
mv.visitInsn(L2F);
|
||||
else if (dest.equals(TargetType.double_))
|
||||
mv.visitInsn(L2D);
|
||||
else if (dest.equals(TargetType.byte_) || dest.equals(TargetType.char_) || dest.equals(TargetType.short_)) {
|
||||
mv.visitInsn(L2I);
|
||||
convertTo(state, TargetType.int_, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.float_)) {
|
||||
if (dest.equals(TargetType.int_))
|
||||
mv.visitInsn(F2I);
|
||||
else if (dest.equals(TargetType.double_))
|
||||
mv.visitInsn(F2D);
|
||||
else if (dest.equals(TargetType.long_))
|
||||
mv.visitInsn(F2L);
|
||||
else if (dest.equals(TargetType.byte_) || dest.equals(TargetType.char_) || dest.equals(TargetType.short_)) {
|
||||
mv.visitInsn(F2I);
|
||||
convertTo(state, TargetType.int_, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.double_)) {
|
||||
if (dest.equals(TargetType.int_))
|
||||
mv.visitInsn(D2I);
|
||||
else if (dest.equals(TargetType.float_))
|
||||
mv.visitInsn(D2F);
|
||||
else if (dest.equals(TargetType.long_))
|
||||
mv.visitInsn(D2L);
|
||||
else if (dest.equals(TargetType.byte_) || dest.equals(TargetType.char_) || dest.equals(TargetType.short_)) {
|
||||
mv.visitInsn(D2I);
|
||||
convertTo(state, TargetType.int_, dest);
|
||||
}
|
||||
} else if (source.equals(TargetType.byte_) || source.equals(TargetType.char_) || source.equals(TargetType.short_) || source.equals(TargetType.int_)) {
|
||||
if (dest.equals(TargetType.byte_))
|
||||
mv.visitInsn(I2B);
|
||||
else if (dest.equals(TargetType.char_))
|
||||
mv.visitInsn(I2C);
|
||||
else if (dest.equals(TargetType.short_))
|
||||
mv.visitInsn(I2S);
|
||||
else if (dest.equals(TargetType.long_))
|
||||
mv.visitInsn(I2L);
|
||||
else if (dest.equals(TargetType.float_))
|
||||
mv.visitInsn(I2F);
|
||||
else if (dest.equals(TargetType.double_))
|
||||
mv.visitInsn(I2D);
|
||||
} else if (source.equals(TargetType.boolean_)) {
|
||||
unboxPrimitive(state, dest);
|
||||
}
|
||||
|
||||
if (!(origDest instanceof TargetPrimitiveType)) {
|
||||
if (dest instanceof TargetPrimitiveType)
|
||||
boxPrimitive(state, dest);
|
||||
else boxPrimitive(state, source);
|
||||
}
|
||||
}
|
||||
|
||||
record TypePair(TargetType from, TargetType to) {}
|
||||
@@ -377,9 +350,9 @@ public class Codegen {
|
||||
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false);
|
||||
} else {
|
||||
generate(state, add.left());
|
||||
convertTo(state, add.left().type(), TargetType.toPrimitive(add.type()));
|
||||
convertTo(state, add.left().type(), add.type());
|
||||
generate(state, add.right());
|
||||
convertTo(state, add.right().type(), TargetType.toPrimitive(add.type()));
|
||||
convertTo(state, add.right().type(), add.type());
|
||||
var type = add.type();
|
||||
if (type.equals(TargetType.Byte) || type.equals(TargetType.Char) || type.equals(TargetType.Integer) || type.equals(TargetType.Short)) {
|
||||
mv.visitInsn(IADD);
|
||||
@@ -392,7 +365,6 @@ public class Codegen {
|
||||
} else {
|
||||
throw new CodeGenException("Invalid argument to Add expression, type: " + add.type());
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
}
|
||||
if (add.type().equals(TargetType.String)) {
|
||||
generate(state, add.right());
|
||||
@@ -404,9 +376,9 @@ public class Codegen {
|
||||
}
|
||||
case Sub sub: {
|
||||
generate(state, sub.left());
|
||||
convertTo(state, sub.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, sub.left().type(), op.type());
|
||||
generate(state, sub.right());
|
||||
convertTo(state, sub.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, sub.right().type(), op.type());
|
||||
var type = sub.type();
|
||||
if (type.equals(TargetType.Byte) || type.equals(TargetType.Char) || type.equals(TargetType.Integer) || type.equals(TargetType.Short)) {
|
||||
mv.visitInsn(ISUB);
|
||||
@@ -419,14 +391,13 @@ public class Codegen {
|
||||
} else {
|
||||
throw new CodeGenException("Invalid argument to Sub expression");
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Div div: {
|
||||
generate(state, div.left());
|
||||
convertTo(state, div.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, div.left().type(), op.type());
|
||||
generate(state, div.right());
|
||||
convertTo(state, div.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, div.right().type(), op.type());
|
||||
var type = div.type();
|
||||
if (type.equals(TargetType.Byte) || type.equals(TargetType.Char) || type.equals(TargetType.Integer) || type.equals(TargetType.Short)) {
|
||||
mv.visitInsn(IDIV);
|
||||
@@ -439,14 +410,13 @@ public class Codegen {
|
||||
} else {
|
||||
throw new CodeGenException("Invalid argument to Div expression");
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Mul mul: {
|
||||
generate(state, mul.left());
|
||||
convertTo(state, mul.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, mul.left().type(), op.type());
|
||||
generate(state, mul.right());
|
||||
convertTo(state, mul.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, mul.right().type(), op.type());
|
||||
var type = mul.type();
|
||||
if (type.equals(TargetType.Byte) || type.equals(TargetType.Char) || type.equals(TargetType.Integer) || type.equals(TargetType.Short)) {
|
||||
mv.visitInsn(IMUL);
|
||||
@@ -459,14 +429,13 @@ public class Codegen {
|
||||
} else {
|
||||
throw new CodeGenException("Invalid argument to Mul expression");
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Rem rem: {
|
||||
generate(state, rem.left());
|
||||
convertTo(state, rem.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, rem.left().type(), op.type());
|
||||
generate(state, rem.right());
|
||||
convertTo(state, rem.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, rem.right().type(), op.type());
|
||||
var type = rem.type();
|
||||
if (type.equals(TargetType.Byte) || type.equals(TargetType.Char) || type.equals(TargetType.Integer) || type.equals(TargetType.Short)) {
|
||||
mv.visitInsn(IREM);
|
||||
@@ -479,7 +448,6 @@ public class Codegen {
|
||||
} else {
|
||||
throw new CodeGenException("Invalid argument to Rem expression");
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Or or: {
|
||||
@@ -487,18 +455,14 @@ public class Codegen {
|
||||
Label or_true = new Label();
|
||||
Label end = new Label();
|
||||
generate(state, or.left());
|
||||
convertTo(state, or.left().type(), TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(IFNE, or_true);
|
||||
generate(state, or.right());
|
||||
convertTo(state, or.right().type(), TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(IFEQ, or_false);
|
||||
mv.visitLabel(or_true);
|
||||
mv.visitInsn(ICONST_1);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(GOTO, end);
|
||||
mv.visitLabel(or_false);
|
||||
mv.visitInsn(ICONST_0);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitLabel(end);
|
||||
break;
|
||||
}
|
||||
@@ -506,54 +470,47 @@ public class Codegen {
|
||||
Label and_false = new Label();
|
||||
Label end = new Label();
|
||||
generate(state, and.left());
|
||||
convertTo(state, and.left().type(), TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(IFEQ, and_false);
|
||||
generate(state, and.right());
|
||||
convertTo(state, and.right().type(), TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(IFEQ, and_false);
|
||||
mv.visitInsn(ICONST_1);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitJumpInsn(GOTO, end);
|
||||
mv.visitLabel(and_false);
|
||||
mv.visitInsn(ICONST_0);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitLabel(end);
|
||||
break;
|
||||
}
|
||||
case BAnd band: {
|
||||
generate(state, band.left());
|
||||
convertTo(state, band.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, band.left().type(), op.type());
|
||||
generate(state, band.right());
|
||||
convertTo(state, band.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, band.right().type(), op.type());
|
||||
if (band.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LAND);
|
||||
else
|
||||
mv.visitInsn(IAND);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case BOr bor: {
|
||||
generate(state, bor.left());
|
||||
convertTo(state, bor.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, bor.left().type(), op.type());
|
||||
generate(state, bor.right());
|
||||
convertTo(state, bor.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, bor.right().type(), op.type());
|
||||
if (bor.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LOR);
|
||||
else
|
||||
mv.visitInsn(IOR);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case XOr xor: {
|
||||
generate(state, xor.left());
|
||||
convertTo(state, xor.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, xor.left().type(), op.type());
|
||||
generate(state, xor.right());
|
||||
convertTo(state, xor.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, xor.right().type(), op.type());
|
||||
if (xor.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LXOR);
|
||||
else
|
||||
mv.visitInsn(IXOR);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Instof instof: {
|
||||
@@ -562,47 +519,44 @@ public class Codegen {
|
||||
}
|
||||
case Shl shl: {
|
||||
generate(state, shl.left());
|
||||
convertTo(state, shl.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, shl.left().type(), op.type());
|
||||
generate(state, shl.right());
|
||||
convertTo(state, shl.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, shl.right().type(), op.type());
|
||||
if (shl.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LSHL);
|
||||
else
|
||||
mv.visitInsn(ISHL);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Shr shr: {
|
||||
generate(state, shr.left());
|
||||
convertTo(state, shr.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, shr.left().type(), op.type());
|
||||
generate(state, shr.right());
|
||||
convertTo(state, shr.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, shr.right().type(), op.type());
|
||||
if (shr.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LSHR);
|
||||
else
|
||||
mv.visitInsn(ISHR);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case UShr ushr: {
|
||||
generate(state, ushr.left());
|
||||
convertTo(state, ushr.left().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, ushr.left().type(), op.type());
|
||||
generate(state, ushr.right());
|
||||
convertTo(state, ushr.right().type(), TargetType.toPrimitive(op.type()));
|
||||
convertTo(state, ushr.right().type(), op.type());
|
||||
if (ushr.type().equals(TargetType.Long))
|
||||
mv.visitInsn(LUSHR);
|
||||
else
|
||||
mv.visitInsn(IUSHR);
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
break;
|
||||
}
|
||||
case Greater greater: {
|
||||
var type = TargetType.toPrimitive(largerType(greater.left().type(), greater.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
var type = largerType(greater.left().type(), greater.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, greater, type, LCMP, IFGT);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, greater, type, FCMPL, IFGT);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, greater, type, DCMPL, IFGT);
|
||||
} else {
|
||||
generateRelationalOperator(state, greater, type, IF_ICMPGT);
|
||||
@@ -610,12 +564,12 @@ public class Codegen {
|
||||
break;
|
||||
}
|
||||
case Less less: {
|
||||
var type = TargetType.toPrimitive(largerType(less.left().type(), less.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
var type = largerType(less.left().type(), less.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, less, type, LCMP, IFLT);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, less, type, FCMPL, IFLT);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, less, type, DCMPL, IFLT);
|
||||
} else {
|
||||
generateRelationalOperator(state, less, type, IF_ICMPLT);
|
||||
@@ -623,12 +577,12 @@ public class Codegen {
|
||||
break;
|
||||
}
|
||||
case GreaterOrEqual greaterOrEqual: {
|
||||
var type = TargetType.toPrimitive(largerType(greaterOrEqual.left().type(), greaterOrEqual.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
var type = largerType(greaterOrEqual.left().type(), greaterOrEqual.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, greaterOrEqual, type, LCMP, IFGE);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, greaterOrEqual, type, FCMPL, IFGE);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, greaterOrEqual, type, DCMPL, IFGE);
|
||||
} else {
|
||||
generateRelationalOperator(state, greaterOrEqual, type, IF_ICMPGE);
|
||||
@@ -636,12 +590,12 @@ public class Codegen {
|
||||
break;
|
||||
}
|
||||
case LessOrEqual lessOrEqual: {
|
||||
var type = TargetType.toPrimitive(largerType(lessOrEqual.left().type(), lessOrEqual.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
var type = largerType(lessOrEqual.left().type(), lessOrEqual.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, lessOrEqual, type, LCMP, IFLE);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, lessOrEqual, type, FCMPL, IFLE);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, lessOrEqual, type, DCMPL, IFLE);
|
||||
} else {
|
||||
generateRelationalOperator(state, lessOrEqual, type, IF_ICMPLE);
|
||||
@@ -649,30 +603,30 @@ public class Codegen {
|
||||
break;
|
||||
}
|
||||
case Equal equal: {
|
||||
var type = TargetType.toPrimitive(largerType(equal.left().type(), equal.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
generateRelationalOperator(state, equal, TargetType.long_, LCMP, IFEQ);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
generateRelationalOperator(state, equal, TargetType.float_, FCMPL, IFEQ);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
generateRelationalOperator(state, equal, TargetType.double_, DCMPL, IFEQ);
|
||||
} else if (type.equals(TargetType.char_) || type.equals(TargetType.short_) || type.equals(TargetType.byte_) || type.equals(TargetType.int_) || type.equals(TargetType.boolean_)) {
|
||||
generateRelationalOperator(state, equal, TargetType.int_, IF_ICMPEQ);
|
||||
var type = largerType(equal.left().type(), equal.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, equal, type, LCMP, IFEQ);
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, equal, type, FCMPL, IFEQ);
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, equal, type, DCMPL, IFEQ);
|
||||
} else if (type.equals(TargetType.Char) || type.equals(TargetType.Short) || type.equals(TargetType.Byte) || type.equals(TargetType.Integer) || type.equals(TargetType.Boolean)) {
|
||||
generateRelationalOperator(state, equal, type, IF_ICMPEQ);
|
||||
} else {
|
||||
generateRelationalOperator(state, equal, type, IF_ACMPEQ);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NotEqual notEqual: {
|
||||
var type = TargetType.toPrimitive(largerType(notEqual.left().type(), notEqual.right().type()));
|
||||
if (type.equals(TargetType.long_)) {
|
||||
generateRelationalOperator(state, notEqual, TargetType.long_, LCMP, IFNE);
|
||||
} else if (type.equals(TargetType.float_)) {
|
||||
generateRelationalOperator(state, notEqual, TargetType.float_, FCMPL, IFNE);
|
||||
} else if (type.equals(TargetType.double_)) {
|
||||
generateRelationalOperator(state, notEqual, TargetType.double_, DCMPL, IFNE);
|
||||
} else if (type.equals(TargetType.char_) || type.equals(TargetType.short_) || type.equals(TargetType.byte_) || type.equals(TargetType.int_) || type.equals(TargetType.boolean_)) {
|
||||
generateRelationalOperator(state, notEqual, TargetType.int_, IF_ICMPNE);
|
||||
var type = largerType(notEqual.left().type(), notEqual.right().type());
|
||||
if (type.equals(TargetType.Long)) {
|
||||
generateRelationalOperator(state, notEqual, type, LCMP, IFNE);
|
||||
} else if (type.equals(TargetType.Float)) {
|
||||
generateRelationalOperator(state, notEqual, type, FCMPL, IFNE);
|
||||
} else if (type.equals(TargetType.Double)) {
|
||||
generateRelationalOperator(state, notEqual, type, DCMPL, IFNE);
|
||||
} else if (type.equals(TargetType.Char) || type.equals(TargetType.Short) || type.equals(TargetType.Byte) || type.equals(TargetType.Integer)) {
|
||||
generateRelationalOperator(state, notEqual, type, IF_ICMPNE);
|
||||
} else {
|
||||
generateRelationalOperator(state, notEqual, type, IF_ACMPNE);
|
||||
}
|
||||
@@ -703,7 +657,6 @@ public class Codegen {
|
||||
generate(state, add.expr());
|
||||
case TargetUnaryOp.Negate negate -> {
|
||||
generate(state, negate.expr());
|
||||
convertTo(state, negate.expr().type(), TargetType.boolean_);
|
||||
if (negate.type().equals(TargetType.Double))
|
||||
mv.visitInsn(DNEG);
|
||||
else if (negate.type().equals(TargetType.Float))
|
||||
@@ -712,11 +665,9 @@ public class Codegen {
|
||||
mv.visitInsn(LNEG);
|
||||
else
|
||||
mv.visitInsn(INEG);
|
||||
boxPrimitive(state, TargetType.toPrimitive(negate.expr().type()));
|
||||
}
|
||||
case TargetUnaryOp.Not not -> {
|
||||
generate(state, not.expr());
|
||||
convertTo(state, not.expr().type(), TargetType.boolean_);
|
||||
if (not.type().equals(TargetType.Long)) {
|
||||
mv.visitLdcInsn(-1L);
|
||||
mv.visitInsn(LXOR);
|
||||
@@ -724,86 +675,93 @@ public class Codegen {
|
||||
mv.visitInsn(ICONST_M1);
|
||||
mv.visitInsn(IXOR);
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(not.expr().type()));
|
||||
}
|
||||
case TargetUnaryOp.PreIncrement preIncrement -> {
|
||||
generate(state, preIncrement.expr());
|
||||
convertTo(state, preIncrement.expr().type(), TargetType.toPrimitive(op.type()));
|
||||
if (preIncrement.type().equals(TargetType.Float)) {
|
||||
mv.visitLdcInsn(1F);
|
||||
mv.visitInsn(FADD);
|
||||
mv.visitInsn(DUP);
|
||||
} else if (preIncrement.type().equals(TargetType.Double)) {
|
||||
mv.visitLdcInsn(1D);
|
||||
mv.visitInsn(DADD);
|
||||
mv.visitInsn(DUP2);
|
||||
} else if (preIncrement.type().equals(TargetType.Long)) {
|
||||
mv.visitLdcInsn(1L);
|
||||
mv.visitInsn(LADD);
|
||||
mv.visitInsn(DUP2);
|
||||
} else {
|
||||
mv.visitLdcInsn(1);
|
||||
mv.visitInsn(IADD);
|
||||
mv.visitInsn(DUP);
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitInsn(DUP);
|
||||
boxPrimitive(state, preIncrement.type());
|
||||
afterIncDec(state, preIncrement);
|
||||
}
|
||||
case TargetUnaryOp.PreDecrement preDecrement -> {
|
||||
generate(state, preDecrement.expr());
|
||||
convertTo(state, preDecrement.expr().type(), TargetType.toPrimitive(op.type()));
|
||||
if (preDecrement.type().equals(TargetType.Float)) {
|
||||
mv.visitLdcInsn(1F);
|
||||
mv.visitInsn(FSUB);
|
||||
mv.visitInsn(DUP);
|
||||
} else if (preDecrement.type().equals(TargetType.Double)) {
|
||||
mv.visitLdcInsn(1D);
|
||||
mv.visitInsn(DSUB);
|
||||
mv.visitInsn(DUP2);
|
||||
} else if (preDecrement.type().equals(TargetType.Long)) {
|
||||
mv.visitLdcInsn(1L);
|
||||
mv.visitInsn(LSUB);
|
||||
mv.visitInsn(DUP2);
|
||||
} else {
|
||||
mv.visitLdcInsn(1);
|
||||
mv.visitInsn(ISUB);
|
||||
mv.visitInsn(DUP);
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
mv.visitInsn(DUP);
|
||||
boxPrimitive(state, preDecrement.type());
|
||||
afterIncDec(state, preDecrement);
|
||||
}
|
||||
case TargetUnaryOp.PostIncrement postIncrement -> {
|
||||
generate(state, postIncrement.expr());
|
||||
mv.visitInsn(DUP);
|
||||
convertTo(state, postIncrement.expr().type(), TargetType.toPrimitive(op.type()));
|
||||
if (postIncrement.type().equals(TargetType.Float)) {
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn(1F);
|
||||
mv.visitInsn(FADD);
|
||||
} else if (postIncrement.type().equals(TargetType.Double)) {
|
||||
mv.visitInsn(DUP2);
|
||||
mv.visitLdcInsn(1D);
|
||||
mv.visitInsn(DADD);
|
||||
} else if (postIncrement.type().equals(TargetType.Long)) {
|
||||
mv.visitInsn(DUP2);
|
||||
mv.visitLdcInsn(1L);
|
||||
mv.visitInsn(LADD);
|
||||
} else {
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn(1);
|
||||
mv.visitInsn(IADD);
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
boxPrimitive(state, postIncrement.type());
|
||||
afterIncDec(state, postIncrement);
|
||||
}
|
||||
case TargetUnaryOp.PostDecrement postDecrement -> {
|
||||
generate(state, postDecrement.expr());
|
||||
mv.visitInsn(DUP);
|
||||
convertTo(state, postDecrement.expr().type(), TargetType.toPrimitive(op.type()));
|
||||
if (postDecrement.type().equals(TargetType.Float)) {
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn(1F);
|
||||
mv.visitInsn(FSUB);
|
||||
} else if (postDecrement.type().equals(TargetType.Double)) {
|
||||
mv.visitInsn(DUP2);
|
||||
mv.visitLdcInsn(1D);
|
||||
mv.visitInsn(DSUB);
|
||||
} else if (postDecrement.type().equals(TargetType.Long)) {
|
||||
mv.visitInsn(DUP2);
|
||||
mv.visitLdcInsn(1L);
|
||||
mv.visitInsn(LSUB);
|
||||
} else {
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn(1);
|
||||
mv.visitInsn(ISUB);
|
||||
}
|
||||
boxPrimitive(state, TargetType.toPrimitive(op.type()));
|
||||
boxPrimitive(state, postDecrement.type());
|
||||
afterIncDec(state, postDecrement);
|
||||
}
|
||||
}
|
||||
@@ -951,7 +909,7 @@ public class Codegen {
|
||||
var local = state.createVariable(varDecl.name(), varDecl.varType());
|
||||
if (varDecl.value() != null) {
|
||||
generate(state, varDecl.value());
|
||||
boxPrimitive(state, varDecl.value().type());
|
||||
boxPrimitive(state, varDecl.varType());
|
||||
mv.visitVarInsn(ASTORE, local.index());
|
||||
} else {
|
||||
mv.visitInsn(ACONST_NULL);
|
||||
@@ -1000,14 +958,14 @@ public class Codegen {
|
||||
mv.visitVarInsn(ALOAD, local.index());
|
||||
// This is a bit weird but sometimes the types don't match (see lambda expressions)
|
||||
convertTo(state, local.type(), localVar.type());
|
||||
//unboxPrimitive(state, local.type());
|
||||
unboxPrimitive(state, local.type());
|
||||
break;
|
||||
}
|
||||
case TargetFieldVar dot: {
|
||||
if (!dot.isStatic())
|
||||
generate(state, dot.left());
|
||||
mv.visitFieldInsn(dot.isStatic() ? GETSTATIC : GETFIELD, dot.left().type().getInternalName(), dot.right(), dot.type().toDescriptor());
|
||||
//unboxPrimitive(state, dot.type());
|
||||
unboxPrimitive(state, dot.type());
|
||||
break;
|
||||
}
|
||||
case TargetFor _for: {
|
||||
@@ -1023,14 +981,11 @@ public class Codegen {
|
||||
Label start = new Label();
|
||||
Label end = new Label();
|
||||
mv.visitLabel(start);
|
||||
if (_for.termination() != null) {
|
||||
if (_for.termination() != null)
|
||||
generate(state, _for.termination());
|
||||
convertTo(state, _for.termination().type(), TargetType.boolean_);
|
||||
mv.visitJumpInsn(IFEQ, end);
|
||||
} else {
|
||||
else
|
||||
mv.visitInsn(ICONST_1);
|
||||
mv.visitJumpInsn(IFEQ, end);
|
||||
}
|
||||
mv.visitJumpInsn(IFEQ, end);
|
||||
|
||||
var env = new BreakEnv();
|
||||
env.startLabel = start;
|
||||
@@ -1062,7 +1017,6 @@ public class Codegen {
|
||||
Label end = new Label();
|
||||
mv.visitLabel(start);
|
||||
generate(state, _while.cond());
|
||||
convertTo(state, _while.cond().type(), TargetType.boolean_);
|
||||
mv.visitJumpInsn(IFEQ, end);
|
||||
|
||||
var env = new BreakEnv();
|
||||
@@ -1093,7 +1047,6 @@ public class Codegen {
|
||||
|
||||
mv.visitLabel(check);
|
||||
generate(state, _do.cond());
|
||||
convertTo(state, _do.cond().type(), TargetType.boolean_);
|
||||
mv.visitJumpInsn(IFEQ, end);
|
||||
mv.visitJumpInsn(GOTO, start);
|
||||
mv.visitLabel(end);
|
||||
@@ -1101,7 +1054,6 @@ public class Codegen {
|
||||
}
|
||||
case TargetIf _if: {
|
||||
generate(state, _if.cond());
|
||||
convertTo(state, _if.cond().type(), TargetType.boolean_);
|
||||
Label _else = new Label();
|
||||
Label end = new Label();
|
||||
mv.visitJumpInsn(IFEQ, _else);
|
||||
@@ -1115,23 +1067,20 @@ public class Codegen {
|
||||
break;
|
||||
}
|
||||
case TargetReturn ret: {
|
||||
if (ret.expression() != null) {
|
||||
if (ret.expression() != null && state.returnType != null) {
|
||||
if (state.returnType instanceof TargetPrimitiveType) {
|
||||
generate(state, ret.expression());
|
||||
// Lambdas wrap the expression in a return if they are a single expression
|
||||
// It means we have to execute the code anyway but not return anything
|
||||
if (state.returnType != null) {
|
||||
convertTo(state, ret.expression().type(), state.returnType);
|
||||
mv.visitInsn(findReturnCode(state.returnType));
|
||||
}
|
||||
|
||||
unboxPrimitive(state, state.returnType);
|
||||
mv.visitInsn(findReturnCode(state.returnType));
|
||||
} else {
|
||||
generate(state, ret.expression());
|
||||
if (state.returnType != null) {
|
||||
convertTo(state, ret.expression().type(), state.returnType);
|
||||
mv.visitInsn(ARETURN);
|
||||
}
|
||||
boxPrimitive(state, ret.expression().type());
|
||||
convertTo(state, ret.expression().type(), state.returnType);
|
||||
mv.visitInsn(ARETURN);
|
||||
}
|
||||
} else mv.visitInsn(RETURN);
|
||||
} else
|
||||
mv.visitInsn(RETURN);
|
||||
break;
|
||||
}
|
||||
case TargetYield yield: {
|
||||
@@ -1178,14 +1127,12 @@ public class Codegen {
|
||||
var arg = call.parameterTypes().get(i);
|
||||
generate(state, e);
|
||||
convertTo(state, e.type(), arg);
|
||||
if (!(arg instanceof TargetPrimitiveType))
|
||||
boxPrimitive(state, e.type());
|
||||
}
|
||||
var descriptor = call.getDescriptor();
|
||||
if (call.owner() instanceof TargetFunNType owner) {
|
||||
// Decay FunN
|
||||
descriptor = TargetMethod.getDescriptor(
|
||||
(owner.returnArguments() == 0 ? null : TargetType.Object),
|
||||
call.parameterTypes().stream().map(x -> TargetType.Object).toArray(TargetType[]::new));
|
||||
}
|
||||
if (call.owner() instanceof TargetFunNType) // Decay FunN
|
||||
descriptor = TargetMethod.getDescriptor(call.returnType() == null ? null : TargetType.Object, call.parameterTypes().stream().map(x -> TargetType.Object).toArray(TargetType[]::new));
|
||||
|
||||
int insn = INVOKEVIRTUAL;
|
||||
if (call.isStatic()) insn = INVOKESTATIC;
|
||||
@@ -1194,13 +1141,11 @@ public class Codegen {
|
||||
|
||||
mv.visitMethodInsn(insn, call.owner().getInternalName(), call.name(), descriptor, call.isInterface());
|
||||
|
||||
/*if (call.type() != null && call.returnType() != null && !(call.returnType() instanceof TargetPrimitiveType)) {
|
||||
if (call.type() != null && call.returnType() != null && !(call.returnType() instanceof TargetPrimitiveType)) {
|
||||
if (!call.returnType().equals(call.type()) && !(call.type() instanceof TargetGenericType))
|
||||
mv.visitTypeInsn(CHECKCAST, call.type().getInternalName());
|
||||
unboxPrimitive(state, call.type());
|
||||
}*/
|
||||
if (call.type() != null)
|
||||
convertTo(state, call.returnType(), call.type());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TargetLambdaExpression lambda:
|
||||
@@ -1209,10 +1154,9 @@ public class Codegen {
|
||||
case TargetNew _new: {
|
||||
mv.visitTypeInsn(NEW, _new.type().getInternalName());
|
||||
mv.visitInsn(DUP);
|
||||
for (var i = 0; i < _new.params().size(); i++) {
|
||||
var e = _new.params().get(i);
|
||||
for (TargetExpression e : _new.params()) {
|
||||
generate(state, e);
|
||||
convertTo(state, e.type(), _new.signature().get(i));
|
||||
boxPrimitive(state, e.type());
|
||||
}
|
||||
mv.visitMethodInsn(INVOKESPECIAL, _new.type().getInternalName(), "<init>", _new.getDescriptor(), false);
|
||||
break;
|
||||
@@ -1224,7 +1168,6 @@ public class Codegen {
|
||||
}
|
||||
case TargetTernary ternary: {
|
||||
generate(state, ternary.cond());
|
||||
convertTo(state, ternary.cond().type(), TargetType.boolean_);
|
||||
var iffalse = new Label();
|
||||
var end = new Label();
|
||||
mv.visitJumpInsn(IFEQ, iffalse);
|
||||
@@ -1278,7 +1221,6 @@ public class Codegen {
|
||||
if (instanceOf.right() instanceof TargetTypePattern right && right.name() == null) {
|
||||
generate(state, instanceOf.left());
|
||||
mv.visitTypeInsn(INSTANCEOF, right.type().getInternalName());
|
||||
boxPrimitive(state, TargetType.boolean_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1286,7 +1228,6 @@ public class Codegen {
|
||||
}
|
||||
|
||||
private void yieldValue(State state, TargetType type) {
|
||||
if (type == null) return;
|
||||
boxPrimitive(state, type);
|
||||
state.mv.visitVarInsn(ASTORE, state.switchResultValue.peek());
|
||||
}
|
||||
@@ -1302,7 +1243,6 @@ public class Codegen {
|
||||
state.pushSwitch();
|
||||
|
||||
generate(state, aSwitch.expr());
|
||||
unboxPrimitive(state, aSwitch.expr().type());
|
||||
|
||||
state.enterScope();
|
||||
|
||||
@@ -1438,7 +1378,6 @@ public class Codegen {
|
||||
|
||||
if (label instanceof TargetGuard gd) {
|
||||
generate(state, gd.expression());
|
||||
unboxPrimitive(state, TargetType.Boolean);
|
||||
var next = new Label();
|
||||
mv.visitJumpInsn(IFNE, next);
|
||||
mv.visitVarInsn(ALOAD, tmp);
|
||||
@@ -1476,7 +1415,7 @@ public class Codegen {
|
||||
if (aSwitch.isExpression()) {
|
||||
if (aSwitch.type() != null) {
|
||||
mv.visitVarInsn(ALOAD, state.switchResultValue.peek());
|
||||
//unboxPrimitive(state, aSwitch.type());
|
||||
unboxPrimitive(state, aSwitch.type());
|
||||
}
|
||||
state.popSwitch();
|
||||
}
|
||||
@@ -1493,8 +1432,8 @@ public class Codegen {
|
||||
}
|
||||
|
||||
private void bindPattern(State state, TargetType type, TargetPattern pat, Label start, int index, int depth) {
|
||||
//if (pat.type() instanceof TargetPrimitiveType)
|
||||
// boxPrimitive(state, pat.type());
|
||||
if (pat.type() instanceof TargetPrimitiveType)
|
||||
boxPrimitive(state, pat.type());
|
||||
|
||||
if (pat.type() instanceof TargetRefType) {
|
||||
state.mv.visitInsn(DUP);
|
||||
@@ -1515,14 +1454,11 @@ public class Codegen {
|
||||
}
|
||||
|
||||
if (pat instanceof TargetExpressionPattern ep) {
|
||||
var cur = state.createVariable(TargetType.toWrapper(pat.type()));
|
||||
var cur = state.createVariable(pat.type());
|
||||
state.mv.visitVarInsn(ASTORE, cur.index);
|
||||
|
||||
// For Strings we must use equals, and why not make it work for all types?
|
||||
generate(state, new TargetLocalVar(cur.type, cur.name));
|
||||
generate(state, ep.expression());
|
||||
boxPrimitive(state, ep.expression().type());
|
||||
state.mv.visitMethodInsn(INVOKESTATIC, "java/util/Objects", "equals", "(Ljava/lang/Object;Ljava/lang/Object;)Z", false);
|
||||
var expr = new Equal(pat.type(), new TargetLocalVar(cur.type, cur.name), ep.expression());
|
||||
generate(state, expr);
|
||||
|
||||
var cont = new Label();
|
||||
state.mv.visitJumpInsn(IFNE, cont);
|
||||
@@ -1720,7 +1656,7 @@ public class Codegen {
|
||||
generate(state, method.block());
|
||||
if (method.signature().returnType() == null)
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitMaxs(0, 0);
|
||||
}
|
||||
mv.visitEnd();
|
||||
}
|
||||
@@ -1736,8 +1672,6 @@ public class Codegen {
|
||||
}
|
||||
if (clazz.superType() != null)
|
||||
ret += clazz.superType().toSignature();
|
||||
else ret += "Ljava/lang/Object;";
|
||||
|
||||
for (var intf : clazz.implementingInterfaces()) {
|
||||
ret += intf.toSignature();
|
||||
}
|
||||
@@ -1840,12 +1774,8 @@ public class Codegen {
|
||||
} else convertTo(state, fromReturn, toReturn);
|
||||
}
|
||||
|
||||
if (toReturn != null) {
|
||||
if ((fromReturn instanceof TargetRefType || fromReturn instanceof TargetGenericType)
|
||||
&& (toReturn instanceof TargetPrimitiveType))
|
||||
unboxPrimitive(state, TargetType.toWrapper(toReturn));
|
||||
if (toReturn != null)
|
||||
mv.visitInsn(findReturnCode(toReturn));
|
||||
}
|
||||
|
||||
else mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
@@ -1854,13 +1784,19 @@ public class Codegen {
|
||||
cw2.visitEnd();
|
||||
var bytes = cw2.toByteArray();
|
||||
compiler.auxiliaries.put(className, bytes);
|
||||
|
||||
// TODO These class loading shenanigans happen in a few places, the tests load the classes individually.
|
||||
// Instead we should just look at the folder.
|
||||
try {
|
||||
converter.classLoader.findClass(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
converter.classLoader.loadClass(className, bytes);
|
||||
} catch (LinkageError ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
cw.visitEnd();
|
||||
//ClassReader cr = new ClassReader(cw.toByteArray());
|
||||
//System.out.println("Checking class " + className);
|
||||
// TODO This fails for multi class projects because it tries to load the other classes
|
||||
//CheckClassAdapter.verify(cr, false, new PrintWriter(System.err));
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class FunNGenerator {
|
||||
if (type == null) return VOID;
|
||||
var res = "L" + type.getInternalName();
|
||||
if (type instanceof TargetSpecializedType a) {
|
||||
if (!a.params().isEmpty() && !(a.params().size() == 1 && a.params().getFirst() == null)) {
|
||||
if (a.params().size() > 0) {
|
||||
res += "<";
|
||||
for (var param : a.params()) {
|
||||
if (param instanceof TargetGenericType gp) {
|
||||
@@ -115,12 +115,11 @@ public class FunNGenerator {
|
||||
superFunNMethodSignature.append(String.format("T%s;", argumentGenericBase + currentParameter));
|
||||
superFunNMethodDescriptor.append(objectSignature);
|
||||
}
|
||||
superFunNClassSignature.append(String.format("%s:%s>%s", returnGeneric, objectSignature, objectSignature));
|
||||
if (numReturnTypes > 0) {
|
||||
superFunNClassSignature.append(String.format("%s:%s>%s", returnGeneric, objectSignature, objectSignature));
|
||||
superFunNMethodSignature.append(String.format(")T%s;", returnGeneric));
|
||||
superFunNMethodDescriptor.append(String.format(")%s", objectSignature));
|
||||
} else {
|
||||
superFunNClassSignature = new StringBuilder(objectSignature);
|
||||
superFunNMethodSignature.append(")V");
|
||||
superFunNMethodDescriptor.append(")V");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import de.dhbwstuttgart.bytecode.FunNGenerator;
|
||||
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||||
import de.dhbwstuttgart.environment.DirectoryClassLoader;
|
||||
import de.dhbwstuttgart.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.languageServerInterface.model.LanguageServerTransferObject;
|
||||
import de.dhbwstuttgart.parser.JavaTXParser;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||
@@ -476,85 +475,6 @@ public class JavaTXCompiler {
|
||||
return results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, Pair.generateTPHMap(cons))))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* TEMPORARY - Only for Language Server Usage
|
||||
*/
|
||||
public LanguageServerTransferObject getResultSetAndAbstractSyntax(File file) throws IOException, ClassNotFoundException {
|
||||
var sf = sourceFiles.get(file);
|
||||
if(sf == null){
|
||||
sf = sourceFiles.values().stream().findFirst().get();
|
||||
}
|
||||
Set<ClassOrInterface> allClasses = new HashSet<>();
|
||||
allClasses.addAll(getAvailableClasses(sf));
|
||||
allClasses.addAll(sf.getClasses());
|
||||
var newClasses = CompilationEnvironment.loadDefaultPackageClasses(sf.getPkgName(), file, this).stream().map(ASTFactory::createClass).collect(Collectors.toSet());
|
||||
for (var clazz : newClasses) {
|
||||
// Don't load classes that get recompiled
|
||||
if (sf.getClasses().stream().anyMatch(nf -> nf.getClassName().equals(clazz.getClassName())))
|
||||
continue;
|
||||
if (allClasses.stream().noneMatch(old -> old.getClassName().equals(clazz.getClassName())))
|
||||
allClasses.add(clazz);
|
||||
}
|
||||
|
||||
final ConstraintSet<Pair> cons = getConstraints(file);
|
||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||
try {
|
||||
Writer logFile = new OutputStreamWriter(new NullOutputStream());
|
||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses.stream().toList(), logFile, classLoader, this);
|
||||
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(this, cons);
|
||||
Function<UnifyPair, UnifyPair> distributeInnerVars = x -> {
|
||||
UnifyType lhs, rhs;
|
||||
if (((lhs = x.getLhsType()) instanceof PlaceholderType) && ((rhs = x.getRhsType()) instanceof PlaceholderType) && (((PlaceholderType) lhs).isInnerType() || ((PlaceholderType) rhs).isInnerType())) {
|
||||
((PlaceholderType) lhs).setInnerType(true);
|
||||
((PlaceholderType) rhs).setInnerType(true);
|
||||
}
|
||||
return x;
|
||||
|
||||
};
|
||||
|
||||
|
||||
unifyCons = unifyCons.map(distributeInnerVars);
|
||||
TypeUnify unify = new TypeUnify();
|
||||
Set<PlaceholderType> varianceTPHold;
|
||||
Set<PlaceholderType> varianceTPH = new HashSet<>();
|
||||
varianceTPH = varianceInheritanceConstraintSet(unifyCons);
|
||||
|
||||
List<Set<Constraint<UnifyPair>>> oderConstraints = unifyCons.getOderConstraints();
|
||||
|
||||
if (resultmodel) {
|
||||
/* UnifyResultModel Anfang */
|
||||
UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure);
|
||||
UnifyResultListenerImpl li = new UnifyResultListenerImpl();
|
||||
urm.addUnifyResultListener(li);
|
||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm, usedTasks);
|
||||
generateBytecode(sf, li.getResults());
|
||||
return new LanguageServerTransferObject(li.getResults(), sf, ASTTypePrinter.print(sf), generatedGenerics);
|
||||
}
|
||||
/* UnifyResultModel End */
|
||||
else {
|
||||
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks);
|
||||
results.addAll(result);
|
||||
|
||||
results = results.stream().map(x -> {
|
||||
Optional<Set<UnifyPair>> res = new RuleSet().subst(x.stream().map(y -> {
|
||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC)
|
||||
y.setPairOp(PairOperator.EQUALSDOT);
|
||||
return y; // alle Paare a <.? b erden durch a =. b ersetzt
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
if (res.isPresent()) {// wenn subst ein Erg liefert wurde was veraendert
|
||||
return new TypeUnifyTask().applyTypeUnificationRules(res.get(), finiteClosure);
|
||||
} else
|
||||
return x; // wenn nichts veraendert wurde wird x zurueckgegeben
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
generateBytecode(sf, results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, Pair.generateTPHMap(cons))))).collect(Collectors.toList()));
|
||||
return new LanguageServerTransferObject(results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, Pair.generateTPHMap(cons))))).collect(Collectors.toList()), sf, ASTTypePrinter.print(sf), generatedGenerics);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Vererbt alle Variancen bei Paaren (a <. theta) oder (Theta <. a) wenn a eine Variance !=0 hat auf alle Typvariablen in Theta.
|
||||
*
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface;
|
||||
|
||||
|
||||
import de.dhbwstuttgart.bytecode.Codegen;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.environment.IByteArrayClassLoader;
|
||||
import de.dhbwstuttgart.languageServerInterface.model.LanguageServerTransferObject;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||
import de.dhbwstuttgart.target.generate.ASTToTargetAST;
|
||||
import de.dhbwstuttgart.target.generate.GenericsResult;
|
||||
import de.dhbwstuttgart.target.tree.TargetStructure;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Implementation of an Interface for the Language-Server to get the Resultset and abstract Syntax.
|
||||
*/
|
||||
public class LanguageServerInterface {
|
||||
|
||||
|
||||
public LanguageServerTransferObject getResultSetAndAbastractSyntax(String path, String resetNamesTo) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||
NameGenerator.resetTo(resetNamesTo);
|
||||
return getResultSetAndAbstractSyntax(path);
|
||||
|
||||
}
|
||||
|
||||
public SourceFile getAst(String path, String resetNamesTo) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||
NameGenerator.resetTo(resetNamesTo);
|
||||
return getAST(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns the ResultSets, GenericResultSet and the AST
|
||||
* You have to give the input as well as the path because of potential locks when the File is currently opened in an IDE.
|
||||
* Example: file:///c:/test/main.jav -> file:///c:/test/out/main.class
|
||||
*
|
||||
* @param pathAsString the URI of the File. See Example.
|
||||
*/
|
||||
public LanguageServerTransferObject getResultSetAndAbstractSyntax(String pathAsString){
|
||||
System.setOut(new PrintStream(OutputStream.nullOutputStream()));
|
||||
try {
|
||||
var uri = new URI(pathAsString);
|
||||
var path = Path.of(uri);
|
||||
var file = path.toFile();
|
||||
Files.createDirectories(path.getParent().resolve("out"));
|
||||
var compiler = new JavaTXCompiler(List.of(file), List.of(path.getParent().toFile()), path.getParent().resolve("out").toFile());
|
||||
|
||||
var parsedSource = compiler.sourceFiles.get(file);
|
||||
var tiResults = compiler.typeInference(file);
|
||||
|
||||
Map<JavaClassName, byte[]> bytecode = compiler.generateBytecode(parsedSource, tiResults);
|
||||
Files.createDirectories(path.getParent().resolve("out"));
|
||||
compiler.writeClassFile(bytecode, path.getParent().resolve("out").toFile(), false);
|
||||
|
||||
return new LanguageServerTransferObject(tiResults, parsedSource, "", compiler.getGeneratedGenerics());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the AST without calculating the result
|
||||
* You have to give the input as well as the path because of potential locks when the File is currently opened in an IDE.
|
||||
* Example: file:///c:/test/main.jav -> file:///c:/test/out/main.class
|
||||
*
|
||||
* @param path the URI of the File. See Example.
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public SourceFile getAST(String path) throws IOException, ClassNotFoundException, URISyntaxException {
|
||||
|
||||
|
||||
System.setOut(new PrintStream(OutputStream.nullOutputStream()));
|
||||
|
||||
|
||||
URI uri = new URI(path);
|
||||
ArrayList<String> pathWithoutName = new ArrayList<>(List.of(uri.getPath().split("/")));
|
||||
pathWithoutName.remove(List.of(uri.getPath().split("/")).size() - 1);
|
||||
String stringPathWithoutName = "";
|
||||
|
||||
for (String i : pathWithoutName) {
|
||||
stringPathWithoutName += "/" + i;
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.cleanDirectory(new File(stringPathWithoutName + "/out"));
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
try {
|
||||
(new File(stringPathWithoutName + "/out")).mkdirs();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
var test = getAST(uri.getPath().split("/")[uri.getPath().split("/").length - 1], new File(stringPathWithoutName).getPath());
|
||||
System.setOut(System.out);
|
||||
return test;
|
||||
}
|
||||
|
||||
public static SourceFile getAST(String filename, String filePath) throws IOException, ClassNotFoundException {
|
||||
var file = Path.of(filePath, filename).toFile();
|
||||
var compiler = new JavaTXCompiler(List.of(file), List.of(file.getParentFile()), Path.of(filePath + "/out").toFile());
|
||||
return compiler.sourceFiles.get(file);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface;
|
||||
|
||||
|
||||
|
||||
import de.dhbwstuttgart.languageServerInterface.model.CustomParserErrorHandler;
|
||||
import de.dhbwstuttgart.languageServerInterface.model.ParserError;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Lexer;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17ParserBaseListener;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParserInterface {
|
||||
|
||||
public List<ParserError> getParseErrors(String input){
|
||||
|
||||
CustomParserErrorHandler errorListener = new CustomParserErrorHandler();
|
||||
CharStream charStream = CharStreams.fromString(input);
|
||||
|
||||
Java17Lexer lexer = new Java17Lexer(charStream);
|
||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||
|
||||
Java17Parser parser = new Java17Parser(tokens);
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(errorListener);
|
||||
|
||||
|
||||
ParseTree tree = parser.sourceFile();
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
Java17ParserBaseListener listener = new Java17ParserBaseListener();
|
||||
walker.walk(listener, tree);
|
||||
|
||||
return errorListener.getErrorMessages();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface.model;
|
||||
|
||||
|
||||
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomParserErrorHandler implements ANTLRErrorListener {
|
||||
private final List<ParserError> errorMessages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
|
||||
int endCharPosition = charPositionInLine;
|
||||
if (offendingSymbol instanceof Token) {
|
||||
Token offendingToken = (Token) offendingSymbol;
|
||||
endCharPosition = charPositionInLine + offendingToken.getText().length();
|
||||
}
|
||||
|
||||
ParserError parserError = new ParserError(line, charPositionInLine, endCharPosition, msg);
|
||||
errorMessages.add(parserError);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAmbiguity(Parser parser, DFA dfa, int i, int i1, boolean b, BitSet bitSet, ATNConfigSet atnConfigSet) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(Parser parser, DFA dfa, int i, int i1, BitSet bitSet, ATNConfigSet atnConfigSet) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(Parser parser, DFA dfa, int i, int i1, int i2, ATNConfigSet atnConfigSet) {
|
||||
|
||||
}
|
||||
|
||||
public List<ParserError> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface.model;
|
||||
|
||||
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.target.generate.GenericsResult;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LanguageServerTransferObject {
|
||||
List<ResultSet> resultSets;
|
||||
SourceFile Ast;
|
||||
String printedAst;
|
||||
Map<SourceFile, List<GenericsResult>> generatedGenerics = new HashMap<>();
|
||||
|
||||
|
||||
public LanguageServerTransferObject(List<ResultSet> resultSets, SourceFile Ast, String printedAst, Map<SourceFile, List<GenericsResult>> generatedGenerics) {
|
||||
this.resultSets = resultSets;
|
||||
this.Ast = Ast;
|
||||
this.printedAst = printedAst;
|
||||
this.generatedGenerics = generatedGenerics;
|
||||
}
|
||||
|
||||
public List<ResultSet> getResultSets() {return resultSets;}
|
||||
public SourceFile getAst() {return Ast;}
|
||||
public String getPrintedAst() {return printedAst;}
|
||||
public Map<SourceFile, List<GenericsResult>> getGeneratedGenerics() {return generatedGenerics;}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface.model;
|
||||
|
||||
public class ParserError {
|
||||
|
||||
private int line;
|
||||
private int charPositionInLine;
|
||||
private int endCharPosition;
|
||||
String msg;
|
||||
|
||||
public ParserError(int line, int charPositionInLine, int endCharPosition, String msg) {
|
||||
this.line = line;
|
||||
this.charPositionInLine = charPositionInLine;
|
||||
this. endCharPosition = endCharPosition;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getEndCharPosition() {
|
||||
return endCharPosition;
|
||||
}
|
||||
|
||||
public void setEndCharPosition(int endCharPosition) {
|
||||
this.endCharPosition = endCharPosition;
|
||||
}
|
||||
|
||||
public void setCharPositionInLine(int charPositionInLine) {
|
||||
this.charPositionInLine = charPositionInLine;
|
||||
}
|
||||
|
||||
public void setLine(int line) {
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCharPositionInLine() {
|
||||
return charPositionInLine;
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package de.dhbwstuttgart.languageServerInterface.model;
|
||||
|
||||
|
||||
import com.google.common.reflect.TypeResolver;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultEvent;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListener;
|
||||
|
||||
public class ResultSetListener implements UnifyResultListener {
|
||||
|
||||
TypeResolver typeResolver;
|
||||
|
||||
public ResultSetListener(TypeResolver typeResolver){
|
||||
this.typeResolver = typeResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewTypeResultFound(UnifyResultEvent evt) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class SyntaxTreeGenerator {
|
||||
this.allmodifiers.put(Modifier.toString(Modifier.INTERFACE), Modifier.INTERFACE);
|
||||
this.allmodifiers.put("sealed", 4096);
|
||||
this.allmodifiers.put("non-sealed", 8192);
|
||||
this.allmodifiers.put("default", 0); // Doesn't exist
|
||||
this.allmodifiers.put("default", 16384);
|
||||
this.allmodifiers.put("strictfp", 32768);
|
||||
|
||||
this.compiler = compiler;
|
||||
|
||||
@@ -168,7 +168,7 @@ public class TypeGenerator {
|
||||
if (generics.contains(name)) {
|
||||
return new GenericRefType(name, offset);
|
||||
} else {
|
||||
Pattern p = Pattern.compile("Fun(Void|VoidImpl|Wrapper)?(\\d+)[$][$]"); // TODO Regex shenanigans
|
||||
Pattern p = Pattern.compile("Fun(\\d+)[$][$]");
|
||||
Matcher m = p.matcher(name);
|
||||
if (m.matches()) {// es ist FunN$$-Type
|
||||
return new RefType(new JavaClassName(name), convert(typeArguments, reg, generics), offset);
|
||||
|
||||
@@ -13,10 +13,6 @@ public class NameGenerator {
|
||||
public static void reset() {
|
||||
strNextName = "A";
|
||||
}
|
||||
|
||||
public static void resetTo(String name) {
|
||||
strNextName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet einen neuen, eindeutigen Namen f�r eine neue
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package de.dhbwstuttgart.target.generate;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.FunNGenerator;
|
||||
@@ -846,6 +845,13 @@ public class ASTToTargetAST {
|
||||
compiler.usedFunNSuperTypes.add(params.size());
|
||||
var code = FunNGenerator.generateSuperBytecode(params.size() - 1, returnType != null ? 1 : 0);
|
||||
var superClassName = FunNGenerator.getSuperClassName(params.size() - 1, returnType != null ? 1 : 0);
|
||||
try {
|
||||
compiler.classLoader.findClass(superClassName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
compiler.classLoader.loadClass(superClassName, code);
|
||||
} catch (LinkageError ignored) {}
|
||||
}
|
||||
compiler.auxiliaries.put(superClassName, code);
|
||||
}
|
||||
FunNGenerator.GenericParameters gep = null;
|
||||
|
||||
@@ -161,6 +161,7 @@ public class StatementToTargetExpression implements ASTVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
var isStatic = false;
|
||||
var type = converter.convert(fieldVar.receiver.getType());
|
||||
var clazz = converter.compiler.getClass(new JavaClassName(type.name()));
|
||||
var field = clazz.getField(fieldVar.fieldVarName).orElseThrow();
|
||||
|
||||
@@ -8,42 +8,42 @@ public sealed interface TargetLiteral extends TargetExpression {
|
||||
record BooleanLiteral(Boolean value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.boolean_;
|
||||
return TargetType.Boolean;
|
||||
}
|
||||
}
|
||||
|
||||
record CharLiteral(Character value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.char_;
|
||||
return TargetType.Char;
|
||||
}
|
||||
}
|
||||
|
||||
record IntLiteral(Integer value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.int_;
|
||||
return TargetType.Integer;
|
||||
}
|
||||
}
|
||||
|
||||
record LongLiteral(Long value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.long_;
|
||||
return TargetType.Long;
|
||||
}
|
||||
}
|
||||
|
||||
record FloatLiteral(Float value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.float_;
|
||||
return TargetType.Float;
|
||||
}
|
||||
}
|
||||
|
||||
record DoubleLiteral(Double value) implements TargetLiteral {
|
||||
@Override
|
||||
public TargetType type() {
|
||||
return TargetType.double_;
|
||||
return TargetType.Double;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,4 @@ public record TargetFunNType(String name, List<TargetType> funNParams, List<Targ
|
||||
public String getInternalName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toSignature() {
|
||||
var args = FunNGenerator.getArguments(funNParams);
|
||||
return "LFun" + args.size() + "$$" + TargetSpecializedType.signatureParameters(funNParams) + ";";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,14 @@ public sealed interface TargetSpecializedType extends TargetType permits TargetF
|
||||
@Override
|
||||
default String toSignature() {
|
||||
String ret = "L" + getInternalName();
|
||||
ret += signatureParameters(params());
|
||||
ret += ";";
|
||||
return ret;
|
||||
}
|
||||
|
||||
static String signatureParameters(List<TargetType> params) {
|
||||
var ret = "";
|
||||
if (!params.isEmpty()) {
|
||||
if (!params().isEmpty()) {
|
||||
ret += "<";
|
||||
for (var param : params) {
|
||||
for (var param : params()) {
|
||||
ret += param.toSignature();
|
||||
}
|
||||
ret += ">";
|
||||
}
|
||||
ret += ";";
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -935,7 +935,7 @@ public class TYPEStmt implements StatementVisitor {
|
||||
@Override
|
||||
public void visit(Yield aYield) {
|
||||
aYield.retexpr.accept(this);
|
||||
constraintsSet.addUndConstraint(new Pair(aYield.getType(), switchStack.peek().getType(), PairOperator.SMALLERDOT, loc(aYield.getOffset())));
|
||||
constraintsSet.addUndConstraint(new Pair(aYield.getType(), switchStack.peek().getType(), PairOperator.EQUALSDOT, loc(aYield.getOffset())));
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,13 @@ public class AllgemeinTest {
|
||||
//String className = "Cycle";
|
||||
//String className = "TripleTest";
|
||||
//String className = "WildcardList";
|
||||
String className = "List";
|
||||
//String className = "List";
|
||||
//String className = "Box";
|
||||
//String className = "GenBox";
|
||||
//String className = "InnerInf";
|
||||
//String className = "Foo";
|
||||
//String className = "Uncurrier";
|
||||
String className = "UncurrierMain";
|
||||
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
|
||||
111
src/test/java/KPSPresentation.java
Normal file
111
src/test/java/KPSPresentation.java
Normal file
@@ -0,0 +1,111 @@
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static targetast.TestCodegen.generateClassFiles;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
|
||||
public class KPSPresentation {
|
||||
|
||||
private static String path;
|
||||
private static File fileToTest;
|
||||
private static JavaTXCompiler compiler;
|
||||
private static ClassLoader loader;
|
||||
private static Class<?> classToTest;
|
||||
private static String pathToClassFile;
|
||||
private static Object instanceOfClass;
|
||||
|
||||
|
||||
public void testAlgo(String className) throws Exception {
|
||||
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/resources/KPSPresentation/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/mathStrucInteger.jav";
|
||||
//compiler = new JavaTXCompiler(Lists.newArrayList(new File(System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav")));
|
||||
///*
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(path)),
|
||||
Lists.newArrayList(new File(System.getProperty("user.dir")+"/resources/KPSPresentation/classFiles/")),
|
||||
new File(System.getProperty("user.dir")+"/resources/KPSPresentation/classFiles/"));
|
||||
//*/
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/resources/KPSPresentation/classFiles/";
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass(className);
|
||||
//classToTest = loader.loadClass("Overloading_Generics");
|
||||
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance("A");
|
||||
//classToTest = loader.loadClass("Overloading_Generics1");
|
||||
//instanceOfClass = classToTest.getDeclaredConstructor(Object.class).newInstance("B");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MainTest() throws Exception {
|
||||
testAlgo("Main");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fstTest() throws Exception {
|
||||
testAlgo("fst");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void IdTest() throws Exception {
|
||||
testAlgo("Id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void OLTest() throws Exception {
|
||||
testAlgo("OL");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MainOLTest() throws Exception {
|
||||
testAlgo("MainOL");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FacTest() throws Exception {
|
||||
testAlgo("Fac");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void FacultyTest() throws Exception {
|
||||
testAlgo("Faculty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MainFacultyTest() throws Exception {
|
||||
testAlgo("MainFaculty");
|
||||
}
|
||||
@Test
|
||||
public void LambdaTest() throws Exception {
|
||||
testAlgo("Lambda");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyLambdaTest() throws Exception {
|
||||
testAlgo("applyLambda");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MatrixTest() throws Exception {
|
||||
testAlgo("Matrix");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MatrixOPTest() throws Exception {
|
||||
testAlgo("MatrixOP");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -735,17 +735,8 @@ public class TestComplete {
|
||||
public void testSwitchRecordLiteral() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "PatternMatchingLiteralStyle.jav");
|
||||
var clazz = classFiles.get("SwitchOverload");
|
||||
var record = classFiles.get("R");
|
||||
var rctor = record.getDeclaredConstructor(String.class);
|
||||
|
||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||
var m = clazz.getDeclaredMethod("m", record);
|
||||
assertEquals(10, m.invoke(instance, rctor.newInstance("test")));
|
||||
assertEquals(20, m.invoke(instance, rctor.newInstance("foo")));
|
||||
assertEquals(0, m.invoke(instance, rctor.newInstance("???")));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchCaseHeritageDetection() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "SwitchCaseHeritageDetection.jav");
|
||||
@@ -1485,42 +1476,4 @@ public class TestComplete {
|
||||
var m = clazz.getDeclaredMethod("main");
|
||||
m.invoke(null);
|
||||
}
|
||||
|
||||
@Disabled("Doesn't work yet")
|
||||
@Test
|
||||
public void testBug378() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug378Main.jav");
|
||||
var clazz = classFiles.get("Bug378Main");
|
||||
var main = clazz.getDeclaredMethod("main", List.class);
|
||||
main.invoke(null, List.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug379() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug379.jav");
|
||||
var clazz = classFiles.get("Bug379");
|
||||
clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug380() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug380.jav");
|
||||
var clazz = classFiles.get("Bug380");
|
||||
clazz.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug382() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug382.jav");
|
||||
var clazz = classFiles.get("Bug382");
|
||||
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBug383() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug383.jav");
|
||||
var clazz = classFiles.get("Bug383");
|
||||
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
|
||||
// TODO This logs output that we should validate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
public class t{
|
||||
public mofus(){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user