JavaPatternMatching/src/mycompiler/mystatement/Statement.java
2014-02-19 05:20:54 +01:00

150 lines
4.7 KiB
Java
Executable File
Raw Blame History

// ino.module.Statement.8652.package
package mycompiler.mystatement;
// ino.end
// ino.module.Statement.8652.import
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
import typinferenz.Typeable;
import typinferenz.assumptions.TypeAssumptions;
import mycompiler.IItemWithOffset;
import mycompiler.SyntaxTreeNode;
import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute;
import mycompiler.myclass.Class;
import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.myexception.JVMCodeException;
import mycompiler.myexception.SCStatementException;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Pair;
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListener;
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
import mycompiler.mytypereconstruction.set.CTripleSet;
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
// ino.end
// ino.class.Statement.26184.declaration
public abstract class Statement extends SyntaxTreeNode implements IItemWithOffset, Typeable, ITypeReplacementListener
// ino.end
// ino.class.Statement.26184.body
{
// ino.attribute.offset.26188.declaration
protected int offset;
// ino.end
// ino.attribute.variableLength.26191.declaration
private int variableLength;
// ino.end
protected Type type;
private SyntaxTreeNode parent;
// ino.method.Statement.26194.definition
public Statement(int offset, int variableLength)
// ino.end
// ino.method.Statement.26194.body
{
this.offset=offset;
this.variableLength=variableLength;
}
// ino.end
// ino.method.getOffset.26197.definition
public int getOffset()
// ino.end
// ino.method.getOffset.26197.body
{
return offset;
}
// ino.end
// ino.method.getVariableLength.26200.definition
public int getVariableLength()
// ino.end
// ino.method.getVariableLength.26200.body
{
return variableLength;
}
// ino.end
// ino.method.codegen.26206.declaration
public abstract void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
throws JVMCodeException;
// ino.end
// ino.method.wandleRefTypeAttributes2GenericAttributes.26224.declaration
public abstract void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters);
// ino.end
public abstract boolean addOffsetsToStatement(CTypeAssumption localAssumption, String NameVariable, boolean isMemberVariable);
/**
* @author AI10023 - Andreas Stadelmeier
* Implementierung des Java 8 - Typinferenzalgorithmus von Martin Pl<50>micke
* Jedes Statement wird im Zuge des Algorithmus durch die TYPEExpr-Funktion angesprochen.
*/
public abstract ConstraintsSet TYPEStmt(TypeAssumptions assumptions);
public Type getType(){
return type;
}
/**
* @author Andreas Stadelmeier, a10023
* Sollte von jedem Statement <20>berschrieben werden.
* Liefert Informationen zum Statment und dessen Typ.
* @return
*/
public String getTypeInformation(){
return this.printJavaCode(new ResultSet(new Vector<Pair>()))+" : "+type.toString();
}
/**
* @author AI10023 - Andreas Stadelmeier
* Jedem Statement und jeder Expression wird im Zuge des Typinferenzalgorithmus eine Typvariable zugewiesen.
* Daher m<>ssen alle Statements und Expressions die Methoden setTypeVariable und getTypeVariable implementieren.
*/
public void setType(Type t)
{
if(this.getType() instanceof TypePlaceholder){
((TypePlaceholder)this.getType()).removeReplacementListener(this);
}
if(t instanceof TypePlaceholder){
((TypePlaceholder)t).addReplacementListener(this);
}
this.type=t;
}
public void replaceType(CReplaceTypeEvent e)
{
if(getType() instanceof TypePlaceholder){
((TypePlaceholder)getType()).removeReplacementListener(this);
}
this.setType(e.getNewType());
}
public abstract JavaCodeResult printJavaCode(ResultSet resultSet);
}
// ino.end