forked from JavaTX/JavaCompilerCore
246 lines
8.3 KiB
Java
246 lines
8.3 KiB
Java
|
// ino.module.Expr.8630.package
|
|||
|
package mycompiler.mystatement;
|
|||
|
// ino.end
|
|||
|
// ino.module.Expr.8630.import
|
|||
|
import java.util.Hashtable;
|
|||
|
import java.util.Iterator;
|
|||
|
import java.util.Vector;
|
|||
|
|
|||
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
|||
|
import typinferenz.ConstraintsSet;
|
|||
|
import typinferenz.TypeAssumptions;
|
|||
|
import mycompiler.myclass.Class;
|
|||
|
import mycompiler.myclass.UsedId;
|
|||
|
import mycompiler.myexception.CTypeReconstructionException;
|
|||
|
import mycompiler.myexception.SCStatementException;
|
|||
|
import mycompiler.mytype.Type;
|
|||
|
import mycompiler.mytype.TypePlaceholder;
|
|||
|
import mycompiler.mytypereconstruction.CMultiplyTuple;
|
|||
|
import mycompiler.mytypereconstruction.CSubstitution;
|
|||
|
import mycompiler.mytypereconstruction.CSupportData;
|
|||
|
import mycompiler.mytypereconstruction.CTriple;
|
|||
|
import mycompiler.mytypereconstruction.set.CMultiplyTupleSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CTripleSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
|||
|
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.class.Expr.25225.declaration
|
|||
|
public abstract class Expr extends ExprStmt
|
|||
|
// ino.end
|
|||
|
// ino.class.Expr.25225.body
|
|||
|
{
|
|||
|
// ino.method.Expr.25229.definition
|
|||
|
public Expr(int offset, int variableLength)
|
|||
|
// ino.end
|
|||
|
// ino.method.Expr.25229.body
|
|||
|
{
|
|||
|
super(offset, variableLength);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.attribute.usedid.25232.declaration
|
|||
|
public UsedId usedid; //String type; ab sofort in die Klasse ExprStmt verlegt. last1 17.03.02
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.set_Type.25235.definition
|
|||
|
public void set_Type(Type type)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_Type.25235.body
|
|||
|
{
|
|||
|
this.setType(type);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.set_UsedId.25238.definition
|
|||
|
public void set_UsedId(UsedId ui)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_UsedId.25238.body
|
|||
|
{
|
|||
|
this.usedid = ui;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.get_UsedId.25241.definition
|
|||
|
public UsedId get_UsedId()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_UsedId.25241.body
|
|||
|
{
|
|||
|
return usedid;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.get_Name_Vector.25244.definition
|
|||
|
public Vector get_Name_Vector()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Name_Vector.25244.body
|
|||
|
{
|
|||
|
return usedid.get_Name();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.get_Type_Vector.25247.definition
|
|||
|
public Vector get_Type_Vector()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Type_Vector.25247.body
|
|||
|
{
|
|||
|
return usedid.get_Typen();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.sc_check.25250.declaration
|
|||
|
public abstract 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.get_Name.25253.declaration
|
|||
|
public abstract String get_Name();
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRExp.25256.declaration
|
|||
|
public abstract CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
throws CTypeReconstructionException;
|
|||
|
// ino.end
|
|||
|
|
|||
|
/**
|
|||
|
* @author AI10023 - Andreas Stadelmeier
|
|||
|
* Implementierung des Java 8 - Typinferenzalgorithmus von Martin Pl<EFBFBD>micke
|
|||
|
* Jede Expression wird im Zuge des Algorithmus durch die TYPEExpr-Funktion angesprochen.
|
|||
|
*/
|
|||
|
public abstract ConstraintsSet TYPEExpr(TypeAssumptions assumptions);
|
|||
|
|
|||
|
/**
|
|||
|
* @author AI10023 - Andreas Stadelmeier
|
|||
|
* Die Funktion <EFBFBD>berschreiben, damit sie von Expressions nicht mehr spezifiziert werden muss.
|
|||
|
* Denn Expressions m<EFBFBD>ssen diese Funktion nicht implementieren.
|
|||
|
*/
|
|||
|
@Override
|
|||
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){
|
|||
|
throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen.
|
|||
|
}
|
|||
|
|
|||
|
// ino.method.TRTuple.25259.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* (siehe Algorithmus 5.28 TRTuple, Martin Pl<EFBFBD>micke)
|
|||
|
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @param result
|
|||
|
* @param terms
|
|||
|
* @param supportData
|
|||
|
* @return
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.TRTuple.25259.definition
|
|||
|
public CMultiplyTupleSet TRTuple(CMultiplyTuple result, Vector<Expr> terms, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRTuple.25259.body
|
|||
|
{
|
|||
|
if(terms.size()==0){
|
|||
|
throw new CTypeReconstructionException("Unify.TRTuple(): Vector \"terms\" ist leer.",this);
|
|||
|
}
|
|||
|
CMultiplyTupleSet results = this.TRMultiply(result, terms.firstElement(), supportData);
|
|||
|
// --------------------------
|
|||
|
// Rekursionsanker erreicht:
|
|||
|
// --------------------------
|
|||
|
if(terms.size()==1){
|
|||
|
return results;
|
|||
|
}
|
|||
|
// --------------------------
|
|||
|
// Rekursiv absteigen:
|
|||
|
// --------------------------
|
|||
|
else {
|
|||
|
CMultiplyTupleSet returnSet = new CMultiplyTupleSet();
|
|||
|
Iterator<CMultiplyTuple> tupleIt = results.getIterator();
|
|||
|
|
|||
|
// PL 05-08-21 vorgezogen, da es sonst bei jedem Iterationsschritt
|
|||
|
//der unterschiedlichen Moeglichkeiten der Typisierung geloescht wird.
|
|||
|
terms.removeElementAt(0);
|
|||
|
|
|||
|
while(tupleIt.hasNext()){
|
|||
|
//terms.removeElementAt(0);
|
|||
|
returnSet.unite(this.TRTuple(tupleIt.next(), terms, supportData));
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRMultiply.25262.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* (siehe Algorithmus 5.29 TRMultiply, Martin Pl<EFBFBD>micke)
|
|||
|
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @param tuple
|
|||
|
* @param t
|
|||
|
* @param supportData
|
|||
|
* @return
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.TRMultiply.25262.definition
|
|||
|
public CMultiplyTupleSet TRMultiply(CMultiplyTuple tuple, Expr t, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRMultiply.25262.body
|
|||
|
{
|
|||
|
// --------------------------
|
|||
|
// TRExp des Terms rufen:
|
|||
|
// --------------------------
|
|||
|
CTripleSet results = t.TRExp(tuple.getSubstitutions(), tuple.getAssumptionSet(), supportData);
|
|||
|
// --------------------------
|
|||
|
// Alle zur<75>ckgelieferten Triple durchgehen:
|
|||
|
// --------------------------
|
|||
|
CMultiplyTupleSet returnSet = new CMultiplyTupleSet();
|
|||
|
Iterator<CTriple> tripleIt = results.getIterator();
|
|||
|
while(tripleIt.hasNext()){
|
|||
|
CTriple triple = tripleIt.next();
|
|||
|
// --------------------------
|
|||
|
// Ergebnis-MultiplyTuple bauen:
|
|||
|
// --------------------------
|
|||
|
CMultiplyTuple retTuple =tuple.clone();
|
|||
|
retTuple.setSubstitutions(triple.getSubstitutions());
|
|||
|
retTuple.setAssumptionSet(triple.getAssumptionSet());
|
|||
|
// --------------------------
|
|||
|
// Substitutionen auf ReturnTypes anwenden:
|
|||
|
// --------------------------
|
|||
|
for(int i=0; i<retTuple.getResultTypes().size(); i++){
|
|||
|
Type type = retTuple.getResultTypes().elementAt(i);
|
|||
|
if(type instanceof TypePlaceholder){
|
|||
|
Iterator<CSubstitution> pairIt = retTuple.getSubstitutions().getIterator();
|
|||
|
while(pairIt.hasNext()){
|
|||
|
CSubstitution pair = pairIt.next();
|
|||
|
// --------------------------
|
|||
|
// Falls Match, dann ReturnType ersetzen:
|
|||
|
// --------------------------
|
|||
|
if(pair.getTypeVar().getName().equals(type.getName())){
|
|||
|
retTuple.getResultTypes().setElementAt(pair.getType(), i);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
retTuple.getResultTypes().addElement(triple.getResultType());
|
|||
|
// --------------------------
|
|||
|
// Tuple zur Ergebnismenge hinzuf<75>gen:
|
|||
|
// --------------------------
|
|||
|
returnSet.addElement(retTuple);
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
public abstract void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable);
|
|||
|
|
|||
|
public boolean addOffsetsToStatement(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
// ino.end
|