Starte mit Löschen alter Typeinferenzalgorithmen

This commit is contained in:
JanUlrich 2014-02-09 16:07:31 +01:00
parent 7ec923c4bb
commit 971fb4ad65
73 changed files with 12829 additions and 1161 deletions

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ import mycompiler.mytype.Pair;
import mycompiler.mytype.RefType; import mycompiler.mytype.RefType;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator; import org.apache.log4j.xml.DOMConfigurator;
@ -538,7 +538,7 @@ public class MyCompiler implements MyCompilerAPI
*/ */
// ino.end // ino.end
// ino.method.typeReconstruction.21304.definition // ino.method.typeReconstruction.21304.definition
public Vector<CTypeReconstructionResult> typeReconstruction() public Vector<TypeinferenceResultSet> typeReconstruction()
throws NullPointerException, CTypeReconstructionException throws NullPointerException, CTypeReconstructionException
// ino.end // ino.end
// ino.method.typeReconstruction.21304.body // ino.method.typeReconstruction.21304.body
@ -550,7 +550,7 @@ public class MyCompiler implements MyCompilerAPI
inferencelog.info("# TypeReconstruction-Algorithmus - START #"); inferencelog.info("# TypeReconstruction-Algorithmus - START #");
inferencelog.info("##########################################\n"); inferencelog.info("##########################################\n");
Vector<CTypeReconstructionResult> result = m_AbstractSyntaxTree.typeReconstruction(); Vector<TypeinferenceResultSet> result = m_AbstractSyntaxTree.typeReconstruction();
inferencelog.info("#########################################"); inferencelog.info("#########################################");
inferencelog.info("# TypeReconstruction-Algorithmus - ENDE #"); inferencelog.info("# TypeReconstruction-Algorithmus - ENDE #");

View File

@ -10,7 +10,7 @@ import java.util.Vector;
import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
import mycompiler.myparser.JavaParser; import mycompiler.myparser.JavaParser;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
// ino.end // ino.end
// ino.class.MyCompilerAPI.21328.description type=javadoc // ino.class.MyCompilerAPI.21328.description type=javadoc
@ -79,7 +79,7 @@ public interface MyCompilerAPI
*/ */
// ino.end // ino.end
// ino.method.typeReconstruction.21340.declaration // ino.method.typeReconstruction.21340.declaration
public Vector<CTypeReconstructionResult> typeReconstruction() public Vector<TypeinferenceResultSet> typeReconstruction()
throws NullPointerException, CTypeReconstructionException; throws NullPointerException, CTypeReconstructionException;
// ino.end // ino.end

View File

@ -7,6 +7,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.myclass.BasicAssumptionClass; import mycompiler.myclass.BasicAssumptionClass;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
import mycompiler.myclass.ImportDeclarations; import mycompiler.myclass.ImportDeclarations;
@ -27,19 +28,19 @@ import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytype.Void; import mycompiler.mytype.Void;
import mycompiler.mytypereconstruction.CIntersectionType; import mycompiler.mytypereconstruction.CIntersectionType;
import mycompiler.mytypereconstruction.CSupportData; import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CParaTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.FC_TTO; import mycompiler.mytypereconstruction.unify.FC_TTO;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import sun.reflect.generics.reflectiveObjects.TypeVariableImpl; import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
// ino.end
@ -648,7 +649,7 @@ public class SourceFile
*/ */
// ino.end // ino.end
// ino.method.typeReconstruction.21406.definition // ino.method.typeReconstruction.21406.definition
public Vector<CTypeReconstructionResult> typeReconstruction() public Vector<TypeinferenceResultSet> typeReconstruction()
throws CTypeReconstructionException throws CTypeReconstructionException
// ino.end // ino.end
// ino.method.typeReconstruction.21406.body // ino.method.typeReconstruction.21406.body
@ -660,9 +661,9 @@ public class SourceFile
// inferencelog.setLevel(Level.INFO); // inferencelog.setLevel(Level.INFO);
Vector<CTypeReconstructionResult> A = new Vector<CTypeReconstructionResult>(); Vector<TypeinferenceResultSet> A = new Vector<TypeinferenceResultSet>();
CTypeReconstructionResult basics; TypeAssumptions basics;
basics = this.makeBasicAssumptions(); //TODO: Diese Funktion ändern, dass nur noch TypeAssumptions zurückgegeben werden. Diese sind wichtig, da hier die Standard-Library von Java als Assumptions generiert wird. basics = this.makeBasicAssumptions(); //TODO: Diese Funktion ändern, dass nur noch TypeAssumptions zurückgegeben werden. Diese sind wichtig, da hier die Standard-Library von Java als Assumptions generiert wird.
@ -755,7 +756,7 @@ public class SourceFile
// dort nnen die Definitionen der Interfaces (Methodintersectiontypes, FieldDecls) abgelegt werden // dort nnen die Definitionen der Interfaces (Methodintersectiontypes, FieldDecls) abgelegt werden
intf.addThisToAssumptions(basics); //intf.addThisToAssumptions(basics);
} }
// Fuer jede Klasse die Assumptions der öffentlichen Felder zusammentragen: // Fuer jede Klasse die Assumptions der öffentlichen Felder zusammentragen:
@ -929,14 +930,15 @@ public class SourceFile
// ino.method.makeBasicAssumptionsFromJRE.21409.definition // ino.method.makeBasicAssumptionsFromJRE.21409.definition
@Deprecated //angefügt von Andreas Stadelmeier. Grund: Die Funktion wurde neu als getBasicAssumptions angelegt @Deprecated //angefügt von Andreas Stadelmeier. Grund: Die Funktion wurde neu als getBasicAssumptions angelegt
private CTypeReconstructionResult makeBasicAssumptionsFromJRE(Vector<UsedId> imports) private TypeinferenceResultSet makeBasicAssumptionsFromJRE(Vector<UsedId> imports)
// ino.end // ino.end
// ino.method.makeBasicAssumptionsFromJRE.21409.body // ino.method.makeBasicAssumptionsFromJRE.21409.body
{ {
return null;
/*
Vector<UsedId> doneImports=new Vector<UsedId>(); Vector<UsedId> doneImports=new Vector<UsedId>();
CTypeReconstructionResult basicAssumptions = new CTypeReconstructionResult(null); TypeinferenceResultSet basicAssumptions = new TypeinferenceResultSet(null);
Modifiers mod = new Modifiers(); Modifiers mod = new Modifiers();
mod.addModifier(new Public()); mod.addModifier(new Public());
@ -1067,6 +1069,7 @@ public class SourceFile
imports.addAll(doneImports); imports.addAll(doneImports);
return basicAssumptions; return basicAssumptions;
*/
} }
// ino.end // ino.end
@ -1134,11 +1137,11 @@ public class SourceFile
*/ */
// ino.end // ino.end
// ino.method.makeBasicAssumptions.21418.definition // ino.method.makeBasicAssumptions.21418.definition
private CTypeReconstructionResult makeBasicAssumptions() private TypeAssumptions makeBasicAssumptions()
// ino.end // ino.end
// ino.method.makeBasicAssumptions.21418.body // ino.method.makeBasicAssumptions.21418.body
{ {
/*
if(LOAD_BASIC_ASSUMPTIONS_FROM_JRE){ if(LOAD_BASIC_ASSUMPTIONS_FROM_JRE){
Vector<UsedId> strImports=new Vector<UsedId>(); Vector<UsedId> strImports=new Vector<UsedId>();
@ -1153,7 +1156,7 @@ public class SourceFile
strImports.addElement(uid); strImports.addElement(uid);
} }
} }
CTypeReconstructionResult res=makeBasicAssumptionsFromJRE(strImports); TypeinferenceResultSet res=makeBasicAssumptionsFromJRE(strImports);
ImportDeclarations newImports=new ImportDeclarations(); ImportDeclarations newImports=new ImportDeclarations();
for(int i=0;i<strImports.size();i++){ for(int i=0;i<strImports.size();i++){
@ -1165,7 +1168,7 @@ public class SourceFile
} }
CTypeReconstructionResult foo = new CTypeReconstructionResult(null); TypeinferenceResultSet foo = new TypeinferenceResultSet(null);
CMethodTypeAssumption meth = null; CMethodTypeAssumption meth = null;
CInstVarTypeAssumption instVar = null; CInstVarTypeAssumption instVar = null;
Class c = null; Class c = null;
@ -1295,6 +1298,8 @@ public class SourceFile
this.addElement(c); this.addElement(c);
return foo; return foo;
*/
return new TypeAssumptions(); //TODO: Diese TypeAssumptions mit basic-Assumptions füllen
} }
// ino.end // ino.end

View File

@ -8,6 +8,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.AClassOrInterface; import mycompiler.AClassOrInterface;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.CTypeReconstructionException;
@ -28,7 +29,7 @@ import mycompiler.mytypereconstruction.CReconstructionTuple;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CSupportData; import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTriple; import mycompiler.mytypereconstruction.CTriple;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent; import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
import mycompiler.mytypereconstruction.set.CReconstructionTupleSet; import mycompiler.mytypereconstruction.set.CReconstructionTupleSet;
import mycompiler.mytypereconstruction.set.CSubstitutionSet; import mycompiler.mytypereconstruction.set.CSubstitutionSet;
@ -43,18 +44,20 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey; import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import mycompiler.SourceFile; import mycompiler.SourceFile;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.OderConstraint; import typinferenz.OderConstraint;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException; import typinferenz.TypinferenzException;
import typinferenz.UndConstraint; import typinferenz.UndConstraint;
import typinferenz.FunN; import typinferenz.FunN;
import typinferenz.assumptions.TypeAssumptions;
@ -692,7 +695,7 @@ public class Class extends AClassOrInterface
*/ */
// ino.end // ino.end
// ino.method.TRProg.23110.definition // ino.method.TRProg.23110.definition
public Vector<CTypeReconstructionResult> TRProg(CSupportData supportData, TypeAssumptions globalAssumptions) public Vector<TypeinferenceResultSet> TRProg(CSupportData supportData, TypeAssumptions globalAssumptions)
throws CTypeReconstructionException throws CTypeReconstructionException
// ino.end // ino.end
// ino.method.TRProg.23110.body // ino.method.TRProg.23110.body
@ -740,7 +743,7 @@ public class Class extends AClassOrInterface
////////////////////////////// //////////////////////////////
// Unifizierung der Constraints: // Unifizierung der Constraints:
////////////////////////////// //////////////////////////////
Vector<CTypeReconstructionResult> ret = new Vector<CTypeReconstructionResult>(); //Generiere das Result-Set Vector<TypeinferenceResultSet> ret = new Vector<TypeinferenceResultSet>(); //Generiere das Result-Set
for(Vector<Pair> constraints : xConstraints){ for(Vector<Pair> constraints : xConstraints){
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen: //Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>(); Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
@ -791,7 +794,7 @@ public class Class extends AClassOrInterface
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen: //Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
for(Vector<Pair> resultSet : result){ for(Vector<Pair> resultSet : result){
//Add Result set as a new ReconstructionResult to ret: //Add Result set as a new ReconstructionResult to ret:
CTypeReconstructionResult reconstructionResult = new CTypeReconstructionResult(this); TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(this);
reconstructionResult.setConstraints(constraints); reconstructionResult.setConstraints(constraints);
reconstructionResult.setUnifiedConstraints(resultSet); reconstructionResult.setUnifiedConstraints(resultSet);
ret.add(reconstructionResult); ret.add(reconstructionResult);
@ -1554,7 +1557,7 @@ public class Class extends AClassOrInterface
* Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt. * Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
* @return Java-Sourcefile * @return Java-Sourcefile
*/ */
public String printJavaCode(CTypeReconstructionResult reconstructionResult){ public String printJavaCode(TypeinferenceResultSet reconstructionResult){
JavaCodeResult ret = new JavaCodeResult("class "); JavaCodeResult ret = new JavaCodeResult("class ");
@ -1619,7 +1622,7 @@ public class Class extends AClassOrInterface
* Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben. * Die berechneten Variablen werden anschließend in die this.genericTypeVars eingesetzt. Dabei werden alte genericTypeVars überschrieben.
* @param reconstructionResult * @param reconstructionResult
*/ */
public void createGenericTypeVars(CTypeReconstructionResult reconstructionResult){ public void createGenericTypeVars(TypeinferenceResultSet reconstructionResult){
this.genericClassParameters = new Vector<GenericTypeVar>(); this.genericClassParameters = new Vector<GenericTypeVar>();
for(Pair pair : reconstructionResult.getUnifiedConstraints()){ for(Pair pair : reconstructionResult.getUnifiedConstraints()){
if(pair.TA2 instanceof TypePlaceholder && pair.TA1 instanceof TypePlaceholder){// if(pair.OperatorSmallerExtends() || pair.OperatorSmaller()){ if(pair.TA2 instanceof TypePlaceholder && pair.TA1 instanceof TypePlaceholder){// if(pair.OperatorSmallerExtends() || pair.OperatorSmaller()){

View File

@ -8,7 +8,7 @@ import java.util.Vector;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.AttributeInfo; import mycompiler.mybytecode.AttributeInfo;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;

View File

@ -6,7 +6,7 @@ import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
// ino.end // ino.end

View File

@ -6,7 +6,7 @@ import java.util.Vector;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
// ino.end // ino.end

View File

@ -4,8 +4,7 @@ import java.util.Vector;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
import mycompiler.mystatement.Expr; import mycompiler.mystatement.Expr;

View File

@ -3,6 +3,7 @@ package mycompiler.myclass;
// ino.end // ino.end
// ino.module.InstVarDecl.8563.import // ino.module.InstVarDecl.8563.import
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.JVMCodeException;
@ -17,12 +18,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.IItemWithOffset; import mycompiler.IItemWithOffset;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
@ -34,8 +35,7 @@ import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
// ino.end

View File

@ -17,7 +17,7 @@ import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType; import mycompiler.mytype.RefType;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytypereconstruction.CIntersectionType; import mycompiler.mytypereconstruction.CIntersectionType;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
@ -185,78 +185,7 @@ public class Interface extends AClassOrInterface
} }
// ino.end // ino.end
// ino.method.addThisToAssumptions.23975.definition
public void addThisToAssumptions(CTypeReconstructionResult assumption)
// ino.end
// ino.method.addThisToAssumptions.23975.body
{
assumption.addClassName(getName());
InterfaceBody body = getInterfaceBody();
if(body!=null){
Vector<GenericTypeVar> genericsList = new Vector<GenericTypeVar>();
if(getParaList()!=null){
for(int ii =0; ii<this.getParaList().size(); ii++){
Type para = (Type)this.getParaList().elementAt(ii);
if(para instanceof GenericTypeVar){
genericsList.addElement((GenericTypeVar)para);
}
}
}
assumption.addGenericTypeVars(this.getName(),genericsList);
// Konstanten in die Assumptions laden
if(body.getConstantVektor()!=null){
for(int cID=0;cID<body.getConstantVektor().size();cID++){
Constant constant=body.getConstantVektor().elementAt(cID);
CInstVarTypeAssumption assum = new CInstVarTypeAssumption(this.getName(), constant.getName(), constant.getType(), constant.getLineNumber(),constant.getOffset(),new Vector<Integer>()); // Typannahme bauen...
assumption.addFieldOrLocalVarAssumption(assum);
}
}
CTypeAssumptionSet V_fields_methods = new CTypeAssumptionSet();
// Methoden in V_fields_methods laden
if(body.getMethodVektor()!=null){
Vector<CMethodTypeAssumption> methodAssumptions=new Vector<CMethodTypeAssumption>();
for(int mID=0;mID<body.getMethodVektor().size();mID++){
Method method=body.getMethodVektor().elementAt(mID);
// FIXME HOTI Hier mit Thomas abklaeren, ob die Offsets geladen werden muessen
CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(new RefType(this.getName(),method.getGenericMethodParameters(), 0), method.get_Method_Name(), method.getReturnType(), method.getParameterCount(),method.getLineNumber(),method.getOffset(),new Vector<Integer>(),method.getGenericMethodParameters()); // Typannahme bauen...
V_fields_methods.addElement(methodAssum);
method.setOverloadedID(methodAssum.getHashSetKey().getOverloadedMethodID());
// Parameter hinzufuegen
ParameterList parameterList = method.getParameterList();
if(parameterList!=null){
for(int i=0; i<parameterList.sc_get_Formalparalist().size(); i++){
FormalParameter para = parameterList.sc_get_Formalparalist().elementAt(i);
// ¿½r V_fields_methods:
CParaTypeAssumption paraAssum = new CParaTypeAssumption(this.getName(), method.get_Method_Name(), method.getParameterCount(), method.getOverloadedID(),para.get_Name(), para.getType(), para.getLineNumber(),para.getOffset(),new Vector<Integer>());
// FIXME HOTI Mit Thomas abklären, was hier getan werden muss!
//Class.addOffsetsToAssumption(paraAssum,method.get_Block(),paraAssum.getIdentifier(),true);
methodAssum.addParaAssumption(paraAssum);
}
}
methodAssumptions.add(methodAssum);
}
// Aus den V_fields_methods die Methoden in die BasicAssumption legen
for(int i=0;i<methodAssumptions.size();i++){
CIntersectionType mISType=new CIntersectionType(methodAssumptions.get(i));
assumption.addMethodIntersectionType(mISType);
}
}
}
}
// ino.end // ino.end
// ino.method.isAGenericType.23978.definition // ino.method.isAGenericType.23978.definition
public boolean isAGenericType(RefType type) public boolean isAGenericType(RefType type)

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -28,14 +29,16 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -29,11 +30,12 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -28,14 +29,15 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException; import typinferenz.TypinferenzException;
import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.BoolLiteral.8626.import // ino.module.BoolLiteral.8626.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -19,13 +20,15 @@ import mycompiler.mytypereconstruction.CTriple;
import mycompiler.mytypereconstruction.set.CSubstitutionSet; import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet; import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,10 +26,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.CharLiteral.8628.import // ino.module.CharLiteral.8628.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -24,10 +25,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.IntLiteral.8635.import // ino.module.IntLiteral.8635.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -30,7 +31,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.EmptyStmt.8629.import // ino.module.EmptyStmt.8629.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -21,11 +22,12 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -8,7 +8,7 @@ import java.util.Vector;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
import mycompiler.myclass.UsedId; import mycompiler.myclass.UsedId;
import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.CTypeReconstructionException;
@ -96,10 +96,6 @@ public abstract class Expr extends ExprStmt
// ino.method.sc_check.25250.declaration
public abstract void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh ,boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException;
// ino.end
@ -107,10 +103,6 @@ public abstract class Expr extends ExprStmt
public abstract String get_Name(); public abstract String get_Name();
// ino.end // ino.end
// ino.method.TRExp.25256.declaration
public abstract CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException;
// ino.end
/** /**
* @author AI10023 - Andreas Stadelmeier * @author AI10023 - Andreas Stadelmeier
@ -129,110 +121,6 @@ public abstract class Expr extends ExprStmt
throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen. throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen.
} }
// ino.method.TRTuple.25259.defdescription type=javadoc
/**
* (siehe Algorithmus 5.28 TRTuple, Martin Pl<EFBFBD>micke)
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param result
* @param terms
* @param supportData
* @return
*/
// ino.end
// ino.method.TRTuple.25259.definition
public CMultiplyTupleSet TRTuple(CMultiplyTuple result, Vector<Expr> terms, CSupportData supportData)
// ino.end
// ino.method.TRTuple.25259.body
{
if(terms.size()==0){
throw new CTypeReconstructionException("Unify.TRTuple(): Vector \"terms\" ist leer.",this);
}
CMultiplyTupleSet results = this.TRMultiply(result, terms.firstElement(), supportData);
// --------------------------
// Rekursionsanker erreicht:
// --------------------------
if(terms.size()==1){
return results;
}
// --------------------------
// Rekursiv absteigen:
// --------------------------
else {
CMultiplyTupleSet returnSet = new CMultiplyTupleSet();
Iterator<CMultiplyTuple> tupleIt = results.getIterator();
// PL 05-08-21 vorgezogen, da es sonst bei jedem Iterationsschritt
//der unterschiedlichen Moeglichkeiten der Typisierung geloescht wird.
terms.removeElementAt(0);
while(tupleIt.hasNext()){
//terms.removeElementAt(0);
returnSet.unite(this.TRTuple(tupleIt.next(), terms, supportData));
}
return returnSet;
}
}
// ino.end
// ino.method.TRMultiply.25262.defdescription type=javadoc
/**
* (siehe Algorithmus 5.29 TRMultiply, Martin Pl<EFBFBD>micke)
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param tuple
* @param t
* @param supportData
* @return
*/
// ino.end
// ino.method.TRMultiply.25262.definition
public CMultiplyTupleSet TRMultiply(CMultiplyTuple tuple, Expr t, CSupportData supportData)
// ino.end
// ino.method.TRMultiply.25262.body
{
// --------------------------
// TRExp des Terms rufen:
// --------------------------
CTripleSet results = t.TRExp(tuple.getSubstitutions(), tuple.getAssumptionSet(), supportData);
// --------------------------
// Alle zur<EFBFBD>ckgelieferten Triple durchgehen:
// --------------------------
CMultiplyTupleSet returnSet = new CMultiplyTupleSet();
Iterator<CTriple> tripleIt = results.getIterator();
while(tripleIt.hasNext()){
CTriple triple = tripleIt.next();
// --------------------------
// Ergebnis-MultiplyTuple bauen:
// --------------------------
CMultiplyTuple retTuple =tuple.clone();
retTuple.setSubstitutions(triple.getSubstitutions());
retTuple.setAssumptionSet(triple.getAssumptionSet());
// --------------------------
// Substitutionen auf ReturnTypes anwenden:
// --------------------------
for(int i=0; i<retTuple.getResultTypes().size(); i++){
Type type = retTuple.getResultTypes().elementAt(i);
if(type instanceof TypePlaceholder){
Iterator<CSubstitution> pairIt = retTuple.getSubstitutions().getIterator();
while(pairIt.hasNext()){
CSubstitution pair = pairIt.next();
// --------------------------
// Falls Match, dann ReturnType ersetzen:
// --------------------------
if(pair.getTypeVar().getName().equals(type.getName())){
retTuple.getResultTypes().setElementAt(pair.getType(), i);
}
}
}
}
retTuple.getResultTypes().addElement(triple.getResultType());
// --------------------------
// Tuple zur Ergebnismenge hinzuf<EFBFBD>gen:
// --------------------------
returnSet.addElement(retTuple);
}
return returnSet;
}
// ino.end
public abstract void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable); public abstract void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable);

View File

@ -79,83 +79,5 @@ public abstract class ExprStmt extends Statement implements ITypeReplacementList
} }
// ino.end // ino.end
// ino.method.unifyAndRegisterType.25294.definition
CTripleSet unifyAndRegisterType(CTripleSet ret, CSupportData supportData)
// ino.end
// ino.method.unifyAndRegisterType.25294.body
{
CTripleSet returnSet = new CTripleSet();
Iterator retIt = ret.getIterator();
while(retIt.hasNext()){
CTriple retTriple = (CTriple)retIt.next();
// --------------------------
// ReturnType mit type von this unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(retTriple.getResultType(), this.getType(), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int j=0; j<unifierPossibilities.size(); j++){
CSubstitutionSet unifier2 = new CSubstitutionSet(unifierPossibilities.elementAt(j));
CTriple intTriple2 = retTriple.cloneAndApplyUnify(unifier2);
//intTriple2.setResultType(new RefType("Boolean"));
intTriple2.setResultType(unifier2.applyThisSubstitutionSet(this.getType()));
// --------------------------
// Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// --------------------------
subSet.addElement(intTriple2);
}
returnSet.unite(subSet);
}
}
return returnSet;
}
// ino.end
// ino.method.registerType.25297.definition
CTripleSet registerType(CTripleSet ret, CSupportData supportData)
// ino.end
// ino.method.registerType.25297.body
{
CTripleSet returnSet = new CTripleSet();
Iterator retIt = ret.getIterator();
while(retIt.hasNext()){
CTriple retTriple = (CTriple)retIt.next();
if (this.getType() instanceof TypePlaceholder) {
// --------------------------
// ReturnType mit type von this unifizieren:
// --------------------------
Vector<Pair> tlvRestype = new Vector<Pair>();
tlvRestype.addElement(new Pair(this.getType(), retTriple.getResultType()));
CSubstitutionSet unifier2 = new CSubstitutionSet(tlvRestype);
// --------------------------
// Unifier zu retTriple hinzufuegen
// --------------------------
CTriple intTriple2 = retTriple.cloneAndApplyUnify(unifier2);
//intTriple2.setResultType(unifier2.applyThisSubstitutionSet(this.getType()));
// --------------------------
// Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// --------------------------
returnSet.addElement(intTriple2);
}
else {//Typ war vorher schon explizit definiert
if (this.getType().equals(retTriple.getResultType())) {
returnSet.addElement(retTriple);
}
}
}
return returnSet;
}
// ino.end
} }
// ino.end // ino.end

View File

@ -25,7 +25,7 @@ import org.apache.log4j.Logger;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -27,13 +28,14 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -34,16 +35,18 @@ import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.MUB; import mycompiler.mytypereconstruction.unify.MUB;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -20,7 +21,7 @@ import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CSupportData; import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTriple; import mycompiler.mytypereconstruction.CTriple;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.set.CSubstitutionSet; import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet; import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
@ -28,14 +29,16 @@ import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CInstVarKey; import mycompiler.mytypereconstruction.typeassumptionkey.CInstVarKey;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
@ -231,7 +234,7 @@ public class InstVar extends Expr
// 1. Alle bisherigen Typkombinationen durchgehen: // 1. Alle bisherigen Typkombinationen durchgehen:
// ########################## // ##########################
for(int i=0; i<supportData.getA().size(); i++){ for(int i=0; i<supportData.getA().size(); i++){
CTypeReconstructionResult possibleComb = supportData.getA().elementAt(i); TypeinferenceResultSet possibleComb = supportData.getA().elementAt(i);
// -------------------------- // --------------------------
// Alle Klassen durchsuchen: // Alle Klassen durchsuchen:
// -------------------------- // --------------------------

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,10 +26,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.IntLiteral.8635.import // ino.module.IntLiteral.8635.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -24,11 +25,12 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -10,9 +10,8 @@ import typinferenz.FreshTypeVariable;
import typinferenz.FunN; import typinferenz.FunN;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.Typable; import typinferenz.Typable;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException; import typinferenz.TypinferenzException;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -26,16 +27,18 @@ import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CInstVarKey; import mycompiler.mytypereconstruction.typeassumptionkey.CInstVarKey;
import mycompiler.mytypereconstruction.typeassumptionkey.CLocalVarKey; import mycompiler.mytypereconstruction.typeassumptionkey.CLocalVarKey;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -32,11 +33,12 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.IntLiteral.8635.import // ino.module.IntLiteral.8635.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -29,7 +30,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -33,7 +34,7 @@ import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CSubstitutionGenVar; import mycompiler.mytypereconstruction.CSubstitutionGenVar;
import mycompiler.mytypereconstruction.CSupportData; import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTriple; import mycompiler.mytypereconstruction.CTriple;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.set.CMultiplyTupleSet; import mycompiler.mytypereconstruction.set.CMultiplyTupleSet;
import mycompiler.mytypereconstruction.set.CSubstitutionSet; import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet; import mycompiler.mytypereconstruction.set.CTripleSet;
@ -44,16 +45,18 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey; import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
import mycompiler.mytypereconstruction.unify.FC_TTO; import mycompiler.mytypereconstruction.unify.FC_TTO;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.Overloading; import typinferenz.Overloading;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
@ -861,30 +864,7 @@ public class MethodCall extends Expr
} }
// ino.end // ino.end
// ino.method.TRStatement.25711.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.27 von Martin Pl�micke <br>
* Author: ¿½rg ¿½uerle
*
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRStatement.25711.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.25711.body
{
CTripleSet resultSet = this.TRExp(sigma, V, supportData);
Iterator it = resultSet.getIterator();
while(it.hasNext()){
((CTriple)it.next()).setResultType(new Void(getOffset()));
}
return resultSet;
}
// ino.end
// ino.method.makeReceiver.25714.definition // ino.method.makeReceiver.25714.definition
private void makeReceiver() private void makeReceiver()
@ -904,271 +884,8 @@ public class MethodCall extends Expr
} }
// ino.end // ino.end
// ino.method.TRExp.25717.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.33 von Martin Pl�micke
* <br/>Author: ¿½rg ¿½uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25717.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25717.body
{
CTripleSet resultSet = new CTripleSet();
//String identifierName = (String)this.usedid.get_Name().elementAt(this.usedid.get_Name().size()-2);
String identifierName = (String)this.usedid.get_Name().elementAt(0);
String functionName = (String)this.usedid.get_Name().elementAt(this.usedid.get_Name().size()-1);
if (receiver == null) { // PL 05-08-21 wenn im Parser nicht primary geparst wurde
// also Aufruf von Objektkette oder Packagekette (nicht impl.)
if (this.usedid.get_Name().size() > 1) {
makeReceiver(); // macht aus der Liste von Strings in usedid.name einen receiver
}
else {
receiver = new Receiver(new This (getOffset(),getVariableLength()));
}
}
//called_method = functionName; MUSS NOCH GESETZT WERDEN, WENN KLAR IST WELCHEN TYP DIE PARAMETER HABEN
Vector<Expr> expressions = new Vector<Expr>();
expressions.addElement(this.receiver.get_Expr());
if(this.arglist!=null){
expressions.addAll(this.arglist.expr);
}
// --------------------------
// TRTuple rufen:
// --------------------------
CMultiplyTupleSet tupleSet = this.TRTuple(new CMultiplyTuple(sigma, new Vector<Type>(), V), expressions, supportData);
Iterator<CMultiplyTuple> tupleIt = tupleSet.getIterator();
int successfulls=0;
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
while(tupleIt.hasNext()){
CMultiplyTuple tuple = tupleIt.next();
int paraCount = 0;
if(this.arglist!=null){
paraCount = this.arglist.expr.size();
}
try{
CTripleSet callAppSet = TRMCallApp(tuple, identifierName, functionName, paraCount, false, supportData);
resultSet.unite(callAppSet);
successfulls++;
}catch(CTypeReconstructionException exception){
exceptions.addElement(exception);
}
}
if(successfulls==0){
if(exceptions.size()>0){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("MethodCall: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
CTripleSet resultSet2 = super.registerType(resultSet, supportData);
return resultSet2;
//ALLE VARIANTEN MethodCall TESTEN UsecaseOne_pl.jav TUT SO NICHT
}
// ino.end
// ino.method.TRMCallApp.25720.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.34 von Martin Pl�micke
* @param multiTuple
* @param classOrIdentifierName
* @param methodName
* @param paraCount
* @param isConstructorCall
* @param supportData
* @return
*/
// ino.end
// ino.method.TRMCallApp.25720.definition
public CTripleSet TRMCallApp(CMultiplyTuple multiTuple, String classOrIdentifierName, String methodName, int paraCount, boolean isConstructorCall, CSupportData supportData)
// ino.end
// ino.method.TRMCallApp.25720.body
{
// ##########################
// 1. Alle bisherigen Typkombinationen durchgehen:
// ##########################
CTripleSet case1 = new CTripleSet();
for(int i=0; i<supportData.getA().size(); i++){
CTypeReconstructionResult possibleComb = supportData.getA().elementAt(i);
// --------------------------
// Bei Konstruktor Klasse bereits bekannt:
// --------------------------
if(isConstructorCall){
searchAndHandleMethod(multiTuple, possibleComb, case1, classOrIdentifierName, methodName, paraCount, supportData,methodsFittingMethodCall);
//searchAndHandleMethod(multiTuple, possibleComb, case1, classOrIdentifierName, classOrIdentifierName, paraCount, supportData,methodsFittingMethodCall);
}
// --------------------------
// Bei normaler Methode alle Klassen durchsuchen:
// --------------------------
else{
for(int j=0; j<possibleComb.getClassNameList().size(); j++){
String clName = possibleComb.getClassNameList().elementAt(j); // ReceiverName
searchAndHandleMethod(multiTuple, possibleComb, case1, clName, methodName, paraCount, supportData,methodsFittingMethodCall);
}
}
}
// ##########################
// 2. Aktuelle Klasse durchsuchen:
// ##########################
CTripleSet case2 = new CTripleSet();
searchAndHandleMethod(multiTuple, multiTuple.getAssumptionSet(), case2, supportData.getCurrentClassType(), methodName, paraCount, supportData,methodsFittingMethodCall);
// ##########################
// 3. Ergebnismengen vereinigen:
// ##########################
case1.unite(case2);
CTripleSet returnSet = case1;
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("MethodCall.TRMCallApp(): Die Methode "+methodName+" konnte mit keiner bekannten Methode unifiziert werden.",this);
}
return returnSet;
}
// ino.end
// ino.method.searchAndHandleMethod.25723.defdescription type=javadoc
/**
* Sucht eine Methode aus einem IntersectionType heraus und ruft
* <code>handleMethodAssum()</code>. <br/>Author: ¿½rg ¿½uerle
* @param multiTuple
* @param possibleTypeComb
* @param returnSet
* @param className
* @param methodName
* @param paraCount
* @param supportData
* @param methodsFittingMethodCall Hashtable in der jede erfolgreiche Methode
* abgelegt wird @return Einen Error-Code: <code>OK</code>,
* <code>UNIFY_ERROR</code> oder <code>METHOD_NOT_FOUND_ERROR</code>
*/
// ino.end
// ino.method.searchAndHandleMethod.25723.definition
private int searchAndHandleMethod(CMultiplyTuple multiTuple, CTypeReconstructionResult possibleTypeComb, CTripleSet returnSet, String className, String methodName, int paraCount, CSupportData supportData, Hashtable<String,CMethodTypeAssumption> methodsFittingMethodCall)
// ino.end
// ino.method.searchAndHandleMethod.25723.body
{
// --------------------------
// Typannahme ¿½r Methode heraussuchen:
// --------------------------
CMethodKey key = new CMethodKey(
className,
methodName,
paraCount
);
Vector<CIntersectionType> intersects = possibleTypeComb.getMethodIntersectionTypes(key);
if(intersects.size()==0){
return METHOD_NOT_FOUND_ERROR;
}
int wellUnifiedMethodCount=0;
// Alle Methoden durchgehen, die gefunden wurden
for(int item=0;item<intersects.size();item++){
CIntersectionType intersect=intersects.get(item);
// Annahme holen
CMethodTypeAssumption methodAssum = intersect.getMethodTypeAssumptions().firstElement().clone();
// Annahme clonen, um sie nachher für die Codegenerierung zu setzen
// (Codegenerierung benötigt die Orginalsignatur)
CMethodTypeAssumption methodAssumCopy = intersect.getMethodTypeAssumptions().firstElement().clone();
// Generics der Klasse holen
Vector<GenericTypeVar> genericClassParameters = possibleTypeComb.getGenerics(className);
// Generics der Methode holen
// p.ex. <E extends Integer> E test(){...}
// ___________________
Vector<GenericTypeVar> genericMethodParameters=methodAssum.getGenericMethodParameters();
// Classtype initialisieren
// Wird fuer die Unifizierung benoetigt
RefType classType;
// Wird spaeter fuer die Codegen benoetigt
RefType classTypeWithRealParameters;
// Klassenparameter berechnen
// => aus p.ex. Vector<E> wird Vector<NEUE_TypePlaceholder-VARIABLE>
Vector<Type> unifyTypePara = new Vector<Type>();
if (genericClassParameters != null && genericClassParameters.size()>0) {
CSubstitutionSet sub = new CSubstitutionSet();
for( int i = 0; i < genericClassParameters.size(); i++ )
{
TypePlaceholder tlv = TypePlaceholder.fresh(this);
unifyTypePara.addElement(tlv);
sub.addElement(new CSubstitutionGenVar(genericClassParameters.elementAt(i), tlv));
}
methodAssum.sub(sub);
classType=new RefType(className,unifyTypePara,getOffset());
classTypeWithRealParameters=new RefType(className,possibleTypeComb.getGenerics(className),getOffset());
}else{
classType=new RefType(className,getOffset());
classTypeWithRealParameters=new RefType(className,getOffset());
}
// Konstruktoren haben (inoffiziell) den Return-Typ des Objektes
if(methodAssum.getIdentifier().equals("<init>")){
methodAssum.setAssumedType(classType);
}
// Generische Methodenparameter hinzufuegen
Vector<Pair> additionalPairsToUnify=new Vector<Pair>();
if (genericMethodParameters != null && genericMethodParameters.size()>0) {
CSubstitutionSet sub = new CSubstitutionSet();
for( int i = 0; i < genericMethodParameters.size(); i++ ){
if(genericMethodParameters.elementAt(i) instanceof BoundedGenericTypeVar){
// Jede Bound als Paar zum Unifizieren vormerken
TypePlaceholder newTLV=TypePlaceholder.fresh(this);
BoundedGenericTypeVar bgtv=(BoundedGenericTypeVar)genericMethodParameters.elementAt(i);
for(int j=0;j<bgtv.getBounds().size();j++){
Type bound=bgtv.getBounds().elementAt(j);
Pair newPairToAdd=new Pair(newTLV,bound);
additionalPairsToUnify.addElement(newPairToAdd);
sub.addElement(new CSubstitutionGenVar(bgtv, newTLV));
}
}else{ // Normale GenericTypeVar
TypePlaceholder newTLV=TypePlaceholder.fresh(this);
sub.addElement(new CSubstitutionGenVar(genericMethodParameters.elementAt(i), newTLV));
}
}
methodAssum.sub(sub);
}
// Versuch, die Methode zu unifizieren
int result=handleMethodAssum(multiTuple, unifyTypePara, returnSet, methodAssum, classType, supportData, additionalPairsToUnify);
if(result==OK){
// Gefundene Methode in
addMethodAndSuperclassMethodsToFittings(classTypeWithRealParameters, methodAssumCopy,supportData.getFiniteClosure());
wellUnifiedMethodCount++;
}
}
if(wellUnifiedMethodCount==1){
return OK;
}else{
return UNIFY_ERROR;
}
}
// ino.end
// ino.method.addMethodAndSuperclassMethodsToFittings.25726.defdescription type=javadoc // ino.method.addMethodAndSuperclassMethodsToFittings.25726.defdescription type=javadoc
/** /**

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -24,13 +25,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.NewArray.8641.import // ino.module.NewArray.8641.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -21,10 +22,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -33,6 +34,7 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.Overloading; import typinferenz.Overloading;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
@ -40,7 +42,7 @@ import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.FunN; import typinferenz.FunN;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -23,13 +24,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.Null.8644.import // ino.module.Null.8644.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -23,10 +24,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.PositivExpr.8645.import // ino.module.PositivExpr.8645.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
@ -20,10 +21,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,13 +26,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,13 +26,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,13 +26,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -5,6 +5,7 @@ package mycompiler.mystatement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,13 +26,15 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.Return.8651.import // ino.module.Return.8651.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,13 +26,14 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.FreshTypeVariable; import typinferenz.FreshTypeVariable;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -11,7 +11,7 @@ import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.Typable; import typinferenz.Typable;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
import mycompiler.IItemWithOffset; import mycompiler.IItemWithOffset;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
@ -78,13 +78,6 @@ public abstract class Statement implements IItemWithOffset, Typable, ITypeReplac
} }
// ino.end // ino.end
// ino.method.sc_check.26203.declaration
abstract void sc_check(Vector<Class> classlist, Hashtable ch, Hashtable<String,String> bh, boolean ext, Hashtable parach, Hashtable<String,Hashtable> parabh)
throws SCStatementException;
// ino.end
// ino.method.codegen.26206.declaration // ino.method.codegen.26206.declaration
public abstract void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public abstract void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException; throws JVMCodeException;
@ -92,122 +85,6 @@ public abstract class Statement implements IItemWithOffset, Typable, ITypeReplac
// ino.method.string_rec.26209.definition
static String string_rec(Hashtable ht)
// ino.end
// ino.method.string_rec.26209.body
{
String record="";
if(ht != null){
record=record.concat("[");
for(Enumeration e=ht.elements(),k=ht.keys();e.hasMoreElements();){
String s = (String)k.nextElement();
Object o = e.nextElement();
record=record.concat(" "+s);
if(o instanceof Type){
record=record.concat(" = "+((Type)o).getName());
}
else if(o instanceof Hashtable){
record=record.concat("= ");
record=record.concat(string_rec((Hashtable)o));
if(e.hasMoreElements())
record=record.concat(", ");
}
else if(o instanceof String){
record=record.concat(" = "+o);
if(e.hasMoreElements())
record=record.concat(", ");
}
else record=("[FEHLER: string_rec: unbekannter Typ!!!!!!");
}
record=record.concat("]");
}
return(record);
}
// ino.end
// ino.method.string_rec.26212.definition
static String string_rec(Vector v)
// ino.end
// ino.method.string_rec.26212.body
{
String record="";
record=record.concat("{");
for(Enumeration e=v.elements();e.hasMoreElements();){
Type t = (Type)e.nextElement();
record=record.concat(" "+t.getName());
if(e.hasMoreElements())
record=record.concat(",");
}
record=record.concat("}");
return(record);
}
// ino.end
// ino.method.string_rec.26215.definition
static String string_rec(String st, Hashtable ht)
// ino.end
// ino.method.string_rec.26215.body
{
String record="";
record=record.concat(st);
record=record.concat("[");
for(Enumeration e=ht.elements(),k=ht.keys();e.hasMoreElements();){
String s = (String)k.nextElement();
Object o = e.nextElement();
record=record.concat(" "+s);
if(o instanceof Type){
record=record.concat(" = "+((Type)o).getName());
}
else if(o instanceof Hashtable){
record=record.concat("= ");
record=record.concat(string_rec((Hashtable)o));
if(e.hasMoreElements())
record=record.concat(", ");
}
else if(o instanceof String){
record=record.concat(" = "+o);
if(e.hasMoreElements())
record=record.concat(", ");
}
else record=("[FEHLER: string_rec: unbekannter Typ!!!!!!");
}
record=record.concat("]");
return(record);
}
// ino.end
// ino.method.string_rec.26218.definition
static String string_rec(String st,Vector v)
// ino.end
// ino.method.string_rec.26218.body
{
String record=(st);
record=record.concat("{");
for(Enumeration e=v.elements();e.hasMoreElements();){
Type t = (Type)e.nextElement();
record=record.concat(" "+t.getName());
if(e.hasMoreElements())
record=record.concat(", ");
}
record=record.concat("}");
return(record);
}
// ino.end
// ino.method.TRStatement.26221.declaration
public abstract CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException;
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26224.declaration // ino.method.wandleRefTypeAttributes2GenericAttributes.26224.declaration
public abstract void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters); public abstract void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters);

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.StringLiteral.8653.import // ino.module.StringLiteral.8653.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -23,10 +24,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -4,6 +4,7 @@ package mycompiler.mystatement;
// ino.module.This.8654.import // ino.module.This.8654.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -25,10 +26,11 @@ import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode; import mycompiler.mybytecode.JVMCode;
@ -30,15 +31,17 @@ import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.SingleConstraint; import typinferenz.SingleConstraint;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -9,7 +9,7 @@ import java.util.Vector;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
// ino.end // ino.end
// ino.class.CByteCodeTest.26367.description type=javadoc // ino.class.CByteCodeTest.26367.description type=javadoc
@ -39,9 +39,9 @@ public class CByteCodeTest
compiler.parse(new File(args[0])); compiler.parse(new File(args[0]));
// Typ-Rekonstruktion // Typ-Rekonstruktion
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
if ((resultSet != null) && (resultSet.size() > 0)) { if ((resultSet != null) && (resultSet.size() > 0)) {
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();

View File

@ -10,7 +10,7 @@ import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
@ -53,7 +53,7 @@ public class CInferenceTest
///////////////////////// /////////////////////////
// Typrekonstruktion: // Typrekonstruktion:
///////////////////////// /////////////////////////
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
///////////////////////// /////////////////////////
// Ausgabe: // Ausgabe:
///////////////////////// /////////////////////////
@ -65,7 +65,7 @@ public class CInferenceTest
} }
// if(true)System.exit(0); // if(true)System.exit(0);
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();

View File

@ -10,7 +10,7 @@ import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// ino.end // ino.end
@ -48,11 +48,11 @@ public class CSimpleTest
///////////////////////// /////////////////////////
// Typrekonstruktion: // Typrekonstruktion:
///////////////////////// /////////////////////////
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
///////////////////////// /////////////////////////
// Ausgabe: // Ausgabe:
///////////////////////// /////////////////////////
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();

View File

@ -9,7 +9,7 @@ import mycompiler.SourceFile;
import mycompiler.mytype.*; import mycompiler.mytype.*;
import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.unify.FC_TTO; import mycompiler.mytypereconstruction.unify.FC_TTO;
import mycompiler.mytypereconstruction.unify.Unify; import mycompiler.mytypereconstruction.unify.Unify;

View File

@ -10,7 +10,7 @@ import junit.framework.TestCase;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.apache.log4j.FileAppender; import org.apache.log4j.FileAppender;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -91,10 +91,10 @@ public class CompilerTestCase extends TestCase
// ino.method.typeReconstruction.26404.body // ino.method.typeReconstruction.26404.body
{ {
// Typ-Rekonstruktion // Typ-Rekonstruktion
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
// Keine Typ-Rekonstruktion erforderlich // Keine Typ-Rekonstruktion erforderlich
if (resultSet == null || resultSet.size() == 0) throw new Exception("Typrekonstruktion nicht durchfuehrbar!"); if (resultSet == null || resultSet.size() == 0) throw new Exception("Typrekonstruktion nicht durchfuehrbar!");
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();

View File

@ -15,15 +15,14 @@ import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout; import org.apache.log4j.PatternLayout;
import org.apache.log4j.SimpleLayout; import org.apache.log4j.SimpleLayout;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException; import typinferenz.TypinferenzException;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
public class LambdaTest { public class LambdaTest {
@ -93,9 +92,9 @@ public class LambdaTest {
* @param variableTypeAssumptions * @param variableTypeAssumptions
*/ */
public void runTestAndCheckResultSet(String classname, HashMap<String,String> variableTypeAssumptions){ public void runTestAndCheckResultSet(String classname, HashMap<String,String> variableTypeAssumptions){
Vector<CTypeReconstructionResult> result = this.runTest(); Vector<TypeinferenceResultSet> result = this.runTest();
if(result.size()==0)fail("Keine Lösung!"); if(result.size()==0)fail("Keine Lösung!");
for(CTypeReconstructionResult result1 : result){ for(TypeinferenceResultSet result1 : result){
TypeAssumptions assumptions = result1.getInterferedClass().getPublicFieldAssumptions();// TypeAssumptions.getAssumptionsFor(classname); TypeAssumptions assumptions = result1.getInterferedClass().getPublicFieldAssumptions();// TypeAssumptions.getAssumptionsFor(classname);
assertTrue("Fehler in Methode TypeAssumptions.getAssumptionsFor", assumptions!=null); assertTrue("Fehler in Methode TypeAssumptions.getAssumptionsFor", assumptions!=null);
for(String variable : variableTypeAssumptions.keySet()){ for(String variable : variableTypeAssumptions.keySet()){
@ -115,22 +114,22 @@ public class LambdaTest {
* Diese eine Lösung wird zurückgegeben. * Diese eine Lösung wird zurückgegeben.
* @return * @return
*/ */
public CTypeReconstructionResult runTestAndGetSingularResultSet(){ public TypeinferenceResultSet runTestAndGetSingularResultSet(){
Vector<CTypeReconstructionResult> result = this.runTest(); Vector<TypeinferenceResultSet> result = this.runTest();
assertTrue("ResultSet muss genau 1 Element enthalten", result.size()==1); assertTrue("ResultSet muss genau 1 Element enthalten", result.size()==1);
CTypeReconstructionResult result1 = result.get(0); TypeinferenceResultSet result1 = result.get(0);
return result1; return result1;
} }
public Vector<CTypeReconstructionResult> runTest() public Vector<TypeinferenceResultSet> runTest()
{ {
//String[] arguments = new String[1]; //String[] arguments = new String[1];
//arguments[0]="/home/janulrich/workspace/JavaCompilerCore/test/LampdaExpressions/general.java"; //arguments[0]="/home/janulrich/workspace/JavaCompilerCore/test/LampdaExpressions/general.java";
//MyCompiler.main(arguments); //MyCompiler.main(arguments);
Vector<CTypeReconstructionResult> resultSet = null; Vector<TypeinferenceResultSet> resultSet = null;
MyCompilerAPI compiler = MyCompiler.getAPI(); MyCompilerAPI compiler = MyCompiler.getAPI();
try{ try{

View File

@ -37,7 +37,7 @@ public class CSupportData
private FC_TTO m_FiniteClosure; private FC_TTO m_FiniteClosure;
// ino.end // ino.end
// ino.attribute.m_A.27085.declaration // ino.attribute.m_A.27085.declaration
private Vector<CTypeReconstructionResult> m_A; private Vector<TypeinferenceResultSet> m_A;
// ino.end // ino.end
// ino.attribute.m_CurrentClass.27088.declaration // ino.attribute.m_CurrentClass.27088.declaration
private String m_CurrentClass; private String m_CurrentClass;
@ -63,7 +63,7 @@ public class CSupportData
// ino.end // ino.end
// ino.method.CSupportData.27109.definition // ino.method.CSupportData.27109.definition
public CSupportData(FC_TTO finiteClosure, Vector<CTypeReconstructionResult> A, String currentClass, Vector<GenericTypeVar> currentClassPara) public CSupportData(FC_TTO finiteClosure, Vector<TypeinferenceResultSet> A, String currentClass, Vector<GenericTypeVar> currentClassPara)
// ino.end // ino.end
// ino.method.CSupportData.27109.body // ino.method.CSupportData.27109.body
{ {
@ -72,7 +72,7 @@ public class CSupportData
// ino.end // ino.end
// ino.method.CSupportData.27112.definition // ino.method.CSupportData.27112.definition
public CSupportData(FC_TTO finiteClosure, Vector<CTypeReconstructionResult> A, String currentClass, Vector<GenericTypeVar> currentClassPara, String currentMethod, int currentMethodParaCount, int currentMethodOverloadedID, Vector<Integer> blockIdList, int blockDepth) public CSupportData(FC_TTO finiteClosure, Vector<TypeinferenceResultSet> A, String currentClass, Vector<GenericTypeVar> currentClassPara, String currentMethod, int currentMethodParaCount, int currentMethodOverloadedID, Vector<Integer> blockIdList, int blockDepth)
// ino.end // ino.end
// ino.method.CSupportData.27112.body // ino.method.CSupportData.27112.body
{ {
@ -107,7 +107,7 @@ public class CSupportData
// ino.end // ino.end
// ino.method.getA.27121.definition // ino.method.getA.27121.definition
public Vector<CTypeReconstructionResult> getA() public Vector<TypeinferenceResultSet> getA()
// ino.end // ino.end
// ino.method.getA.27121.body // ino.method.getA.27121.body
{ {
@ -116,7 +116,7 @@ public class CSupportData
// ino.end // ino.end
// ino.method.setA.27124.definition // ino.method.setA.27124.definition
public void setA(Vector<CTypeReconstructionResult> A) public void setA(Vector<TypeinferenceResultSet> A)
// ino.end // ino.end
// ino.method.setA.27124.body // ino.method.setA.27124.body
{ {
@ -324,7 +324,7 @@ public class CSupportData
// ino.method.clone.27184.body // ino.method.clone.27184.body
{ {
CSupportData dolly = new CSupportData( CSupportData dolly = new CSupportData(
m_FiniteClosure, (Vector<CTypeReconstructionResult>)m_A.clone(), m_FiniteClosure, (Vector<TypeinferenceResultSet>)m_A.clone(),
m_CurrentClass, (Vector<GenericTypeVar>) m_CurrentClassPara.clone(), m_CurrentMethod, m_CurrentMethodParaCount,m_CurrentMethodOverloadedID, m_CurrentClass, (Vector<GenericTypeVar>) m_CurrentClassPara.clone(), m_CurrentMethod, m_CurrentMethodParaCount,m_CurrentMethodOverloadedID,
(Vector<Integer>)m_BlockIdList.clone(), m_CurrentBlockDepth (Vector<Integer>)m_BlockIdList.clone(), m_CurrentBlockDepth
); );

View File

@ -1,312 +0,0 @@
// ino.module.CTypeReconstructionResult.8689.package
package mycompiler.mytypereconstruction;
// ino.end
// ino.module.CTypeReconstructionResult.8689.import
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
import typinferenz.ConstraintsSet;
import typinferenz.ResultSet;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Pair;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
import mycompiler.mytypereconstruction.typeassumptionkey.CTypeAssumptionKey;
// ino.end
// ino.class.CTypeReconstructionResult.27238.description type=javadoc
/**
* Diese Container-Klasse kapselt alle Ergebniswerte ¿½r eine ¿½gliche
* Typkombination aller Klassen und deren Methoden sowie lokalen Variablen. Eine
* Instanz dieser Klasse steht ¿½r genau eine ¿½gliche Typkombination.<br/>
* Objekte dieser Klasse werden vom Typrekonstruktionsalgorithmus �ber die
* Compiler-API zur�ckgegeben.
* @author ¿½rg ¿½uerle
* @version $Date: 2013/09/22 20:13:02 $
*/
// ino.end
// ino.class.CTypeReconstructionResult.27238.declaration
public class CTypeReconstructionResult
// ino.end
// ino.class.CTypeReconstructionResult.27238.body
{
// ino.attribute.m_MethodIntersectionTypes.27241.declaration
private Hashtable<CMethodKey, CIntersectionType> m_MethodIntersectionTypes;
// ino.end
// ino.attribute.m_FieldAndLocalVarAssumptions.27244.declaration
private Hashtable<CTypeAssumptionKey, CTypeAssumption> m_FieldAndLocalVarAssumptions;
// ino.end
// ino.attribute.m_Substitutions.27247.declaration
private CSubstitutionSet m_Substitutions;
// ino.end
// ino.attribute.m_ClassNames.27250.declaration
private Vector<String> m_ClassNames;
// ino.end
// ino.attribute.m_GenericTypeVars.27253.declaration
private Hashtable<String, Vector<GenericTypeVar>> m_GenericTypeVars;
// ino.end
private Vector<Pair> constraints;
private ResultSet unifiedConstraints;
private mycompiler.myclass.Class ownerOfResultSet;//Jedes Resultset gilt immer nur für eine Klasse. Diese wird in dieser Variable gespeichert.
// ino.method.CTypeReconstructionResult.27256.definition
public CTypeReconstructionResult(mycompiler.myclass.Class inferedClass)
// ino.end
// ino.method.CTypeReconstructionResult.27256.body
{
this.ownerOfResultSet = inferedClass;
m_MethodIntersectionTypes = new Hashtable<CMethodKey, CIntersectionType>();
m_FieldAndLocalVarAssumptions = new Hashtable<CTypeAssumptionKey, CTypeAssumption>();
m_Substitutions = new CSubstitutionSet();
m_ClassNames = new Vector<String>();
m_GenericTypeVars = new Hashtable<String, Vector<GenericTypeVar>>();
}
// ino.end
// ino.method.getFieldAndLocalVarAssumptions.27259.definition
public Hashtable<CTypeAssumptionKey, CTypeAssumption> getFieldAndLocalVarAssumptions()
// ino.end
// ino.method.getFieldAndLocalVarAssumptions.27259.body
{
return m_FieldAndLocalVarAssumptions;
}
// ino.end
// ino.method.setFieldAndLocalVarAssumptions.27262.definition
public void setFieldAndLocalVarAssumptions(Hashtable<CTypeAssumptionKey, CTypeAssumption> fieldAndLocalVarAssumptions)
// ino.end
// ino.method.setFieldAndLocalVarAssumptions.27262.body
{
m_FieldAndLocalVarAssumptions = fieldAndLocalVarAssumptions;
}
// ino.end
// ino.method.addFieldOrLocalVarAssumption.27265.definition
public void addFieldOrLocalVarAssumption(CTypeAssumption assum)
// ino.end
// ino.method.addFieldOrLocalVarAssumption.27265.body
{
m_FieldAndLocalVarAssumptions.put(assum.getHashSetKey(), assum);
}
// ino.end
// ino.method.getMethodIntersectionTypes.27268.definition
public Hashtable<CMethodKey, CIntersectionType> getMethodIntersectionTypes()
// ino.end
// ino.method.getMethodIntersectionTypes.27268.body
{
return m_MethodIntersectionTypes;
}
// ino.end
// ino.method.addMethodIntersectionType.27271.definition
public void addMethodIntersectionType(CIntersectionType intersect)
// ino.end
// ino.method.addMethodIntersectionType.27271.body
{
m_MethodIntersectionTypes.put(intersect.getIntersectionTypeKey(), intersect);
}
// ino.end
// ino.method.getMethodIntersectionTypes.27274.definition
public Vector<CIntersectionType> getMethodIntersectionTypes(CMethodKey key)
// ino.end
// ino.method.getMethodIntersectionTypes.27274.body
{
Vector<CIntersectionType> elements=new Vector<CIntersectionType>();
CMethodKey keyToIterate=key.getFirstMethodKey();
CIntersectionType elem;
while((elem=m_MethodIntersectionTypes.get(keyToIterate))!=null){
elements.add(elem);
keyToIterate=keyToIterate.getNextMethodKey();
}
return(elements);
// ALTE VERSION:
// return m_MethodIntersectionTypes.get(key);
}
// ino.end
// ino.method.getSubstitutions.27277.definition
public CSubstitutionSet getSubstitutions()
// ino.end
// ino.method.getSubstitutions.27277.body
{
return m_Substitutions;
}
// ino.end
// ino.method.setSubstitutions.27280.definition
public void setSubstitutions(CSubstitutionSet substitutions)
// ino.end
// ino.method.setSubstitutions.27280.body
{
m_Substitutions = substitutions;
}
// ino.end
// ino.method.addDataFromTupel.27283.definition
public void addDataFromTupel(CReconstructionTuple tuple)
// ino.end
// ino.method.addDataFromTupel.27283.body
{
this.addDataFromSubstitutionSet(tuple.getSubSet());
this.addDataFromTypeAssumptionSet(tuple.getAssumSet());
}
// ino.end
// ino.method.addDataFromSubstitutionSet.27286.definition
private void addDataFromSubstitutionSet(CSubstitutionSet subSet)
// ino.end
// ino.method.addDataFromSubstitutionSet.27286.body
{
this.getSubstitutions().getVector().addAll(subSet.getVector());
}
// ino.end
// ino.method.addDataFromTypeAssumptionSet.27289.definition
private void addDataFromTypeAssumptionSet(CTypeAssumptionSet assumSet)
// ino.end
// ino.method.addDataFromTypeAssumptionSet.27289.body
{
Iterator assumIter = assumSet.getIterator();
while(assumIter.hasNext()){
CTypeAssumption assum = (CTypeAssumption)assumIter.next();
if(assum instanceof CMethodTypeAssumption){
this.addMethodIntersectionType(new CIntersectionType((CMethodTypeAssumption)assum));
}
else{
this.addFieldOrLocalVarAssumption(assum);
}
}
}
// ino.end
// ino.method.addClassName.27292.definition
public void addClassName(String className)
// ino.end
// ino.method.addClassName.27292.body
{
m_ClassNames.addElement(className);
}
// ino.end
// ino.method.getClassNameList.27295.definition
public Vector<String> getClassNameList()
// ino.end
// ino.method.getClassNameList.27295.body
{
return m_ClassNames;
}
// ino.end
// ino.method.addGenericTypeVars.27298.definition
public void addGenericTypeVars(String className, Vector<GenericTypeVar> typeVarList)
// ino.end
// ino.method.addGenericTypeVars.27298.body
{
m_GenericTypeVars.put(className, typeVarList);
}
// ino.end
// ino.method.getGenericsTable.27301.definition
public Hashtable<String, Vector<GenericTypeVar>> getGenericsTable()
// ino.end
// ino.method.getGenericsTable.27301.body
{
return m_GenericTypeVars;
}
// ino.end
// ino.method.getGenerics.27304.definition
public Vector<GenericTypeVar> getGenerics(String key)
// ino.end
// ino.method.getGenerics.27304.body
{
return m_GenericTypeVars.get(key);
}
// ino.end
// ino.method.shallowCopy.27307.definition
public CTypeReconstructionResult shallowCopy()
// ino.end
// ino.method.shallowCopy.27307.body
{
CTypeReconstructionResult dolly = new CTypeReconstructionResult(this.ownerOfResultSet);
Iterator<CTypeAssumption> assumIter = m_FieldAndLocalVarAssumptions.values().iterator();
while(assumIter.hasNext()){
dolly.addFieldOrLocalVarAssumption(assumIter.next());
}
dolly.m_MethodIntersectionTypes = (Hashtable<CMethodKey, CIntersectionType>)m_MethodIntersectionTypes.clone();
dolly.m_Substitutions.getVector().addAll(m_Substitutions.getVector());
dolly.m_ClassNames.addAll(m_ClassNames);
dolly.m_GenericTypeVars = (Hashtable<String, Vector<GenericTypeVar>>)m_GenericTypeVars.clone();
return dolly;
}
// ino.end
/**
* @author Andreas Stadelmeier, a10023
* Anhand des Syntaxbaums errechnet der Typinferenzalgorithmus ein Set von Constraints.
* Diese Funktion ist nur für automatisierte Tests interessant.
* Zum abrufen der Unifizierten Constraints siehe <code>getUnifiedConstraints()</code>
* @return
*/
public Vector<Pair> getConstraints() {
return this.constraints;
}
public void setConstraints(Vector<Pair> constraints) {
this.constraints = constraints;
}
/**
* @author Andreas Stadelmeier, a10023
* Nach dem Durchführen des Interferenzalgorithmus von Lambda 8 entsteht für jede Lösung ein Set con Constraints.
* Diese Constraints haben bereits den Unify-Algorithmus durchlaufen und weißen die errechneten Typen den Typeplacholdern zu.
* @return Das fertige ConstraintsSet dieser CTypeRecunstructionResult
*/
public ResultSet getUnifiedConstraints() {
return unifiedConstraints;
}
public void setUnifiedConstraints(Vector<Pair> unifiedConstraints) {
this.unifiedConstraints = new ResultSet(unifiedConstraints);
}
/**
* Ermittelt den in diesem ResultSet für den TypePlaceholder tph zugewiesenen Wert.
* @author Andreas Stadelmeier, a10023
*/
public Type getTypeOfPlaceholder(TypePlaceholder tph){
return this.getUnifiedConstraints().getTypeEqualTo(tph);
}
/**
* Jedes TypeReconstructionResultSet entstand bei der Typinferierung einer Klasse.
* @return Gibt die Klasse zurück der dieses ResultSet zugeordnet ist.
*/
public mycompiler.myclass.Class getInterferedClass(){
return this.ownerOfResultSet;
}
@Override
public String toString(){
return "Unified Constraints: "+this.unifiedConstraints.toString();
}
}
// ino.end

View File

@ -0,0 +1,109 @@
// ino.module.CTypeReconstructionResult.8689.package
package mycompiler.mytypereconstruction;
// ino.end
// ino.module.CTypeReconstructionResult.8689.import
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
import typinferenz.ConstraintsSet;
import typinferenz.ResultSet;
import typinferenz.TypinferenzException;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Pair;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
import mycompiler.mytypereconstruction.typeassumptionkey.CMethodKey;
import mycompiler.mytypereconstruction.typeassumptionkey.CTypeAssumptionKey;
// ino.end
// ino.class.CTypeReconstructionResult.27238.description type=javadoc
/**
* Diese Container-Klasse kapselt alle Ergebniswerte ¿½r eine ¿½gliche
* Typkombination aller Klassen und deren Methoden sowie lokalen Variablen. Eine
* Instanz dieser Klasse steht ¿½r genau eine ¿½gliche Typkombination.<br/>
* Objekte dieser Klasse werden vom Typrekonstruktionsalgorithmus �ber die
* Compiler-API zur�ckgegeben.
* @author ¿½rg ¿½uerle
* @version $Date: 2013/09/22 20:13:02 $
*/
// ino.end
// ino.class.CTypeReconstructionResult.27238.declaration
public class TypeinferenceResultSet
{
private Vector<Pair> constraints;
private ResultSet unifiedConstraints;
private mycompiler.myclass.Class ownerOfResultSet;//Jedes Resultset gilt immer nur für eine Klasse. Diese wird in dieser Variable gespeichert.
// ino.method.CTypeReconstructionResult.27256.definition
public TypeinferenceResultSet(mycompiler.myclass.Class inferedClass)
// ino.end
// ino.method.CTypeReconstructionResult.27256.body
{
this.ownerOfResultSet = inferedClass;
}
// ino.end
/**
* @author Andreas Stadelmeier, a10023
* Anhand des Syntaxbaums errechnet der Typinferenzalgorithmus ein Set von Constraints.
* Diese Funktion ist nur für automatisierte Tests interessant.
* Zum abrufen der Unifizierten Constraints siehe <code>getUnifiedConstraints()</code>
* @return
*/
public Vector<Pair> getConstraints() {
return this.constraints;
}
public void setConstraints(Vector<Pair> constraints) {
this.constraints = constraints;
}
/**
* @author Andreas Stadelmeier, a10023
* Nach dem Durchführen des Interferenzalgorithmus von Lambda 8 entsteht für jede Lösung ein Set con Constraints.
* Diese Constraints haben bereits den Unify-Algorithmus durchlaufen und weißen die errechneten Typen den Typeplacholdern zu.
* @return Das fertige ConstraintsSet dieser CTypeRecunstructionResult
*/
public ResultSet getUnifiedConstraints() {
return unifiedConstraints;
}
public void setUnifiedConstraints(Vector<Pair> unifiedConstraints) {
this.unifiedConstraints = new ResultSet(unifiedConstraints);
}
/**
* Ermittelt den in diesem ResultSet für den TypePlaceholder tph zugewiesenen Wert.
* @author Andreas Stadelmeier, a10023
*/
public Type getTypeOfPlaceholder(TypePlaceholder tph){
return this.getUnifiedConstraints().getTypeEqualTo(tph);
}
/**
* Jedes TypeReconstructionResultSet entstand bei der Typinferierung einer Klasse.
* @return Gibt die Klasse zurück der dieses ResultSet zugeordnet ist.
*/
public mycompiler.myclass.Class getInterferedClass(){
return this.ownerOfResultSet;
}
@Override
public String toString(){
return "Unified Constraints: "+this.unifiedConstraints.toString();
}
}
// ino.end

View File

@ -4,6 +4,7 @@ package typinferenz;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mytype.GenericTypeVar; import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType; import mycompiler.mytype.RefType;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;

View File

@ -2,6 +2,7 @@ package typinferenz;
import java.util.Vector; import java.util.Vector;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.mystatement.MethodCall; import mycompiler.mystatement.MethodCall;
import mycompiler.mytype.RefType; import mycompiler.mytype.RefType;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;

View File

@ -1,10 +1,11 @@
package typinferenz; package typinferenz.assumptions;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.FunN;
import typinferenz.TypinferenzException;
import mycompiler.mytype.GenericTypeVar; import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType; import mycompiler.mytype.RefType;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;

View File

@ -7,7 +7,7 @@ import java.util.Vector;
import mycompiler.MyCompiler; import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI; import mycompiler.MyCompilerAPI;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import typinferenz.TypinferenzException; import typinferenz.TypinferenzException;
import java.util.*; import java.util.*;
@ -30,7 +30,7 @@ public class ConsoleInterface {
} }
public static void run(Vector<String> filenames){ public static void run(Vector<String> filenames){
Vector<CTypeReconstructionResult> resultSet = null; Vector<TypeinferenceResultSet> resultSet = null;
MyCompilerAPI compiler = MyCompiler.getAPI(); MyCompilerAPI compiler = MyCompiler.getAPI();
try{ try{
@ -53,7 +53,7 @@ public class ConsoleInterface {
/////////////////////// ///////////////////////
if(resultSet == null)System.out.println("Keine Lösung!"); if(resultSet == null)System.out.println("Keine Lösung!");
ArrayList<String> resultJavaCodes = new ArrayList<String>(); ArrayList<String> resultJavaCodes = new ArrayList<String>();
for(CTypeReconstructionResult result : resultSet){ for(TypeinferenceResultSet result : resultSet){
String javaCode = result.getInterferedClass().printJavaCode(result); String javaCode = result.getInterferedClass().printJavaCode(result);
if(!resultJavaCodes.contains(javaCode))resultJavaCodes.add(javaCode); if(!resultJavaCodes.contains(javaCode))resultJavaCodes.add(javaCode);
} }

View File

@ -15,7 +15,7 @@ import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CIntersectionType; import mycompiler.mytypereconstruction.CIntersectionType;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
@ -108,7 +108,7 @@ public abstract class AbstractInferenceTest extends TestCase {
throws Exception throws Exception
{ {
// Typ-Rekonstruktion // Typ-Rekonstruktion
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
testlog.info("Type reconstruction completed..."); testlog.info("Type reconstruction completed...");
// Keine Typ-Rekonstruktion erforderlich // Keine Typ-Rekonstruktion erforderlich
if (resultSet == null || resultSet.size() == 0) throw new Exception("Type reconstruction could not be done!"); if (resultSet == null || resultSet.size() == 0) throw new Exception("Type reconstruction could not be done!");
@ -120,7 +120,7 @@ public abstract class AbstractInferenceTest extends TestCase {
else else
testlog.info("An Error has occurred receiving the expectations for this testcase: "+ this.javFile); testlog.info("An Error has occurred receiving the expectations for this testcase: "+ this.javFile);
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();
@ -147,7 +147,7 @@ public abstract class AbstractInferenceTest extends TestCase {
* @param expect * @param expect
*/ */
protected void checkResults(Vector<CTypeReconstructionResult> resultSet, Expectation expect) { protected void checkResults(Vector<TypeinferenceResultSet> resultSet, Expectation expect) {
//iterates thru all available assumption-sets //iterates thru all available assumption-sets
testlog.info("Starting checking for valid type assumptions..."); testlog.info("Starting checking for valid type assumptions...");
@ -383,7 +383,7 @@ public abstract class AbstractInferenceTest extends TestCase {
* @param assumption * @param assumption
* @param expectation * @param expectation
*/ */
protected void checkClasses(CTypeReconstructionResult assumption, Expectation expectation) { protected void checkClasses(TypeinferenceResultSet assumption, Expectation expectation) {
for (String expect : expectation.getClasses().keySet()) { for (String expect : expectation.getClasses().keySet()) {

View File

@ -6,11 +6,11 @@ import static org.junit.Assert.fail;
import java.util.Vector; import java.util.Vector;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
public class ConstructorTest { public class ConstructorTest {
@ -28,9 +28,9 @@ public class ConstructorTest {
public void executeTest(){ public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFiles); LambdaTest tester = new LambdaTest(exampleJavFiles);
Vector<CTypeReconstructionResult> results = tester.runTest(); Vector<TypeinferenceResultSet> results = tester.runTest();
int anzahlGeparsterKlassen = 0; int anzahlGeparsterKlassen = 0;
for(CTypeReconstructionResult res : results){ for(TypeinferenceResultSet res : results){
mycompiler.myclass.Class cl = res.getInterferedClass(); mycompiler.myclass.Class cl = res.getInterferedClass();
TypeAssumptions ass = cl.getPublicFieldAssumptions(); TypeAssumptions ass = cl.getPublicFieldAssumptions();
if(cl.getName().equals("ConstructorTest1")){ if(cl.getName().equals("ConstructorTest1")){

View File

@ -1,7 +1,7 @@
package mycompiler.test.lambda; package mycompiler.test.lambda;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;
@ -16,6 +16,6 @@ public class GenericParameterTest {
public void executeTest(){ public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFile); LambdaTest tester = new LambdaTest(exampleJavFile);
CTypeReconstructionResult result1 = tester.runTestAndGetSingularResultSet(); TypeinferenceResultSet result1 = tester.runTestAndGetSingularResultSet();
} }
} }

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.util.Vector; import java.util.Vector;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;
@ -21,7 +21,7 @@ public class GenericVarTest {
public void executeTest(){ public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFile); LambdaTest tester = new LambdaTest(exampleJavFile);
CTypeReconstructionResult result1 = tester.runTestAndGetSingularResultSet(); TypeinferenceResultSet result1 = tester.runTestAndGetSingularResultSet();
} }
} }

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.util.Vector; import java.util.Vector;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;
@ -21,7 +21,7 @@ public class OverloadingTest {
public void executeTest(){ public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFile); LambdaTest tester = new LambdaTest(exampleJavFile);
Vector<CTypeReconstructionResult> result1 = tester.runTest(); Vector<TypeinferenceResultSet> result1 = tester.runTest();
} }
} }

View File

@ -1,13 +1,14 @@
package mycompiler.test.lambda; package mycompiler.test.lambda;
import java.util.Vector; import java.util.Vector;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
public class ParseMultipleFilesTest { public class ParseMultipleFilesTest {
@ -25,9 +26,9 @@ public class ParseMultipleFilesTest {
public void executeTest(){ public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFiles); LambdaTest tester = new LambdaTest(exampleJavFiles);
Vector<CTypeReconstructionResult> results = tester.runTest(); Vector<TypeinferenceResultSet> results = tester.runTest();
int anzahlGeparsterKlassen = 0; int anzahlGeparsterKlassen = 0;
for(CTypeReconstructionResult res : results){ for(TypeinferenceResultSet res : results){
mycompiler.myclass.Class cl = res.getInterferedClass(); mycompiler.myclass.Class cl = res.getInterferedClass();
TypeAssumptions ass = cl.getPublicFieldAssumptions(); TypeAssumptions ass = cl.getPublicFieldAssumptions();
if(cl.getName().equals("Klasse1")){ if(cl.getName().equals("Klasse1")){

View File

@ -5,7 +5,7 @@ import java.util.Vector;
import junit.framework.TestCase; import junit.framework.TestCase;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.util.HashMap; import java.util.HashMap;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import org.junit.Test; import org.junit.Test;

View File

@ -8,12 +8,12 @@ import java.util.Vector;
import mycompiler.mytest.LambdaTest; import mycompiler.mytest.LambdaTest;
import mycompiler.mytype.Type; import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet; import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import org.junit.Test; import org.junit.Test;
import typinferenz.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;
public class TestWhile { public class TestWhile {

View File

@ -11,7 +11,7 @@ import mycompiler.MyCompilerAPI;
import mycompiler.mytype.GenericTypeVar; import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytypereconstruction.CIntersectionType; import mycompiler.mytypereconstruction.CIntersectionType;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
@ -50,7 +50,7 @@ public abstract class AbstractInferenceTestOLD_2 extends TestCase{
throws Exception throws Exception
{ {
// Typ-Rekonstruktion // Typ-Rekonstruktion
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
// Keine Typ-Rekonstruktion erforderlich // Keine Typ-Rekonstruktion erforderlich
if (resultSet == null || resultSet.size() == 0) throw new Exception("Typrekonstruktion nicht durchfuehrbar!"); if (resultSet == null || resultSet.size() == 0) throw new Exception("Typrekonstruktion nicht durchfuehrbar!");
@ -61,7 +61,7 @@ public abstract class AbstractInferenceTestOLD_2 extends TestCase{
checkResults(resultSet, testedClass); checkResults(resultSet, testedClass);
} }
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();
@ -155,7 +155,7 @@ public abstract class AbstractInferenceTestOLD_2 extends TestCase{
// } // }
// } // }
// } // }
protected void checkResults(Vector<CTypeReconstructionResult> resultSet, String testedClass) { protected void checkResults(Vector<TypeinferenceResultSet> resultSet, String testedClass) {
//check valid - implementation //check valid - implementation
System.out.println("Länge ResultSet: " + resultSet.size()); System.out.println("Länge ResultSet: " + resultSet.size());

View File

@ -14,7 +14,7 @@ import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder; import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CIntersectionType; import mycompiler.mytypereconstruction.CIntersectionType;
import mycompiler.mytypereconstruction.CSubstitution; import mycompiler.mytypereconstruction.CSubstitution;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CInstVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
@ -92,14 +92,14 @@ public abstract class AbstractInferenceTestOld extends TestCase {
throws Exception throws Exception
{ {
// Typ-Rekonstruktion // Typ-Rekonstruktion
Vector<CTypeReconstructionResult> resultSet = compiler.typeReconstruction(); Vector<TypeinferenceResultSet> resultSet = compiler.typeReconstruction();
// Keine Typ-Rekonstruktion erforderlich // Keine Typ-Rekonstruktion erforderlich
if (resultSet == null || resultSet.size() == 0) throw new Exception("Type reconstruction could not be done!"); if (resultSet == null || resultSet.size() == 0) throw new Exception("Type reconstruction could not be done!");
if (this.expectation.getClasses()!=null) if (this.expectation.getClasses()!=null)
checkResults(resultSet,this.expectation); checkResults(resultSet,this.expectation);
CTypeReconstructionResult onePossibility = resultSet.firstElement(); TypeinferenceResultSet onePossibility = resultSet.firstElement();
Iterator substIt = onePossibility.getSubstitutions().getIterator(); Iterator substIt = onePossibility.getSubstitutions().getIterator();
while(substIt.hasNext()){ while(substIt.hasNext()){
CSubstitution subst = (CSubstitution)substIt.next(); CSubstitution subst = (CSubstitution)substIt.next();
@ -126,7 +126,7 @@ public abstract class AbstractInferenceTestOld extends TestCase {
* @param expect * @param expect
*/ */
protected void checkResults(Vector<CTypeReconstructionResult> resultSet, Expectation expect) { protected void checkResults(Vector<TypeinferenceResultSet> resultSet, Expectation expect) {
//iterates thru all available assumption-sets //iterates thru all available assumption-sets
for (int resIndex=0; resIndex < resultSet.size(); resIndex++) { for (int resIndex=0; resIndex < resultSet.size(); resIndex++) {
@ -331,7 +331,7 @@ System.out.println(" here " + t + " -- " + e);
* @param assumption * @param assumption
* @param expectation * @param expectation
*/ */
protected void checkClasses(CTypeReconstructionResult assumption, Expectation expectation) { protected void checkClasses(TypeinferenceResultSet assumption, Expectation expectation) {
for (String expect : expectation.getClasses().keySet()) { for (String expect : expectation.getClasses().keySet()) {

View File

@ -2,10 +2,10 @@ package mycompiler.test.notUsedAnymore;
import java.util.Vector; import java.util.Vector;
import mycompiler.mytypereconstruction.CTypeReconstructionResult; import mycompiler.mytypereconstruction.TypeinferenceResultSet;
public interface IResultValidator { public interface IResultValidator {
public void checkResults(Vector<CTypeReconstructionResult> resultSet); public void checkResults(Vector<TypeinferenceResultSet> resultSet);
} }