forked from JavaTX/JavaCompilerCore
fixed Construct. Changed Field and Method Types to GenericRefType.
This commit is contained in:
parent
ab46709390
commit
a17342458e
@ -51,7 +51,7 @@ public class Construct extends DefaultASTVisitor {
|
||||
this.newInterf.forEach(i -> i.accept(this));
|
||||
return constructedInterfaces;
|
||||
}
|
||||
|
||||
|
||||
public InferredTypes getInferredTypes() {
|
||||
return inferredTypes;
|
||||
}
|
||||
@ -59,8 +59,8 @@ public class Construct extends DefaultASTVisitor {
|
||||
public List<SubTypeConstraint> getSubTypeConstraints() {
|
||||
return subTypeConstraints;
|
||||
}
|
||||
|
||||
public Set<UnifyPair> getSubTypeConstraintsAsUnifyPairs(){
|
||||
|
||||
public Set<UnifyPair> getSubTypeConstraintsAsUnifyPairs() {
|
||||
return subTypeConstraints.stream().map(SubTypeConstraint::getAsUnifyPair).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@ -79,10 +79,11 @@ public class Construct extends DefaultASTVisitor {
|
||||
this.constructedInterfaces.add(this.constructInterface(typePlaceholder, name));
|
||||
}
|
||||
|
||||
//check nur TPH in newInterf
|
||||
// check nur TPH in newInterf
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
throw new IllegalInterfaceTypeException(String.format("%s is not a valid type to generate an interface for.", refType));
|
||||
throw new IllegalInterfaceTypeException(
|
||||
String.format("%s is not a valid type to generate an interface for.", refType));
|
||||
}
|
||||
|
||||
private ClassOrInterface constructInterface(TypePlaceholder i, JavaClassName name) {
|
||||
@ -94,12 +95,11 @@ public class Construct extends DefaultASTVisitor {
|
||||
|
||||
// Schleife über alle FieldConstraints mit ClassType i
|
||||
this.constraintsSet.getFieldConstraints().stream().filter(fc -> fc.getClassType().equals(i)).forEach(fc -> {
|
||||
TypePlaceholder type = TypePlaceholder.fresh(offset);
|
||||
//TODO welcher Typ für field TPH, GenRT,...?
|
||||
GenericRefType grt = new GenericRefType(type.getName(), offset);
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
// Typ für field: GenericRefType
|
||||
GenericRefType grt = new GenericRefType(tph.getName(), offset);
|
||||
parameterInhTyterm.add(fc.getFieldType());
|
||||
generics.add(new GenericTypeVar( type.getName(),
|
||||
new ArrayList<>(), offset, offset));
|
||||
generics.add(new GenericTypeVar(tph.getName(), new ArrayList<>(), offset, offset));
|
||||
Field field = new Field(fc.getFieldName(), grt, Modifier.PUBLIC, offset);
|
||||
fielddecl.add(field);
|
||||
});
|
||||
@ -113,15 +113,17 @@ public class Construct extends DefaultASTVisitor {
|
||||
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), offset);
|
||||
List<FormalParameter> params = new ArrayList<>();
|
||||
mc.getArguments().stream().map(a -> a.getSupertype()).forEach(supertype -> {
|
||||
//TODO welcher Typ für argument?
|
||||
// Typ für argument: GenericRefType
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
params.add(new FormalParameter(tph.getName(), tph, offset));
|
||||
GenericRefType grt = new GenericRefType(tph.getName(), offset);
|
||||
params.add(new FormalParameter(tph.getName(), grt, offset));
|
||||
parameterInhTyterm.add(supertype);
|
||||
generics.add(new GenericTypeVar(tph.getName(), new ArrayList<>(), offset, offset));
|
||||
});
|
||||
ParameterList parameterList = new ParameterList(params, offset);
|
||||
//TODO Welcher returnType für method
|
||||
Method method = new Method(Modifier.PUBLIC, mc.getMethodName(), returnType, parameterList, block, gtvDeclarations, offset);
|
||||
// returnType für method: GenericRefType
|
||||
Method method = new Method(Modifier.PUBLIC, mc.getMethodName(),
|
||||
new GenericRefType(returnType.getName(), offset), parameterList, block, gtvDeclarations, offset);
|
||||
methods.add(method);
|
||||
});
|
||||
|
||||
@ -131,14 +133,14 @@ public class Construct extends DefaultASTVisitor {
|
||||
this.inferredTypes.put(i, x);
|
||||
this.subTypeConstraints.forEach(sc -> sc.inferTypes(this.inferredTypes));
|
||||
|
||||
|
||||
final int modifiers = Modifier.PUBLIC;
|
||||
final RefType superClass = this.createSuperClass();
|
||||
final boolean isInterface = true;
|
||||
final List<Constructor> constructors = new ArrayList<>();
|
||||
final List<RefType> implementedInterfaces = new ArrayList<>();
|
||||
GenericDeclarationList genericClassParameters = new GenericDeclarationList(generics, i.getOffset());
|
||||
ClassOrInterface constructedInterface = new ClassOrInterface(modifiers, name, fielddecl, methods, constructors, genericClassParameters, superClass, isInterface, implementedInterfaces, offset);
|
||||
ClassOrInterface constructedInterface = new ClassOrInterface(modifiers, name, fielddecl, methods, constructors,
|
||||
genericClassParameters, superClass, isInterface, implementedInterfaces, offset);
|
||||
return constructedInterface;
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,8 @@ public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
public String getParsedName(){
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GRT " + this.name ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(ASTVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user