forked from JavaTX/JavaCompilerCore
Bugfix #4 (FunVoidN Typen)
This commit is contained in:
parent
642394c25b
commit
388685d3b2
@ -9,6 +9,7 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
|||||||
import de.dhbwstuttgart.syntaxtree.NullSyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.NullSyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.FunN;
|
import de.dhbwstuttgart.syntaxtree.type.FunN;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.FunVoidN;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
@ -108,7 +109,7 @@ public class UnifyTypeFactory {
|
|||||||
params.add(UnifyTypeFactory.convert(pT));
|
params.add(UnifyTypeFactory.convert(pT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = FunNType.getFunNType(new TypeParams(params));
|
ret = FunNType.getFunNType(t.getName().toString(), new TypeParams(params));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,16 +215,6 @@ public class LambdaExpression extends Expr{
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
private List<LocalOrFieldVarOrClassname> crawlVariables(SyntaxTreeNode inStatements){
|
|
||||||
List<LocalOrFieldVarOrClassname> ret = new ArrayList<>();
|
|
||||||
for(SyntaxTreeNode child : inStatements.getChildren()){
|
|
||||||
ret.addAll(crawlVariables(child));
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
DHBWConstantPoolGen cp = cg.getConstantPool();
|
DHBWConstantPoolGen cp = cg.getConstantPool();
|
||||||
|
@ -17,6 +17,7 @@ import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
|||||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +158,7 @@ public class FunN extends RefType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FunNInterface getCorrespondingInterface(){
|
public FunNInterface getCorrespondingInterface(){
|
||||||
return null;
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
import de.dhbwstuttgart.parser.JavaClassName;
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
import de.dhbwstuttgart.syntaxtree.Method;
|
||||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
@ -29,7 +33,7 @@ public class FunVoidN extends FunN {
|
|||||||
* @param T
|
* @param T
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FunVoidN(Menge<Type> T) {
|
public FunVoidN(List<Type> T) {
|
||||||
super(T.size());
|
super(T.size());
|
||||||
this.setR(new Void(this, -1));
|
this.setR(new Void(this, -1));
|
||||||
this.setT(T);
|
this.setT(T);
|
||||||
@ -56,5 +60,17 @@ public class FunVoidN extends FunN {
|
|||||||
if(T!=null)t.addAll(T);
|
if(T!=null)t.addAll(T);
|
||||||
this.set_ParaList(t);
|
this.set_ParaList(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
|
||||||
|
//FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt:
|
||||||
|
List<Type> paraList = new ArrayList<>();
|
||||||
|
if(this.T != null && this.T.size() > 0)for(Type t : this.T){
|
||||||
|
Type toAdd = t.TYPE(ass, parent);
|
||||||
|
//if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this);
|
||||||
|
paraList.add(toAdd);
|
||||||
|
}
|
||||||
|
FunVoidN ret = new FunVoidN(paraList);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ public class FunNType extends UnifyType {
|
|||||||
/**
|
/**
|
||||||
* Creates a FunN-Type with the specified TypeParameters.
|
* Creates a FunN-Type with the specified TypeParameters.
|
||||||
*/
|
*/
|
||||||
protected FunNType(TypeParams p) {
|
protected FunNType(String name, TypeParams p) {
|
||||||
super("Fun"+(p.size()-1), p);
|
super(name, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,13 +23,13 @@ public class FunNType extends UnifyType {
|
|||||||
* @return A FunNType.
|
* @return A FunNType.
|
||||||
* @throws IllegalArgumentException is thrown when there are to few type parameters or there are wildcard-types.
|
* @throws IllegalArgumentException is thrown when there are to few type parameters or there are wildcard-types.
|
||||||
*/
|
*/
|
||||||
public static FunNType getFunNType(TypeParams tp) throws IllegalArgumentException {
|
public static FunNType getFunNType(String name, TypeParams tp) throws IllegalArgumentException {
|
||||||
if(tp.size() == 0)
|
if(tp.size() == 0)
|
||||||
throw new IllegalArgumentException("FunNTypes need at least one type parameter");
|
throw new IllegalArgumentException("FunNTypes need at least one type parameter");
|
||||||
for(UnifyType t : tp)
|
for(UnifyType t : tp)
|
||||||
if(t instanceof WildcardType)
|
if(t instanceof WildcardType)
|
||||||
throw new IllegalArgumentException("Invalid TypeParams for a FunNType: " + tp);
|
throw new IllegalArgumentException("Invalid TypeParams for a FunNType: " + tp);
|
||||||
return new FunNType(tp);
|
return new FunNType(name,tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +43,7 @@ public class FunNType extends UnifyType {
|
|||||||
public UnifyType setTypeParams(TypeParams newTp) {
|
public UnifyType setTypeParams(TypeParams newTp) {
|
||||||
if(newTp.hashCode() == typeParams.hashCode() && newTp.equals(typeParams))
|
if(newTp.hashCode() == typeParams.hashCode() && newTp.equals(typeParams))
|
||||||
return this;
|
return this;
|
||||||
return getFunNType(newTp);
|
return getFunNType(this.getName(), newTp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,7 +64,7 @@ public class FunNType extends UnifyType {
|
|||||||
if(newParams.hashCode() == typeParams.hashCode() && newParams.equals(typeParams))
|
if(newParams.hashCode() == typeParams.hashCode() && newParams.equals(typeParams))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
return new FunNType(newParams);
|
return new FunNType(this.getName(), newParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class FunVoid {
|
|||||||
@Test
|
@Test
|
||||||
public void run(){
|
public void run(){
|
||||||
Menge<String> mustContain = new Menge<String>();
|
Menge<String> mustContain = new Menge<String>();
|
||||||
//mustContain.add("TestIfStmt var");
|
mustContain.add("FunVoid");
|
||||||
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||||
ArrayList l = new ArrayList();
|
ArrayList l = new ArrayList();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user