Compare commits
6 Commits
targetByte
...
unifyDev
Author | SHA1 | Date | |
---|---|---|---|
|
343ce89f7d | ||
|
d65db7b55e | ||
|
ba19df8587 | ||
|
b318a315a6 | ||
|
8e1d7f703c | ||
|
ea6ff84c9f |
@ -61,6 +61,474 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
// ino.end
|
||||
// ino.class.Method.23482.body
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
// ino.attribute.block.23488.declaration
|
||||
private Block block;
|
||||
// ino.end
|
||||
// ino.attribute.parameterlist.23491.declaration
|
||||
public ParameterList parameterlist = new ParameterList();
|
||||
// ino.end
|
||||
// ino.attribute.exceptionlist.23494.declaration
|
||||
private ExceptionList exceptionlist;
|
||||
// ino.end
|
||||
// ino.attribute.returntype.23497.declaration
|
||||
private Type returntype;
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.genericMethodParameters.23500.decldescription type=javadoc
|
||||
/**
|
||||
* HOTI 4.5.06
|
||||
* Dieser Vektor beinhaltet alle Generischen Typen und v.a. die
|
||||
* F-Bounded-Generics, die die Methode besitzt
|
||||
* size()==0, falls es keine gibt
|
||||
*/
|
||||
// ino.end
|
||||
// ino.attribute.genericMethodParameters.23500.declaration
|
||||
//private Vector<GenericTypeVar> genericMethodParameters=new Vector<GenericTypeVar>();
|
||||
// ino.end
|
||||
|
||||
// ino.attribute.overloadedID.23503.declaration
|
||||
private int overloadedID;
|
||||
// ino.end
|
||||
// ino.attribute.isAbstract.23506.declaration
|
||||
private boolean isAbstract = false;
|
||||
// ino.end
|
||||
// ino.attribute.types_in_parameterlist.23509.declaration
|
||||
private Vector<String> types_in_parameterlist = new Vector<String>();
|
||||
// ino.end
|
||||
// ino.attribute.m_LineNumber.23512.declaration
|
||||
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
||||
// ino.end
|
||||
private int m_Offset = -1; //hinzugef<EFBFBD>gt hoth: 07.04.2006
|
||||
// ino.attribute.inferencelog.23515.declaration
|
||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.23518.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
// ino.end
|
||||
|
||||
public Method(int offset){
|
||||
super(offset);
|
||||
}
|
||||
|
||||
/*
|
||||
// ino.method.setGenericMethodParameters.23521.definition
|
||||
public void setGenericMethodParameters(Vector<GenericTypeVar> genericMethodParameters)
|
||||
// ino.end
|
||||
// ino.method.setGenericMethodParameters.23521.body
|
||||
{
|
||||
this.genericMethodParameters=genericMethodParameters;
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.getGenericMethodParameters.23524.definition
|
||||
public Vector<GenericTypeVar> getGenericMethodParameters()
|
||||
// ino.end
|
||||
// ino.method.getGenericMethodParameters.23524.body
|
||||
{
|
||||
return(genericMethodParameters);
|
||||
}
|
||||
// ino.end
|
||||
*/
|
||||
/*
|
||||
// ino.method.sc_init_parameterlist.23530.definition
|
||||
public void sc_init_parameterlist(boolean ext)
|
||||
// ino.end
|
||||
// ino.method.sc_init_parameterlist.23530.body
|
||||
{
|
||||
DeclId hilf=null;
|
||||
Vector<FormalParameter> list;
|
||||
FormalParameter para;
|
||||
String typeofpara;
|
||||
int i=1;
|
||||
if(this.getParameterList()!=null) //es gibt Parameter, dann:
|
||||
{
|
||||
hilf=declid.elementAt(0);
|
||||
if(ext)
|
||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" bergabewerte gefunden:");
|
||||
list=this.getParameterList().sc_get_Formalparalist(); //Vector Formalparalist aus FormalParameterList wird zwischen gesichert
|
||||
for(Enumeration<FormalParameter> el2=list.elements(); el2.hasMoreElements();)
|
||||
{
|
||||
para=el2.nextElement();
|
||||
typeofpara=para.getTypeName();
|
||||
if(ext)
|
||||
parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara);
|
||||
types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden im Vector abgelegt
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else //keine Parameter vorhanden:
|
||||
{
|
||||
if(ext)
|
||||
{
|
||||
hilf=declid.elementAt(0);
|
||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" keine bergabewerte gefunden.");
|
||||
}
|
||||
}
|
||||
if(ext)
|
||||
{
|
||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+ types_in_parameterlist.size()+" bergabeparameter gefunden.");
|
||||
parserlog.debug(" namentlich: "+types_in_parameterlist.toString());
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
*/
|
||||
// ino.method.getTypeName.23533.defdescription type=line
|
||||
// Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die
|
||||
// get_ReturnType() auf eigene Gefahr lschen.
|
||||
// ino.end
|
||||
|
||||
// ino.method.getTypeName.23533.definition
|
||||
public JavaClassName getTypeName()
|
||||
// ino.end
|
||||
// ino.method.getTypeName.23533.body
|
||||
{
|
||||
if( this.getType() == null )
|
||||
return null;
|
||||
else
|
||||
return this.getType().getName();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Block.23536.definition
|
||||
public Block get_Block()
|
||||
// ino.end
|
||||
// ino.method.get_Block.23536.body
|
||||
{
|
||||
return block;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setReturnType.23539.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Jrg Buerle
|
||||
* @param type
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.setReturnType.23539.definition
|
||||
private void setReturnType(Type type)
|
||||
// ino.end
|
||||
// ino.method.setReturnType.23539.body
|
||||
{
|
||||
this.returntype = type;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Block.23542.definition
|
||||
public void set_Block( Block blo)
|
||||
// ino.end
|
||||
// ino.method.set_Block.23542.body
|
||||
{
|
||||
if(blo.getType() == null)blo.setType(this.returntype);
|
||||
this.block = blo;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_Modifiers.23545.definition
|
||||
public void set_Modifiers(Modifiers modif)
|
||||
// ino.end
|
||||
// ino.method.set_Modifiers.23545.body
|
||||
{
|
||||
declid.firstElement().set_Modifiers(modif);
|
||||
// this.modi = modif;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.set_ExceptionList.23548.definition
|
||||
public void set_ExceptionList(ExceptionList exlist)
|
||||
// ino.end
|
||||
// ino.method.set_ExceptionList.23548.body
|
||||
{
|
||||
this.exceptionlist = exlist;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setParameterList.23551.definition
|
||||
public void setParameterList( ParameterList paralist )
|
||||
// ino.end
|
||||
// ino.method.setParameterList.23551.body
|
||||
{
|
||||
this.parameterlist = paralist;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getParameterList.23554.definition
|
||||
public ParameterList getParameterList( )
|
||||
// ino.end
|
||||
// ino.method.getParameterList.23554.body
|
||||
{
|
||||
// otth: gibt die Parameterliste zurueck
|
||||
return this.parameterlist;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getParameterCount.23557.defdescription type=javadoc
|
||||
/**
|
||||
* Author: Jrg Buerle<br/>
|
||||
* @return Die Anzahl der Methoden-Paramater
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.getParameterCount.23557.definition
|
||||
public int getParameterCount()
|
||||
// ino.end
|
||||
// ino.method.getParameterCount.23557.body
|
||||
{
|
||||
if(this.getParameterList() == null)
|
||||
return 0;
|
||||
else
|
||||
return this.getParameterList().getParameterCount();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_ExceptionList.23560.definition
|
||||
public ExceptionList get_ExceptionList()
|
||||
// ino.end
|
||||
// ino.method.get_ExceptionList.23560.body
|
||||
{
|
||||
// otth: gibt die Exceptionliste zurueck
|
||||
return this.exceptionlist;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getOverloadedID.23563.definition
|
||||
public int getOverloadedID()
|
||||
// ino.end
|
||||
// ino.method.getOverloadedID.23563.body
|
||||
{
|
||||
return(overloadedID);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setOverloadedID.23566.definition
|
||||
public void setOverloadedID(int overloadedID)
|
||||
// ino.end
|
||||
// ino.method.setOverloadedID.23566.body
|
||||
{
|
||||
this.overloadedID=overloadedID;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
// ino.method.get_codegen_Param_Type.23572.definition
|
||||
public String get_codegen_Param_Type(Vector paralist)
|
||||
// ino.end
|
||||
// ino.method.get_codegen_Param_Type.23572.body
|
||||
{
|
||||
String ret = new String();
|
||||
if(this.getParameterList() == null)
|
||||
{
|
||||
ret += "()";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += this.getParameterList().get_codegen_ParameterList(paralist);
|
||||
}
|
||||
if(this.getType() == null)
|
||||
{
|
||||
ret += "V";
|
||||
}
|
||||
else
|
||||
{
|
||||
ret += this.getType().get_codegen_Type(paralist);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.get_Method_Name.23575.definition
|
||||
public String get_Method_Name()
|
||||
// ino.end
|
||||
// ino.method.get_Method_Name.23575.body
|
||||
{
|
||||
DeclId hilf=declid.elementAt(0);
|
||||
return hilf.get_Name();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.get_Type_Paralist.23578.definition
|
||||
public Vector get_Type_Paralist()
|
||||
// ino.end
|
||||
// ino.method.get_Type_Paralist.23578.body
|
||||
{
|
||||
return types_in_parameterlist;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
// ino.method.codegen.23581.definition
|
||||
public void codegen(ClassFile classfile, Vector paralist)
|
||||
throws JVMCodeException
|
||||
// ino.end
|
||||
// ino.method.codegen.23581.body
|
||||
{
|
||||
classfile.add_method(declid.firstElement().get_Name(), this.get_codegen_Param_Type(paralist), this.getParameterList(), this.getType(), block, declid.firstElement().get_access_flags(), paralist, isAbstract);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getLineNumber.23584.definition
|
||||
public int getLineNumber()
|
||||
// ino.end
|
||||
// ino.method.getLineNumber.23584.body
|
||||
{
|
||||
return m_LineNumber;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setLineNumber.23587.definition
|
||||
public void setLineNumber(int lineNumber)
|
||||
// ino.end
|
||||
// ino.method.setLineNumber.23587.body
|
||||
{
|
||||
m_LineNumber = lineNumber;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getOffset.23590.defdescription type=line
|
||||
// hinzugef<EFBFBD>gt hoth: 07.04.2006
|
||||
// ino.end
|
||||
// ino.method.getOffset.23590.definition
|
||||
public int getOffset()
|
||||
// ino.end
|
||||
// ino.method.getOffset.23590.body
|
||||
{
|
||||
return m_Offset;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.getVariableLength.23593.definition
|
||||
public int getVariableLength()
|
||||
// ino.end
|
||||
// ino.method.getVariableLength.23593.body
|
||||
{
|
||||
return get_Method_Name().length();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setOffset.23596.defdescription type=line
|
||||
// hinzugef<EFBFBD>gt hoth: 07.04.2006
|
||||
// ino.end
|
||||
// ino.method.setOffset.23596.definition
|
||||
public void setOffset(int Offset)
|
||||
// ino.end
|
||||
// ino.method.setOffset.23596.body
|
||||
{
|
||||
m_Offset = Offset;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
// ino.method.getTypeLineNumber.23602.defdescription type=javadoc
|
||||
/**
|
||||
* <br>Author: Jrg Buerle
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.getTypeLineNumber.23602.definition
|
||||
public int getTypeLineNumber()
|
||||
// ino.end
|
||||
// ino.method.getTypeLineNumber.23602.body
|
||||
{
|
||||
return this.getLineNumber();
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.toString.23605.defdescription type=javadoc
|
||||
/**
|
||||
* <br/>Author: Martin Pl<EFBFBD>micke
|
||||
* @return
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.toString.23605.definition
|
||||
public String toString()
|
||||
// ino.end
|
||||
// ino.method.toString.23605.body
|
||||
{
|
||||
return this.getType() + " "+ this.get_Name() + parameterlist.toString() +( (block!=null)?block.toString():"");
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.setAbstract.23608.defdescription type=javadoc
|
||||
/**
|
||||
* Legt fuer die ByteCodeGen fest, ob Bytecode
|
||||
* innerhalb der Methode generiert wird.
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.setAbstract.23608.definition
|
||||
public void setAbstract(boolean b)
|
||||
// ino.end
|
||||
// ino.method.setAbstract.23608.body
|
||||
{
|
||||
isAbstract = b;
|
||||
}
|
||||
// ino.end
|
||||
|
||||
// ino.method.isAbstract.23611.defdescription type=javadoc
|
||||
/**
|
||||
* Gibt zurueck, ob ByteCode innerhabl der Methode
|
||||
* generiert wird.
|
||||
*/
|
||||
// ino.end
|
||||
// ino.method.isAbstract.23611.definition
|
||||
public boolean isAbstract()
|
||||
// ino.end
|
||||
// ino.method.isAbstract.23611.body
|
||||
{
|
||||
return isAbstract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> classParalist)
|
||||
{
|
||||
/*
|
||||
Vector<Type> paralist = new Vector<Type>();//Mit den Generischen Typen der Methode
|
||||
paralist.addAll(classParalist);
|
||||
paralist.addAll(this.genericMethodParameters);
|
||||
|
||||
// Zuerst Returntype untersuchen
|
||||
Type returnType=getType();
|
||||
Type pendantReturnType = null;
|
||||
if(returnType instanceof RefType)pendantReturnType = ((RefType)returnType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
|
||||
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
|
||||
setReturnType(pendantReturnType);
|
||||
}
|
||||
|
||||
// Dann parameterlist untersuchen
|
||||
for(int par=0;par<getParameterCount();par++){
|
||||
FormalParameter fp=parameterlist.formalparameter.get(par);
|
||||
Type fpType=fp.getType();
|
||||
// Nur wenn es sich um ein RefType-Field handelt
|
||||
Type pendantPara = null;
|
||||
if(fpType instanceof RefType)pendantPara = ((RefType)fpType).findGenericType(paralist, new Vector<GenericTypeVar>());
|
||||
//GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
||||
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
|
||||
fp.setType(pendantPara);
|
||||
}
|
||||
}
|
||||
|
||||
// Zuletzt alle Lokalen Variablendeklarationen durchgehen
|
||||
if(block!=null){
|
||||
block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
||||
}
|
||||
*/
|
||||
}
|
||||
// ino.end
|
||||
// ino.method.set_Method_Name.23617.definition
|
||||
public void set_Method_Name(String string)
|
||||
// ino.end
|
||||
// ino.method.set_Method_Name.23617.body
|
||||
{
|
||||
declid.set(0,new DeclId(string));
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
=======
|
||||
// ino.attribute.block.23488.declaration
|
||||
private Block block;
|
||||
// ino.end
|
||||
@ -498,6 +966,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
declid.set(0, new DeclId(string));
|
||||
}
|
||||
|
||||
>>>>>>> refactoring
|
||||
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
TypeAssumptions localAss = new TypeAssumptions();
|
||||
|
@ -37,6 +37,7 @@ import de.dhbwstuttgart.typeinference.ByteCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.FunNInterface;
|
||||
import de.dhbwstuttgart.typeinference.FunNMethod;
|
||||
import de.dhbwstuttgart.typeinference.KarthesischesProdukt;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
@ -50,7 +51,9 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.typeinference.unify.FC_TTO;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unifier;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unify;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.OderConstraint;
|
||||
import de.dhbwstuttgart.typeinference.UndConstraint;
|
||||
import de.dhbwstuttgart.typeinference.SingleConstraint;
|
||||
|
||||
|
||||
|
||||
@ -656,6 +659,47 @@ public class SourceFile
|
||||
return publicAssumptions;
|
||||
}
|
||||
|
||||
Vector<OderConstraint> divideOderConstraints(OderConstraint oc) {
|
||||
|
||||
//Schritt 1: Variablen an Hand des 1. Elements der UndConstraints gruppieren
|
||||
//!!! KLAEREN OB ES PASSIEREN KANN, DASS IM 2., 3. , ... ELEMENT ANDERE VARIABLEN VORKOMMEN KOENNEN!!!
|
||||
//WENN JA, DANN MUESSEN DIE VARIABLEN UEBER ALLE ELEMENTE (NICHT NUR DAS 1.) AUFGESAMMELT WERDEN
|
||||
Vector<Pair> pairs = oc.getUndConstraints().elementAt(0).getSingleConstraints().stream()
|
||||
.map(x -> x.getPair())
|
||||
.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
Vector<Vector<TypePlaceholder>> pairvars = pairs.stream().map(p -> {Vector<TypePlaceholder> TPHs = new Vector<>();
|
||||
TPHs.addAll(p.TA1.getInvolvedTypePlaceholder());
|
||||
TPHs.addAll(p.TA2.getInvolvedTypePlaceholder());
|
||||
return TPHs;}
|
||||
).collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
//Schritt 2: Schnittmengen jedes Elements mit jedem Elememt von vars bilden und dann index zusammenfassen
|
||||
//in indexset sind dann die Mengen von Indizes enthalten, die gemeisam unifiziert wreden müssen
|
||||
Vector<Vector<Integer>> indexeset1 = new Vector<>();
|
||||
if (pairvars != null && pairvars.size()>0) {
|
||||
indexeset1 = Unify.schnitt(pairvars);
|
||||
}
|
||||
|
||||
//Schritt 3
|
||||
//Aus den Indexmengen die UndConstraints als OderConstraint neu gruppieren
|
||||
java.util.function.BiFunction<UndConstraint,SingleConstraint,UndConstraint> accSC = (a,b) -> { a.addConstraint(b); return a;};
|
||||
java.util.function.BinaryOperator<UndConstraint> combUC = (a,b) -> { a.getUndConstraints().addAll(b.getUndConstraints()); return a;};
|
||||
|
||||
Vector<OderConstraint> ret = new Vector<OderConstraint>();
|
||||
for (Vector<Integer> is : indexeset1) {
|
||||
Stream<Stream<SingleConstraint>> vs = oc.getUndConstraints().stream().map(x -> is.stream().map(i -> x.getSingleConstraints().elementAt(i)));//.collect(Vector::new, Vector::add, Vector::addAll);;
|
||||
//Vector<OderConstraint> us = vs.map(x -> x.reduce(new UndConstraint(), (a,b) -> { a.addConstraint((SingleConstraint)b); return a;}))
|
||||
//.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
OderConstraint OCnew = vs.reduce(new OderConstraint(),
|
||||
(y,x) -> { y.addConstraint(x.reduce(new UndConstraint(), accSC, combUC)); return y;},
|
||||
(a,b) -> { a.getUndConstraints().addAll(b.getUndConstraints()); return a;}
|
||||
);
|
||||
ret.addElement(OCnew);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// TypeReconstructionAlgorithmus
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
@ -676,7 +720,11 @@ public class SourceFile
|
||||
// ino.end
|
||||
// ino.method.typeReconstruction.21406.body
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
//Vector<TypeinferenceResultSet> ret = new Vector<TypeinferenceResultSet>();
|
||||
=======
|
||||
Menge<TypeinferenceResultSet> ret = new Menge<TypeinferenceResultSet>();
|
||||
>>>>>>> refactoring
|
||||
|
||||
//Logger initialisieren:
|
||||
Logger typinferenzLog = Logger.getLogger("Typeinference");
|
||||
@ -695,7 +743,7 @@ public class SourceFile
|
||||
FC_TTO finiteClosure = this.makeFC(globalAssumptions);
|
||||
|
||||
typinferenzLog.debug("FiniteClosure: \n"+finiteClosure, Section.TYPEINFERENCE);
|
||||
|
||||
|
||||
ConstraintsSet oderConstraints = new ConstraintsSet();
|
||||
//Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln:
|
||||
for(Class klasse : KlassenVektor){
|
||||
@ -711,6 +759,71 @@ public class SourceFile
|
||||
Menge<Menge<Pair>> retValue = new Menge<>();
|
||||
retValue = Unify.unify(pairs, finiteClosure);
|
||||
return retValue;};
|
||||
<<<<<<< HEAD
|
||||
oderConstraints.filterWrongConstraints(unifier);
|
||||
//oderConstraints.unifyUndConstraints(unifier);
|
||||
|
||||
java.util.function.BiFunction<Vector<OderConstraint>,OderConstraint,Vector<OderConstraint>> divideOC =
|
||||
(a,b) -> {
|
||||
if ((b instanceof SingleConstraint) || (b instanceof UndConstraint)) { a.addElement(b); }
|
||||
else { a.addAll(divideOderConstraints(b)); } // (b instanceof OderConstraint)
|
||||
return a;
|
||||
};
|
||||
java.util.function.BinaryOperator<Vector<OderConstraint>> oderAll = (a,b) -> { a.addAll(b); return a;};
|
||||
|
||||
|
||||
Vector<OderConstraint> vecoderConstraints = oderConstraints.getConstraintsSet().stream().reduce(new Vector<OderConstraint>(), divideOC, oderAll);
|
||||
|
||||
ConstraintsSet devidedOderConstraints = new ConstraintsSet();
|
||||
devidedOderConstraints.addAll(vecoderConstraints);
|
||||
//HIER WEITERMACHEN: oderConstraints in devidedOderConstraints umaendern
|
||||
//1. Schritt:
|
||||
Stream<Vector<Pair>> streamOneExample =
|
||||
devidedOderConstraints.getConstraintsSet().stream().map(
|
||||
(constr) -> constr.getOneExample()); //.reduce(Vector::new, Vector::addAll);
|
||||
Vector<Vector<Pair>> vecOneExample = streamOneExample.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
//2. Schritt
|
||||
Stream<Vector<TypePlaceholder>> streamvars = vecOneExample.stream().map(x -> x.stream().map(
|
||||
p -> { Vector<TypePlaceholder> TPHs = new Vector<>();
|
||||
TPHs.addAll(p.TA1.getInvolvedTypePlaceholder());
|
||||
TPHs.addAll(p.TA2.getInvolvedTypePlaceholder());
|
||||
return TPHs;}
|
||||
).reduce(new Vector<TypePlaceholder>(),(a, b) -> { for (TypePlaceholder ty : b ) { if (!a.contains(ty)) a.add(ty); } return a; }));
|
||||
|
||||
Vector<Vector<TypePlaceholder>> vecvars = streamvars.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
//Schritt 3: Schnittmengen jedes Elements mit jedem Elememt von vars bilden und dann index zusammenfassen
|
||||
//in indexset sind dann die Mengen von Indizes enthalten, die gemeisam unifiziert wreden müssen
|
||||
Vector<Vector<Integer>> indexeset = new Vector<>();
|
||||
if (vecvars != null && vecvars.size()>0) {
|
||||
indexeset = Unify.schnitt(vecvars);
|
||||
}
|
||||
|
||||
//Schritt 3: Umwandlung der Indizes in die zugehoerigen Elemente
|
||||
// In streamconstraintsclone sind die Mengen von Paar enthalten die unifiziert werden muessen
|
||||
Stream<Vector<OderConstraint>> streamoderconstraints = indexeset.stream().map(x -> x.stream()
|
||||
.map(i -> devidedOderConstraints.getConstraintsSet().elementAt(i))
|
||||
.collect(Vector::new, Vector::add, Vector::addAll));
|
||||
Vector<Vector<OderConstraint>> vecconstraintsclone = streamoderconstraints.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
Stream<ConstraintsSet> constraintsclone = vecconstraintsclone.stream().map(
|
||||
oderConstraintsSubset -> {
|
||||
ConstraintsSet ConsoderConstraintsSubset = new ConstraintsSet ();
|
||||
ConsoderConstraintsSubset.addAll(oderConstraintsSubset);
|
||||
System.out.println(oderConstraintsSubset);
|
||||
return ConsoderConstraintsSubset; }
|
||||
);
|
||||
//Vector<ConstraintsSet> xxx1 = constraintsclone.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
Stream<Vector<TypeinferenceResultSet>> ressets = constraintsclone.map(constraintsSubset -> {
|
||||
typinferenzLog.debug("Übriggebliebene Konstraints:\n"+devidedOderConstraints+"\n", Section.TYPEINFERENCE);
|
||||
//Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden):
|
||||
Vector<TypeinferenceResultSet> ret = new Vector<TypeinferenceResultSet>();
|
||||
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = devidedOderConstraints.getConstraints();
|
||||
for(Vector<UndConstraint> uC : constraintsSubset.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
|
||||
Vector<Pair> cons = new Vector<Pair>(); //HIER STIMMT ES NICHT constraintsSubset ein Element OderConstraint enthaelt vgl. (TPH AGG <. java.lang.Integer), ]| [
|
||||
//(TPH AGG <. java.lang.Long), ]| [
|
||||
//(TPH AGG <. java.lang.Double), ]| ]],
|
||||
=======
|
||||
//oderConstraints.filterWrongConstraints(unifier);
|
||||
oderConstraints.unifyUndConstraints(unifier);
|
||||
typinferenzLog.debug("Ãbriggebliebene Konstraints:\n"+oderConstraints+"\n", Section.TYPEINFERENCE);
|
||||
@ -719,6 +832,7 @@ public class SourceFile
|
||||
/*
|
||||
for(Menge<UndConstraint> uC : oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
|
||||
Menge<Pair> cons = new Menge<Pair>();
|
||||
>>>>>>> refactoring
|
||||
for(UndConstraint undCons:uC){
|
||||
cons.addAll(undCons.getConstraintPairs());
|
||||
}
|
||||
@ -805,19 +919,32 @@ public class SourceFile
|
||||
).collect(Menge::new, Menge::add, Menge::addAll);
|
||||
|
||||
//Schritt 2: Schnittmengen jedes Elements mit jedem Elememt von vars bilden und dann index zusammenfassen
|
||||
<<<<<<< HEAD
|
||||
//in indexset sind dann die Mengen von Indizes enthalten, die gemeisam unifiziert wreden müssen
|
||||
Vector<Vector<Integer>> indexeset1 = new Vector<>();
|
||||
=======
|
||||
//in indexset sind dann die Mengen von Indizes enthalten, die gemeisam unifiziert wreden müssen
|
||||
Menge<Menge<Integer>> indexeset = new Menge<>();
|
||||
>>>>>>> refactoring
|
||||
if (constraintsclonevars != null && constraintsclonevars.size()>0) {
|
||||
indexeset = Unify.schnitt(constraintsclonevars);
|
||||
indexeset1 = Unify.schnitt(constraintsclonevars);
|
||||
}
|
||||
|
||||
//Schritt 3: Umwandlung der Indizes in die zugehoerigen Elemente
|
||||
// In streamconstraintsclone sind die Mengen von Paar enthalten die unifiziert werden muessen
|
||||
<<<<<<< HEAD
|
||||
Stream<Vector<Pair>> streamconstraintsclone = indexeset1.stream().map(x -> x.stream()
|
||||
.map(i -> constraintsClone.elementAt(i))
|
||||
.collect(Vector::new, Vector::add, Vector::addAll));
|
||||
// Vector<Vector<Pair>> vecconstraintsclone1 = streamconstraintsclone.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
=======
|
||||
Stream<Menge<Pair>> streamconstraintsclone = indexeset.stream().map(x -> x.stream()
|
||||
.map(i -> constraintsClone.elementAt(i))
|
||||
.<Menge<Pair>>collect(Menge::new, Menge::add, Menge::addAll));
|
||||
//Menge<Menge<Pair>> vecconstraintsclone = streamconstraintsclone.collect(Menge::new, Menge::add, Menge::addAll);
|
||||
System.out.println();
|
||||
>>>>>>> refactoring
|
||||
//Schritt 4: Unifikation
|
||||
Menge<Menge<Menge<Pair>>> vecunifyResult =
|
||||
//streamconstraintsclone.map(x -> Unify.unify(x, finiteClosure)).collect(Menge::new, Menge::add, Menge::addAll);
|
||||
@ -910,7 +1037,7 @@ public class SourceFile
|
||||
//typinferenzLog.debug(supportData.getFiniteClosure());
|
||||
//typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers));
|
||||
|
||||
typinferenzLog.debug("\nJavaFiles:\n", Section.TYPEINFERENCE);
|
||||
//typinferenzLog.debug("\nJavaFiles:\n", Section.TYPEINFERENCE);
|
||||
|
||||
//typinferenzLog.debug(this.printJavaCode(new ResultSet(new Menge<Pair>())));
|
||||
|
||||
@ -934,7 +1061,51 @@ public class SourceFile
|
||||
if(unifyFail){
|
||||
if(!this.KlassenVektor.isEmpty())throw new TypeinferenceException("Fehler in Typinferierung", this.KlassenVektor.firstElement());
|
||||
}
|
||||
return ret;
|
||||
return ret;});
|
||||
Vector<Vector<TypeinferenceResultSet>> vecressets = ressets.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
SourceFile.inferencelog.debug("vecressets:\n" + vecressets, Section.TYPEINFERENCE);
|
||||
//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<>();
|
||||
/*
|
||||
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit
|
||||
// in der GUI (Eclipse-Plugin) die Console nicht zugemüllt wird.
|
||||
|
@ -21,6 +21,14 @@ public class ConstraintsSet extends UndMenge<Pair> implements Iterable<OderConst
|
||||
public void add(OderConstraint constraint){
|
||||
constraintsSet.add(constraint);
|
||||
}
|
||||
|
||||
public void addAll(Vector<OderConstraint> vecconstraint){
|
||||
constraintsSet.addAll(vecconstraint);
|
||||
}
|
||||
|
||||
public Vector<OderConstraint> getConstraintsSet() {
|
||||
return constraintsSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
|
@ -3,17 +3,30 @@ package de.dhbwstuttgart.typeinference;
|
||||
|
||||
public abstract class KarthesischesProdukt {
|
||||
|
||||
<<<<<<< HEAD
|
||||
public Vector<Vector<M>> berechneKarthesischesProdukt(Vector<Vector<M>> m1){
|
||||
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>();
|
||||
=======
|
||||
public static <M> Menge<Menge<M>> berechneKarthesischesProdukt(Menge<Menge<M>> m1){
|
||||
if(m1.size()==0)return m1;
|
||||
if(m1.size()==1){
|
||||
Menge<Menge<M>> ret = new Menge<Menge<M>>();
|
||||
for(M o : m1.firstElement()){
|
||||
Menge<M> v = new Menge<M>();
|
||||
>>>>>>> refactoring
|
||||
v.add(o);
|
||||
ret.add(v);
|
||||
}
|
||||
return ret;
|
||||
<<<<<<< HEAD
|
||||
//return m1;//throw new TypinferenzException("m1 hat zu wenige Objekte für ein Karthesisches Produkt. Es müssen mindestens 2 sein.");
|
||||
=======
|
||||
//return m1;//throw new TypinferenzException("m1 hat zu wenige Objekte für ein Karthesisches Produkt. Es müssen mindestens 2 sein.");
|
||||
>>>>>>> refactoring
|
||||
}
|
||||
return berechneKarthesischesProdukt(m1, null);
|
||||
}
|
||||
|
@ -33,7 +33,18 @@ public class OderConstraint extends OderMenge<Pair>{
|
||||
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* gibt ein Exemplar zurück um die Variablen zu bestimmen
|
||||
*/
|
||||
public Vector<Pair> getOneExample() {
|
||||
return this.getUndConstraints().elementAt(0).getConstraintPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert alle in diesem OderConstraint enthaltene Constraints. Dabei gehen die Verknüpfungen (Oder/Und) verloren.
|
||||
=======
|
||||
* Liefert alle in diesem OderConstraint enthaltene Constraints. Dabei gehen die Verkn<EFBFBD>pfungen (Oder/Und) verloren.
|
||||
>>>>>>> refactoring
|
||||
* @return
|
||||
*/
|
||||
public Menge<Pair> getConstraintPairs(){
|
||||
@ -44,6 +55,8 @@ public class OderConstraint extends OderMenge<Pair>{
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* F<EFBFBD>gt ein Pair(p1, p2) dem Constraint hinzu
|
||||
* @param p1
|
||||
@ -69,6 +82,17 @@ public class OderConstraint extends OderMenge<Pair>{
|
||||
}
|
||||
return ret+"]";
|
||||
}
|
||||
|
||||
public Vector<SingleConstraint> getSingleConstraints() {
|
||||
Vector<SingleConstraint> ret = new Vector<SingleConstraint>();
|
||||
for(UndConstraint uc : oderConstraintPairs) {
|
||||
if (uc instanceof SingleConstraint) {
|
||||
ret.add((SingleConstraint)uc);
|
||||
}
|
||||
//else return new Exception();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Vector<UndConstraint> getUndConstraints() {
|
||||
return this.oderConstraintPairs;
|
||||
|
@ -46,6 +46,11 @@ public class SingleConstraint extends UndConstraint{
|
||||
public Pair getPair(){
|
||||
return constraintPair;
|
||||
}
|
||||
|
||||
@Override //liefert das eine Paar zurueck
|
||||
public Vector<Pair> getOneExample() {
|
||||
return getConstraintPairs();
|
||||
}
|
||||
|
||||
@Override //Methode überschreiben, damit immer nur ein Vector mit nur einem Element zurückgeliefert wird.
|
||||
public Menge<Pair> getConstraintPairs(){
|
||||
|
@ -47,6 +47,7 @@ public class UndConstraint extends UndMenge<Pair> {
|
||||
super(p1, p2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<UndConstraint> getUndConstraints() {
|
||||
Vector<UndConstraint> ret = new Vector<UndConstraint>();
|
||||
|
7
test/plugindevelopment/MartinTestCases/Matrix3.jav
Normal file
7
test/plugindevelopment/MartinTestCases/Matrix3.jav
Normal file
@ -0,0 +1,7 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Matrix3 extends Vector<Vector<Integer>> {
|
||||
|
||||
op = (f) -> f.apply(this);
|
||||
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
import java.util.Vector;
|
||||
|
||||
<<<<<<< HEAD
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
op = (m) -> (f) -> f.apply(this, m);
|
||||
=======
|
||||
class Matrix {
|
||||
op = (m) -> (f) -> f.apply(m);
|
||||
>>>>>>> refactoring
|
||||
}
|
5
test/plugindevelopment/TypeInsertTests/Matrix3.jav
Normal file
5
test/plugindevelopment/TypeInsertTests/Matrix3.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class Matrix3 extends Vector<Vector<Integer>> {
|
||||
|
||||
op = (f) -> f.apply(this);
|
||||
|
||||
}
|
20
test/plugindevelopment/TypeInsertTests/Matrix3.java
Normal file
20
test/plugindevelopment/TypeInsertTests/Matrix3.java
Normal file
@ -0,0 +1,20 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
|
||||
public class Matrix3 {
|
||||
private static final String TEST_FILE = "Matrix3.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("TestIfStmt var");
|
||||
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
6
test/plugindevelopment/TypeInsertTests/Matrix_lambda.jav
Normal file
6
test/plugindevelopment/TypeInsertTests/Matrix_lambda.jav
Normal file
@ -0,0 +1,6 @@
|
||||
import java.util.Vector;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
op = (f) -> f.apply(this);
|
||||
|
||||
}
|
20
test/plugindevelopment/TypeInsertTests/Matrix_lambda.java
Normal file
20
test/plugindevelopment/TypeInsertTests/Matrix_lambda.java
Normal file
@ -0,0 +1,20 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
|
||||
public class Matrix_lambda {
|
||||
private static final String TEST_FILE = "Matrix_lambda.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("TestIfStmt var");
|
||||
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user