2013-10-18 13:33:46 +02:00
|
|
|
// ino.module.ParameterList.8565.package
|
2014-09-02 10:33:54 +02:00
|
|
|
package de.dhbwstuttgart.syntaxtree;
|
2013-10-18 13:33:46 +02:00
|
|
|
// ino.end
|
|
|
|
// ino.module.ParameterList.8565.import
|
2015-04-22 21:40:22 +02:00
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
2014-04-09 14:12:55 +02:00
|
|
|
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
|
2015-09-10 16:21:30 +02:00
|
|
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
2014-09-02 10:33:54 +02:00
|
|
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
|
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
|
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
2015-11-27 16:10:35 +01:00
|
|
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
2014-09-02 10:33:54 +02:00
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.class.ParameterList.23620.declaration
|
2015-02-25 16:34:29 +01:00
|
|
|
public class ParameterList extends SyntaxTreeNode implements Iterable<FormalParameter>
|
2013-10-18 13:33:46 +02:00
|
|
|
// ino.end
|
|
|
|
// ino.class.ParameterList.23620.body
|
|
|
|
{
|
|
|
|
// ino.attribute.formalparameter.23623.declaration
|
2015-04-22 21:40:22 +02:00
|
|
|
public Menge<FormalParameter> formalparameter = new Menge<FormalParameter>();
|
2013-10-18 13:33:46 +02:00
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.set_AddParameter.23626.definition
|
|
|
|
public void set_AddParameter(FormalParameter fp)
|
|
|
|
// ino.end
|
|
|
|
// ino.method.set_AddParameter.23626.body
|
|
|
|
{
|
|
|
|
formalparameter.addElement(fp);
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
// ino.method.getParameterAt.23632.definition
|
|
|
|
public FormalParameter getParameterAt(int i)
|
|
|
|
// ino.end
|
|
|
|
// ino.method.getParameterAt.23632.body
|
|
|
|
{
|
|
|
|
if (i >= formalparameter.size() ) return null;
|
|
|
|
|
|
|
|
return formalparameter.elementAt(i);
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.sc_get_Formalparalist.23635.definition
|
2015-04-22 21:40:22 +02:00
|
|
|
public Menge<FormalParameter> sc_get_Formalparalist()
|
2013-10-18 13:33:46 +02:00
|
|
|
// ino.end
|
|
|
|
// ino.method.sc_get_Formalparalist.23635.body
|
|
|
|
{
|
|
|
|
return formalparameter;
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.getParameterCount.23641.defdescription type=javadoc
|
|
|
|
/**
|
2015-05-12 19:49:27 +02:00
|
|
|
* Author: J�rg B�uerle<br/>
|
2013-10-18 13:33:46 +02:00
|
|
|
* @return Die Anzahl der Parameter
|
|
|
|
*/
|
|
|
|
// ino.end
|
|
|
|
// ino.method.getParameterCount.23641.definition
|
|
|
|
public int getParameterCount()
|
|
|
|
// ino.end
|
|
|
|
// ino.method.getParameterCount.23641.body
|
|
|
|
{
|
|
|
|
return formalparameter.size();
|
|
|
|
}
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Andreas Stadelmeier, a10023
|
|
|
|
* @return Die Typinformationen der Parameter in der Parameterliste
|
|
|
|
*/
|
|
|
|
public String getTypeInformation() {
|
|
|
|
String ret = "";
|
|
|
|
for(FormalParameter param : this.formalparameter){
|
|
|
|
ret += param.getTypeInformation();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString(){
|
|
|
|
if(formalparameter == null)return "[]"; //"Leere Parameterliste";
|
2015-05-12 19:49:27 +02:00
|
|
|
//String ret = "ParameterListe, "+formalparameter.size()+" Einträge [ ";
|
2013-10-18 13:33:46 +02:00
|
|
|
String ret = " [ ";
|
|
|
|
for(FormalParameter param : this.formalparameter){
|
|
|
|
ret += param.toString()+", ";
|
|
|
|
}
|
|
|
|
return ret + "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
JavaCodeResult ret = new JavaCodeResult();
|
|
|
|
Iterator<FormalParameter> it = this.formalparameter.iterator();
|
|
|
|
while(it.hasNext()){
|
|
|
|
FormalParameter param = it.next();
|
|
|
|
ret.attach(param.printJavaCode(resultSet));
|
|
|
|
if(it.hasNext())ret.attach(", ");
|
|
|
|
}
|
|
|
|
//if(this.formalparameter.size()>0)ret = ret.substring(0, ret.length() - 2);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-02-19 17:32:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterator<FormalParameter> iterator() {
|
|
|
|
return this.formalparameter.iterator();
|
|
|
|
}
|
|
|
|
|
2014-04-09 14:12:55 +02:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if(!(obj instanceof ParameterList))return false;
|
|
|
|
ParameterList equals = (ParameterList)obj;
|
|
|
|
if((this.formalparameter == null )!=(equals.formalparameter==null))return false;
|
|
|
|
if(this.formalparameter!=null)return this.formalparameter.equals(equals.formalparameter);
|
|
|
|
return true;
|
|
|
|
}
|
2015-02-25 16:34:29 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getOffset() {
|
|
|
|
if(formalparameter == null || formalparameter.size()==0)return 0;
|
|
|
|
return formalparameter.firstElement().getOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getVariableLength() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-22 21:40:22 +02:00
|
|
|
public Menge<? extends SyntaxTreeNode> getChildren() {
|
2015-02-25 16:34:29 +01:00
|
|
|
return formalparameter;
|
|
|
|
}
|
2015-08-27 13:36:14 +02:00
|
|
|
|
|
|
|
public int size() {
|
|
|
|
return this.formalparameter.size();
|
|
|
|
}
|
2015-02-25 16:34:29 +01:00
|
|
|
|
2015-11-27 16:10:35 +01:00
|
|
|
public org.apache.commons.bcel6.generic.Type[] getBytecodeTypeList(ClassGenerator cg, TypeinferenceResultSet rs){
|
2015-09-10 16:21:30 +02:00
|
|
|
org.apache.commons.bcel6.generic.Type[] ret = new org.apache.commons.bcel6.generic.Type[formalparameter.size()];
|
|
|
|
int i = 0;
|
|
|
|
for(FormalParameter f : formalparameter){
|
2015-11-27 16:10:35 +01:00
|
|
|
ret[i] = f.getType().getBytecodeType(cg, rs);
|
2015-09-10 16:21:30 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String[] getParameterNameArray() {
|
|
|
|
String[] ret = new String[formalparameter.size()];
|
|
|
|
int i = 0;
|
|
|
|
for(FormalParameter f : formalparameter){
|
|
|
|
ret[i] = f.getIdentifier();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
}
|
|
|
|
// ino.end
|