Dateien vergessen

This commit is contained in:
JanUlrich 2014-04-23 14:36:50 +02:00
parent db4442628b
commit b2e79b35f3
4 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,93 @@
package typinferenz;
import java.util.Iterator;
import java.util.Vector;
import mycompiler.IItemWithOffset;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Pair;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
/**
* Ein InsertPoint für Generische Variablen
* @author janulrich
*
*/
public class GenericTypeInsertPoint extends TypeInsertPoint {
private Vector<Pair> genericPairs = new Vector<Pair>();
public GenericTypeInsertPoint(TypeInsertPoint p) {
super(p.point, p.type, p.resultSet);
}
/**
* Fügt eine generische Variable in Form eines Pairs an.
* @param p
*/
public void addGenericPair(Pair p){
if(!this.genericPairs.contains(p))this.genericPairs.add(p);
}
@Override
public JavaCodeResult getTypeInsertString() {
if(genericPairs.size()==0)return new JavaCodeResult();
return super.getTypeInsertString();
}
@Override
protected Type getInsertType(){
if(genericPairs.size()==0)return this.type;
Iterator<Pair> it = genericPairs.iterator();
String genericTypeParameters = "<";
while(it.hasNext()){
genericTypeParameters += new GenericTypeVar(it.next(), 0).printJavaCode(this.getResultSet());
if(it.hasNext())genericTypeParameters += ", ";
}
genericTypeParameters += ">";
//Der Generische Variablen String zum Einsetzen ist nun vorhanden
this.type = new RefType(genericTypeParameters,0);
return this.type;
}
@Override
public boolean equals(Object obj){
if(obj instanceof GenericTypeInsertPoint)return super.equals(obj);
return false;
}
@Override
public int compareTo(TypeInsertPoint arg0) {
int ret = new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
if(ret == 0){
if(! (arg0 instanceof GenericTypeInsertPoint)){
ret = new Integer(this.getOffset()-1).compareTo(new Integer(arg0.getOffset()));
}
}
return ret;
}
@Override
public IItemWithOffset getInsertNode(){
return super.getGenericTypeVarInsertNode();
}
/**
* Versucht den GenericTypeInsertPoint mit dem übergebenenen p2 zusammenzuführen,
* basierend auf ihren insertPoints.
* @param p2
* @return - Die bei der Zusammenführung entstandene GenericTypeInsertPoints
*/
public Vector<GenericTypeInsertPoint> merge(GenericTypeInsertPoint p2) {
Vector<GenericTypeInsertPoint> ret = new Vector<GenericTypeInsertPoint>();
if(this.getInsertNode().equals(p2.getInsertNode())){
for(Pair p : p2.genericPairs)this.addGenericPair(p);
ret.add(this);
}else{
ret.add(this);
ret.add(p2);
}
return ret;
}
}

View File

@ -0,0 +1,17 @@
package typinferenz;
import java.util.Vector;
import mycompiler.mytype.TypePlaceholder;
/**
*
* @author janulrich
*
*/
public class TIPConstraints {
public TIPConstraints(Vector<TypePlaceholder> involvedTPHs){
}
}

View File

@ -0,0 +1,3 @@
class Matrix{
op = (m) -> (f) -> f.apply(this, m);
}

View File

@ -0,0 +1,18 @@
package plugindevelopment.TypeInsertTests;
import java.util.Vector;
import org.junit.Test;
public class LambdaTest6 {
private static final String TEST_FILE = "LambdaTest6.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
//mustContain.add("A var");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
}
}