fixed some bugs
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / FunctionHeader.java
index 60f7700c2459139a0bd042bf001547c7a8961a8a..769087dcd7a6298f172b6e1e5006251cd6c7547c 100644 (file)
@@ -2,20 +2,69 @@ package edu.uci.eecs.specCompiler.specExtraction;
 
 import java.util.ArrayList;
 
+import com.sun.xml.internal.ws.wsdl.parser.ParserUtil;
+
 public class FunctionHeader {
-       public final ArrayList<VariableDeclaration> templateList;
+       private ArrayList<VariableDeclaration> templateList;
        
        public final String returnType;
        public final QualifiedName qualifiedName;
        public final ArrayList<VariableDeclaration> args;
 
-       public FunctionHeader(ArrayList<VariableDeclaration> templateList, String returnType, QualifiedName qualifiedName,
+       public FunctionHeader(String returnType, QualifiedName qualifiedName,
                        ArrayList<VariableDeclaration> args) {
-               this.templateList = templateList;
+               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.size() == 0)
+                       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() {
                String res = returnType + " " + qualifiedName.fullName + "(";
@@ -32,7 +81,7 @@ public class FunctionHeader {
        public FunctionHeader getRenamedHeader(String prefix) {
                String newFullName = qualifiedName.qualifiedName + prefix + "_"
                                + qualifiedName.bareName;
-               FunctionHeader newHeader = new FunctionHeader(templateList, returnType,
+               FunctionHeader newHeader = new FunctionHeader(returnType,
                                new QualifiedName(newFullName), args);
                return newHeader;
        }