2013-10-18 11:33:46 +00:00
|
|
|
|
// ino.module.FormalParameter.8561.package
|
|
|
|
|
package mycompiler.myclass;
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.module.FormalParameter.8561.import
|
2014-03-18 12:38:47 +00:00
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
import mycompiler.SyntaxTreeNode;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
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;
|
2014-02-10 03:25:14 +00:00
|
|
|
|
|
2013-10-18 11:33:46 +00:00
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
// ino.end
|
|
|
|
|
|
2014-02-10 03:25:14 +00:00
|
|
|
|
|
2014-02-12 21:10:33 +00:00
|
|
|
|
|
2014-02-19 04:20:54 +00:00
|
|
|
|
|
2014-03-18 12:38:47 +00:00
|
|
|
|
|
|
|
|
|
|
2014-03-18 13:04:31 +00:00
|
|
|
|
|
2014-03-18 19:18:57 +00:00
|
|
|
|
|
2014-03-25 03:41:07 +00:00
|
|
|
|
|
|
|
|
|
|
2014-04-09 12:12:55 +00:00
|
|
|
|
|
2014-04-26 18:10:18 +00:00
|
|
|
|
|
2014-05-07 11:01:14 +00:00
|
|
|
|
|
2014-06-19 17:40:13 +00:00
|
|
|
|
|
2014-02-12 21:10:33 +00:00
|
|
|
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
import typinferenz.JavaCodeResult;
|
|
|
|
|
import typinferenz.ResultSet;
|
2014-02-11 15:30:38 +00:00
|
|
|
|
import typinferenz.Typeable;
|
2014-02-10 03:25:14 +00:00
|
|
|
|
import typinferenz.TypeInsertable;
|
2014-04-15 12:56:20 +00:00
|
|
|
|
import typinferenz.exceptions.TypeinferenceException;
|
2014-06-19 17:40:13 +00:00
|
|
|
|
import typinferenz.typedeployment.TypeInsertPoint;
|
|
|
|
|
import typinferenz.typedeployment.TypeInsertSet;
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
// ino.class.FormalParameter.23391.declaration
|
2014-03-18 12:38:47 +00:00
|
|
|
|
public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementListener, Typeable, 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
|
|
|
|
|
|
2014-03-18 13:04:31 +00:00
|
|
|
|
public FormalParameter(DeclId name){
|
|
|
|
|
this.set_DeclId(name);
|
|
|
|
|
}
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
|
2014-04-09 12:12:55 +00:00
|
|
|
|
@Override
|
|
|
|
|
public boolean equals(Object object) {
|
|
|
|
|
if(!super.equals(object))return false;
|
|
|
|
|
if(!(object instanceof FormalParameter))return false;
|
|
|
|
|
FormalParameter equals = (FormalParameter)object;
|
|
|
|
|
if((this.type==null)!=(equals.type == null))return false;
|
2014-04-28 06:26:11 +00:00
|
|
|
|
if(this.type != null){
|
|
|
|
|
return this.type.equals(equals.type);
|
|
|
|
|
}
|
2014-04-09 12:12:55 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.setType.23404.defdescription type=javadoc
|
2013-10-18 11:33:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* <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
|
|
|
|
|
{
|
2014-03-18 13:04:31 +00:00
|
|
|
|
if(did == null)throw new NullPointerException();
|
2013-10-18 11:33:46 +00:00
|
|
|
|
this.declid = did;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.get_Name.23410.definition
|
2014-02-19 04:20:54 +00:00
|
|
|
|
public String getIdentifier()
|
2013-10-18 11:33:46 +00:00
|
|
|
|
// 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
|
2014-04-15 12:56:20 +00:00
|
|
|
|
{ if(this.getType() == null)return "";
|
2013-10-18 11:33:46 +00:00
|
|
|
|
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
|
|
|
|
|
{
|
2014-02-19 04:20:54 +00:00
|
|
|
|
inferencelog.debug("Ersetze Typ in FormalParameter \""+this.getIdentifier()+"\"");
|
2013-10-18 11:33:46 +00:00
|
|
|
|
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 String getTypeInformation() {
|
2014-02-19 04:20:54 +00:00
|
|
|
|
return getType().toString() + " " +this.getIdentifier();
|
2013-10-18 11:33:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString(){
|
|
|
|
|
String ret = "";
|
2014-02-11 15:30:38 +00:00
|
|
|
|
if(this.getType() != null)ret += this.getType().toString();
|
2014-02-19 04:20:54 +00:00
|
|
|
|
if(this.getIdentifier() != null)ret += " "+getIdentifier();
|
2013-10-18 11:33:46 +00:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
|
JavaCodeResult ret = new JavaCodeResult();
|
2014-02-11 15:30:38 +00:00
|
|
|
|
if(this.getType() != null)ret.attach(this.getType().printJavaCode(resultSet));
|
2014-02-19 04:20:54 +00:00
|
|
|
|
if(this.getIdentifier() != null)ret.attach(" "+getIdentifier());
|
2013-10-18 11:33:46 +00:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2014-02-12 21:10:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-26 18:10:18 +00:00
|
|
|
|
|
|
|
|
|
|
2014-02-12 21:10:33 +00:00
|
|
|
|
@Override
|
|
|
|
|
public void setOffset(int offset) {
|
|
|
|
|
//Das Offset steht in declId
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2014-02-19 04:20:54 +00:00
|
|
|
|
|
|
|
|
|
|
2014-03-18 12:38:47 +00:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Vector<SyntaxTreeNode> getChildren() {
|
|
|
|
|
return new Vector<SyntaxTreeNode>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
|
|
|
|
super.parserPostProcessing(parent);
|
|
|
|
|
if(this.type==null)this.type = TypePlaceholder.fresh(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-03-25 03:41:07 +00:00
|
|
|
|
@Override
|
|
|
|
|
public TypeInsertPoint createTypeInsertPoint(TypePlaceholder tph,
|
|
|
|
|
ResultSet resultSet) {
|
|
|
|
|
if(this.getOffset()<=0)return null;
|
2014-04-23 13:19:56 +00:00
|
|
|
|
Type t = resultSet.getTypeEqualTo(tph);
|
2014-07-23 15:24:08 +00:00
|
|
|
|
return new TypeInsertPoint(this, this, t, resultSet);
|
2014-03-25 03:41:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-04-15 12:56:20 +00:00
|
|
|
|
@Override
|
|
|
|
|
public int getVariableLength() {
|
|
|
|
|
int ret = 0;
|
|
|
|
|
ret += this.getTypeName().length();
|
|
|
|
|
ret +=this.getIdentifier().length();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-04-23 13:19:56 +00:00
|
|
|
|
public DeclId getDeclId() {
|
|
|
|
|
return this.declid;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-26 18:10:18 +00:00
|
|
|
|
@Override
|
|
|
|
|
public String getDescription() {
|
|
|
|
|
String ret = "";
|
|
|
|
|
if(this.getType() != null && !(this.getType() instanceof TypePlaceholder)){
|
|
|
|
|
ret += this.getType().getName() + " ";
|
|
|
|
|
}
|
|
|
|
|
return ret+this.getIdentifier();
|
|
|
|
|
}
|
2014-04-23 13:19:56 +00:00
|
|
|
|
|
2013-10-18 11:33:46 +00:00
|
|
|
|
}
|
|
|
|
|
// ino.end
|