forked from JavaTX/JavaCompilerCore
333 lines
8.4 KiB
Java
Executable File
333 lines
8.4 KiB
Java
Executable File
// ino.module.UsedId.8567.package
|
||
package mycompiler.myclass;
|
||
// ino.end
|
||
// ino.module.UsedId.8567.import
|
||
import java.util.Iterator;
|
||
import java.util.Vector;
|
||
|
||
import typinferenz.JavaCodeResult;
|
||
import typinferenz.ResultSet;
|
||
import typinferenz.exceptions.TypeinferenceException;
|
||
import mycompiler.IItemWithOffset;
|
||
import mycompiler.mybytecode.JVMCode;
|
||
import mycompiler.mytype.Type;
|
||
// ino.end
|
||
|
||
|
||
// ino.class.UsedId.23659.declaration
|
||
public class UsedId implements IItemWithOffset
|
||
// ino.end
|
||
// ino.class.UsedId.23659.body
|
||
{
|
||
// ino.attribute.name.23663.declaration
|
||
public Vector<String> name = new Vector<String>(); // Vector mit Strings
|
||
// ino.end
|
||
// ino.attribute.typen.23666.declaration
|
||
private Vector typen = new Vector(); // Vector mit Typen
|
||
// ino.end
|
||
// ino.attribute.paralist.23669.declaration
|
||
private Vector<Type> paralist = null;
|
||
// ino.end
|
||
// ino.attribute.vParaOrg.23672.declaration
|
||
public Vector<Type> vParaOrg = null; // otth: originale Parameterliste
|
||
// ino.end
|
||
private int m_Offset = -1; //hinzugef<65>gt hoth: 07.04.2006
|
||
|
||
// ino.method.UsedId.23675.definition
|
||
public UsedId(int offset)
|
||
// ino.end
|
||
// ino.method.UsedId.23675.body
|
||
{
|
||
m_Offset=offset;
|
||
}
|
||
// ino.end
|
||
|
||
public UsedId(String name, int offset)
|
||
{
|
||
this(offset);
|
||
this.set_Name(name);
|
||
}
|
||
|
||
// ino.method.getOffset.23678.defdescription type=line
|
||
// hinzugef<65>gt hoth: 07.04.2006
|
||
// ino.end
|
||
// ino.method.getOffset.23678.definition
|
||
public int getOffset()
|
||
// ino.end
|
||
// ino.method.getOffset.23678.body
|
||
{
|
||
return m_Offset;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getVariableLength.23681.definition
|
||
public int getVariableLength()
|
||
// ino.end
|
||
// ino.method.getVariableLength.23681.body
|
||
{
|
||
return get_Name_1Element().length();
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.setOffset.23684.defdescription type=line
|
||
// hinzugef<65>gt hoth: 07.04.2006
|
||
// ino.end
|
||
// ino.method.setOffset.23684.definition
|
||
public void setOffset(int Offset)
|
||
// ino.end
|
||
// ino.method.setOffset.23684.body
|
||
{
|
||
m_Offset = Offset;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Name.23687.definition
|
||
public void set_Name( String name)
|
||
// ino.end
|
||
// ino.method.set_Name.23687.body
|
||
{
|
||
this.name.addElement(name);
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Name.23690.definition
|
||
public Vector get_Name()
|
||
// ino.end
|
||
// ino.method.get_Name.23690.body
|
||
{
|
||
return name;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_Name_1Element.23693.definition
|
||
public String get_Name_1Element()
|
||
// ino.end
|
||
// ino.method.get_Name_1Element.23693.body
|
||
{
|
||
return (String) name.elementAt(0);
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_Typen.23696.definition
|
||
public void set_Typen(Vector t)
|
||
// ino.end
|
||
// ino.method.set_Typen.23696.body
|
||
{
|
||
typen=t;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.set_ParaList.23699.definition
|
||
public void set_ParaList(Vector<Type> pl)
|
||
// ino.end
|
||
// ino.method.set_ParaList.23699.body
|
||
{
|
||
this.paralist = pl;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_RealParaList.23702.definition
|
||
public Vector<Type> get_RealParaList()
|
||
// ino.end
|
||
// ino.method.get_RealParaList.23702.body
|
||
{
|
||
return this.paralist;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_ParaList.23705.definition
|
||
public Vector<Type> get_ParaList()
|
||
// ino.end
|
||
// ino.method.get_ParaList.23705.body
|
||
{
|
||
if(this.paralist != null)
|
||
return this.paralist;
|
||
else return new Vector<Type>();
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_vParaOrg.23708.definition
|
||
public Vector<Type> get_vParaOrg()
|
||
// ino.end
|
||
// ino.method.get_vParaOrg.23708.body
|
||
{
|
||
return this.vParaOrg;
|
||
}
|
||
// ino.end
|
||
|
||
|
||
// ino.method.get_Typen.23711.definition
|
||
public Vector get_Typen()
|
||
// ino.end
|
||
// ino.method.get_Typen.23711.body
|
||
{
|
||
return typen;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.get_codegen_UsedId.23714.definition
|
||
public String get_codegen_UsedId()
|
||
// ino.end
|
||
// ino.method.get_codegen_UsedId.23714.body
|
||
{
|
||
String name_string = new String();
|
||
name_string += (String)name.elementAt(0);
|
||
for(int i = 1; i < name.size(); i++)
|
||
name_string += ("/" + (String)name.elementAt(i));
|
||
return name_string;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getSignatureUsedId.23717.definition
|
||
public String getSignatureUsedId()
|
||
// ino.end
|
||
// ino.method.getSignatureUsedId.23717.body
|
||
{
|
||
String basis = JVMCode.get_codegen_Type(getQualifiedName(),null);
|
||
|
||
if (paralist == null || paralist.size() ==0)
|
||
return basis;
|
||
|
||
StringBuffer sb = new StringBuffer();
|
||
|
||
// Basistyp, ; entfernen
|
||
basis = basis.substring(0, basis.length() -1);
|
||
sb.append(basis);
|
||
|
||
sb.append("<");
|
||
|
||
for(int i = 0; i< paralist.size(); i++) {
|
||
|
||
sb.append(paralist.elementAt(i).get_codegen_Type(null));
|
||
}
|
||
|
||
sb.append(">;");
|
||
|
||
return sb.toString();
|
||
}
|
||
// ino.end
|
||
|
||
|
||
// ino.method.removeLast.23720.definition
|
||
public void removeLast()
|
||
// ino.end
|
||
// ino.method.removeLast.23720.body
|
||
{
|
||
name.removeElementAt(name.size()-1);
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.toString.23723.defdescription type=javadoc
|
||
/**
|
||
* <br/>Author: Martin Pl<50>micke
|
||
* @return
|
||
*/
|
||
// ino.end
|
||
// ino.method.toString.23723.definition
|
||
public String toString()
|
||
// ino.end
|
||
// ino.method.toString.23723.body
|
||
{
|
||
return this.get_Name_1Element();//name.toString(); //ge<67>ndert von Andreas Stadelmeier
|
||
/*String s = "";
|
||
for(int i = 0; i<name.size();i++)
|
||
{
|
||
if(i<name.size() -1)
|
||
s += name.get(i) + ".";
|
||
else
|
||
s += name.get(i);
|
||
}
|
||
return s;*/
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getQualifiedName.23726.definition
|
||
public String getQualifiedName()
|
||
// ino.end
|
||
// ino.method.getQualifiedName.23726.body
|
||
{
|
||
StringBuffer sb=new StringBuffer();
|
||
if(name!=null){
|
||
for(int j=0;j<name.size();j++){
|
||
sb.append(name.get(j));
|
||
if(j<name.size()-1)
|
||
sb.append(".");
|
||
}
|
||
}
|
||
return(sb.toString());
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.createFromQualifiedName.23729.definition
|
||
public static UsedId createFromQualifiedName(String qualifiedName, int offset)
|
||
// ino.end
|
||
// ino.method.createFromQualifiedName.23729.body
|
||
{
|
||
String[] steps=qualifiedName.split("\\.");
|
||
UsedId uid=new UsedId(offset);
|
||
uid.name=new Vector<String>();
|
||
for(int i=0;i<steps.length;i++){
|
||
uid.name.addElement(steps[i]);
|
||
}
|
||
return(uid);
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.hasWildCard.23732.definition
|
||
public boolean hasWildCard()
|
||
// ino.end
|
||
// ino.method.hasWildCard.23732.body
|
||
{
|
||
if(name!=null && name.size()>0){
|
||
return(name.elementAt(name.size()-1).equals("*"));
|
||
}
|
||
return(false);
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getPackageName.23735.definition
|
||
public UsedId getPackageName()
|
||
// ino.end
|
||
// ino.method.getPackageName.23735.body
|
||
{
|
||
UsedId uid=new UsedId(-1);
|
||
uid.name=new Vector<String>();
|
||
for(int i=0;i<name.size()-1;i++){
|
||
uid.name.add(name.elementAt(i));
|
||
}
|
||
return uid;
|
||
}
|
||
// ino.end
|
||
|
||
// ino.method.getSimpleName.23738.definition
|
||
public String getSimpleName()
|
||
// ino.end
|
||
// ino.method.getSimpleName.23738.body
|
||
{
|
||
if(name!=null && name.size()>0)
|
||
return name.lastElement();
|
||
else
|
||
return null;
|
||
}
|
||
// ino.end
|
||
|
||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||
if(this.name.size()>1)throw new TypeinferenceException("Es kann maximal nur eine Superklasse pro Klasse geben", this);
|
||
JavaCodeResult ret = new JavaCodeResult(this.getQualifiedName());
|
||
if(this.paralist != null){
|
||
ret.attach( "<" );
|
||
Iterator<Type> it = this.paralist.iterator();
|
||
while(it.hasNext()){
|
||
Type para = it.next();
|
||
ret.attach(para.printJavaCode(resultSet));
|
||
if(it.hasNext())ret.attach(", ");
|
||
}
|
||
//ret = ret.substring(0, ret.length()-2);
|
||
ret.attach(">");
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
}
|
||
// ino.end
|