forked from JavaTX/JavaCompilerCore
Die Bestimmung der Constraints aus dem ResolvedType herausgenommen und im ResultSet integriert.
Damit kommen immer die gleichen Constraints raus. Diese werden ohnehin in der Bytecodegenerierung nochmals ausgewertet. modified: ../../../../main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java Zugriff auf Constraints ueber ResultSet eingefuehrt modified: ../../../../main/java/de/dhbwstuttgart/bytecode/signature/Signature.java Zugriff auf Constraints ueber ResultSet eingefuehrt modified: ../../../../main/java/de/dhbwstuttgart/core/JavaTXCompiler.java modified: ../../../../main/java/de/dhbwstuttgart/typeinference/result/GenericInsertPair.java modified: ../../../../main/java/de/dhbwstuttgart/typeinference/result/PairTPHequalRefTypeOrWildcardType.java modified: ../../../../main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java toString veraendert modified: ../../../../main/java/de/dhbwstuttgart/typeinference/result/ResultSet.java Attribut genIns eingefuehrt, indem alle GenericInsertPairs gespeichert werden, die Form (TPH a <. TPH b) im Attribut results haben modified: ../../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../../bytecode/javFiles/Id.jav modified: ../../bytecode/javFiles/MatrixOP.jav
This commit is contained in:
parent
1454281628
commit
588212389a
@ -90,7 +90,8 @@ public class TPHExtractor extends AbstractASTWalker {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
resultSet.resolveType(tph).additionalGenerics.forEach(ag -> {
|
//resultSet.resolveType(tph).getAdditionalGenerics().forEach(ag -> {
|
||||||
|
resultSet.genIns.forEach(ag -> {
|
||||||
|
|
||||||
// if (ag.contains(resolvedTPH) /* && ag.TA1.equals(resolvedTPH) */ && !contains(allPairs, ag)) {
|
// if (ag.contains(resolvedTPH) /* && ag.TA1.equals(resolvedTPH) */ && !contains(allPairs, ag)) {
|
||||||
if (inMethod)
|
if (inMethod)
|
||||||
|
@ -235,7 +235,8 @@ public class Signature {
|
|||||||
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric resolved = resType.resolvedType;
|
RefTypeOrTPHOrWildcardOrGeneric resolved = resType.resolvedType;
|
||||||
if(resolved instanceof TypePlaceholder) {
|
if(resolved instanceof TypePlaceholder) {
|
||||||
resType.additionalGenerics.forEach(ag ->{
|
//resType.getAdditionalGenerics().forEach(ag ->{
|
||||||
|
resultSet.genIns.forEach(ag ->{
|
||||||
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||||
if(!contains(res,constr)) {
|
if(!contains(res,constr)) {
|
||||||
res.add(constr);
|
res.add(constr);
|
||||||
@ -246,7 +247,8 @@ public class Signature {
|
|||||||
WildcardType resWC = (WildcardType) resolved;
|
WildcardType resWC = (WildcardType) resolved;
|
||||||
ResolvedType resType2 = resultSet.resolveType(resWC.getInnerType());
|
ResolvedType resType2 = resultSet.resolveType(resWC.getInnerType());
|
||||||
if(resType2.resolvedType instanceof TypePlaceholder) {
|
if(resType2.resolvedType instanceof TypePlaceholder) {
|
||||||
resType2.additionalGenerics.forEach(ag ->{
|
//resType2.getAdditionalGenerics().forEach(ag ->{
|
||||||
|
resultSet.genIns.forEach(ag ->{
|
||||||
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
TPHConstraint constr = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||||
if(!contains(res,constr)) {
|
if(!contains(res,constr)) {
|
||||||
res.add(constr);
|
res.add(constr);
|
||||||
|
@ -51,6 +51,7 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
||||||
|
import org.apache.commons.io.output.NullOutputStream;
|
||||||
//import org.apache.commons.io.output.NullOutputStream;
|
//import org.apache.commons.io.output.NullOutputStream;
|
||||||
|
|
||||||
public class JavaTXCompiler {
|
public class JavaTXCompiler {
|
||||||
@ -563,8 +564,8 @@ public class JavaTXCompiler {
|
|||||||
}
|
}
|
||||||
/* UnifyResultModel End */
|
/* UnifyResultModel End */
|
||||||
else {
|
else {
|
||||||
Set<Set<UnifyPair>> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
//Set<Set<UnifyPair>> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
||||||
//Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
||||||
System.out.println("RESULT: " + result);
|
System.out.println("RESULT: " + result);
|
||||||
logFile.write("RES: " + result.toString()+"\n");
|
logFile.write("RES: " + result.toString()+"\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
|
@ -23,4 +23,9 @@ public class GenericInsertPair {
|
|||||||
if(TA2.equals(additionalTPH))return true;
|
if(TA2.equals(additionalTPH))return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GenIns(" + TA1.toString() + " < " + TA2.toString() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,4 +21,9 @@ public class PairTPHequalRefTypeOrWildcardType extends ResultPair{
|
|||||||
public void accept(ResultPairVisitor visitor) {
|
public void accept(ResultPairVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "(" + left.toString() + " = " + right.toString() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,9 @@ public class PairTPHsmallerTPH extends ResultPair{
|
|||||||
public void accept(ResultPairVisitor visitor) {
|
public void accept(ResultPairVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "(" + left.toString() + " < " + right.toString() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,16 @@ import de.dhbwstuttgart.syntaxtree.type.*;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ResultSet {
|
public class ResultSet {
|
||||||
public final Set<ResultPair> results;
|
public final Set<ResultPair> results;
|
||||||
|
public Set<GenericInsertPair> genIns;
|
||||||
public ResultSet(Set<ResultPair> results){
|
public ResultSet(Set<ResultPair> results){
|
||||||
this.results = results;
|
this.results = results;
|
||||||
|
this.genIns = results.stream().filter(a -> a instanceof PairTPHsmallerTPH)
|
||||||
|
.map(b -> new GenericInsertPair( (TypePlaceholder)(b.getLeft()), (TypePlaceholder)(b.getRight())))
|
||||||
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResolvedType resolveType(RefTypeOrTPHOrWildcardOrGeneric type) {
|
public ResolvedType resolveType(RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||||
|
@ -19,6 +19,8 @@ import java.util.function.BinaryOperator;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.apache.commons.io.output.NullOutputStream;
|
||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.parser.NullToken;
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||||
@ -46,6 +48,7 @@ import de.dhbwstuttgart.typeinference.unify.model.Pair;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
@ -165,7 +168,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
thNo = totalnoOfThread;
|
thNo = totalnoOfThread;
|
||||||
writeLog("thNo2 " + thNo);
|
writeLog("thNo2 " + thNo);
|
||||||
try {
|
try {
|
||||||
this.logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"Thread_"+thNo));
|
this.logFile = new OutputStreamWriter(new NullOutputStream());
|
||||||
|
//new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"Thread_"+thNo));
|
||||||
|
logFile.write("");
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("log-File nicht vorhanden");
|
System.err.println("log-File nicht vorhanden");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
public class Id {
|
public class Id {
|
||||||
|
|
||||||
<A extends B, B> B id(A b){
|
id(b){
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.lang.Byte;
|
//import java.lang.Byte;
|
||||||
import java.lang.Boolean;
|
import java.lang.Boolean;
|
||||||
|
|
||||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||||
@ -18,7 +18,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Fun2$$<java.util.Vector<? extends java.util.Vector<? extends java.lang.Byte>>, java.util.Vector<? extends java.util.Vector<? extends java.lang.Byte>>, MatrixOP> mul = (m1, m2) -> {
|
mul = (m1, m2) -> {
|
||||||
var ret = new MatrixOP();
|
var ret = new MatrixOP();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while(i < m1.size()) {
|
while(i < m1.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user