JavaCompilerCore/src/mycompiler/myclass/FormalParameter.java

212 lines
5.1 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.FormalParameter.8561.package
package mycompiler.myclass;
// ino.end
// ino.module.FormalParameter.8561.import
import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListener;
2013-10-18 11:33:46 +00:00
import org.apache.log4j.Logger;
// ino.end
2013-10-18 11:33:46 +00:00
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
import typinferenz.Typable;
import typinferenz.TypeInsertable;
2013-10-18 11:33:46 +00:00
// ino.class.FormalParameter.23391.declaration
public class FormalParameter implements ITypeReplacementListener, Typable, TypeInsertable
2013-10-18 11:33:46 +00:00
// ino.end
// ino.class.FormalParameter.23391.body
{
// ino.attribute.type.23395.declaration
private Type type;
// ino.end
// ino.attribute.declid.23398.declaration
private DeclId declid;
// ino.end
// ino.attribute.inferencelog.23401.declaration
protected static Logger inferencelog = Logger.getLogger("inference");
// ino.end
// ino.method.setType.23404.defdescription type=javadoc
/**
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param t
*/
// ino.end
// ino.method.setType.23404.definition
public void setType(Type t)
// ino.end
// ino.method.setType.23404.body
{
if(this.type instanceof TypePlaceholder){
((TypePlaceholder)this.type).removeReplacementListener(this);
}
if(t instanceof TypePlaceholder){
((TypePlaceholder)t).addReplacementListener(this);
}
this.type = t;
}
// ino.end
// ino.method.set_DeclId.23407.definition
public void set_DeclId(DeclId did)
// ino.end
// ino.method.set_DeclId.23407.body
{
this.declid = did;
}
// ino.end
// ino.method.get_Name.23410.definition
public String get_Name()
// ino.end
// ino.method.get_Name.23410.body
{
return declid.get_Name();
}
// ino.end
// ino.method.getType.23413.definition
public Type getType()
// ino.end
// ino.method.getType.23413.body
{
return type;
}
// ino.end
// ino.method.getTypeName.23416.definition
public String getTypeName()
// ino.end
// ino.method.getTypeName.23416.body
{
return this.getType().getName();
}
// ino.end
// ino.method.codegen.23419.definition
public void codegen(ClassFile classfile, CodeAttribute code)
// ino.end
// ino.method.codegen.23419.body
{
code.add_local(declid.get_Name(), this.getType());
}
// ino.end
// ino.method.getOffset.23422.defdescription type=javadoc
/**
* <br/>Author: Thomas Hornberger 09.04.2006
* @return
*/
// ino.end
// ino.method.getOffset.23422.definition
public int getOffset()
// ino.end
// ino.method.getOffset.23422.body
{
return declid.getOffset();
}
// ino.end
// ino.method.getLineNumber.23425.defdescription type=javadoc
/**
* <br/>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @return
*/
// ino.end
// ino.method.getLineNumber.23425.definition
public int getLineNumber()
// ino.end
// ino.method.getLineNumber.23425.body
{
return declid.getLineNumber();
}
// ino.end
// ino.method.replaceType.23428.defdescription type=javadoc
/**
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @param e
*/
// ino.end
// ino.method.replaceType.23428.definition
public void replaceType(CReplaceTypeEvent e)
// ino.end
// ino.method.replaceType.23428.body
{
inferencelog.debug("Ersetze Typ in FormalParameter \""+this.get_Name()+"\"");
if(type instanceof TypePlaceholder){
((TypePlaceholder)type).removeReplacementListener(this);
}
this.setType(e.getNewType());
}
// ino.end
// ino.method.getTypeLineNumber.23431.defdescription type=javadoc
/**
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
* @return
*/
// ino.end
// ino.method.getTypeLineNumber.23431.definition
public int getTypeLineNumber()
// ino.end
// ino.method.getTypeLineNumber.23431.body
{
return this.getLineNumber();
}
// ino.end
//private Type typeVariable;
public void setTypeVariable(Type typ) {
this.setType(typ);
}
public Type getTypeVariable() {
return this.getType();
}
public String getTypeInformation() {
return getTypeVariable().toString() + " " +this.get_Name();
}
@Override
public String toString(){
String ret = "";
if(this.getTypeVariable() != null)ret += this.getTypeVariable().toString();
if(this.get_Name() != null)ret += " "+get_Name();
return ret;
}
public JavaCodeResult printJavaCode(ResultSet resultSet) {
JavaCodeResult ret = new JavaCodeResult();
if(this.getTypeVariable() != null)ret.attach(this.getTypeVariable().printJavaCode(resultSet));
if(this.get_Name() != null)ret.attach(" "+get_Name());
return ret;
}
}
// ino.end