forked from JavaTX/JavaCompilerCore
162 lines
5.4 KiB
Java
162 lines
5.4 KiB
Java
|
// ino.module.ExprStmt.8631.package
|
|||
|
package mycompiler.mystatement;
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.module.ExprStmt.8631.import
|
|||
|
import java.util.Iterator;
|
|||
|
import java.util.Vector;
|
|||
|
import mycompiler.MyCompiler;
|
|||
|
import mycompiler.mytype.Pair;
|
|||
|
import mycompiler.mytype.Type;
|
|||
|
import mycompiler.mytype.TypePlaceholder;
|
|||
|
import mycompiler.mytypereconstruction.CSupportData;
|
|||
|
import mycompiler.mytypereconstruction.CTriple;
|
|||
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
|||
|
import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListener;
|
|||
|
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CTripleSet;
|
|||
|
import mycompiler.mytypereconstruction.unify.Unify;
|
|||
|
import org.apache.log4j.Logger;
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.class.ExprStmt.25265.declaration
|
|||
|
public abstract class ExprStmt extends Statement implements ITypeReplacementListener
|
|||
|
// ino.end
|
|||
|
// ino.class.ExprStmt.25265.body
|
|||
|
{
|
|||
|
// ino.method.ExprStmt.25270.definition
|
|||
|
public ExprStmt(int offset, int variableLength)
|
|||
|
// ino.end
|
|||
|
// ino.method.ExprStmt.25270.body
|
|||
|
{
|
|||
|
super(offset,variableLength);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
// ino.attribute.type.25273.declaration
|
|||
|
//protected Type type; // Type type;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.inferencelog.25276.declaration
|
|||
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.getTypeName.25279.definition
|
|||
|
public String getTypeName()
|
|||
|
// ino.end
|
|||
|
// ino.method.getTypeName.25279.body
|
|||
|
{
|
|||
|
if (getTypeVariable()!=null)
|
|||
|
return getTypeVariable().getName();
|
|||
|
else
|
|||
|
return null;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.getType.25282.definition
|
|||
|
public Type getType()
|
|||
|
// ino.end
|
|||
|
// ino.method.getType.25282.body
|
|||
|
{
|
|||
|
return getTypeVariable();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.getTypeLineNumber.25291.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @return
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.getTypeLineNumber.25291.definition
|
|||
|
public int getTypeLineNumber()
|
|||
|
// ino.end
|
|||
|
// ino.method.getTypeLineNumber.25291.body
|
|||
|
{
|
|||
|
return MyCompiler.NO_LINENUMBER;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.unifyAndRegisterType.25294.definition
|
|||
|
CTripleSet unifyAndRegisterType(CTripleSet ret, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.unifyAndRegisterType.25294.body
|
|||
|
{
|
|||
|
CTripleSet returnSet = new CTripleSet();
|
|||
|
Iterator retIt = ret.getIterator();
|
|||
|
while(retIt.hasNext()){
|
|||
|
CTriple retTriple = (CTriple)retIt.next();
|
|||
|
// --------------------------
|
|||
|
// ReturnType mit type von this unifizieren:
|
|||
|
// --------------------------
|
|||
|
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(retTriple.getResultType(), this.getType(), supportData.getFiniteClosure());
|
|||
|
// --------------------------
|
|||
|
// Wenn Unifier vorhanden, dann
|
|||
|
// anwenden und Triple hinzuf<75>gen:
|
|||
|
// --------------------------
|
|||
|
if(unifierPossibilities.size()!=0){
|
|||
|
// --------------------------
|
|||
|
// Subset bauen:
|
|||
|
// --------------------------
|
|||
|
CTripleSet subSet = new CTripleSet();
|
|||
|
// --------------------------
|
|||
|
// Alle m<>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<>ckgabemenge hinzuf<75>gen
|
|||
|
// --------------------------
|
|||
|
subSet.addElement(intTriple2);
|
|||
|
}
|
|||
|
returnSet.unite(subSet);
|
|||
|
}
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
// ino.method.registerType.25297.definition
|
|||
|
CTripleSet registerType(CTripleSet ret, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.registerType.25297.body
|
|||
|
{
|
|||
|
CTripleSet returnSet = new CTripleSet();
|
|||
|
Iterator retIt = ret.getIterator();
|
|||
|
while(retIt.hasNext()){
|
|||
|
CTriple retTriple = (CTriple)retIt.next();
|
|||
|
if (this.getType() instanceof TypePlaceholder) {
|
|||
|
// --------------------------
|
|||
|
// ReturnType mit type von this unifizieren:
|
|||
|
// --------------------------
|
|||
|
Vector<Pair> tlvRestype = new Vector<Pair>();
|
|||
|
tlvRestype.addElement(new Pair(this.getType(), retTriple.getResultType()));
|
|||
|
CSubstitutionSet unifier2 = new CSubstitutionSet(tlvRestype);
|
|||
|
// --------------------------
|
|||
|
// Unifier zu retTriple hinzufuegen
|
|||
|
// --------------------------
|
|||
|
CTriple intTriple2 = retTriple.cloneAndApplyUnify(unifier2);
|
|||
|
//intTriple2.setResultType(unifier2.applyThisSubstitutionSet(this.getType()));
|
|||
|
// --------------------------
|
|||
|
// Triple zu R<>ckgabemenge hinzuf<75>gen
|
|||
|
// --------------------------
|
|||
|
returnSet.addElement(intTriple2);
|
|||
|
}
|
|||
|
else {//Typ war vorher schon explizit definiert
|
|||
|
if (this.getType().equals(retTriple.getResultType())) {
|
|||
|
returnSet.addElement(retTriple);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
}
|
|||
|
// ino.end
|