forked from JavaTX/JavaCompilerCore
Aufräumen
This commit is contained in:
parent
1f825360df
commit
47c9be5488
@ -214,7 +214,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
private Menge<Field> fielddecl = new Menge<Field>();
|
||||
private GenericDeclarationList genericClassParameters;
|
||||
private int offset;
|
||||
private Type superClass;
|
||||
private RefType superClass;
|
||||
|
||||
|
||||
// ino.method.Class.23041.definition
|
||||
@ -240,7 +240,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
* @param modifiers
|
||||
* @param supertypeGenPara - Eine Liste von Namen, welche die Generischen Parameter der Klasse darstellen.
|
||||
*/
|
||||
public Class(String name, Type superClass, Modifiers modifiers, Menge<String> supertypeGenPara) {
|
||||
public Class(String name, RefType superClass, Modifiers modifiers, Menge<String> supertypeGenPara) {
|
||||
this(name,superClass,modifiers,0);
|
||||
if(supertypeGenPara == null)return;
|
||||
Menge<GenericTypeVar> gtvs = new Menge<>();
|
||||
@ -261,7 +261,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
this.setGenericParameter(new GenericDeclarationList(gtvs,0));
|
||||
}
|
||||
|
||||
public Class(String name, Type superClass, Modifiers mod, int offset){
|
||||
public Class(String name, RefType superClass, Modifiers mod, int offset){
|
||||
this(name,mod,offset);
|
||||
if(superClass == null)this.superClass = new Class("java.lang.Object",-1).getType();
|
||||
else this.superClass = superClass;
|
||||
@ -293,14 +293,14 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
public Class(String name2, Modifiers object, ClassBody classBody,
|
||||
Menge<Type> containedTypes2, Menge<Type> typeMenge,
|
||||
Menge<Type> paraMenge, int offset2) {
|
||||
this(name2, object, classBody, containedTypes2,(Type)null, typeMenge, paraMenge, offset2);
|
||||
this(name2, object, classBody, containedTypes2,(RefType)null, typeMenge, paraMenge, offset2);
|
||||
}
|
||||
private static Menge<Type> usedIdToRefType(Menge<UsedId> superif2) {
|
||||
Menge<Type> ret = new Menge<>();
|
||||
for(UsedId id : superif2)ret.add(usedIdToRefType(id));
|
||||
return ret;
|
||||
}
|
||||
private static Type usedIdToRefType(UsedId superclass2) {
|
||||
private static RefType usedIdToRefType(UsedId superclass2) {
|
||||
RefType ret = new RefType(superclass2.getSimpleName(), null, superclass2.getOffset());
|
||||
ret.set_ParaList(superclass2.get_ParaList());
|
||||
return ret;
|
||||
@ -314,7 +314,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
// ino.end
|
||||
// ino.method.Class.23047.definition
|
||||
public Class(String name, Modifiers mod, ClassBody cb, Menge<Type> ct,
|
||||
Type superclass, Menge<Type> Menge, Menge<? extends Type> paralist, int offset)
|
||||
RefType superclass, Menge<Type> Menge, Menge<? extends Type> paralist, int offset)
|
||||
// ino.end
|
||||
// ino.method.Class.23047.body
|
||||
{
|
||||
@ -671,7 +671,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
|
||||
//ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
|
||||
|
||||
this.superClass = this.superClass.TYPE(assumptions, this);
|
||||
//Gibt es hier eine ClassCastException stimmt etwas grundsätzlich nicht!
|
||||
this.superClass = (RefType)this.superClass.TYPE(assumptions, this);
|
||||
|
||||
for(Field f:this.getFields()){
|
||||
oderConstraints.add(f.TYPE(assumptions));
|
||||
@ -1028,7 +1029,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
|
||||
* Die Super Klasse dieser Klasse.
|
||||
* @return null für Klasse Object
|
||||
*/
|
||||
public Type getSuperClass(){
|
||||
public RefType getSuperClass(){
|
||||
return this.superClass;
|
||||
}
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import de.dhbwstuttgart.typeinference.unify.model.MPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.SimpleType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
|
||||
public class UnifyTypeFactory {
|
||||
@ -28,7 +29,7 @@ public class UnifyTypeFactory {
|
||||
HashSet<MPair> pairs = new HashSet<>();
|
||||
for(ClassAssumption cAss : fromAss.getClassAssumptions()){
|
||||
UnifyType tl = UnifyTypeFactory.convert(cAss.getAssumedClass().getType());
|
||||
Type superClass = cAss.getAssumedClass().getSuperClass();
|
||||
RefType superClass = cAss.getAssumedClass().getSuperClass();
|
||||
if(superClass != null){
|
||||
UnifyType tr = UnifyTypeFactory.convert(superClass);
|
||||
pairs.add(smaller(tl, tr));
|
||||
@ -57,7 +58,7 @@ public class UnifyTypeFactory {
|
||||
for(Type pT : t.getParaList()){
|
||||
params.add(UnifyTypeFactory.convert(pT));
|
||||
}
|
||||
ret = new SimpleType(t.get_Name(),params.toArray());
|
||||
ret = new SimpleType(t.get_Name(),new TypeParams(params));
|
||||
}else{
|
||||
ret = new SimpleType(t.get_Name());
|
||||
}
|
||||
|
@ -17,7 +17,11 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
class Test {
|
||||
void methode(ArrayList<? super Integer> t){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Die Klasse Type muss abstract werden!
|
||||
// ino.class.Type.26716.declaration
|
||||
|
@ -9,7 +9,7 @@ public final class SimpleType extends UnifyType {
|
||||
super(name, new TypeParams(typeParams));
|
||||
}
|
||||
|
||||
private SimpleType(String name, TypeParams params) {
|
||||
public SimpleType(String name, TypeParams params) {
|
||||
super(name, params);
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,18 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
public final class TypeParams implements Iterable<UnifyType>{
|
||||
private final UnifyType[] typeParams;
|
||||
|
||||
public TypeParams(Menge<UnifyType> types){
|
||||
typeParams = new UnifyType[types.size()];
|
||||
for(int i=0;i<types.size();i++){
|
||||
typeParams[i] = types.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
public TypeParams(UnifyType... types) {
|
||||
typeParams = types;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package unify;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.ImportDeclarations;
|
||||
@ -12,6 +14,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
|
||||
public class GenerateFiniteClosure {
|
||||
|
||||
@ -41,7 +44,8 @@ public class GenerateFiniteClosure {
|
||||
String importClass = "java.util.Vector";
|
||||
TypeAssumptions ass = generateAssumptionsFromImport(importClass);
|
||||
FiniteClosure fc = UnifyTypeFactory.generateFC(ass);
|
||||
System.out.println(fc);
|
||||
Set<UnifyType> test = fc.getAllTypes(importClass);
|
||||
assertTrue(test.size()>0);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user