forked from JavaTX/JavaCompilerCore
This reverts commit 711c0d2f79aa9543d66e99ca0ac4c4412c24c8e4, reversing changes made to 2b47b8e5bf66687f5b3da23fefe70e364881792f.
454 lines
10 KiB
Java
454 lines
10 KiB
Java
package de.dhbwstuttgart.syntaxtree;
|
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
|
|
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
|
import de.dhbwstuttgart.parser.JavaClassName;
|
|
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
|
|
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
|
|
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
|
import de.dhbwstuttgart.typeinference.SingleConstraint;
|
|
import de.dhbwstuttgart.typeinference.assumptions.ConstructorAssumption;
|
|
import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption;
|
|
import de.dhbwstuttgart.typeinference.assumptions.ParameterAssumption;
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
|
|
|
public class Constructor extends Method {
|
|
private Method methode;
|
|
|
|
/**
|
|
* Parser kann nicht zwischen einem Konstruktor und einer Methode unterscheiden.
|
|
* Diese Klasse beherbegt den als Methode geparsten Konstruktor und wandelt sein verhalten zu dem eines Konstruktors ab.
|
|
*/
|
|
public Constructor(Method methode){
|
|
super(methode.get_Method_Name(), methode.getType(), methode.getParameterList(),methode.get_Block(), methode.getGenericDeclarationList(), methode.getOffset());
|
|
}
|
|
@Override
|
|
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
|
this.parent = classmember;
|
|
Class parentClass = this.getParentClass();
|
|
TypeAssumptions ret = new TypeAssumptions();
|
|
ret.addAssumption(new ConstructorAssumption(this, parentClass));
|
|
return ret;
|
|
}
|
|
/*
|
|
@Override
|
|
public void parserPostProcessing(SyntaxTreeNode parent){
|
|
if(this.parameterlist != null){
|
|
for(FormalParameter fp : this.parameterlist){
|
|
fp.parserPostProcessing(this);
|
|
}
|
|
}
|
|
for(GenericTypeVar gtv : this.getGenericParameter()){
|
|
gtv.parserPostProcessing(this);
|
|
}
|
|
}
|
|
*/
|
|
@Override
|
|
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
|
//super.setType(this.getParentClass().getType());
|
|
super.setType(new Void(this, 0));
|
|
return super.TYPE(ass);
|
|
}
|
|
@Override
|
|
public void setType(Type t) {
|
|
super.setType(new Void(this, this.getOffset()));
|
|
//throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
|
|
//this.methode.setType(t);
|
|
}
|
|
/*
|
|
public Constructor(Method methode){
|
|
super(methode.getOffset());
|
|
this.methode = methode;
|
|
this.setDeclIdMenge(methode.getDeclIdMenge());
|
|
this.methode.setType(this.methode.getParentClass().getType());
|
|
}
|
|
|
|
@Override
|
|
public Menge<GenericTypeVar> getGenericParameter() {
|
|
return this.methode.getGenericParameter();
|
|
}
|
|
|
|
|
|
@Override
|
|
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
|
ResultSet resultSet) {
|
|
return this.methode.createTypeInsertPoint(tph, resultSet);
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean isPublic() {
|
|
return this.methode.isPublic();
|
|
}
|
|
|
|
|
|
@Override
|
|
public String getGenericVarDeclarationString(String genericVarDeclaration) {
|
|
return this.methode.getGenericVarDeclarationString(genericVarDeclaration);
|
|
}
|
|
|
|
|
|
@Override
|
|
public int getGenericVarDeclarationOffset() {
|
|
return this.methode.getGenericVarDeclarationOffset();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setGenericParameter(GenericDeclarationList params) {
|
|
this.methode.setGenericParameter(params);
|
|
}
|
|
|
|
|
|
@Override
|
|
public GTVDeclarationContext getGTVDeclarationContext() {
|
|
return this;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void addTypeInsertPoints(TypeInsertSet insertSet, ResultSet result) {
|
|
this.methode.addTypeInsertPoints(insertSet, result);
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean seesType(Type tA2) {
|
|
return this.methode.seesType(tA2);
|
|
}
|
|
|
|
|
|
@Override
|
|
public JavaClassName getTypeName() {
|
|
|
|
return this.getType().getName();
|
|
}
|
|
|
|
@Override
|
|
public Block get_Block() {
|
|
|
|
return this.methode.get_Block();
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void set_Block(Block blo) {
|
|
|
|
this.methode.set_Block(blo);
|
|
}
|
|
|
|
@Override
|
|
public void set_Modifiers(Modifiers modif) {
|
|
|
|
this.methode.set_Modifiers(modif);
|
|
}
|
|
|
|
@Override
|
|
public void set_ExceptionList(ExceptionList exlist) {
|
|
|
|
this.methode.set_ExceptionList(exlist);
|
|
}
|
|
|
|
@Override
|
|
public void setParameterList(ParameterList paralist) {
|
|
|
|
this.methode.setParameterList(paralist);
|
|
}
|
|
|
|
@Override
|
|
public ParameterList getParameterList() {
|
|
|
|
return this.methode.getParameterList();
|
|
}
|
|
|
|
@Override
|
|
public int getParameterCount() {
|
|
|
|
return this.methode.getParameterCount();
|
|
}
|
|
|
|
@Override
|
|
public ExceptionList get_ExceptionList() {
|
|
|
|
return this.methode.get_ExceptionList();
|
|
}
|
|
|
|
@Override
|
|
public int getOverloadedID() {
|
|
|
|
return this.methode.getOverloadedID();
|
|
}
|
|
|
|
@Override
|
|
public void setOverloadedID(int overloadedID) {
|
|
|
|
this.methode.setOverloadedID(overloadedID);
|
|
}
|
|
|
|
@Override
|
|
public String get_codegen_Param_Type(Menge paralist) {
|
|
|
|
return this.methode.get_codegen_Param_Type(paralist);
|
|
}
|
|
|
|
@Override
|
|
public String get_Method_Name() {
|
|
|
|
return this.methode.get_Method_Name();
|
|
}
|
|
|
|
@Override
|
|
public Menge get_Type_Paralist() {
|
|
|
|
return this.methode.get_Type_Paralist();
|
|
}
|
|
|
|
@Override
|
|
public void codegen(ClassFile classfile, Menge paralist)
|
|
throws JVMCodeException {
|
|
|
|
this.methode.codegen(classfile, paralist);
|
|
}
|
|
|
|
@Override
|
|
public int getLineNumber() {
|
|
|
|
return this.methode.getLineNumber();
|
|
}
|
|
|
|
@Override
|
|
public void setLineNumber(int lineNumber) {
|
|
|
|
this.methode.setLineNumber(lineNumber);
|
|
}
|
|
|
|
@Override
|
|
public int getOffset() {
|
|
|
|
return this.methode.getOffset();
|
|
}
|
|
|
|
@Override
|
|
public int getVariableLength() {
|
|
|
|
return this.methode.getVariableLength();
|
|
}
|
|
|
|
@Override
|
|
public void setOffset(int Offset) {
|
|
|
|
this.methode.setOffset(Offset);
|
|
}
|
|
|
|
@Override
|
|
public int getTypeLineNumber() {
|
|
|
|
return this.methode.getTypeLineNumber();
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
|
|
return this.methode.toString();
|
|
}
|
|
|
|
@Override
|
|
public void setAbstract(boolean b) {
|
|
|
|
this.methode.setAbstract(b);
|
|
}
|
|
|
|
@Override
|
|
public boolean isAbstract() {
|
|
|
|
return this.methode.isAbstract();
|
|
}
|
|
|
|
@Override
|
|
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist) {
|
|
|
|
this.methode.wandleRefTypeAttributes2GenericAttributes(paralist);
|
|
}
|
|
|
|
@Override
|
|
public void set_Method_Name(String string) {
|
|
|
|
this.methode.set_Method_Name(string);
|
|
}
|
|
|
|
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
|
ConstraintsSet ret = new ConstraintsSet();
|
|
ret.add(this.methode.get_Block().TYPEStmt(ass));
|
|
return ret;
|
|
}
|
|
|
|
@Override
|
|
public String getTypeInformation() {
|
|
|
|
return this.methode.getTypeInformation();
|
|
}
|
|
|
|
@Override
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
return this.methode.printJavaCode(resultSet);
|
|
}
|
|
|
|
@Override
|
|
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
|
Class parentClass = this.getParentClass();
|
|
TypeAssumptions ret = new TypeAssumptions();
|
|
ret.addAssumption(new ConstructorAssumption(this, parentClass));
|
|
return ret;
|
|
}
|
|
|
|
@Override
|
|
public SyntaxTreeNode getParent(){
|
|
return this.methode.getParent();
|
|
}
|
|
|
|
@Override
|
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
|
|
|
this.methode.parserPostProcessing(parent);
|
|
}
|
|
|
|
@Override
|
|
public Menge<SyntaxTreeNode> getChildren() {
|
|
|
|
return this.methode.getChildren();
|
|
}
|
|
|
|
@Override
|
|
public void setType(Type t) {
|
|
throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
|
|
//this.methode.setType(t);
|
|
}
|
|
|
|
@Override
|
|
public Type getType() {
|
|
return this.methode.getType();
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
return this.methode.equals(obj);
|
|
}
|
|
|
|
|
|
@Override
|
|
public void set_DeclId(DeclId did) {
|
|
this.methode.set_DeclId(did);
|
|
}
|
|
|
|
|
|
@Override
|
|
public Menge<DeclId> get_Name() {
|
|
return this.methode.get_Name();
|
|
}
|
|
|
|
|
|
@Override
|
|
public Menge<DeclId> getDeclIdMenge() {
|
|
return this.methode.getDeclIdMenge();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setDeclIdMenge(Menge<DeclId> vDeclId) {
|
|
this.methode.setDeclIdMenge(vDeclId);
|
|
}
|
|
|
|
|
|
@Override
|
|
public String getIdentifier() {
|
|
return this.methode.getIdentifier();
|
|
}
|
|
|
|
|
|
@Override
|
|
public String getDescription() {
|
|
return this.methode.getDescription();
|
|
}
|
|
|
|
|
|
@Override
|
|
public Class getParentClass() {
|
|
return this.methode.getParentClass();
|
|
}
|
|
*/
|
|
|
|
}
|
|
|
|
/*
|
|
// ino.class.Constructor.23267.declaration
|
|
public class Constructor_Backup extends Method
|
|
// ino.end
|
|
// ino.class.Constructor.23267.body
|
|
{
|
|
// ino.method.Constructor.23271.definition
|
|
public Constructor_Backup()
|
|
// ino.end
|
|
// ino.method.Constructor.23271.body
|
|
{
|
|
this.setParameterList(null);
|
|
// #JB# 04.06.2005
|
|
// ###########################################################
|
|
DeclId decl = new DeclId();
|
|
decl.set_Name("<init>");
|
|
this.set_DeclId(decl);
|
|
// ###########################################################
|
|
}
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.get_codegen_Param_Type.23274.definition
|
|
public String get_codegen_Param_Type(Menge paralist)
|
|
// ino.end
|
|
// ino.method.get_codegen_Param_Type.23274.body
|
|
{
|
|
String ret = new String();
|
|
if(this.getParameterList() == null)
|
|
{
|
|
ret += "()";
|
|
}
|
|
else
|
|
{
|
|
ret += this.getParameterList().get_codegen_ParameterList(paralist);
|
|
}
|
|
ret += "V";
|
|
return ret;
|
|
}
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.codegen.23277.definition
|
|
public void codegen(ClassFile classfile, Menge paralist)
|
|
throws JVMCodeException
|
|
// ino.end
|
|
// ino.method.codegen.23277.body
|
|
{
|
|
classfile.set_constructor_founded(true);
|
|
classfile.add_method("<init>", this.get_codegen_Param_Type(paralist), this.getParameterList(), null, get_Block(), declid.firstElement().get_access_flags(), paralist, false);
|
|
}
|
|
// ino.end
|
|
|
|
}
|
|
*/
|