forked from JavaTX/JavaCompilerCore
Fehler in Overloading im Bezug auf FunNInterface behoben
This commit is contained in:
parent
ddb9ef6d7d
commit
f16a9345eb
@ -1,13 +1,18 @@
|
|||||||
package typinferenz;
|
package typinferenz;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import mycompiler.mytype.*;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
|
|
||||||
|
|
||||||
public class FunNInterface extends Class{
|
public class FunNInterface extends Class{
|
||||||
//TODO: Diese Klasse sollte eigentlich von Interface erben
|
//TODO: Diese Klasse sollte eigentlich von Interface erben
|
||||||
|
|
||||||
public FunNInterface(int parameterCount) {
|
public FunNInterface(Vector<Type> parameter) {
|
||||||
super("Fun"+parameterCount);
|
super("Fun"+parameter.size());
|
||||||
|
this.set_ParaList(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import typinferenz.assumptions.MethodAssumption;
|
import typinferenz.assumptions.MethodAssumption;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
import mycompiler.mystatement.Expr;
|
||||||
import mycompiler.mystatement.MethodCall;
|
import mycompiler.mystatement.MethodCall;
|
||||||
import mycompiler.mytype.RefType;
|
import mycompiler.mytype.RefType;
|
||||||
import mycompiler.mytype.Type;
|
import mycompiler.mytype.Type;
|
||||||
@ -55,7 +56,11 @@ public class Overloading{
|
|||||||
*/
|
*/
|
||||||
public OderConstraint generateConsstraints(){
|
public OderConstraint generateConsstraints(){
|
||||||
OderConstraint ret = new OderConstraint();
|
OderConstraint ret = new OderConstraint();
|
||||||
for(MethodAssumption methodAssumption : assumptions.getMethodAssumptions(methodCall.getName(), methodCall.getArgumentList().size())){
|
Vector<Type> parameterList = new Vector<Type>();
|
||||||
|
for(Expr argument : methodCall.getArgumentList().expr){
|
||||||
|
parameterList.add(argument.getType());
|
||||||
|
}
|
||||||
|
for(MethodAssumption methodAssumption : assumptions.getMethodAssumptions(methodCall.getName(), parameterList)){
|
||||||
if(!(this.type instanceof TypePlaceholder) && !this.type.equals(methodAssumption.getAssumedType()))break;
|
if(!(this.type instanceof TypePlaceholder) && !this.type.equals(methodAssumption.getAssumedType()))break;
|
||||||
UndConstraint methodConstraint = new UndConstraint();
|
UndConstraint methodConstraint = new UndConstraint();
|
||||||
//Ein Constraint für den ReturnType der Methode...
|
//Ein Constraint für den ReturnType der Methode...
|
||||||
|
@ -134,10 +134,11 @@ public class TypeAssumptions {
|
|||||||
/**
|
/**
|
||||||
* Sucht nach Assumptions zu einer Methode mit dem Namen methodName und parameterCount Parametern.
|
* Sucht nach Assumptions zu einer Methode mit dem Namen methodName und parameterCount Parametern.
|
||||||
* @param methodName
|
* @param methodName
|
||||||
* @param parameterCount Anzahl der Parameter der gesuchten Methoden-Assumption
|
* @param parameter Die Parameter, welche die Methode verarbeiten soll
|
||||||
* @return
|
* @return Alle Methoden in den Assumptions, welche eine Parameterliste der Länge der übergebenen Parameterliste (parameter) verarbeiten können.
|
||||||
*/
|
*/
|
||||||
public Vector<MethodAssumption> getMethodAssumptions(String methodName, int parameterCount){
|
public Vector<MethodAssumption> getMethodAssumptions(String methodName, Vector<Type> parameter){
|
||||||
|
int parameterCount = parameter.size();
|
||||||
Vector<MethodAssumption> ret = new Vector<MethodAssumption>();
|
Vector<MethodAssumption> ret = new Vector<MethodAssumption>();
|
||||||
for(MethodAssumption ass : this.methodAssumptions){
|
for(MethodAssumption ass : this.methodAssumptions){
|
||||||
if(ass.getMethodName().equals(methodName) && ass.getParaCount() == parameterCount){
|
if(ass.getMethodName().equals(methodName) && ass.getParaCount() == parameterCount){
|
||||||
@ -148,7 +149,7 @@ public class TypeAssumptions {
|
|||||||
//Falls es sich um die apply-Methode eines FunN-Interface handelt:
|
//Falls es sich um die apply-Methode eines FunN-Interface handelt:
|
||||||
if(methodName.equals("apply")){ //Ein Workaround für den Typinferenzalgorithmus TODO: Das hier rausnehmen.
|
if(methodName.equals("apply")){ //Ein Workaround für den Typinferenzalgorithmus TODO: Das hier rausnehmen.
|
||||||
//CMethodTypeAssumption funNAssumption = new FunN(parameterCount).toCMethodTypeAssumption();
|
//CMethodTypeAssumption funNAssumption = new FunN(parameterCount).toCMethodTypeAssumption();
|
||||||
MethodAssumption funNAssumption = new MethodAssumption(new FunNMethod(parameterCount), new FunNInterface(parameterCount));
|
MethodAssumption funNAssumption = new MethodAssumption(new FunNMethod(parameterCount), new FunNInterface(parameter));
|
||||||
ret.add(funNAssumption);
|
ret.add(funNAssumption);
|
||||||
}
|
}
|
||||||
if(ret.size()==0)throw new TypinferenzException("Eine Methode "+methodName+" ist in den Assumptions nicht vorhanden");
|
if(ret.size()==0)throw new TypinferenzException("Eine Methode "+methodName+" ist in den Assumptions nicht vorhanden");
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user