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 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; $$ = $1;
} }
@ -2026,6 +2017,7 @@ classinstancecreationexpression : NEW classtype '(' ')'
{ {
NewClass NC = new NewClass($2.getOffset(),$2.getVariableLength()); NewClass NC = new NewClass($2.getOffset(),$2.getVariableLength());
NC.set_UsedId($2); NC.set_UsedId($2);
usedIdsToCheck.addElement($2); usedIdsToCheck.addElement($2);
//auskommentiert von Andreas Stadelmeier (a10023) NC.setType(TypePlaceholder.fresh()); //auskommentiert von Andreas Stadelmeier (a10023) NC.setType(TypePlaceholder.fresh());
$$=NC; $$=NC;

View File

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

View File

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

View File

@ -1,10 +1,12 @@
// ino.module.NewClass.8642.package // ino.module.NewClass.8642.package
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import java.util.ArrayList;
// ino.end // ino.end
// ino.module.NewClass.8642.import // ino.module.NewClass.8642.import
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import org.apache.commons.bcel6.Constants; import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.ClassGen; 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.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.ParameterList;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.misc.UsedId; import de.dhbwstuttgart.syntaxtree.misc.UsedId;
import de.dhbwstuttgart.syntaxtree.type.FunN; import de.dhbwstuttgart.syntaxtree.type.FunN;
@ -60,6 +63,7 @@ public class NewClass extends Expr
// ino.attribute.arglist.25837.declaration // ino.attribute.arglist.25837.declaration
private ArgumentList arglist; private ArgumentList arglist;
private boolean isStatement = false; private boolean isStatement = false;
private List<Type> parameterList = new ArrayList<>();
// ino.end // ino.end
// ino.attribute.parserlog.25840.declaration // ino.attribute.parserlog.25840.declaration
protected static Logger parserlog = Logger.getLogger("parser"); protected static Logger parserlog = Logger.getLogger("parser");
@ -131,7 +135,6 @@ public class NewClass extends Expr
@Override @Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
//TODO: Das hier noch vervollständigen
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
UndConstraint callConstraints = new UndConstraint(); UndConstraint callConstraints = new UndConstraint();
@ -144,7 +147,19 @@ public class NewClass extends Expr
ret.add(this.arglist.expr.elementAt(i).TYPEExpr(assumptions)); 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)); 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); this.setType(thisT);
return ret; return ret;