modified: ../../src/de/dhbwstuttgart/core/JavaTXCompiler.java
cardProd als Variable eingfuegt modified: ../../src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java toString() eingfuegt modified: ../../src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java toString() eingfuegt modified: ../../src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java BinaryOp <. statt =. modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Bei nicht importierten (result []) undefinPair gesetzt modified: ../javFiles/Matrix.jav falsche importe rausgenommen
This commit is contained in:
parent
06a0cb8eaf
commit
c597b0430a
@ -111,7 +111,8 @@ public class JavaTXCompiler {
|
|||||||
logFile.write(ASTTypePrinter.print(sf));
|
logFile.write(ASTTypePrinter.print(sf));
|
||||||
}
|
}
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
for (List<Constraint<UnifyPair>> xCons : unifyCons.cartesianProduct()) {
|
Set<List<Constraint<UnifyPair>>> cardProd = unifyCons.cartesianProduct();
|
||||||
|
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
||||||
Set<UnifyPair> xConsSet = new HashSet<>();
|
Set<UnifyPair> xConsSet = new HashSet<>();
|
||||||
for (Constraint<UnifyPair> constraint : xCons) {
|
for (Constraint<UnifyPair> constraint : xCons) {
|
||||||
xConsSet.addAll(constraint);
|
xConsSet.addAll(constraint);
|
||||||
|
@ -106,4 +106,8 @@ public class ClassOrInterface extends SyntaxTreeNode implements TypeScope{
|
|||||||
public Collection<RefType> getSuperInterfaces() {
|
public Collection<RefType> getSuperInterfaces() {
|
||||||
return implementedInterfaces;
|
return implementedInterfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.name.toString() + this.genericClassParameters.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,8 @@ public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<G
|
|||||||
public void accept(ASTVisitor visitor) {
|
public void accept(ASTVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.gtvs.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,34 +223,34 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
//see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17
|
||||||
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||||
Constraint<Pair> numeric = new Constraint<>();
|
Constraint<Pair> numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), longg, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), floatt, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), doublee, PairOperator.EQUALSDOT));
|
numeric.add(new Pair(binary.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
/*
|
/*
|
||||||
In Java passiert bei den binären Operatoren eine sogenannte Type Promotion:
|
In Java passiert bei den binären Operatoren eine sogenannte Type Promotion:
|
||||||
|
@ -142,6 +142,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @return The set of all principal type unifiers
|
* @return The set of all principal type unifiers
|
||||||
*/
|
*/
|
||||||
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||||
|
Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
|
).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
||||||
|
if (aas.isEmpty()) {
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||||
*/
|
*/
|
||||||
@ -789,6 +795,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
||||||
//System.out.println(x1);
|
//System.out.println(x1);
|
||||||
result.get(0).add(x1);
|
result.get(0).add(x1);
|
||||||
|
if (x1.isEmpty()) {
|
||||||
|
undefined.add(pair); //Theta ist nicht im FC => Abbruch
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<UnifyPair> s1 = new HashSet<>();
|
Set<UnifyPair> s1 = new HashSet<>();
|
||||||
@ -802,7 +811,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Case 2: (a <.? ? ext Theta')
|
// Case 2: (a <.? ? ext Theta')
|
||||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType)
|
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
result.get(1).add(unifyCase2(pair, fc));
|
Set<Set<UnifyPair>> x1 = unifyCase2(pair, fc);
|
||||||
|
result.get(1).add(x1);
|
||||||
|
if (x1.isEmpty()) {
|
||||||
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<UnifyPair> s1 = new HashSet<>();
|
Set<UnifyPair> s1 = new HashSet<>();
|
||||||
@ -815,7 +828,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Case 3: (a <.? ? sup Theta')
|
// Case 3: (a <.? ? sup Theta')
|
||||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof SuperType)
|
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof SuperType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
result.get(2).add(unifyCase3(pair, fc));
|
Set<Set<UnifyPair>> x1 = unifyCase3(pair, fc);
|
||||||
|
result.get(2).add(x1);
|
||||||
|
if (x1.isEmpty()) {
|
||||||
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<UnifyPair> s1 = new HashSet<>();
|
Set<UnifyPair> s1 = new HashSet<>();
|
||||||
@ -833,9 +850,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Case 5: (Theta <. a)
|
// Case 5: (Theta <. a)
|
||||||
else if(pairOp == PairOperator.SMALLERDOT && rhsType instanceof PlaceholderType)
|
else if(pairOp == PairOperator.SMALLERDOT && rhsType instanceof PlaceholderType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
if (rhsType.getName().equals("A"))
|
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
|
||||||
System.out.println();
|
result.get(4).add(x1);
|
||||||
result.get(4).add(unifyCase5(pair, fc));
|
if (x1.isEmpty()) {
|
||||||
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<UnifyPair> s1 = new HashSet<>();
|
Set<UnifyPair> s1 = new HashSet<>();
|
||||||
@ -858,8 +877,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Case 8: (Theta <.? a)
|
// Case 8: (Theta <.? a)
|
||||||
else if(pairOp == PairOperator.SMALLERDOTWC && rhsType instanceof PlaceholderType)
|
else if(pairOp == PairOperator.SMALLERDOTWC && rhsType instanceof PlaceholderType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
result.get(7).add(
|
Set<Set<UnifyPair>> x1 = unifyCase8(pair, fc);
|
||||||
unifyCase8(pair, fc));
|
result.get(7).add(x1);
|
||||||
|
if (x1.isEmpty()) {
|
||||||
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<UnifyPair> s1 = new HashSet<>();
|
Set<UnifyPair> s1 = new HashSet<>();
|
||||||
@ -892,9 +914,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
PlaceholderType a = (PlaceholderType)pair.getLhsType();
|
PlaceholderType a = (PlaceholderType)pair.getLhsType();
|
||||||
UnifyType thetaPrime = pair.getRhsType();
|
UnifyType thetaPrime = pair.getRhsType();
|
||||||
byte variance = pair.getVariance();
|
byte variance = pair.getVariance();
|
||||||
if (a.getName().equals("D")) {
|
|
||||||
System.out.print("");
|
|
||||||
}
|
|
||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
|
|
||||||
boolean allGen = thetaPrime.getTypeParams().size() > 0;
|
boolean allGen = thetaPrime.getTypeParams().size() > 0;
|
||||||
@ -906,6 +926,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
Set<UnifyType> cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector<NP>, java.util.Vector<java.util.Vector<java.lang.Integer>>, ????java.util.Vector<gen_hv>???]
|
Set<UnifyType> cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector<NP>, java.util.Vector<java.util.Vector<java.lang.Integer>>, ????java.util.Vector<gen_hv>???]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//PL 18-02-06 entfernt, kommt durch unify wieder rein
|
//PL 18-02-06 entfernt, kommt durch unify wieder rein
|
||||||
//cs.add(thetaPrime);
|
//cs.add(thetaPrime);
|
||||||
//PL 18-02-06 entfernt
|
//PL 18-02-06 entfernt
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.lang.Boolean;
|
|
||||||
import java.lang.String;
|
|
||||||
|
|
||||||
class Matrix extends Vector<Vector<Integer>> {
|
class Matrix extends Vector<Vector<Integer>> {
|
||||||
Integer mul1(Integer x, Integer y) { return x;}
|
Integer mul1(Integer x, Integer y) { return x;}
|
||||||
@ -17,9 +15,9 @@ class Matrix extends Vector<Vector<Integer>> {
|
|||||||
var erg = 0;
|
var erg = 0;
|
||||||
var k = 0;
|
var k = 0;
|
||||||
while(k < v1.size()) {
|
while(k < v1.size()) {
|
||||||
//erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
||||||
erg = add1(erg, mul1(v1.elementAt(k),
|
//erg = add1(erg, mul1(v1.elementAt(k),
|
||||||
m.elementAt(k).elementAt(j)));
|
// m.elementAt(k).elementAt(j)));
|
||||||
k++; }
|
k++; }
|
||||||
v2.addElement(new Integer(erg));
|
v2.addElement(new Integer(erg));
|
||||||
j++; }
|
j++; }
|
||||||
|
Loading…
Reference in New Issue
Block a user