CTypeResultSet umbenannt und nicht gebrauchte Funktionen entfernt

This commit is contained in:
JanUlrich 2014-02-09 18:52:04 +01:00
parent 971fb4ad65
commit bda8dbe671
26 changed files with 272 additions and 15678 deletions

View File

@ -81,115 +81,5 @@ public class EqualOp extends RelOp
} }
// ino.end // ino.end
// ino.method.TRExp.24131.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.53 von Martin Pl�micke
* <br/>Achtung Workaround: Wenn die BaseTypes endlich korrekt implementiert sind,
* dann sollte der RefType "Boolean" �berall durch den BaseType "BooleanType"
* ersetzt werden!!! <br>Author: ¿½rg ¿½uerle
* @param binary
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.24131.definition
public CTripleSet TRExp(Binary binary, CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.24131.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr ¿½r Expr1 rufen:
// --------------------------
CTripleSet expr1Set = binary.get_Expr1().TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
// Hier für 2 verschiedene Ebenen abfangen L1= Layer1
Vector<CTypeReconstructionException> exceptionsL1=new Vector<CTypeReconstructionException>();
int successfullsL1=0;
Iterator<CTriple> expr1It = expr1Set.getIterator();
while(expr1It.hasNext()){
CTriple expr1Triple = expr1It.next();
// --------------------------
// TRExpr ¿½r Expr2 rufen:
// --------------------------
try{
CTripleSet expr2Set = binary.get_Expr2().TRExp(expr1Triple.getSubstitutions(), expr1Triple.getAssumptionSet(), supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> expr2It = expr2Set.getIterator();
while(expr2It.hasNext()){
CTriple expr2Triple = expr2It.next();
// --------------------------
// Beide ReturnTypes unifizieren:
// --------------------------
// ty_i <=* ty_i,j :
Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(expr1Triple.getResultType(), expr2Triple.getResultType(), supportData.getFiniteClosure());
// ty_i,j <=* ty_i :
Vector<Vector<Pair>> unifierPossibilities2 = Unify.unify(expr2Triple.getResultType(), expr1Triple.getResultType(), supportData.getFiniteClosure());
// Vereinigen:
Vector<Vector<Pair>> unifierPossibilities = unifierPossibilities2;
for(int k=0; k<unifierPossibilities1.size(); k++){
if(!unifierPossibilities.contains(unifierPossibilities1.elementAt(k))){
unifierPossibilities.addElement(unifierPossibilities1.elementAt(k));
}
}
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Alle ¿½glichen Unifier auf V_i,j anwenden:
// --------------------------
for(int k=0; k<unifierPossibilities.size(); k++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(k));
// --------------------------
// Typannahmen bauen:
// --------------------------
CTypeAssumptionSet V_ij_substituted = expr2Triple.getAssumptionSet().deepCopy();
V_ij_substituted.sub(unifier);
// --------------------------
// Substitutionen bauen:
// --------------------------
CSubstitutionSet substSet = expr2Triple.getSubstitutions().deepCopy();
substSet.applyUnifier(unifier);
substSet.unite(unifier);
// --------------------------
CTriple resultTriple = new CTriple(substSet, new RefType("java.lang.Boolean",-1), V_ij_substituted);
// --------------------------
// Triple zu ¿½ckgabemenge hinzuf�gen
// --------------------------
returnSet.addElement(resultTriple);
}
}
// --------------------------
// Ansonsten Fehlermeldung:
// --------------------------
else {
throw new CTypeReconstructionException("EqualOp.TRExp(): Typ \""+expr1Triple.getResultType()+"\" l�sst sich nicht mit Typ \""+expr2Triple.getResultType()+"\" unifizieren.",this);
}
}
successfullsL1++;
}catch(CTypeReconstructionException tre){
exceptionsL1.addElement(tre);
}
}
if(successfullsL1==0){
if(exceptionsL1.size()==1){
throw exceptionsL1.elementAt(0);
}
throw new CTypeReconstructionException("EqualOp: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptionsL1,this);
}
return returnSet;
}
// ino.end
} }
// ino.end // ino.end

View File

@ -81,111 +81,5 @@ public class NotEqualOp extends RelOp
} }
// ino.end // ino.end
// ino.method.TRExp.24254.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.54 von Martin Pl<EFBFBD>micke
* <br/>Achtung Workaround: Wenn die BaseTypes endlich korrekt implementiert sind,
* dann sollte der RefType "Boolean" <EFBFBD>berall durch den BaseType "BooleanType"
* ersetzt werden!!! <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param binary
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.24254.definition
public CTripleSet TRExp(Binary binary, CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.24254.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr1 rufen:
// --------------------------
CTripleSet expr1Set = binary.get_Expr1().TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> expr1It = expr1Set.getIterator();
int successfulls=0;
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
while(expr1It.hasNext()){
CTriple expr1Triple = expr1It.next();
// --------------------------
// TRExpr f<EFBFBD>r Expr2 rufen:
// --------------------------
try{
CTripleSet expr2Set = binary.get_Expr2().TRExp(expr1Triple.getSubstitutions(), expr1Triple.getAssumptionSet(), supportData);
// --------------------------
// Alle Boolean-Triple nehmen:
// --------------------------
Iterator<CTriple> expr2It = expr2Set.getIterator();
while(expr2It.hasNext()){
CTriple expr2Triple = expr2It.next();
// --------------------------
// Beide ReturnTypes unifizieren:
// --------------------------
// ty_i <=* ty_i,j :
Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(expr1Triple.getResultType(), expr2Triple.getResultType(), supportData.getFiniteClosure());
// ty_i,j <=* ty_i :
Vector<Vector<Pair>> unifierPossibilities2 = Unify.unify(expr2Triple.getResultType(), expr1Triple.getResultType(), supportData.getFiniteClosure());
// Vereinigen:
Vector<Vector<Pair>> unifierPossibilities = unifierPossibilities2;
for(int k=0; k<unifierPossibilities1.size(); k++){
if(!unifierPossibilities.contains(unifierPossibilities1.elementAt(k))){
unifierPossibilities.addElement(unifierPossibilities1.elementAt(k));
}
}
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Alle m<EFBFBD>glichen Unifier auf V_i,j anwenden:
// --------------------------
for(int k=0; k<unifierPossibilities.size(); k++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(k));
// --------------------------
// Typannahmen bauen:
// --------------------------
CTypeAssumptionSet V_ij_substituted = expr2Triple.getAssumptionSet().deepCopy();
V_ij_substituted.sub(unifier);
// --------------------------
// Substitutionen bauen:
// --------------------------
CSubstitutionSet substSet = expr2Triple.getSubstitutions().deepCopy();
substSet.applyUnifier(unifier);
substSet.unite(unifier);
// --------------------------
CTriple resultTriple = new CTriple(substSet, new RefType("java.lang.Boolean",-1), V_ij_substituted);
// --------------------------
// Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// --------------------------
returnSet.addElement(resultTriple);
}
}
// --------------------------
// Ansonsten Fehlermeldung:
// --------------------------
else {
throw new CTypeReconstructionException("NotEqualOp.TRExp(): Typ \""+expr1Triple.getResultType()+"\" l<>sst sich nicht mit Typ \""+expr2Triple.getResultType()+"\" unifizieren.",this);
}
}
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("NotEqualOp: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
return returnSet;
}
// ino.end
} }
// ino.end // ino.end

View File

@ -71,41 +71,6 @@ public abstract class Operator implements IItemWithOffset
public abstract void codegen(ClassFile classfile, CodeAttribute code, Expr expr, boolean neg_not, Vector paralist) public abstract void codegen(ClassFile classfile, CodeAttribute code, Expr expr, boolean neg_not, Vector paralist)
throws JVMCodeException; throws JVMCodeException;
// ino.end // ino.end
// ino.method.TRExp.24279.declaration
public CTripleSet TRExp(Binary binary, CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
{
Vector<CTypeReconstructionException> exceptions = new Vector<CTypeReconstructionException>();
Hashtable<RefType, RefType> opTypes = getOperatorTypes();
Vector<CTripleSet> sets = new Vector<CTripleSet>();
for (RefType type : opTypes.keySet() ) {
try{
sets.addElement(TRExpPossibility(binary,sigma,V,supportData, type, opTypes.get(type)));
}catch(CTypeReconstructionException ex) {
exceptions.addElement(ex);
}
}
if( sets.size() == 0 ) {
throw new CTypeReconstructionException("Keiner der Operatoren konnte auf die Datentypen angewandt werden", exceptions, this);
}
if( sets.size() == 1 ) {
return sets.elementAt(0);
}
CTripleSet result = new CTripleSet();
for ( CTripleSet sset : sets ) {
result.addAll(sset);
}
return result;
}
// ino.end
/** /**
* @author timo * @author timo
@ -116,94 +81,6 @@ public abstract class Operator implements IItemWithOffset
*/ */
protected abstract Hashtable<RefType, RefType> getOperatorTypes( ); protected abstract Hashtable<RefType, RefType> getOperatorTypes( );
public CTripleSet TRExpPossibility(Binary binary, CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData, RefType inputType, RefType outputType)
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr1 rufen:
// --------------------------
CTripleSet expr1Set = binary.get_Expr1().TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> expr1It = expr1Set.getIterator();
while(expr1It.hasNext()){
CTriple expr1Triple = expr1It.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(expr1Triple.getResultType(), inputType, supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities1.size()!=0){
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
int successfulls=0;
for(int i=0; i<unifierPossibilities1.size(); i++){
try{
CSubstitutionSet unifier1 = new CSubstitutionSet(unifierPossibilities1.elementAt(i));
CTriple intTriple1 = expr1Triple.cloneAndApplyUnify(unifier1);
// --------------------------
// TRExpr f<EFBFBD>r Expr2 rufen:
// --------------------------
CTripleSet expr2Set = binary.get_Expr2().TRExp(intTriple1.getSubstitutions(), intTriple1.getAssumptionSet(), supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> expr2It = expr2Set.getIterator();
while(expr2It.hasNext()){
CTriple expr2Triple = expr2It.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities2 = Unify.unify(expr2Triple.getResultType(), inputType, supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities2.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int j=0; j<unifierPossibilities2.size(); j++){
CSubstitutionSet unifier2 = new CSubstitutionSet(unifierPossibilities2.elementAt(j));
CTriple intTriple2 = expr2Triple.cloneAndApplyUnify(unifier2);
intTriple2.setResultType(outputType);
// --------------------------
// Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// --------------------------
subSet.addElement(intTriple2);
}
returnSet.unite(subSet);
}
}
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("RelOp: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("RelOp.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.method.makePrimitive.29391.defdescription type=line // ino.method.makePrimitive.29391.defdescription type=line
// Unter der Annahme, dass sich ein Integer-Objekt auf dem Stack // Unter der Annahme, dass sich ein Integer-Objekt auf dem Stack

View File

@ -87,106 +87,6 @@ public class Assign extends Expr
// ino.method.sc_check.24945.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.24945.body
{
SCStatementException except = null;
try
{
expr1.sc_check(classname, ch, bh, ext, parach, parabh);
}
catch(SCStatementException ex)
{
except=ex;
}
try
{
expr2.sc_check(classname, ch, bh, ext, parach, parabh);
}
catch(SCStatementException ex)
{
if(except==null)
{
except=ex;
}
else
{
Vector<SCExcept> v = ex.get_exlist();
SCExcept hilf;
for(Enumeration<SCExcept> el=v.elements() ; el.hasMoreElements() ; )
{
hilf = el.nextElement();
except.addException(hilf);
}
}
}
expr1.getTypeName();
expr2.getTypeName();
parserlog.debug( "SC -> Expression linker Typ: " + expr1.getTypeName());
parserlog.debug( "SC -> Expression rechter Typ: " + expr1.getTypeName());
if( expr1.getTypeName() == null || expr2.getTypeName() == null )
{
SCExcept ex = new SCExcept();
ex.set_error("Eine Variable ist ohne gesetzten Typ.");
ex.set_statement("Assign");
if( except == null )
{
except=new SCStatementException();
}
except.addException(ex);
}
else
{
if(expr2.getTypeName().equals("__NULL__"))
{
if(ext)
{
parserlog.debug("Assign setzt Variable auf null");
}
}
else
{
if(!expr1.getTypeName().equals(expr2.getTypeName()))
{
// Linker Typ = Rechter Typ
parserlog.debug( "SC -> Linker Typ = Rechter Typ");
if(expr1.getTypeName().equals("int")&&expr2.getTypeName().equals("char"))
{
parserlog.info("ACHTUNG! Hier wird einem int ein char zugewiesen.");
if(expr1.get_UsedId()==null)
{
parserlog.error("UsedId geht net");
}
parserlog.debug("int "+expr1.get_UsedId().get_Name().toString()+" = char "+expr2.get_UsedId().get_Name().toString());
}
else
{
if(ext)
{
parserlog.error("Typfehler: -->Assign.sc_check() ");
}
SCExcept neu=new SCExcept();
neu.set_error("Typfehler");
neu.set_statement("Assign: "+expr1.getTypeName()+" = "+expr2.getTypeName());
if(except == null)
{
except=new SCStatementException();
}
except.addException(neu);
}
}
}
}
if(except!= null)
{
throw except;
}
}
// ino.end
// ino.method.get_Name.24948.definition // ino.method.get_Name.24948.definition
@ -315,148 +215,7 @@ public class Assign extends Expr
return ret; return ret;
} }
// ino.method.TRExp.24954.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.30 von Martin Pl<EFBFBD>micke
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.24954.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.24954.body
{
CTripleSet returnSet = new CTripleSet();
Vector<Expr> epressions = new Vector<Expr>();
epressions.addElement(this.expr1);
epressions.addElement(this.expr2);
// --------------------------
// TRTuple rufen:
// --------------------------
CMultiplyTupleSet tupleSet = this.TRTuple(new CMultiplyTuple(sigma, new Vector<Type>(), V), epressions, supportData);
Iterator<CMultiplyTuple> tupleIt = tupleSet.getIterator();
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
while(tupleIt.hasNext()){
CMultiplyTuple tuple = tupleIt.next();
if(tuple.getResultTypes().size()!=2){
throw new CTypeReconstructionException("Assign.TRExp(): Ung<6E>ltige Anzahl von ReturnTypes",this);
}
// --------------------------
// Die beiden ReturnTypes unifizieren:
// --------------------------
Type ty1 = tuple.getResultTypes().elementAt(0);
Type ty2 = tuple.getResultTypes().elementAt(1);
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(ty2, ty1, supportData.getFiniteClosure());
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Alle m<EFBFBD>glichen Unifier auf V anwenden:
// --------------------------
for(int k=0; k<unifierPossibilities.size(); k++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(k));
// --------------------------
// Typannahmen bauen:
// --------------------------
CTypeAssumptionSet V_substituted = tuple.getAssumptionSet().deepCopy();
V_substituted.sub(unifier);
// --------------------------
// Substitutionen bauen:
// --------------------------
CSubstitutionSet substitutionSet = tuple.getSubstitutions().deepCopy();
substitutionSet.applyUnifier(unifier);
substitutionSet.unite(unifier);
//PL geaendert 05-08-23 applyThisSubstitutionSet eingefuegt
// --------------------------
// R<EFBFBD>ckgabetyp bauen:
// --------------------------
// if(ty1 instanceof TypePlaceholder){
// Iterator<CSubstitution> pairIt = unifier.getIterator();
// while(pairIt.hasNext()){
// CSubstitution pair = pairIt.next();
// if(pair.getTypeVar().getName().equals(ty1.getName())){
// ty1 = pair.getType();
// break;
// }
// }
// }
// --------------------------
CTriple subTriple = new CTriple(substitutionSet, substitutionSet.applyThisSubstitutionSet(ty1), V_substituted);
// --------------------------
// Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// --------------------------
subSet.addElement(subTriple);
}
}
// --------------------------
// Ansonsten Fehlermeldung:
// --------------------------
else {
//MUSS AUSSERHALB DER ITERATOR WHILE-SRHLEIFE PL 07-08-11 STEHEN
//throw new CTypeReconstructionException("Assign.TRExp(): Typen "+ty1+" und "+ty2+" lassen sich nicht unifizieren.",this);
exceptions.add(new CTypeReconstructionException("Assign.TRExp(): Typen "+ty1+" und "+ty2+" lassen sich nicht unifizieren.",this));
}
returnSet.unite(subSet);
}
//CTripleSet returnSet2 = super.unifyAndRegisterType(returnSet, supportData);
CTripleSet returnSet2 = super.registerType(returnSet, supportData);
//eingefuegt PL 07-08-11
//Anfang
if(returnSet.getCardinality()==0){
if (exceptions.size()==1) {
throw exceptions.elementAt(0);
}
else {
throw new CTypeReconstructionException("Assign.TRExp(): Es gibt kein Typpaar das sich unifizieren laesst.",this);
}
}
//Ende
return returnSet2;
}
// ino.end
// ino.method.TRStatement.24957.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.25 von Martin Pl<EFBFBD>micke
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRStatement.24957.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.24957.body
{
CTripleSet resultSet = this.TRExp(sigma, V, supportData);
resultSet = resultSet.deepCopy();
Iterator<CTriple> it = resultSet.getIterator();
while(it.hasNext()){
it.next().setResultType(new Void(getOffset()));
}
return resultSet;
}
// ino.end
// ino.method.toString.24960.defdescription type=javadoc // ino.method.toString.24960.defdescription type=javadoc
/** /**

View File

@ -76,73 +76,6 @@ public class Binary extends BinaryExpr
public Expr expr2; public Expr expr2;
// ino.end // ino.end
// ino.method.sc_check.24985.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.24985.body
{
Operator testen = get_Operator();
if(ext)
parserlog.debug(" ---Binary---");
SCStatementException except=null;
try
{
expr1.sc_check(classname, ch, bh, ext, parach, parabh);
parserlog.debug("expr1.get_Type: "+expr1.getTypeName());
}
catch(SCStatementException ex)
{
except=ex;
}
try
{
expr2.sc_check(classname, ch, bh, ext, parach, parabh);
parserlog.debug("expr1.get_Type: "+expr2.getTypeName());
}
//System/.out.println(expr1.get_Type());
//System/.out.println(expr2.get_Type());
catch(SCStatementException ex)
{
if(except==null)
except=ex;
else
{
Vector<SCExcept> v;
SCExcept hilf;
v=ex.get_exlist();
for(Enumeration<SCExcept> el=v.elements();el.hasMoreElements();)
{
hilf=el.nextElement();
except.addException(hilf);
}
}
}
//Type type1 = new Type(expr1.getTypeName());
if(!expr1.getTypeName().equals(expr2.getTypeName()))
{
if(ext)
parserlog.error("Typfehler: -->Binary.sc_check() ");
SCExcept neu=new SCExcept();
neu.set_error("Typfehler: "+expr1.getTypeName()+" != "+expr2.getTypeName());
neu.set_statement("Binary");
if(except==null)
except=new SCStatementException();
except.addException(neu);
}
else
{
if(testen instanceof AddOp ||testen instanceof MulOp)
this.setType(new Type(expr1.getTypeName(),getOffset()));
else
this.setType(new Type("boolean",getOffset()));
}
if(except!=null)
throw except;
}
// ino.end
// ino.method.set_Expr1.24988.definition // ino.method.set_Expr1.24988.definition
public void set_Expr1(Expr exp) public void set_Expr1(Expr exp)
@ -300,68 +233,6 @@ public class Binary extends BinaryExpr
// ino.method.TRExp.25021.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException
// ino.end
// ino.method.TRExp.25021.body
{
CTripleSet ret = op.TRExp(this, sigma, V, supportData);
//CTripleSet returnSet = super.unifyAndRegisterType(ret, supportData);
CTripleSet returnSet = super.registerType(ret, supportData);
// //CTripleSet expr2Set = binary.get_Expr2().TRExp(intTriple1.getSubstitutions(), intTriple1.getAssumptionSet(), supportData);
// // --------------------------
// // Alle Triple durchgehen:
// // --------------------------
// Iterator retIt = ret.getIterator();
// while(retIt.hasNext()){
// CTriple retTriple = (CTriple)retIt.next();
// // --------------------------
// // ReturnType mit type von this (Binary) unifizieren:
// // --------------------------
// Vector<Vector<Pair>> unifierPossibilities = Unify.unify(retTriple.getResultType(), this.getType(), supportData.getFiniteClosure());
// // --------------------------
// // Wenn Unifier vorhanden, dann
// // anwenden und Triple hinzuf<EFBFBD>gen:
// // --------------------------
// if(unifierPossibilities.size()!=0){
// // --------------------------
// // Subset bauen:
// // --------------------------
// CTripleSet subSet = new CTripleSet();
// // --------------------------
// // Alle m<EFBFBD>glichen Unifier anwenden:
// // --------------------------
// for(int j=0; j<unifierPossibilities.size(); j++){
// CSubstitutionSet unifier2 = new CSubstitutionSet(unifierPossibilities.elementAt(j));
// CTriple intTriple2 = retTriple.cloneAndApplyUnify(unifier2);
// //intTriple2.setResultType(new RefType("Boolean"));
// intTriple2.setResultType(unifier2.applyThisSubstitutionSet(this.getType()));
// // --------------------------
// // Triple zu R<EFBFBD>ckgabemenge hinzuf<EFBFBD>gen
// // --------------------------
// subSet.addElement(intTriple2);
// }
// returnSet.unite(subSet);
// }
// }
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("RelOp.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ "+this.getTypeName()+" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.25024.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.25024.body
{
throw CTypeReconstructionException.createNotImplementedException();
}
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25027.definition // ino.method.wandleRefTypeAttributes2GenericAttributes.25027.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)

View File

@ -86,54 +86,6 @@ public class Block extends Statement
// ino.end // ino.end
protected static Logger typinferenceLog = Logger.getLogger("Typeinference"); protected static Logger typinferenceLog = Logger.getLogger("Typeinference");
// ino.method.sc_check.25062.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String,String> bh, boolean ext, Hashtable parach, Hashtable<String,Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25062.body
{
SCStatementException except = null;
SCExcept hilfex;
Statement tempStatement;
Vector<SCExcept> v;
this.HashTabelleKlasse = ch;
this.HashTabelleBlock = (Hashtable) bh.clone();
this.block_para = (Hashtable) parabh.clone();
// otth: Alle Statements durchgehen und von allen Statements den Semantik-Check machen
parserlog.debug( "Statements (Anzahl): " + statements.size());
parserlog.debug( "Statements: " + statements);
for( Enumeration<Statement> el = this.statements.elements(); el.hasMoreElements(); )
{
tempStatement = el.nextElement();
try
{
// Semantik-Check
tempStatement.sc_check( classname, HashTabelleKlasse, HashTabelleBlock, ext, parach, block_para );
}
catch (SCStatementException ex)
{
// Fehler abfangen
if( except==null )
except=new SCStatementException();
v = ex.get_exlist();
for( Enumeration<SCExcept> el1=v.elements();el1.hasMoreElements(); )
{
hilfex=el1.nextElement();
except.addException(hilfex);
}
}
}
if(except!=null)
{
throw except;
}
parserlog.debug("SC -> SC f�r Block war erfoglreich!");
parserlog.debug("SC -> Blockhashtabelle: " + HashTabelleBlock);
}
// ino.end
// ino.method.get_Statement.25065.definition // ino.method.get_Statement.25065.definition
@ -188,125 +140,7 @@ public class Block extends Statement
// TypeReconstructionAlgorithmus // TypeReconstructionAlgorithmus
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// ino.method.TRStatement.25077.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.20 von Martin Pl�micke
* <br>Author: ¿½rg ¿½uerle
* @param sigma
* @param V
* @param supportData
* @return
* @throws CTypeReconstructionException
*/
// ino.end
// ino.method.TRStatement.25077.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException
// ino.end
// ino.method.TRStatement.25077.body
{
supportData.incBlockDepth();
CTypeAssumptionSet V_Start = V.shallowCopy();
CTripleSet returnSet = this.TRStatements(sigma, V, statements, 0, V_Start, supportData);
supportData.decBlockDepth();
return returnSet;
}
// ino.end
// ino.method.TRStatements.25080.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.19 von Martin Pl�micke
* <br/>Author: ¿½rg ¿½uerle
* @param sigma
* @param V
* @param statementList
* @param index
* @param V_start
* @param supportData
* @return
* @throws CTypeReconstructionException
*/
// ino.end
// ino.method.TRStatements.25080.definition
public CTripleSet TRStatements(CSubstitutionSet sigma, CTypeAssumptionSet V, Vector<Statement> statementList, int index, CTypeAssumptionSet V_start, CSupportData supportData)
throws CTypeReconstructionException
// ino.end
// ino.method.TRStatements.25080.body
{
CTripleSet returnSet = new CTripleSet();
////////////////////
// Leere Statementsliste:
////////////////////
if(index>statements.size()-1){
// HOTI Bei leeren Blöcken sollte dann schon aber auch was zurück gegeben werden
if(statements.size()==0){
returnSet.addElement(new CTriple(sigma, new Void(this.getOffset()), V));
}
return returnSet;
}
////////////////////
// Letztes Statement erreicht (Rekursionsanker):
////////////////////
if(index==statements.size()-1){
// TRStatement ¿½r aktuelles Statement rufen:
Statement stmnt = statementList.elementAt(index);
returnSet = stmnt.TRStatement(sigma, V, supportData);
inferencelog.debug(stmnt.toString());
// Das ¿½schen von Typannahmen ¿½r lokale Variablen ist bei dieser Implementierung nicht notwendig.
// Im Gegenteil: Die lokalen Variablen ¿½ssen sogar erhalten bleiben.
}
////////////////////
// Statementliste rekursiv durcharbeiten:
////////////////////
else{
// TRStatement ¿½r aktuelles Statement rufen:
Statement stmnt = statementList.elementAt(index);
//setze Block ¿½r Offset-Setzung ¿½r lokale Variablen
if(stmnt instanceof LocalVarDecl)//hinzugef�gt hoth: 07.04.2006
{
LocalVarDecl lokaleVar = (LocalVarDecl)stmnt;
lokaleVar.block=this;
}
CTripleSet set = stmnt.TRStatement(sigma, V, supportData);
// Alle ¿½glichen Kombinationen herstellen:
Iterator<CTriple> it = set.getIterator();
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
int successfulls=0;
while(it.hasNext()){
CTriple triple = it.next();
if (it.hasNext()) {
inferencelog.debug(stmnt.toString());
}
// Rekursionsaufruf:
if(triple.getResultType() instanceof Void){
// SupportData muss geklont werden, damit BlockID nicht mehrmals hochgez�hlt wird...
try{
CTripleSet subset = this.TRStatements(triple.getSubstitutions(),triple.getAssumptionSet(),statementList,index+1,V_start,supportData.clone());
// Rekursions-¿½ckgabewert mit aktueller Menge vereinigen:
returnSet.unite(subset);
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
}
else {
throw new CTypeReconstructionException("Block.TRStatements(): Unerreichbare Anweisung",this);
}
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("Block: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
}
return returnSet;
}
// ino.end
// ino.method.toString.25083.defdescription type=javadoc // ino.method.toString.25083.defdescription type=javadoc
/** /**

View File

@ -60,41 +60,6 @@ public class CastExpr extends UnaryExpr
// ino.end // ino.end
// ino.method.sc_check.25142.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25142.body
{
if(ext)
parserlog.debug(" ---CastExpr---");
SCStatementException except=null;
if(ext)
parserlog.debug("CastExpr.sc_check() berechnet Typ von expr und ceckt kompatibilitaet");
try
{
expr.sc_check(classname, ch, bh, ext, parach, parabh);
}
catch(SCStatementException ex)
{
except=ex;
}
if(this.type.getName() != expr.getTypeName())
{
if(ext)
parserlog.error("Typinkompatibilitaet - moeglicher Datenverlust --> CastExpr.sc_check() ");
SCExcept neu=new SCExcept();
neu.set_error("Typfehler");
neu.set_statement("ArrayAccess");
if(except==null)
except=new SCStatementException();
except.addException(neu);
}
if(except!=null)
throw except;
}
// ino.end
// ino.method.get_Name.25145.definition // ino.method.get_Name.25145.definition
@ -155,47 +120,6 @@ public class CastExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.TRExp.25157.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.43 von Martin Pl<EFBFBD>micke
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25157.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25157.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// ReturnType der Triple <EFBFBD>ndern:
// --------------------------
Iterator<CTriple> exprIt = exprSet.deepCopy().getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
exprTriple.setResultType(this.type);
returnSet.addElement(exprTriple);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.25160.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.25160.body
{
throw CTypeReconstructionException.createNotImplementedException();
}
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.25163.definition // ino.method.wandleRefTypeAttributes2GenericAttributes.25163.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)

View File

@ -70,184 +70,6 @@ public class ForStmt extends Statement
} }
/**
* Implementierung des Algorithmus 5.23 von Martin Pl�micke
* <br/>Achtung Workaround: RefType "Boolean" muss noch durch BaseType
* "BooleanType" ersetzt werden.
* <br>Author: ¿½rg ¿½uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
{
CTripleSet start_set = new CTripleSet();
CTripleSet init_set = new CTripleSet();
CTripleSet cond_set = new CTripleSet();
CTripleSet return_set = new CTripleSet();
//Expressions kopieren für die Typrekonstruktion um Codegen nicht zu tangieren
head_Initializer_1 = head_Initializer;
head_Condition_1 = head_Condition;
head_Loop_expr_1 = head_Loop_expr;
//Fälle überprüfen, in denen nicht alle drei Expressions im Schleifenkopf existieren
//Überprüfen, ob eine Expression existiert und diese in ersatz speichern
boolean condition_exists = true;
Expr ersatz = null;
if(head_Initializer_1 == null){
if(head_Condition_1 == null){
condition_exists = false;
if(head_Loop_expr_1 == null){
//Falls keine Expression existiert, nur TRStatement mit Loop-Block
return_set = body_Loop_block.TRStatement(sigma, V,supportData);
return return_set;
}
else ersatz = head_Loop_expr_1;
}
else ersatz = head_Condition_1;
}
else ersatz = head_Initializer_1;
//Falls mindestens eine Expression existiert, werden die leeren mit ersatz überschrieben
if(ersatz != null){
if(head_Initializer_1 == null) head_Initializer_1 = ersatz;
if(head_Condition_1 == null) head_Condition_1 = ersatz;
if(head_Loop_expr_1 == null) head_Loop_expr_1 = ersatz;
}
//Folgender Code wird ausgeführt, wenn mindestens eine Expression existiert
start_set = head_Initializer_1.TRExp(sigma,V,supportData);
Iterator<CTriple> it_init = start_set.getIterator();
//--------------------------
// Initializer-Typ rekonstruieren:
// --------------------------
int successfulls1 = 0;
Vector<CTypeReconstructionException> exceptions1 = new Vector<CTypeReconstructionException>();
while( it_init.hasNext() ) {
// CTriple initTriple = it_init.next();
// init_set.unite(head_Condition_1.TRExp(initTriple.getSubstitutions(), initTriple.getAssumptionSet(),supportData));
// //init_set = head_Condition_1.TRExp(initTriple.getSubstitutions(), initTriple.getAssumptionSet(),supportData);
// Type r = initTriple.getResultType();
try{
CTriple initTriple = it_init.next();
CTripleSet condit = head_Condition_1.TRExp(initTriple.getSubstitutions(), initTriple.getAssumptionSet (),supportData);
init_set.unite( condit );
//init_set = head_Condition_1.TRExp(initTriple.getSubstitutions(), initTriple.getAssumptionSet(),supportData);
Type r = initTriple.getResultType ();
successfulls1++;
} catch (CTypeReconstructionException tre) {
exceptions1.addElement(tre);
}
}
if (successfulls1 == 0) {
if (exceptions1.size() == 1) {
throw exceptions1.elementAt(0);
}
throw new CTypeReconstructionException(
"ForStmt: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",
exceptions1, this);
}
Iterator<CTriple> it_cond = init_set.getIterator();
while(it_cond.hasNext()){
CTriple condTriple = it_cond.next();
//Wird ausgeführt, falls die Condition existiert
if(condition_exists == true){
// --------------------------
// Rückgabe der Condition mit Boolean unifizieren:
// --------------------------
Vector<Vector<Pair>> cond_poss = Unify.unify(condTriple.getResultType(), new RefType("java.lang.Boolean",getOffset()), supportData.getFiniteClosure());
// System.out.println("cond_set:"+cond_set.toString());
// System.out.println("condTriple:"+condTriple.toString());
if (cond_poss.size() != 0) {
// --------------------------
// Alle möglichen Unifier anwenden:
// --------------------------
int successfulls = 0;
Vector<CTypeReconstructionException> exceptions = new Vector<CTypeReconstructionException>();
for (int i = 0; i < cond_poss.size(); i++) {
// --------------------------
// Condition-Typ rekonstruieren:
// --------------------------
try {
CSubstitutionSet unifier = new CSubstitutionSet(cond_poss.elementAt(i));
CTriple boolTriple = condTriple.cloneAndApplyUnify(unifier);
cond_set.unite(head_Loop_expr_1.TRExp(boolTriple.getSubstitutions(),
boolTriple.getAssumptionSet(), supportData));
successfulls++;
} catch (CTypeReconstructionException tre) {
exceptions.addElement(tre);
}
if (successfulls == 0) {
if (exceptions.size() == 1) {
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException(
"ForStmt: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",
exceptions, this);
}
}
} else {
throw new CTypeReconstructionException("ForStmt.TRStatement(): Bedingung muss boolean sein!",this);
}
}
//Wird ausgeführt, falls keine Condition existiert
else{
int successfulls2 = 0;
Vector<CTypeReconstructionException> exceptions2 = new Vector<CTypeReconstructionException>();
try{
CTripleSet condit = head_Loop_expr_1.TRExp(condTriple.getSubstitutions(), condTriple.getAssumptionSet (),supportData);
cond_set.unite( condit );
successfulls2++;
} catch (CTypeReconstructionException tre) {
exceptions2.addElement(tre);
}
if (successfulls2 == 0) {
if (exceptions2.size() == 1) {
throw exceptions2.elementAt(0);
}
throw new CTypeReconstructionException(
"ForStmt: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",
exceptions2, this);
}
}
}
Iterator<CTriple> it_loop_block = cond_set.getIterator();
// --------------------------
// Loop-Expression-Typ rekonstruieren:
// --------------------------
while( it_loop_block.hasNext() ) {
CTriple loop_blockTriple = it_loop_block.next();
return_set.unite(body_Loop_block.TRStatement(loop_blockTriple.getSubstitutions(), loop_blockTriple.getAssumptionSet(),supportData));
}
return return_set;
}
public String toString() public String toString()
{ {

View File

@ -116,79 +116,6 @@ public class IfStmt extends Statement
// ino.method.sc_check.25331.definition
void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25331.body
{
if(ext)
{
parserlog.debug(" ---IfStmt---");
}
SCStatementException exc = null;
try
{
expr.sc_check(classname,ch,bh,ext,parach, parabh);
}
catch(SCStatementException ex)
{
exc = ex;
}
try
{
then_block.sc_check(classname,ch,(Hashtable) bh.clone(), ext, parach, (Hashtable)parabh.clone());
}
catch(SCStatementException ex)
{
if(exc == null)
{
exc = ex;
}
else
{
Vector<SCExcept> v=ex.get_exlist();
SCExcept hilfe;
for(Enumeration<SCExcept> el = v.elements() ; el.hasMoreElements() ; )
{
hilfe=el.nextElement();
exc.addException(hilfe);
}
}
}
if(else_block != null)
{
try
{
else_block.sc_check(classname,ch,(Hashtable) bh.clone(), ext, parach, (Hashtable)parabh.clone());
}
catch(SCStatementException ex)
{
if(exc == null)
{
exc=ex;
}
else
{
Vector<SCExcept> v=ex.get_exlist();
SCExcept hilfe;
for(Enumeration<SCExcept> el=v.elements() ; el.hasMoreElements() ; )
{
hilfe=el.nextElement();
exc.addException(hilfe);
}
}
}
}
if(exc != null)
{
throw exc;
}
}
// ino.end
// ino.method.codegen.25334.definition // ino.method.codegen.25334.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
@ -314,143 +241,6 @@ public class IfStmt extends Statement
// ino.method.TRStatement.25340.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.21 von Martin Pl<EFBFBD>micke
* <br/>Achtung Workaround: RefType "Boolean" durch BaseType \code{BooleanType}
* ersetzen. <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRStatement.25340.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException
// ino.end
// ino.method.TRStatement.25340.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// Bedingungsausdruck rekonstruieren:
// --------------------------
CTripleSet exprTSet = this.expr.TRExp(sigma, V, supportData);
// --------------------------
// Bedingungs-Triple durchgehen:
// --------------------------
Iterator<CTriple> exprTIt = exprTSet.getIterator();
while(exprTIt.hasNext()){
CTriple exprTriple = exprTIt.next();
// --------------------------
// ReturnType mit Boolean unifizieren:
// --------------------------
// Sollte doch mit "boolean" statt "Boolean" unifiziert werden?
// Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(exprTriple.getResultType(), new BooleanType()/*new RefType("Boolean")*/, supportData.getFiniteClosure());
Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Boolean",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities1.size()!=0){
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
int successfulls=0;
for(int i=0; i<unifierPossibilities1.size(); i++){
try{
CSubstitutionSet unifier1 = new CSubstitutionSet(unifierPossibilities1.elementAt(i));
CTriple boolTriple = exprTriple.cloneAndApplyUnify(unifier1);
// --------------------------
// Then-Zweig rekonstruieren:
// --------------------------
CTripleSet thenTSet = this.then_block.TRStatement(boolTriple.getSubstitutions(), boolTriple.getAssumptionSet(), supportData);
// --------------------------
// ReturnType <EFBFBD>berpr<EFBFBD>fen:
// --------------------------
boolean isThenBlockVoid = false;
if(thenTSet.getCardinality()!=0){
isThenBlockVoid = (thenTSet.getVector().firstElement().getResultType() instanceof Void);
}
// --------------------------
// Then-Triples durchgehen:
// --------------------------
Iterator<CTriple> thenTIt = thenTSet.getIterator();
while(thenTIt.hasNext()){
CTriple thenTriple = thenTIt.next();
// --------------------------
// Else-Zweig rekonstruieren:
// --------------------------
if(this.else_block==null){
returnSet.addElement(thenTriple);
continue;
}
CTripleSet elseTSet = this.else_block.TRStatement(thenTriple.getSubstitutions(), thenTriple.getAssumptionSet(), supportData);
// --------------------------
// ReturnType <EFBFBD>berpr<EFBFBD>fen:
// --------------------------
//boolean isElseBlockVoid = false;
if(elseTSet.getCardinality()!=0){
///*isElseBlockVoid =*/ (((CTriple)elseTSet.getVector().firstElement()).getResultType() instanceof Void);
}
// --------------------------
// Else-Triples durchgehen:
// --------------------------
Iterator<CTriple> elseTIt = elseTSet.getIterator();
while(elseTIt.hasNext()){
CTriple elseTriple = elseTIt.next();
// --------------------------
// Wenn Void, Typannahmen zur<EFBFBD>ckliefern:
// --------------------------
if(isThenBlockVoid){
/*
Urspr<EFBFBD>nglich nach Pl<EFBFBD>micke:
if(isElseBlockVoid){
returnSet.addElement(new CTriple(elseTriple.getSubstitutions(), elseTriple.getResultType(), elseTriple.getAssumptionSet()));
}
else {
throw new CTypeReconstructionException("IfStmt.TRStatement(): Typen nicht vereinbar - Then-Zweig hat ReturnType, Else-Zweig ist Void");
} */ // Korrekt aber so:
returnSet.addElement(new CTriple(elseTriple.getSubstitutions(), elseTriple.getResultType(), elseTriple.getAssumptionSet()));
}
// --------------------------+
// Ansonsten ReturnTypes-unifizieren:
// --------------------------
else {
// --------------------------
// MUB berechen
// --------------------------
MUB mub = Unify.unify_Mub(thenTriple.getResultType(), elseTriple.getResultType(), supportData.getFiniteClosure());
// --------------------------
// Unifier anwenden:
// --------------------------
this.makeNewResult(mub, elseTriple, elseTriple.getAssumptionSet(), returnSet);
}
}
}
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("IfStmt: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
}else {
throw new CTypeReconstructionException("IfStmt.TRStatement(): Bedingung muss boolean sein!",this);
}
}
return returnSet;
}
// ino.end
// ino.method.makeNewResult.25343.definition // ino.method.makeNewResult.25343.definition
private void makeNewResult(MUB Mub, CTriple triple, CTypeAssumptionSet V, CTripleSet returnSet) private void makeNewResult(MUB Mub, CTriple triple, CTypeAssumptionSet V, CTripleSet returnSet)
throws CTypeReconstructionException throws CTypeReconstructionException

View File

@ -184,108 +184,7 @@ public class InstVar extends Expr
} }
// ino.end // ino.end
// ino.method.TRExp.25432.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.38 von Martin Pl<EFBFBD>micke
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25432.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25432.body
{
CTripleSet resultSet = new CTripleSet();
CTripleSet tripleSet = this.expr.TRExp(sigma, V, supportData);
Iterator<CTriple> tripleIt = tripleSet.getIterator();
while(tripleIt.hasNext()){
CTriple triple = tripleIt.next();
CTripleSet instVarSet = this.TRInstVar(triple, supportData);
resultSet.unite(instVarSet);
}
//PL 05-08-17 unifyAndRegisterType eingebaut
//return resultSet;
CTripleSet resultSet2 = super.registerType(resultSet, supportData);
return resultSet2;
}
// ino.end
// ino.method.TRInstVar.25435.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.38-1 von Martin Pl<EFBFBD>micke
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param triple
* @param supportData
* @return
*/
// ino.end
// ino.method.TRInstVar.25435.definition
public CTripleSet TRInstVar(CTriple triple, CSupportData supportData)
// ino.end
// ino.method.TRInstVar.25435.body
{
CTripleSet returnSet = new CTripleSet();
// ##########################
// 1. Alle bisherigen Typkombinationen durchgehen:
// ##########################
for(int i=0; i<supportData.getA().size(); i++){
TypeinferenceResultSet possibleComb = supportData.getA().elementAt(i);
// --------------------------
// Alle Klassen durchsuchen:
// --------------------------
for(int j=0; j<possibleComb.getClassNameList().size(); j++){
String className = possibleComb.getClassNameList().elementAt(j); // ReceiverName
// --------------------------
// Typannahme f<EFBFBD>r Methode heraussuchen:
// --------------------------
//PL geaendert 05-08-04 get_Name durch usedid.get_Name_1Element() ersetzt
//CInstVarKey key = new CInstVarKey(className, this.get_Name());
CInstVarKey key = new CInstVarKey(className, this.usedid.get_Name_1Element());
CInstVarTypeAssumption instAssum = (CInstVarTypeAssumption)possibleComb.getFieldAndLocalVarAssumptions().get(key);
// --------------------------
// Typen rekonstruieren:
// --------------------------
if(instAssum!=null){
this.handleInstVarAssum(triple, new RefType(className,getOffset()), instAssum.getAssumedType(), returnSet, supportData);
}
}
}
// ##########################
// 2. Aktuelle Klasse durchsuchen:
// ##########################
// --------------------------
// Typannahme f<EFBFBD>r Methode heraussuchen:
// --------------------------
//PL geaendert 05-08-04 get_Name durch usedid.get_Name_1Element() ersetzt
//CInstVarKey key = new CInstVarKey(supportData.getCurrentClass(), this.get_Name());
CInstVarKey key = new CInstVarKey(supportData.getCurrentClass(), this.usedid.get_Name_1Element());
CInstVarTypeAssumption instAssum = (CInstVarTypeAssumption)triple.getAssumptionSet().getElement(key);
// --------------------------
// Typen rekonstruieren:
// --------------------------
if(instAssum!=null){
//PL 05-08-18 geaendert
this.handleInstVarAssum(triple, new RefType(supportData.getCurrentClass(), supportData.getCurrentClassPara(),getOffset()), instAssum.getAssumedType(), returnSet, supportData);
//this.handleInstVarAssum(triple, new RefType(supportData.getCurrentClass()), instAssum.getAssumedType(), returnSet, supportData);
}
// ##########################
// 3. Ergebnismenge zur<EFBFBD>ckgeben:
// ##########################
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("InstVar.TRInstVar(): Die angegebene Feldvariable " + this.usedid.getQualifiedName() + " konnte mit keiner bekannten Feldvariable unifiziert werden.",this);
}
return returnSet;
}
// ino.end
// ino.method.handleInstVarAssum.25438.defdescription type=javadoc // ino.method.handleInstVarAssum.25438.defdescription type=javadoc
/** /**

View File

@ -86,88 +86,6 @@ public class InstanceOf extends BinaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.25374.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25374.body
{
if(ext)
parserlog.debug(" ---InstanceOf---");
Class cl;
String hilf, basis;
boolean merker=false;
if(ext)
parserlog.debug("InstanceOf ruft sc_check von expr auf");
try
{
expr.sc_check(classname,ch,bh,ext, parach, parabh);
}
catch(SCStatementException ex)
{
throw ex;
}
if(ext)
parserlog.debug("InstanceOf pr<70>ft Typgleichheit: ");
if(expr.getTypeName().equals(reftype.getName()))
{
//is_instance = true;
if(ext)
parserlog.debug("...erf<72>llt!");
}
else
{
//is_instance = false;
if(ext)
parserlog.debug("...nicht erf<72>llt!");
}
if(!reftype.getName().equals("int")|| !reftype.getName().equals("char") || !reftype.getName().equals("String") || !reftype.getName().equals("boolean"))
{
if(ext)
parserlog.debug("Pr<EFBFBD>fe auf Basisklassen");
hilf=expr.getTypeName();
for(;;)
{
if(merker)
break;
for(Enumeration<Class> el=classname.elements();el.hasMoreElements();)
{
cl=el.nextElement();
if(cl.getName().equals(hilf))
{
basis=cl.get_Superclass_Name();
if(basis==null)
{
if(ext)
parserlog.debug("Keine Basisklasse gefunden!");
//is_instance=false;
merker=true;
break;
}
else
if(reftype.getName().equals(basis))
{
if(ext)
parserlog.debug("Basisklasse "+basis+" gefunden!Typ korrekt!");
merker=true;
break;
}
else
{
if(ext)
parserlog.debug("Gehe in n<>chste Vererbungsebene......");
hilf=basis;
merker=false;
break;
}
}
}
}
}
}
// ino.end
// ino.method.get_Name.25377.definition // ino.method.get_Name.25377.definition
public String get_Name() public String get_Name()

View File

@ -66,14 +66,6 @@ public class LambdaExpression extends Expr{
this.params = params; this.params = params;
} }
@Override
public
void sc_check(Vector<Class> classlist, Hashtable ch,
Hashtable<String, String> bh, boolean ext, Hashtable parach,
Hashtable<String, Hashtable> parabh) throws SCStatementException {
// TODO Auto-generated method stub
}
@Override @Override
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
@ -82,15 +74,6 @@ public class LambdaExpression extends Expr{
} }
@Override
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V,
CSupportData supportData) throws CTypeReconstructionException {
// TODO An dieser Funktion weiterarbeiten
CTripleSet ret;
ret = new CTripleSet();
//ret.
return ret;
}
@Override @Override
public void wandleRefTypeAttributes2GenericAttributes( public void wandleRefTypeAttributes2GenericAttributes(
@ -113,14 +96,6 @@ public class LambdaExpression extends Expr{
return null; return null;
} }
@Override
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V,
CSupportData supportData) throws CTypeReconstructionException {
// Diese Funktion wird aufgerufen wenn die LambdaExpression als Expression behandelt wird.
CTripleSet tripleSet = new CTripleSet();
tripleSet.addElement(new CTriple(sigma, new DoubleType(),V));
return tripleSet;
}
@Override @Override
public void addOffsetsToExpression(CTypeAssumption localAssumption, public void addOffsetsToExpression(CTypeAssumption localAssumption,

View File

@ -73,185 +73,6 @@ public class LocalOrFieldVar extends Expr
} }
// ino.end // ino.end
// ino.method.sc_check.25516.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25516.body
{
Vector<String> typen = new Vector<String>();
SCStatementException except=null;
Vector name = usedid.get_Name();
Class klasse = null;
Class hilfe = null;
String hilfstr;
Hashtable parahilf=null;
for(Enumeration el = name.elements(); el.hasMoreElements();)
{
String name1 = (String) el.nextElement();
if(klasse!=null) //hier geht's rein, wenn eine Instanzvariable gefunden wurde
{
if(!el.hasMoreElements()) //es folgen keine weiteren Strings mehr -> name1 muss der Variablen-Name sein.
{
this.setType(new Type(klasse.is_member(name1),getOffset()));
if(klasse.get_ParaHash().containsKey(name1))
{
/* Typ der Klasse ist parametrisierbar, nach Zuweisung schauen */
if(parahilf!=null){
this.setType((Type)parahilf.get(name1));
for(Enumeration e3=parahilf.keys();e3.hasMoreElements();)
{
// System.out.println("parahilf.typen "+ (String)e3.nextElement());
// System.out.print("+++++++++ "+type.get_Type()+" ");
parserlog.debug(string_rec(parahilf));
// System.out.println();
}
}
}
if(this.getType().getName()==null)
{
SCExcept exc = new SCExcept();
except = new SCStatementException();
exc.set_error("Variable "+name1+" nicht gefunden");
exc.set_statement("LocalOrFieldVar");
except.addException(exc);
throw except;
}
else
{
typen.addElement(this.getType().getName());
}
}
else //es folgen Strings -> weitere Klassen m<EFBFBD>ssen auf die Variable <EFBFBD>berpr<EFBFBD>ft werden
{
this.setType(new Type(klasse.is_member(name1),getOffset()));
if( this.getType().getName() == null )
{
SCExcept exc=new SCExcept();
except=new SCStatementException();
exc.set_error("Variable "+name1+" nicht gefunden");
exc.set_statement("LocalOrFieldVar");
except.addException(exc);
throw except;
}
else{
typen.addElement(this.getType().getName());
}
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();){
hilfe=el1.nextElement();
hilfstr=hilfe.getName();
if(this.getType().getName().equals(hilfstr)){
klasse = hilfe; }
}
}
}
else if(!el.hasMoreElements()) //es steht nur der Variablenname im Vector name,
{ //also MUSS die Variable in dieser Klasse deklariert sein
if(bh.containsKey(name1))
{
this.setType(new Type( (String)bh.get(name1),getOffset()));
typen.addElement(this.getType().getName());
if(bh.containsKey(name1))
{
// System.out.println("type enthalten in bh: "+name1+ " - " +type.get_Type());
}
/************/
if(parabh.containsKey(name1))
{
parahilf = (Hashtable) parabh.get(name1);
parserlog.debug(string_rec(parahilf));
}
}
else if(ch.containsKey(name1))
{
this.setType(new Type((String)ch.get(name1),getOffset()));
typen.addElement(this.getType().getName());
if(ch.contains(this.getType().getName()))
{
// System.out.println("type enthalten in ch: " + name1 + " - " +type.get_Type());
}
if(parach.containsKey(name1))
{
parahilf = (Hashtable) parach.get(name1);
// System.out.print("parahilf: "); string_rec(parahilf); System.out.println();
}
}
else
{
SCExcept exc=new SCExcept();
except=new SCStatementException();
exc.set_error("Variable "+name1+" nicht gefunden");
exc.set_statement("LocalOrFieldVar");
except.addException(exc);
throw except;
}
}
else //es folgen Strings im Vector, also handelt es sich um eine Instanzvar.
{ //wir m<EFBFBD>ssen in Blockhash und Classhash nach der zugeh<EFBFBD>rigen Klasse suchen.
if(bh.containsKey(name1))
{
this.setType(new Type((String)bh.get(name1),getOffset())); //Attribut "type" von Basisklasse Expr
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();)
{
hilfe = el1.nextElement();
hilfstr = hilfe.getName();
if(this.getType().getName().equals(hilfstr)){
klasse = hilfe;}
}
typen.addElement(this.getType().getName());
if(bh.containsKey(name1))
parserlog.debug("type enthalten in bh: "+name1+ " - " + this.getType().getName() );
/***********************/
if(parabh.containsKey(name1)){
parahilf = (Hashtable) parabh.get(name1);
// System.out.print("parahilf: "); string_rec(parahilf); System.out.println();
}
}
else if(ch.containsKey(name1))
{
this.setType(new Type((String)ch.get(name1),getOffset())); //Attribut "type" von Basisklasse Expr
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();)
{
hilfe = el1.nextElement();
hilfstr = hilfe.getName();
parserlog.debug(this.getType().getName()+" ********* "+hilfstr);
if(this.getType().getName().equals(hilfstr)){
klasse = hilfe;}
}
typen.addElement(this.getType().getName());
if(ch.containsKey(name1))
{
// System.out.println("type enthalten in ch: "+name1+ " - " +type.get_Type());
}
/*****************/
if(parach.containsKey(name1)){
parahilf = (Hashtable) parach.get(name1);
// System.out.print("parahilf: "); string_rec(parahilf); System.out.println();
}
}
else
{
SCExcept exc=new SCExcept();
except=new SCStatementException();
exc.set_error("Variable "+name1+" nicht gefunden");
exc.set_statement("LocalOrFieldVar");
except.addException(exc);
throw except;
}
}
}
usedid.set_Typen(typen);
parserlog.debug("SC -> Semantik-Check in LocalOrFieldVar erfolgreich!");
}
// ino.end
// ino.method.set_UsedId.25519.definition // ino.method.set_UsedId.25519.definition
public void set_UsedId(UsedId u) public void set_UsedId(UsedId u)
// ino.end // ino.end
@ -336,67 +157,6 @@ public class LocalOrFieldVar extends Expr
} }
// ino.end // ino.end
// ino.method.TRExp.25528.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.37 von Martin Pl<EFBFBD>micke
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25528.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25528.body
{
CTypeAssumption assum = null;
// --------------------------
// Lokale Variable aufsteigend
// in den Bl<EFBFBD>cken suchen:
// --------------------------
for(int depth=supportData.getCurrentBlockDepth(); assum==null && depth>0; depth--){
CLocalVarKey localKey = new CLocalVarKey(
supportData.getCurrentClass(),
supportData.getCurrentMethod(),
supportData.getCurrentMethodParaCount(),
supportData.getCurrentMethodOverloadedID(),
supportData.getBlockId(depth),
this.get_Name());
assum = V.getElement(localKey);
}
// --------------------------
// Falls keine gefunden, Feldvariable suchen:
// --------------------------
if(assum==null){
CInstVarKey instKey = new CInstVarKey(
supportData.getCurrentClass(),
this.get_Name());
assum = V.getElement(instKey);
}
//--------------------------
// Falls nichts gefunden:
// --------------------------
if(assum==null){
//--------------------------
// 15.04.2007 feda
// Wenn nichts gefunden dann neuen Typ anlegen. Verdacht auf Klassenmethode mit static
//--------------------------
CTripleSet retSet = new CTripleSet();
retSet.addElement(new CTriple(sigma, new RefType(this.get_Name(),this.getOffset()) , V));
CTripleSet retSet2 = super.registerType(retSet, supportData);
return retSet2;
}else{
//--------------------------
// Ergebnismenge bauen:
// --------------------------
CTripleSet retSet = new CTripleSet();
retSet.addElement(new CTriple(sigma, assum.getAssumedType(), V));
CTripleSet retSet2 = super.registerType(retSet, supportData);
return retSet2;
}
}
// ino.end // ino.end
// ino.method.TRStatement.25531.definition // ino.method.TRStatement.25531.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData) public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)

View File

@ -134,144 +134,6 @@ public class LocalVarDecl extends Statement implements ITypeReplacementListener
} }
// ino.end // ino.end
// ino.method.sc_check.25584.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String,String> bh, boolean ext, Hashtable parach, Hashtable<String,Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25584.body
{
parserlog.debug("SC -> Blockhashtab. vor LocalVarDecl.sc_check: " + bh);
DeclId hilf;
ExprStmt hilf2;
for(Enumeration<DeclId> e1=declid.elements(); e1.hasMoreElements();)
{
hilf=e1.nextElement();
//************* Hashtabelle f<EFBFBD>r die LocalVar wird erzeugt
if(hilf.paratyp != null)
{
this.paralist = hilf.get_Paratyp();
parserlog.debug("++++ localvardecl.declid.paralist:");
parserlog.debug(string_rec(this.paralist));
for(Enumeration e11=this.paralist.elements();e11.hasMoreElements();){
Type t = (Type)e11.nextElement();
try{
is_declared(t,classname);
}
catch(SCStatementException ex){
throw ex;
}
}
try{
check_anz(this.getDeclType(),paralist,classname);
}
catch(SCStatementException ex){
throw ex;
}
// Erstellen der Hashtabelle f<EFBFBD>r die Instaz der Klasse mit den zugewiesesen Parameter-Variablen
for(Enumeration<Class> e=classname.elements();e.hasMoreElements();){
Class cl = e.nextElement();
if(this.getDeclType().getName().equals(cl.getName())){
if(ext){
parserlog.debug("++ Klasse verifiziert, parahash und paralist: "+cl.get_ParaHash().toString()+" ");
parserlog.debug(string_rec(this.paralist));
}
String para,var;
Type typ;
Hashtable<String,Type> ph = new Hashtable<String,Type>();
Hashtable<String,String> clph = cl.get_ParaHash();
// System.out.println("*********clph.size() = "+ clph.size()+" paralist.size()= " +paralist.size());
if(clph.size() != paralist.size()){
SCExcept exc = new SCExcept();
exc.set_error("Anzahl der Parameter bei der Instantiierung von \""+ hilf.get_Name() +"\" stimmt nicht!");
exc.set_statement("LocalVarDecl");
SCStatementException ex = new SCStatementException();
ex.addException(exc);
throw ex;
}
//Hashtabelle in Class mu<EFBFBD> die gleiche Anzahl an Elementen haben, wie die Parameterliste!! ** noch Abbruchbedingung impl.**
for(Enumeration en = clph.keys();en.hasMoreElements();){
var = (String)en.nextElement();
para= (String)cl.get_ParaHash().get(var); // sucht die Parametervariable f<EFBFBD>r die Variable aus der Parahash-Tabelle...
parserlog.debug("var: "+var+" para: "+para);
//for(Enumeration e3=this.paralist.elements() ;e3.hasMoreElements();){
for(Enumeration e2=cl.get_ParaList().elements(),e3=this.paralist.elements();e2.hasMoreElements();){
Type t1 = (Type)e2.nextElement();
Type t2 = (Type)e3.nextElement();
if(t1.getName().equals(para)){
typ = t2; // bestimmt die neue Zuordnung an der entsprechenden Stelle
ph.put(var,typ); // f<EFBFBD>gt Variable und neuer Typ in die Hashtabelle ein
// System.out.println("++ typ "+typ.get_Type());
}
}
}
this.parahash = ph;
parabh.put(hilf.get_Name(),ph);
if(ext){
parserlog.debug("++ ParaHashtabelle der InstVar: "+this.parahash.toString());
parserlog.debug("++ parach der InstVar: ");
parserlog.debug(string_rec(parach));
parserlog.debug("++ parabh der InstVar: ");
parserlog.debug(string_rec(parabh));
parserlog.debug(string_rec("paralist: ",paralist));
}
}
}
}
//**********************************
bh.put(hilf.get_Name(), this.getDeclType().getName());
hilf2=hilf.get_Wert();
if(hilf2!=null)
{
try
{
hilf2.sc_check(classname,ch,bh,ext, parach, parabh);
}
catch (SCStatementException ex)
{
throw ex;
}
if(!hilf2.getTypeName().equals(this.getDeclType().getName()))
{
if(this.getDeclType().getName().equals("int"))
{
if(hilf2.getTypeName().equals("char"))
{
parserlog.error("ACHTUNG! Hier wird einem int ein char zugewiesen!");
parserlog.error("int "+get_Name());
}
}
else
{
parserlog.error("Falscher Typ wird der neu deklarierten Variable zugewiesen. ---> SCWrongTypeAssignError");
SCExcept exc = new SCExcept();
exc.set_error("Der neu deklarierten Variable "+hilf.get_Name()+" vom Typ "+this.getDeclType().getName()+" soll ein Objekt vom Typ "+hilf2.getTypeName()+" zugewiesen werden. ---> SCWrongTypeAssignError :-)");
exc.set_statement("LocalVarDecl");
SCStatementException ex = new SCStatementException();
ex.addException(exc);
throw ex;
}
}
}
}
parserlog.debug( "SC -> Blockhashtab. nach LocalVarDecl.sc_check: " + bh);
}
// ino.end
// ino.method.is_declared.25587.definition // ino.method.is_declared.25587.definition
public void is_declared(Type t, Vector<Class> classlist) public void is_declared(Type t, Vector<Class> classlist)
throws SCStatementException throws SCStatementException

View File

@ -170,556 +170,6 @@ public class MethodCall extends Expr
this.usedid = new UsedId(name, 0); this.usedid = new UsedId(name, 0);
} }
// ino.method.sc_check.25678.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25678.body
{
if(ext)
parserlog.debug(" --- MethodCall ---");
parserlog.debug("ch: "+ch.toString());
SCStatementException except=null;
// 1. Vector expr wird nun durchgegangen, um die Typen der <EFBFBD>bergabewerte zu erhalten
parserlog.debug(" ---- 1. Vector expr wird nun durchgegangen, um die Typen der <20>bergabewerte zu erhalten ---- ");
if(arglist!=null)
{
for(Enumeration el2 = arglist.expr.elements(); el2.hasMoreElements();)
{
Expr e=(Expr)el2.nextElement();
try
{
e.sc_check(classname,ch,bh,ext, parach, parabh);
}
catch(SCStatementException ex)
{
if(except==null)
except=ex;
else
{
Vector<SCExcept> v;
SCExcept hilf;
v=ex.get_exlist();
for(Enumeration<SCExcept> el=v.elements();el.hasMoreElements();)
{
hilf=el.nextElement();
except.addException(hilf);
}
}
}
if(except!=null)
throw except;
if(ext)
parserlog.debug("Es wird in den Vector exprtypes ein Element eingefuegt vom Typ: "+e.getTypeName());
exprtypes.addElement(e.getTypeName());
}
}
// 2. <EFBFBD>berpr<EFBFBD>fung des Methodennamens
parserlog.debug(" ---- 2. <20>berpr<70>fung des Methodennamens ---- ");
Vector name = usedid.get_Name();
Vector<String> typen = new Vector<String>();
Class klasse = null; //Klasse wird auf null gesetzt um zuerst in der aktuellen Klasse zu checken
Hashtable parahilf=null;
for(Enumeration el = name.elements(); el.hasMoreElements();)
{
String name1 = (String) el.nextElement();
Class hilfe;
String hilfstr=null;
if(name1.equals("System"))
{
if(ext)
parserlog.debug("Semantikcheck wird an CODEGEN weitergeleitet.");
typen.addElement("System");
break;
}
if(klasse!=null) //hier geht's rein, wenn eine Instanzvariable gefunden wurde
{
if(!el.hasMoreElements()) //es folgen keine weiteren Strings mehr -> name1 muss der Methoden-Name sein.
{
if(ext)
inferencelog.debug("Checke Methode " + name1 + " in Klasse " + this.getType().getName());
this.setType(new Type(klasse.is_member(name1),getOffset()));
if(this.getType()==null)
{
if(ext)
parserlog.debug("Methode "+name1+" nicht gefunden.sc_check-->MethodCall.sc_check()");
SCExcept exc =new SCExcept();
exc.set_error("Methode " + name1 + " in Klasse " + klasse.getName() + " nicht gefunden!");
exc.set_statement("MethodCall");
SCStatementException ex = new SCStatementException();
ex.addException(exc);
throw ex;
}
else
{
if(ext)
parserlog.debug("Methode "+name1+" gefunden.");
class_name=klasse.getName();
// System.out.println("typen: "+typen.toString()+" type: "+ type+" parach: "+parach.toString()+" parabh: "+parabh.toString());
if(parahilf != null){
if(parahilf.containsKey(name1))
this.setType((Type)parahilf.get(name1));
}
parserlog.debug("typen: "+typen.toString()+", (ret.)type: "+ this.getType().getName()+", parach: ");
parserlog.debug(string_rec(parach));
parserlog.debug(", parabh: ");
parserlog.debug(string_rec(parabh));
parserlog.debug("name1 "+name1 +" hilfstr "+hilfstr);
typen.addElement(this.getType().getName());
}
sc_check_get_Method(classname,name1,ext,parach,parabh);
}
else //es folgen Strings -> weitere Klassen m<EFBFBD>ssen auf die Methode <EFBFBD>berpr<EFBFBD>ft werden
{
if(ext)
parserlog.debug("Checke Variable "+name1+"in Klasse "+this.getType().getName()+".");
this.setType(new Type(klasse.is_member(name1),getOffset()));
if(this.getType()==null)
{
if(ext)
parserlog.debug("Variable "+name1+" nicht gefunden.sc_check-->MethodCall.sc_check()");
SCExcept exc=new SCExcept();
exc.set_error("Variable "+name1+" wurde in Klasse "+klasse.getName()+" nicht gefunden.");
exc.set_statement("MethodCall");
SCStatementException ex = new SCStatementException();
ex.addException(exc);
throw ex;
}
else
{
parserlog.debug(this.getType().getName()+" ******** 1");
typen.addElement(this.getType().getName());
if(ext)
parserlog.debug("Variable "+name1+" gefunden.");
}
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();)
{
hilfe=el1.nextElement();
hilfstr=hilfe.getName();
if(this.getType().equals(hilfstr))
klasse = hilfe;
}
}
}
else if(!el.hasMoreElements()) //es steht nur der Methoden-Aufruf im Vector name,
{ //also MUSS die Methode in dieser Klasse deklariert sein
if(ch.containsKey(name1))
{
this.setType(new Type((String)ch.get(name1),getOffset()));
if(ext)
parserlog.debug("Methode " + name1 + " in Class gefunden vom Typ: " + this.getType().getName());
class_name=(String)ch.get("###_classname");
typen.addElement(this.getType().getName());
try
{
sc_check_get_Method(classname,name1, ext,parach,parabh); //hier geht's weiter!!!
}
catch(SCStatementException ex)
{
throw ex;
}
}
else
{
if(ext)
parserlog.error("Methode "+name1+" nicht in Class gefunden.sc_check-->MethodCall.sc_check()");
SCExcept exc= new SCExcept();
exc.set_error("Methode "+name1+" nicht gefunden.");
exc.set_statement("MethodCall");
SCStatementException ex=new SCStatementException();
ex.addException(exc);
throw ex;
}
}
else if(bh.containsKey(name1)) //es folgen Strings im Vector, also handelt es sich um eine Instanzvar.
{ //wir m<EFBFBD>ssen im Blockhash nach der zugeh<EFBFBD>rigen Klasse suchen.
this.setType(new Type((String)bh.get(name1),getOffset())); //Attribut "type" von Basisklasse Expr
if(ext)
parserlog.debug("Variable " + name1 + " im Block gefunden.");
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();)
{
hilfe = el1.nextElement();
hilfstr = hilfe.getName();
if(this.getType().getName().equals(hilfstr))
klasse = hilfe;
}
if(parabh.containsKey(name1))
parahilf =(Hashtable) parabh.get(name1);
typen.addElement(this.getType().getName());
parserlog.debug(this.getType().getName()+" ******** 2 parahilf:");
parserlog.debug(string_rec(parahilf));
}
else if(ch.containsKey(name1)) //im Blockhash wurde der String nicht gefunden, also
{ //m<EFBFBD>ssen wir im Classhash nach der zugeh<EFBFBD>rigen Klasse suchen.
this.setType(new Type((String)ch.get(name1),getOffset())); //Attribut "type" von Basisklasse Expr
if(ext)
parserlog.debug("Variable " + name1 + " im ClassBody gefunden.");
for(Enumeration<Class> el1 = classname.elements();el1.hasMoreElements();)
{
hilfe = el1.nextElement();
hilfstr = hilfe.getName();
if(this.getType().getName().equals(hilfstr))
klasse = hilfe;
}
if(parach.containsKey(name1))
parahilf =(Hashtable) parach.get(name1);
typen.addElement(this.getType().getName());
parserlog.debug(this.getType().getName()+" ******** 3 parahilf:");
parserlog.debug(string_rec(parahilf));
}
else
{
if(ext)
parserlog.debug("Methoden-Aufruf "+name1+" nicht gefunden.sc_check-->MethodCall.sc_check()");
SCExcept exc = new SCExcept();
exc.set_error(name1+ " weder in Blockhash noch in Classhash gefunden.");
exc.set_statement("MethodCall");
SCStatementException ex = new SCStatementException();
ex.addException(exc);
throw ex;
}
}
usedid.set_Typen(typen);
// 3. Ueberpruefung, welche Methode den/die richtigen <EFBFBD>bergabeparmeter hat
// findet in der Funktion void sc_check_get_Method() statt
}
// ino.end
// ino.method.sc_check_get_Method.25681.definition
public void sc_check_get_Method(Vector<Class> classlist, String methodname, boolean ext,Hashtable parach, Hashtable parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check_get_Method.25681.body
{
Class hilf;
String hilfclassname;
ClassBody hilfbody;
Vector varundmeth;
Object typecheck;
Vector<Method> method=new Vector<Method>();
Method moeglich;
String vergleich;
String classname;
int no_of_exprtypes;
Vector paralist;
no_of_exprtypes=exprtypes.size(); //Hier wird die Anzahl der <EFBFBD>bergabeparameter festgestellt
if(ext)
parserlog.debug("Semantik-Check ist in sc_check_get_Method: Die Methode hat "+no_of_exprtypes+" <20>bergabewerte.");
for(Enumeration<Class> el=classlist.elements();el.hasMoreElements();) //wir suchen alle Methoden mit dem gleichen
{ //Namen, wie die aufgerufene Methode, die in der Klasse vorkommen
hilf=el.nextElement();
hilfclassname=hilf.getName();
if(hilfclassname.equals(class_name))
{
hilfbody=hilf.get_ClassBody();
varundmeth=hilfbody.get_FieldDeclVector();
for(Enumeration el1=varundmeth.elements();el1.hasMoreElements();)
{
typecheck=el1.nextElement();
if(typecheck instanceof Method)
{
moeglich=(Method)typecheck;
vergleich=moeglich.get_Method_Name();
if(vergleich.equals(methodname))
{
paralist=moeglich.get_Type_Paralist();
if(ext)
parserlog.error("Es wurde eine Methode mit dem gleichen Namen gefunden. Sie hat "+paralist.size()+" <20>bergabewerte");
if(paralist.size()==no_of_exprtypes)//Es werden nur noch Methoden hier hinzugefuegt, die die richtige Parameteranzahl
{ //haben. last1 07.03.02
method.addElement(moeglich);
}
}
}
}
if(hilf.does_Class_extend()) //hat die Klasse geerbt suchen wir in der Basisklasse nach weiteren
{ //Methoden mit dem selben Namen
classname=hilf.get_Superclass_Name();
sc_init_extended_fcts(method,classlist,methodname,classname,ext);
}
}
}
//Jetzt befinden sich im Vector method alle Funktionen mit dem richtigen Namen und der richtigen Anzahl an Parametern!, die
//m<EFBFBD>glich sind => Wir koennen also die <EFBFBD>bergabewerte pruefen
for(int i=0;exprtypes.size()>i;i++) //l<EFBFBD>uft so ab: F<EFBFBD>r jeden <EFBFBD>bergabeparameter wird die Funktion
{ //sc_check_uebergabe aufgerufen
try
{
sc_check_uebergabe(classlist,method,ext,i,parach, parabh);
}
catch(SCStatementException ex)
{
throw ex;
}
finde_method.addElement(uebernachdurch);
if (ext)
parserlog.debug("Wir sind dabei, die Hashtables in den Vector zu schreiben.");
}
//jetzt muss noch die passende Methode rausgefischt werden
Hashtable<String,Method> zumueberpruefen;
String intnummern;
Method passt;
int indexnr=0;
boolean best=false;
int vererbschritte=0;
int zaehlen=0;
Vector<Method> aussuchen=new Vector<Method>();
for(int j=0;exprtypes.size()>j;j++)
{
if(ext)
parserlog.debug("Hashtable Nr. "+j+" wird gecheckt.");
zumueberpruefen=finde_method.elementAt(j); //wir benutzen dazu die in sc_check_uebergabe
for(int k=0;k<10;k++) //erstellten Hashtables, ist die Schl<EFBFBD>ssel-Nr.
{ //m<EFBFBD>glichst klein, ist die Methode in der Hash-
intnummern=String.valueOf(k); //table die bestpassende.
if(j==0)
{
if(zumueberpruefen.containsKey(intnummern))
{
if(ext)
parserlog.debug("Methode wird in den Moeglichkeits-Vector aufgenommen!");
aussuchen.addElement(zumueberpruefen.get(intnummern));
if(best==false)
{
best=true;
vererbschritte=k;
}
}
}
else
{
if(zumueberpruefen.containsKey(intnummern))
{
passt=zumueberpruefen.get(intnummern);
aussuchen.indexOf(passt);
if(indexnr!=zaehlen&&k<vererbschritte)
{
// Method hilfmirhier;
// hilfmirhier=(Method)method.elementAt(zaehlen);
aussuchen.remove(zaehlen);
//method.addElement(hilfmirhier);
zaehlen++;
}
}
}
}
}
if(arglist!=null)
called_method=aussuchen.elementAt(zaehlen);
else
called_method=method.elementAt(0);
Vector testerichtig;
testerichtig=called_method.get_Type_Paralist();
if(ext)
{
parserlog.debug("Semantik-Check hat die aufgerufene Methode mit folgenden <20>bergabewerten gefunden: "+testerichtig.toString()); //Zur Ueberpruefung werden bei eingeschaltetem ext die Typen der gefundenen Methode ausgegeben.
}
}
// ino.end
// ino.method.sc_check_uebergabe.25684.definition
public void sc_check_uebergabe(Vector<Class> classlist,Vector<Method> method,boolean ext,int paranum, Hashtable parach, Hashtable parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check_uebergabe.25684.body
{
Vector parameterlist;
String soll,ist;
boolean found=false;
Class hilfscl;
Method moeglich;
//String geerbt;
String intnummern;
uebernachdurch=new Hashtable<String,Method>();
if(ext)
parserlog.debug("Semantik-Check pr<70>ft "+paranum+". <20>bergabewert.");
int vectorlaenge=method.size();
for(int zaehl=0;zaehl<vectorlaenge;zaehl++)
{
moeglich=method.elementAt(zaehl);
parameterlist=moeglich.get_Type_Paralist();
soll=(String)parameterlist.elementAt(paranum);
ist=(String)exprtypes.elementAt(paranum);
/******
parserlog.debug(string_rec(parach));parserlog.debug(string_rec(parabh));
System.out.println(parameterlist.toString());
System.out.println("soll: "+soll);*/
for(Enumeration<Class> e = classlist.elements();e.hasMoreElements();){
hilfscl = e.nextElement();
if(hilfscl.getName().equals(this.class_name)){
if(hilfscl.get_ParaHash().containsValue(soll)){
soll=ist;
}
}
}
/******/
if(ist.equals(soll)) //hier wird untersucht, ob die <EFBFBD>bergabetypen passen
{
found=true;
intnummern="0";
uebernachdurch.put(intnummern,moeglich); //passen sie sofort -> Eintragung der Methode in Hashtable
if(ext) //unter Schl<EFBFBD>ssel "0"
parserlog.debug("Semantik-Check hat "+paranum+". <20>bergabewert vom Typ "+ist+" gefunden.");
}
else
{
if(ist.equals("String")||ist.equals("int")||ist.equals("char")||ist.equals("boolean"))
{ //ist der Typ String, int, char oder boolean passt die Methode im Normalfall nicht
found=false;
if(ist.equals("char"))
{
if(soll.equals("int"))
{
parserlog.info("ACHTUNG! Hier wird einem int ein char zugewiesen!");
parserlog.info("Methode: "+usedid.get_Name().toString());
found=true;
}
}
}
else // bei anderem Typ muss auf Vererbung <EFBFBD>berpr<EFBFBD>ft werden
{
if(ext)
parserlog.debug("Semantik-Check hat noch nichts gefunden. <20>bergabewert vom Typ "+ist+" k<>nnte vererbt sein.");
counter=0;
found=sc_check_method_kleiner(classlist,ist,soll,ext);//hier wird auf Vererbung gepr<EFBFBD>ft
if(found)
{
intnummern=String.valueOf(counter); //Counter gibt an wieviele Schritte bis zur richtigen
uebernachdurch.put(intnummern,moeglich); //Klasse durchgef<EFBFBD>hrt wurden -> Counter ist
if(ext) //der Schl<EFBFBD>ssel zur m<EFBFBD>glichen Methode
parserlog.debug("Semantik-Check hat Uebergabewert vom Typ "+ist+" vererbt gefunden nach "+counter+" Durchl<68>ufen.");
}
}
}
if(!found)
{
if(ext)
parserlog.debug("Nicht passende Funktion gefunden, wird vom Vector gel<65>scht.");
method.remove(moeglich); //Die m<EFBFBD>gliche Methode wird gel<EFBFBD>scht, wenn die Parameter nicht passen.
}
if(vectorlaenge!=method.size())
{
vectorlaenge=method.size();
zaehl=-1;
}
}
if(method.isEmpty())
{
SCExcept ex=new SCExcept();
ex.set_error("Keine passende Funktion gefunden!");
ex.set_statement("Method - Call");
SCStatementException exce=new SCStatementException();
exce.addException(ex);
throw exce;
}
}
// ino.end
// ino.method.sc_check_method_kleiner.25687.definition
public boolean sc_check_method_kleiner(Vector<Class> classlist,String ist,String soll,boolean ext)
// ino.end
// ino.method.sc_check_method_kleiner.25687.body
{
Class hilf;
String geerbtvon;
String hilfmir;
boolean erg=false;
counter++;
for(Enumeration<Class> el1=classlist.elements();el1.hasMoreElements();)
{
hilf=el1.nextElement();
hilfmir=hilf.getName();
if(hilfmir.equals(ist))
{
if(ext)
parserlog.debug("Habe Klasse gefunden "+hilfmir);
geerbtvon=hilf.get_Superclass_Name();
if(ext)
parserlog.debug("Aktuell geerbtvon: "+geerbtvon);
if(geerbtvon!=null)
{
if(geerbtvon.equals(soll))
{
if(ext)
parserlog.debug("Kleiner gefunden. Klassenname "+geerbtvon);
erg=true;
break;
}
else
{
erg=sc_check_method_kleiner(classlist,geerbtvon,soll,ext);
break;
}
}
else
erg=false;
}
else
erg=false;
}
return erg;
}
// ino.end
// ino.method.sc_init_extended_fcts.25690.definition
public void sc_init_extended_fcts(Vector<Method> method, Vector<Class> classlist, String methodname, String classname, boolean ext)
// ino.end
// ino.method.sc_init_extended_fcts.25690.body
{ //hier werden die Funktionen mit dem gleichen Namen, die von einer anderen Klasse geerbt wurden in den
Class hilf; //Vektor der m<EFBFBD>glichen Methoden mitaufgenommen.
String hilfclassname;
ClassBody hilfbody;
Vector varundmeth;
Object typecheck;
Method moeglich;
String vergleich;
for(Enumeration<Class> el=classlist.elements();el.hasMoreElements();)
{
hilf=el.nextElement();
hilfclassname=hilf.getName();
if(hilfclassname.equals(classname))
{
hilfbody=hilf.get_ClassBody();
varundmeth=hilfbody.get_FieldDeclVector();
for(Enumeration el1=varundmeth.elements();el1.hasMoreElements();)
{
typecheck=el1.nextElement();
if(typecheck instanceof Method)
{
moeglich=(Method)typecheck;
vergleich=moeglich.get_Method_Name();
if(vergleich.equals(methodname))
method.addElement(moeglich);
}
}
if(hilf.does_Class_extend())
{
classname=hilf.get_Superclass_Name();
sc_init_extended_fcts(method,classlist,methodname,classname,ext);
}
}
}
}
// ino.end
// ino.method.set_Receiver.25693.definition // ino.method.set_Receiver.25693.definition
public void set_Receiver(Receiver rec) public void set_Receiver(Receiver rec)

View File

@ -70,40 +70,6 @@ public class NegativeExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.25763.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25763.body
{
if(ext)
parserlog.debug(" ---NegativeExpr---");
SCStatementException except=null;
String type = this.expr.getTypeName();
try
{
this.expr.sc_check(classname,ch,bh,ext, parach, parabh);
}
catch(SCStatementException ex)
{
except=ex;
}
if(type != "int" || type != "boolean")
{
if(ext)
parserlog.warn("Warnung -- Typfehler!! Moeglicher Datenverlust --> NegativeExpr.sc_check()");
SCExcept neu=new SCExcept();
neu.set_error("Typfehler");
neu.set_statement("NegativeExpr");
if(except==null)
except=new SCStatementException();
except.addException(neu);
}
if(except!=null)
throw except;
}
// ino.end
// ino.method.set_UnaryMinus.25766.definition // ino.method.set_UnaryMinus.25766.definition
public void set_UnaryMinus(UnaryMinus umin) public void set_UnaryMinus(UnaryMinus umin)
// ino.end // ino.end
@ -152,66 +118,6 @@ public class NegativeExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.TRExp.25778.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.41 von Martin Pl<EFBFBD>micke
* <br/>Achtung Workaround: Wenn die BaseTypes endlich korrekt implementiert sind,
* dann sollte der RefType "Integer" <EFBFBD>berall durch den BaseType "IntegerType"
* ersetzt werden!!! <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25778.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25778.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Integer",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple intTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(intTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("NegativeExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.25781.definition // ino.method.TRStatement.25781.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData) public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end // ino.end

View File

@ -202,81 +202,7 @@ public class NewClass extends Expr
} }
// ino.end // ino.end
// ino.method.TRExp.25864.defdescription type=javadoc // ino.method.toString.25867.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.31 von Martin Pl<EFBFBD>micke
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25864.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25864.body
{
String constructorName = (String)this.usedid.getQualifiedName();
Vector typeParaList = this.usedid.get_RealParaList(); //eingefuegt 05-07-26 PL
CTripleSet resultSet = new CTripleSet();
// --------------------------
// Standard-Konstruktor:
// --------------------------
if(this.arglist==null || this.arglist.expr.size()==0){
//resultSet.addElement(new CTriple(sigma, new RefType(constructorName), V));
//eingefuegt 05-07-26 PL
resultSet.addElement(new CTriple(sigma, new RefType(constructorName, typeParaList,getOffset()), V));
//return resultSet; 05-07-31 auskommentiert siehe nach else
}
// --------------------------
// Konstruktor mit Argumenten:
// --------------------------
else {
Vector<Expr> expressions = new Vector<Expr>();
if(this.arglist!=null){
expressions.addAll(this.arglist.expr);
}
// --------------------------
// TRTuple rufen:
// --------------------------
CMultiplyTupleSet tupleSet = this.TRTuple(new CMultiplyTuple(sigma, new Vector<Type>(), V), expressions, supportData);
Iterator<CMultiplyTuple> tupleIt = tupleSet.getIterator();
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
int successfulls=0;
while(tupleIt.hasNext()){
CMultiplyTuple tuple = tupleIt.next();
int paraCount = 0;
if(this.arglist!=null){
paraCount = this.arglist.expr.size();
}
MethodCall constructorCall=new MethodCall(getOffset(),getVariableLength());
try{
CTripleSet callAppSet = constructorCall.TRMCallApp(tuple, constructorName, "<init>", paraCount, true, supportData);
resultSet.unite(callAppSet);
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("NewClass: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
}
//CTripleSet resultSet2 = super.unifyAndRegisterType(resultSet, supportData);
CTripleSet resultSet2 = super.registerType(resultSet, supportData);
return resultSet2;
}
// ino.end
// ino.method.toString.25867.defdescription type=javadoc
/** /**
* <br/>Author: Martin Pl<EFBFBD>micke * <br/>Author: Martin Pl<EFBFBD>micke
* @return * @return

View File

@ -62,40 +62,6 @@ public class NotExpr extends UnaryExpr
// ino.method.sc_check.25889.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.25889.body
{
if(ext)
parserlog.debug(" ---NotExpr---");
SCStatementException except=null;
try
{
expr.sc_check(classname, ch, bh,ext, parach, parabh);
}
catch (SCStatementException ex)
{
except=ex;
}
this.setType(new Type( "boolean",getOffset()));
/*if(expr.get_Type() != "int" || expr.get_Type() != "boolean")
{
if(ext)
System.out.println("Warnung -- Typfehler!! Moeglicher Datenverlust --> NegativeExpr.sc_check()");
scexcept exception =new scexcept();
exception.set_error("Warnung!!! Moeglicher Datenverlust!!!");
exception.set_statement("NotExpr");
if(except==null)
except=new SCStatementException();
except.addException(exception);
}*/
if(except!=null)
throw except;
}
// ino.end
// ino.method.get_Name.25892.definition // ino.method.get_Name.25892.definition
public String get_Name() public String get_Name()
// ino.end // ino.end
@ -171,65 +137,6 @@ public class NotExpr extends UnaryExpr
} }
*/ */
// ino.method.TRExp.25910.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.42 von Martin Pl<EFBFBD>micke
* <br/>Achtung Workaround: Wenn die BaseTypes endlich korrekt implementiert sind,
* dann sollte der RefType "Boolean" <EFBFBD>berall durch den BaseType "BooleanType"
* ersetzt werden!!! <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.25910.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.25910.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Boolean",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple boolTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(boolTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("NotExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Boolean\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.25913.definition // ino.method.TRStatement.25913.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData) public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end // ino.end

View File

@ -79,55 +79,7 @@ public class PostDecExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.26006.definition // ino.method.codegen.26009.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26006.body
{
SCStatementException ex=null;
if(ext)
parserlog.debug(" ---PostDecExpr---");
try
{
expr.sc_check(classname,ch,bh,ext,parach, parabh);
this.setType(new Type(expr.getTypeName(),getOffset()));
}
catch (SCStatementException except)
{
ex=except;
}
if(this.getType()==null)
{
if(ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! --- NoTypeDefError :-)");
if(ex==null)
ex=new SCStatementException();
SCExcept exc = new SCExcept();
exc.set_error("Kein Typ vorhanden - NoTypeDefError");
exc.set_statement("PostDecExpr");
ex.addException(exc);
}
else
{
if(!this.getType().getName().equals("int"))
{
if (ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! -- wird auf anderen Typ als int angewendet.");
SCExcept exc = new SCExcept();
exc.set_error("-- Operator wird auf "+this.getType()+" angewendet.");
exc.set_statement("PostDecExpr");
if(ex==null)
ex = new SCStatementException();
ex.addException(exc);
}
}
if(ex!=null)
throw ex;
}
// ino.end
// ino.method.codegen.26009.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
// ino.end // ino.end
@ -204,64 +156,6 @@ throws SCStatementException
} }
// ino.end // ino.end
// ino.method.TRExp.26012.defdescription type=javadoc
/**
* Achtung Workaround: RefType "Integer" sollte irgendwann gegen BaseType
* <code>IntegerType</code> ausgetauscht werden.
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.26012.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.26012.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Integer",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple intTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(intTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("PostDecExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.26015.definition // ino.method.TRStatement.26015.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData) public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end // ino.end

View File

@ -79,55 +79,6 @@ public class PostIncExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.26040.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26040.body
{
SCStatementException ex=null;
if(ext)
parserlog.debug(" ---PostIncExpr---");
try
{
expr.sc_check(classname,ch,bh,ext,parach,parabh);
this.setType(new Type(expr.getTypeName(),getOffset()));
}
catch (SCStatementException except)
{
ex=except;
}
if(this.getType()==null)
{
if(ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! --- NoTypeDefError :-)");
if(ex==null)
ex=new SCStatementException();
SCExcept exc = new SCExcept();
exc.set_error("Kein Typ vorhanden - NoTypeDefError");
exc.set_statement("PostIncExpr");
ex.addException(exc);
}
else
{
if(!this.getType().getName().equals("int"))
{
if (ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! ++ wird auf anderen Typ als int angewendet.");
SCExcept exc = new SCExcept();
exc.set_error("++ Operator wird auf "+this.getType()+" angewendet.");
exc.set_statement("PostIncExpr");
if(ex==null)
ex = new SCStatementException();
ex.addException(exc);
}
}
if(ex!=null)
throw ex;
}
// ino.end
// ino.method.codegen.26043.definition // ino.method.codegen.26043.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
@ -205,76 +156,6 @@ public class PostIncExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.TRExp.26046.defdescription type=javadoc
/**
* Achtung Workaround: RefType "Integer" sollte irgendwann gegen BaseType
* <code>IntegerType</code> ausgetauscht werden.
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.26046.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.26046.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Integer",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple intTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(intTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("PostIncExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.26049.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.26049.body
{
CTripleSet tripleSet = this.TRExp(sigma, V, supportData).deepCopy();
Iterator<CTriple> tripleIt = tripleSet.getIterator();
while(tripleIt.hasNext()){
tripleIt.next().setResultType(new Void(getOffset()));
}
return tripleSet;
}
// ino.end // ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26052.definition // ino.method.wandleRefTypeAttributes2GenericAttributes.26052.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)

View File

@ -79,54 +79,6 @@ public class PreDecExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.26074.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26074.body
{
SCStatementException ex=null;
if(ext)
parserlog.debug(" ---PreDecExpr---");
try
{
expr.sc_check(classname,ch,bh,ext,parach,parabh);
this.setType(new Type(expr.getTypeName(),getOffset()));
}
catch (SCStatementException except)
{
ex=except;
}
if(this.getType()==null)
{
if(ext)
parserlog.debug("Semantik-Check hat einen Typ-Fehler gefunden!!! --- NoTypeDefError :-)");
if(ex==null)
ex=new SCStatementException();
SCExcept exc = new SCExcept();
exc.set_error("Kein Typ vorhanden - NoTypeDefError");
exc.set_statement("PostDecExpr");
ex.addException(exc);
}
else
{
if(!this.getType().getName().equals("int"))
{
if (ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! -- wird auf anderen Typ als int angewendet.");
SCExcept exc = new SCExcept();
exc.set_error("-- Operator wird auf "+this.getType()+" angewendet.");
exc.set_statement("PreDecExpr");
if(ex==null)
ex = new SCStatementException();
ex.addException(exc);
}
}
if(ex!=null)
throw ex;
}
// ino.end
// ino.method.codegen.26077.definition // ino.method.codegen.26077.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
@ -204,76 +156,6 @@ public class PreDecExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.TRExp.26080.defdescription type=javadoc
/**
* Achtung Workaround: RefType "Integer" sollte irgendwann gegen BaseType
* <code>IntegerType</code> ausgetauscht werden.
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.26080.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.26080.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Integer",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple intTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(intTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("PreDecExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.26083.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.26083.body
{
CTripleSet tripleSet = this.TRExp(sigma, V, supportData).deepCopy();
Iterator<CTriple> tripleIt = tripleSet.getIterator();
while(tripleIt.hasNext()){
tripleIt.next().setResultType(new Void(getOffset()));
}
return tripleSet;
}
// ino.end // ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26086.definition // ino.method.wandleRefTypeAttributes2GenericAttributes.26086.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)

View File

@ -80,54 +80,6 @@ public class PreIncExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.sc_check.26108.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26108.body
{
SCStatementException ex=null;
if(ext)
parserlog.debug(" ---PreIncExpr---");
try
{
expr.sc_check(classname,ch,bh,ext,parach,parabh);
this.setType(new Type(expr.getTypeName(),getOffset()));
}
catch (SCStatementException except)
{
ex=except;
}
if(this.getType().getName()==null)
{
if(ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! --- NoTypeDefError :-)");
if(ex==null)
ex=new SCStatementException();
SCExcept exc = new SCExcept();
exc.set_error("Kein Typ vorhanden - NoTypeDefError");
exc.set_statement("PreIncExpr");
ex.addException(exc);
}
else
{
if(!this.getType().getName().equals("int"))
{
if (ext)
parserlog.error("Semantik-Check hat einen Typ-Fehler gefunden!!! -- wird auf anderen Typ als int angewendet.");
SCExcept exc = new SCExcept();
exc.set_error("++ Operator wird auf "+this.getType()+" angewendet.");
exc.set_statement("PreIncExpr");
if(ex==null)
ex = new SCStatementException();
ex.addException(exc);
}
}
if(ex!=null)
throw ex;
}
// ino.end
// ino.method.codegen.26111.definition // ino.method.codegen.26111.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
@ -205,76 +157,6 @@ public class PreIncExpr extends UnaryExpr
} }
// ino.end // ino.end
// ino.method.TRExp.26114.defdescription type=javadoc
/**
* Achtung Workaround: RefType "Integer" sollte irgendwann gegen BaseType
* <code>IntegerType</code> ausgetauscht werden.
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRExp.26114.definition
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRExp.26114.body
{
CTripleSet returnSet = new CTripleSet();
// --------------------------
// TRExpr f<EFBFBD>r Expr rufen:
// --------------------------
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
// --------------------------
// Alle Triple durchgehen:
// --------------------------
Iterator<CTriple> exprIt = exprSet.getIterator();
while(exprIt.hasNext()){
CTriple exprTriple = exprIt.next();
// --------------------------
// ReturnType mit Integer unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Integer",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann
// anwenden und Triple hinzuf<EFBFBD>gen:
// --------------------------
if(unifierPossibilities.size()!=0){
// --------------------------
// Subset bauen:
// --------------------------
CTripleSet subSet = new CTripleSet();
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
for(int i=0; i<unifierPossibilities.size(); i++){
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
CTriple intTriple = exprTriple.cloneAndApplyUnify(unifier);
subSet.addElement(intTriple);
}
returnSet.unite(subSet);
}
}
if(returnSet.getCardinality()==0){
throw new CTypeReconstructionException("PreIncExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Integer\" unifizieren.",this);
}
return returnSet;
}
// ino.end
// ino.method.TRStatement.26117.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.26117.body
{
CTripleSet tripleSet = this.TRExp(sigma, V, supportData).deepCopy();
Iterator<CTriple> tripleIt = tripleSet.getIterator();
while(tripleIt.hasNext()){
tripleIt.next().setResultType(new Void(getOffset()));
}
return tripleSet;
}
// ino.end // ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26120.definition // ino.method.wandleRefTypeAttributes2GenericAttributes.26120.definition
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters) public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)

View File

@ -42,28 +42,6 @@ public class Receiver
} }
// ino.end // ino.end
// ino.method.sc_check.26135.definition
public void sc_check(Vector<Class> classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach, Hashtable parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26135.body
{
if(ext)
parserlog.debug(" ---Receiver---");
SCStatementException except=null;
try
{
expr.sc_check(classname,ch,bh, ext,parach,parabh);
}
catch(SCStatementException ex)
{
except=ex;
}
if(except!=null)
throw except;
}
// ino.end
// ino.method.get_Type.26138.definition // ino.method.get_Type.26138.definition
public String get_Type() public String get_Type()
// ino.end // ino.end

View File

@ -60,46 +60,6 @@ public class Return extends Statement
// ino.method.sc_check.26163.definition
void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26163.body
{
if(ext)
parserlog.debug(" ---Return---");
SCStatementException excep=null;
if(ext)
parserlog.debug("Semantik-Check pr<70>ft Return-Anweisung");
try
{
retexpr.sc_check(classname,ch,bh,ext, parach, parabh);
}
catch (SCStatementException ex)
{
excep=ex;
}
String gefordert;
String ist;
ist=get_Type();
gefordert=(String)bh.get("###_Method_Ret_Type");
parserlog.debug(ist+gefordert);
if(!ist.equals(gefordert))
{
if(ext)
parserlog.error("FEHLER: R<>ckgabewert hat anderen Typ als von Methode gefordert sc_check-->Return");
SCExcept exc=new SCExcept();
exc.set_error("R<EFBFBD>ckgabewert hat anderen Typ als von Methode gefordert!");
exc.set_statement("Return");
if(excep==null)
excep = new SCStatementException();
excep.addException(exc);
}
if(excep!=null)
throw excep;
}
// ino.end
// ino.method.set_ReturnExpr.26166.definition // ino.method.set_ReturnExpr.26166.definition
public Return set_ReturnExpr(Expr ret) public Return set_ReturnExpr(Expr ret)
// ino.end // ino.end
@ -130,27 +90,6 @@ public class Return extends Statement
} }
// ino.end // ino.end
// ino.method.TRStatement.26175.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.22 von Martin Pl<EFBFBD>micke
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
* @throws CTypeReconstructionException
*/
// ino.end
// ino.method.TRStatement.26175.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
throws CTypeReconstructionException
// ino.end
// ino.method.TRStatement.26175.body
{
return retexpr.TRExp(sigma, V, supportData);
}
// ino.end
// ino.method.toString.26178.definition // ino.method.toString.26178.definition
public String toString() public String toString()
// ino.end // ino.end

View File

@ -89,53 +89,6 @@ public class WhileStmt extends Statement
} }
// ino.end // ino.end
// ino.method.sc_check.26348.definition
void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
throws SCStatementException
// ino.end
// ino.method.sc_check.26348.body
{
if(ext)
parserlog.debug(" ---WhileStmt---");
SCStatementException exc=null;
if(ext)
{
parserlog.debug("Semantik-Check ist in der Klasse WhileStmt");
parserlog.debug("Semantik-Check ueberprueft While-Bedingung-Expression.");
}
try
{
expr.sc_check(classname,ch,bh,ext,parach,parabh);
}
catch (SCStatementException ex)
{
exc=ex;
}
try
{
loop_block.sc_check(classname,ch,(Hashtable) bh.clone(),ext,parach, (Hashtable)parabh.clone());
}
catch (SCStatementException ex)
{
if(exc==null)
exc=ex;
else
{
Vector<SCExcept> v;
SCExcept hilf;
v=ex.get_exlist();
for(Enumeration<SCExcept> el=v.elements();el.hasMoreElements();)
{
hilf=el.nextElement();
exc.addException(hilf);
}
}
}
if(exc!=null)
throw exc;
}
// ino.end
// ino.method.codegen.26351.definition // ino.method.codegen.26351.definition
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException throws JVMCodeException
@ -189,73 +142,6 @@ public class WhileStmt extends Statement
} }
// ino.end // ino.end
// ino.method.TRStatement.26357.defdescription type=javadoc
/**
* Implementierung des Algorithmus 5.23 von Martin Pl<EFBFBD>micke
* <br/>Achtung Workaround: RefType "Boolean" muss noch durch BaseType
* "BooleanType" ersetzt werden.
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param sigma
* @param V
* @param supportData
* @return
*/
// ino.end
// ino.method.TRStatement.26357.definition
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
// ino.end
// ino.method.TRStatement.26357.body
{
CTripleSet returnSet = new CTripleSet();
CTripleSet tripleSet = expr.TRExp(sigma, V, supportData);
Iterator<CTriple> exprTIt = tripleSet.getIterator();
while(exprTIt.hasNext()){
CTriple exprTriple = exprTIt.next();
// --------------------------
// ReturnType mit Boolean unifizieren:
// --------------------------
Vector<Vector<Pair>> unifierPossibilities1 = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Boolean",getOffset()), supportData.getFiniteClosure());
// --------------------------
// Wenn Unifier vorhanden, dann anwenden:
// --------------------------
if(unifierPossibilities1.size()!=0){
// --------------------------
// Alle m<EFBFBD>glichen Unifier anwenden:
// --------------------------
int successfulls=0;
Vector<CTypeReconstructionException> exceptions=new Vector<CTypeReconstructionException>();
for(int i=0; i<unifierPossibilities1.size(); i++){
try{
CSubstitutionSet unifier1 = new CSubstitutionSet(unifierPossibilities1.elementAt(i));
CTriple boolTriple = exprTriple.cloneAndApplyUnify(unifier1);
returnSet.unite(this.loop_block.TRStatement(boolTriple.getSubstitutions(), boolTriple.getAssumptionSet(), supportData));
successfulls++;
}catch(CTypeReconstructionException tre){
exceptions.addElement(tre);
}
if(successfulls==0){
if(exceptions.size()==1){
throw exceptions.elementAt(0);
}
throw new CTypeReconstructionException("WhileStmt: Es konnte keine Assumption gefunden werden, die auf die Anforderung passt.",exceptions,this);
}
}
}
else {
throw new CTypeReconstructionException("WhileStmt.TRStatement(): Bedingung muss boolean sein!",this);
}
}
return returnSet;
}
// ino.end
// ino.method.toString.26360.defdescription type=javadoc // ino.method.toString.26360.defdescription type=javadoc
/** /**
* <br/>Author: Martin Pl<EFBFBD>micke * <br/>Author: Martin Pl<EFBFBD>micke

File diff suppressed because one or more lines are too long