import java.util.ArrayList;
+import com.sun.xml.internal.ws.wsdl.parser.ParserUtil;
+
public class FunctionHeader {
+ private ArrayList<VariableDeclaration> templateList;
+
public final String returnType;
public final QualifiedName qualifiedName;
public final ArrayList<VariableDeclaration> args;
public FunctionHeader(String returnType, QualifiedName qualifiedName,
ArrayList<VariableDeclaration> args) {
+ this.templateList = null;
this.returnType = returnType;
this.qualifiedName = qualifiedName;
this.args = args;
}
+
+ public void setTemplateList(ArrayList<VariableDeclaration> templateList) {
+ this.templateList = templateList;
+ }
+
+ public ArrayList<VariableDeclaration> getTemplateList() {
+ return this.templateList;
+ }
+
+ public String getTemplateFullStr() {
+ String templateStr = "";
+ if (templateList == null)
+ return templateStr;
+ VariableDeclaration decl;
+ decl = templateList.get(0);
+ templateStr = "<" + decl.type + " " + decl.name;
+ for (int i = 1; i < templateList.size(); i++) {
+ decl = templateList.get(i);
+ templateStr = templateStr + ", " + decl.type + " " + decl.name;
+ }
+ templateStr = templateStr + ">";
+ return templateStr;
+ }
+
+ public String getTemplateArgStr() {
+ String templateStr = null;
+ if (templateList.size() == 0)
+ return templateStr;
+ templateStr = "<" + templateList.get(0).name;
+ for (int i = 1; i < templateList.size(); i++) {
+ templateStr = templateStr + ", " + templateList.get(i);
+ }
+ templateStr = templateStr + ">";
+ return templateStr;
+ }
+
+ public String getFuncStr() {
+ String res = returnType + " " + qualifiedName.fullName + "(";
+ if (args.size() >= 1) {
+ res = res + args.get(0);
+ }
+ for (int i = 1; i < args.size(); i++) {
+ res = res + ", " + args.get(i);
+ }
+ res = res + ")";
+ return res;
+ }
public String toString() {
- return "Ret: " + returnType + "\n" + qualifiedName + "\n" + args;
+ String res = returnType + " " + qualifiedName.fullName + "(";
+ if (args.size() >= 1) {
+ res = res + args.get(0);
+ }
+ for (int i = 1; i < args.size(); i++) {
+ res = res + ", " + args.get(i);
+ }
+ res = res + ")";
+ return res;
+ }
+
+ public FunctionHeader getRenamedHeader(String prefix) {
+ String newFullName = qualifiedName.qualifiedName + prefix + "_"
+ + qualifiedName.bareName;
+ FunctionHeader newHeader = new FunctionHeader(returnType,
+ new QualifiedName(newFullName), args);
+ return newHeader;
+ }
+
+ // No support for template right now
+ public String getDeclaration() {
+ String res = returnType + " " + qualifiedName.fullName + "(";
+ if (args.size() >= 1) {
+ res = res + args.get(0).type + " " + args.get(0).name;
+ }
+ for (int i = 1; i < args.size(); i++) {
+ res = res + ", " + args.get(i).type + " " + args.get(i).name;
+ }
+ res = res + ")";
+ return res;
+ }
+
+ public String getRenamedCall(String prefix) {
+ String res = prefix + "_" + qualifiedName.fullName + "(";
+ if (args.size() >= 1) {
+ res = res + args.get(0).name;
+ }
+ for (int i = 1; i < args.size(); i++) {
+ res = res + ", " + args.get(i).name;
+ }
+ res = res + ")";
+ return res;
}
}