forked from JavaTX/JavaCompilerCore
Fehler in Lambda2_2 gefixt
This commit is contained in:
parent
c5f0e73e50
commit
61a4bc3cd7
@ -26,6 +26,7 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.OderConstraint;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.UndConstraint;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
@ -210,8 +211,14 @@ public class MethodCall extends Expr
|
||||
//Noch das Overloading-Constraint anhängen:
|
||||
ret.add(overloading(assumptions));
|
||||
|
||||
de.dhbwstuttgart.syntaxtree.Class receiverCl = assumptions.getClassAssumptionFor(receiver.get_Expr().getType()).getAssumedClass();
|
||||
/*
|
||||
//Die Klasse für den Receiver setzen: Das ist für die Bytecodegenerierung notwendig.
|
||||
ClassAssumption receiverClassAssumption = assumptions.getClassAssumptionFor(receiver.get_Expr().getType());
|
||||
de.dhbwstuttgart.syntaxtree.Class receiverCl = receiverClassAssumption.getAssumedClass();
|
||||
this.receiver.setClass(receiverCl);
|
||||
*/
|
||||
//Die Assumptions für den Receiver setzen:
|
||||
this.receiver.setAssumptions(assumptions);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -322,7 +329,7 @@ public class MethodCall extends Expr
|
||||
|
||||
//Herausfinden, ob eine Methode oder ein Interface aufgerufen wird:
|
||||
Type receiverType = this.receiver.get_Expr().getType();
|
||||
de.dhbwstuttgart.syntaxtree.Class receiverClass = this.receiver.getReceiverClass();
|
||||
de.dhbwstuttgart.syntaxtree.Class receiverClass = this.receiver.getReceiverClass(cg);
|
||||
short kind = 0;
|
||||
if(receiverClass.isInterface()){
|
||||
kind = Constants.INVOKEINTERFACE;
|
||||
@ -343,7 +350,7 @@ public class MethodCall extends Expr
|
||||
}
|
||||
|
||||
org.apache.commons.bcel6.generic.Type returnType = this.getType().getBytecodeType(cg);
|
||||
il.append(_factory.createInvoke(receiver.getReceiverClass().getName().toString(), this.get_Name(), returnType , argumentTypen, kind));
|
||||
il.append(_factory.createInvoke(receiver.getReceiverClass(cg).getName().toString(), this.get_Name(), returnType , argumentTypen, kind));
|
||||
return il;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
|
||||
// ino.module.Receiver.8650.import
|
||||
import java.util.Hashtable;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
// ino.end
|
||||
|
||||
@ -14,8 +14,13 @@ import de.dhbwstuttgart.logger.Logger;
|
||||
|
||||
import de.dhbwstuttgart.myexception.SCStatementException;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
|
||||
|
||||
|
||||
@ -27,7 +32,7 @@ public class Receiver
|
||||
{
|
||||
// ino.attribute.expr.26126.declaration
|
||||
private Expr expr;
|
||||
private de.dhbwstuttgart.syntaxtree.Class receiverClass;
|
||||
private TypeAssumptions typeAssumptions;
|
||||
// ino.end
|
||||
// ino.attribute.parserlog.26129.declaration
|
||||
protected static Logger parserlog = Logger.getLogger("parser");
|
||||
@ -90,14 +95,34 @@ public class Receiver
|
||||
}
|
||||
// ino.end
|
||||
|
||||
/*
|
||||
public void setClass(Class cl){
|
||||
this.receiverClass = cl;
|
||||
}
|
||||
*/
|
||||
|
||||
public Class getReceiverClass(){
|
||||
return this.receiverClass;
|
||||
public Class getReceiverClass(ClassGenerator cg){
|
||||
de.dhbwstuttgart.syntaxtree.type.Type receiverType = this.get_Expr().getType();
|
||||
if(receiverType instanceof TypePlaceholder){
|
||||
receiverType = cg.resolveTPH((TypePlaceholder)receiverType);
|
||||
}
|
||||
if(!(receiverType instanceof RefType)){
|
||||
throw new TypeinferenceException("Typ des Receivers nicht eindeutig",this.get_Expr());
|
||||
}
|
||||
ClassAssumption receiverClassAssumption = typeAssumptions.getClassAssumptionFor((RefType)receiverType);
|
||||
de.dhbwstuttgart.syntaxtree.Class receiverCl = receiverClassAssumption.getAssumedClass();
|
||||
return receiverCl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setzt die TypeAssumptions für diesen Receiver.
|
||||
* Das ist notwendig für die Bytecodegenerierung
|
||||
* @param ass
|
||||
*/
|
||||
public void setAssumptions(TypeAssumptions ass){
|
||||
this.typeAssumptions = ass;
|
||||
}
|
||||
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult().attach(this.get_Expr().printJavaCode(resultSet));
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ public class TypeAssumptions {
|
||||
return this.classAssumptions;
|
||||
}
|
||||
|
||||
public ClassAssumption getClassAssumptionFor(Type t){
|
||||
public ClassAssumption getClassAssumptionFor(RefType t){
|
||||
for(ClassAssumption cA : this.getClassAssumptions()){
|
||||
if(cA.getAssumedClass().getType().equals(t))return cA;
|
||||
}
|
||||
|
@ -102,10 +102,7 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
||||
for(String containString : mustContain){
|
||||
TestCase.assertTrue("\""+containString+"\" muss in den inferierten Lösungen vorkommen",gesamterSrc.contains(containString));
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
try {
|
||||
Files.write(Logger.getWholeLog().getBytes(),new File(rootDirectory+sourceFileToInfere+".log"));
|
||||
=======
|
||||
|
||||
writeLog(sourceFileToInfere+".log");
|
||||
}
|
||||
|
||||
@ -114,7 +111,6 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
||||
log+=Timewatch.getTimewatch().dumpTimeData();
|
||||
try {
|
||||
Files.write(log.getBytes(),new File(rootDirectory+toFile));
|
||||
>>>>>>> master
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
TestCase.fail();
|
||||
|
Loading…
Reference in New Issue
Block a user