Ergebnis Sourcefile.typeReconstruction ist neue Datenstruktur

This commit is contained in:
Martin Plümicke 2015-01-02 12:44:31 +01:00
parent ea6ff84c9f
commit 8e1d7f703c
5 changed files with 63 additions and 3 deletions

7
bin/.gitignore vendored
View File

@ -1 +1,8 @@
/bytecode/
/de/ /de/
/log4j.xml
/log4jTesting.xml
/mycompiler/
/parser/
/plugindevelopment/
/syntaxTree/

View File

@ -434,7 +434,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
// ino.end // ino.end
// ino.method.toString.23605.body // ino.method.toString.23605.body
{ {
return this.getType() + " "+ this.get_Name() +( (block!=null)?block.toString():""); return this.getType() + " "+ this.get_Name() + parameterlist.toString() +( (block!=null)?block.toString():"");
} }
// ino.end // ino.end

View File

@ -35,6 +35,7 @@ import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.FunN; import de.dhbwstuttgart.typeinference.FunN;
import de.dhbwstuttgart.typeinference.FunNInterface; import de.dhbwstuttgart.typeinference.FunNInterface;
import de.dhbwstuttgart.typeinference.FunNMethod; import de.dhbwstuttgart.typeinference.FunNMethod;
import de.dhbwstuttgart.typeinference.KarthesischesProdukt;
import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
@ -684,6 +685,7 @@ public class SourceFile
return ret; return ret;
} }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// TypeReconstructionAlgorithmus // TypeReconstructionAlgorithmus
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -1011,6 +1013,47 @@ public class SourceFile
} }
return ret;}); return ret;});
Vector<Vector<TypeinferenceResultSet>> vecressets = ressets.collect(Vector::new, Vector::add, Vector::addAll); Vector<Vector<TypeinferenceResultSet>> vecressets = ressets.collect(Vector::new, Vector::add, Vector::addAll);
System.out.println("vecressets:\n" + vecressets);
//Vector<Integer> vecressets = ressets.map(x -> x.size()).collect(Vector::new, Vector::add, Vector::addAll);
//Vector<Vector<TypeinferenceResultSet>> ret = new KarthesischesProdukt<TypeinferenceResultSet>().berechneKarthesischesProdukt(vecressets);
Stream<Vector<Vector<Pair>>> ressetspairs = vecressets.stream().map(x -> x.stream().map(y -> y.getUnifiedConstraints().getResultSet())
.collect(Vector::new, Vector::add, Vector::addAll));
java.util.Comparator<Vector<Vector<Pair>>> comp = (x,y) -> { if (x.size() < y.size()) return -1;
else if (x.size() == y.size()) return 0;
else return 1;
};
//Vector<Integer> ressetspairs_size = ressetspairs.sorted(comp).map(x -> x.size()).collect(Vector::new, Vector::add, Vector::addAll);
//cart. Produkt mit Linkverschiebung//FUNKTIONIERT NICHT WIRD ZU GROSS
Vector<Vector<Pair>> cardprodret_start = new Vector<>();
cardprodret_start.add(new Vector<Pair>());
//Vector<Vector<Pair>> ret = ressetspairs.sorted(comp).reduce(cardprodret_start, (x, y) -> {
Vector<Vector<Pair>> ret = ressetspairs.reduce(cardprodret_start, (x, y) -> {
Vector<Vector<Pair>> cardprodret= new Vector<>();
if (y.size() > 0) {
//System.out.println(y);
//Vector<Vector<Pair>> cardprodretold = x;
//cardprodret = new Vector<>();
for(int j = 0; j < x.size(); j++) {
for (int k = 0; k < y.size(); k++){
Vector<Pair> help = new Vector<>();
help.addAll(y.elementAt(k));
help.addAll(x.elementAt(j));
cardprodret.add(help);
}
}
}
else
return new Vector<>(); //kein unifiziertes Ergebnis, damit wird das Geseamtergebnis []
return cardprodret;
});
return new Vector(); return new Vector();
/* /*
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit // HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit

View File

@ -5,7 +5,17 @@ import java.util.Vector;
public class KarthesischesProdukt<M> { public class KarthesischesProdukt<M> {
public Vector<Vector<M>> berechneKarthesischesProdukt(Vector<Vector<M>> m1){ public Vector<Vector<M>> berechneKarthesischesProdukt(Vector<Vector<M>> m1){
if(m1.size()<2)return m1;//throw new TypinferenzException("m1 hat zu wenige Objekte für ein Karthesisches Produkt. Es müssen mindestens 2 sein."); if(m1.size()==0)return m1;
if(m1.size()==1){
Vector<Vector<M>> ret = new Vector<Vector<M>>();
for(M o : m1.firstElement()){
Vector<M> v = new Vector<M>();
v.add(o);
ret.add(v);
}
return ret;
//return m1;//throw new TypinferenzException("m1 hat zu wenige Objekte für ein Karthesisches Produkt. Es müssen mindestens 2 sein.");
}
return berechneKarthesischesProdukt(m1, null); return berechneKarthesischesProdukt(m1, null);
} }

View File

@ -1,5 +1,5 @@
import java.util.Vector; import java.util.Vector;
class Matrix extends Vector<Vector<Integer>> { class Matrix extends Vector<Vector<Integer>> {
op = (Matrix m) -> (f) -> f.apply(this, m); op = (m) -> (f) -> f.apply(this, m);
} }