Bug 49 und 52 fix

This commit is contained in:
JanUlrich 2016-05-24 00:36:59 +02:00
parent b67816775e
commit 0d51c3e94d
5 changed files with 244 additions and 245 deletions

File diff suppressed because it is too large Load Diff

View File

@ -663,15 +663,6 @@ modifier : PUBLIC
classtype : classorinterfacetype
{
//PL 05-07-30 eingefuegt containedTypes ANFANG
RefType RT = new RefType($1.get_Name_1Element(),null,-1);
//RT.set_UsedId($1);
//RT.setName(RT.get_UsedId().get_Name_1Element());
RT.set_ParaList($1.get_RealParaList());
//RT.setName($1.get_Name_1Element());
containedTypes.addElement(RT);
//PL 05-07-30 eingefuegt containedTypes ENDE
$$ = $1;
}
@ -2026,6 +2017,7 @@ classinstancecreationexpression : NEW classtype '(' ')'
{
NewClass NC = new NewClass($2.getOffset(),$2.getVariableLength());
NC.set_UsedId($2);
usedIdsToCheck.addElement($2);
//auskommentiert von Andreas Stadelmeier (a10023) NC.setType(TypePlaceholder.fresh());
$$=NC;

View File

@ -232,11 +232,6 @@ public class SourceFile
globalAssumptions.add(importAssumptions);
typinferenzLog.debug("Von JRE erstellte Assumptions: "+importAssumptions, Section.TYPEINFERENCE);
//FiniteClosure generieren:
FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(globalAssumptions);
typinferenzLog.debug("FiniteClosure: \n"+finiteClosure, Section.TYPEINFERENCE);
ConstraintsSet oderConstraints = new ConstraintsSet();
//Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln:
for(Class klasse : KlassenVektor){
@ -249,6 +244,11 @@ public class SourceFile
*/////////////////
//UnifyTypeFactory.convert(oderConstraints);
//FiniteClosure generieren:
FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(globalAssumptions);
typinferenzLog.debug("FiniteClosure: \n"+finiteClosure, Section.TYPEINFERENCE);
////////////////
//Typen in UnifyTypen umwandeln:

View File

@ -50,10 +50,10 @@ public class UnifyTypeFactory {
public static FiniteClosure generateFC(TypeAssumptions fromAss){
HashSet<UnifyPair> pairs = new HashSet<>();
for(ClassAssumption cAss : fromAss.getClassAssumptions()){
UnifyType tl = UnifyTypeFactory.convert(cAss.getAssumedClass().getType());
RefType superClass = cAss.getAssumedClass().getSuperClass();
UnifyType tl = UnifyTypeFactory.convert(cAss.getAssumedClass().getType().TYPE(fromAss, cAss.getAssumedClass()));
Type superClass = cAss.getAssumedClass().getSuperClass();
if(superClass != null){
UnifyType tr = UnifyTypeFactory.convert(superClass);
UnifyType tr = UnifyTypeFactory.convert(superClass.TYPE(fromAss, cAss.getAssumedClass()));
pairs.add(generateSmallerPair(tl, tr));
}
}

View File

@ -1,10 +1,12 @@
// ino.module.NewClass.8642.package
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.ArrayList;
// ino.end
// ino.module.NewClass.8642.import
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.ClassGen;
@ -23,6 +25,7 @@ import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.misc.UsedId;
import de.dhbwstuttgart.syntaxtree.type.FunN;
@ -60,6 +63,7 @@ public class NewClass extends Expr
// ino.attribute.arglist.25837.declaration
private ArgumentList arglist;
private boolean isStatement = false;
private List<Type> parameterList = new ArrayList<>();
// ino.end
// ino.attribute.parserlog.25840.declaration
protected static Logger parserlog = Logger.getLogger("parser");
@ -131,7 +135,6 @@ public class NewClass extends Expr
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
//TODO: Das hier noch vervollständigen
ConstraintsSet ret = new ConstraintsSet();
UndConstraint callConstraints = new UndConstraint();
@ -144,7 +147,19 @@ public class NewClass extends Expr
ret.add(this.arglist.expr.elementAt(i).TYPEExpr(assumptions));
callConstraints.addConstraint( this.arglist.expr.elementAt(i).getType().TYPE(assumptions, this), cA.getParameterType(i).TYPE(assumptions, this));
}
Type thisT = assumptions.checkType(new RefType(this.get_Name(),this,0), (SyntaxTreeNode)this);
//Die Parameterliste befindet sich in der UsedID:
for(Type param : this.usedid.get_ParaList()){
this.parameterList.add(param.TYPE(assumptions, this));
}
//Den Typ der Instruktion setzen:
RefType refTypeToCheck;
if(this.parameterList.size() == 0){
refTypeToCheck = new RefType(this.get_Name(),this,0);
}else{
refTypeToCheck = new RefType(this.get_Name(),this.parameterList,this,0);
}
Type thisT = assumptions.checkType(refTypeToCheck, (SyntaxTreeNode)this);
this.setType(thisT);
return ret;