package de.dhbwstuttgart.syntaxtree; import de.dhbwstuttgart.typeinference.Menge; import java.util.List; import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.TypeInsertable; import de.dhbwstuttgart.typeinference.Typeable; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; public class FormalParameter extends SyntaxTreeNode implements Typeable, TypeInsertable { private Type type; private String name; protected static Logger inferencelog = Logger.getLogger("inference"); public FormalParameter(String name, Type type, int offset){ super(offset); this.name = name; this.type = type; } @Override public boolean equals(Object object) { //if(!super.equals(object))return false; //Nicht die Position im SyntaxBaum prüfen. if(!(object instanceof FormalParameter))return false; FormalParameter equals = (FormalParameter)object; if((this.type==null)!=(equals.type == null))return false; if(this.type != null){ return this.type.equals(equals.type); } return true; } public String getIdentifier() { return name; } public Type getType() { return type; } @Override public String toString(){ String ret = ""; if(this.getType() != null)ret += this.getType().toString(); if(this.getIdentifier() != null)ret += " "+getIdentifier(); return ret; } public JavaCodeResult printJavaCode(ResultSet resultSet) { JavaCodeResult ret = new JavaCodeResult(); if(this.getType() != null)ret.attach(this.getType().printJavaCode(resultSet)); if(this.getIdentifier() != null)ret.attach(" "+getIdentifier()); return ret; } @Override public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph, ResultSet resultSet) { if(this.getOffset()<=0)return null; Type t = resultSet.getTypeEqualTo(tph); return new TypeInsertPoint(this, this, t, resultSet); } @Override public String getDescription(){ String ret = ""; if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){ ret += this.getType().toString();//getBytecodeSignature(null, null); } return ret+this.getIdentifier(); } }