cb6da9dbae743a229bbebc8fe2ffc0dd34be5be6
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / FunctionHeader.java
1 package edu.uci.eecs.specCompiler.specExtraction;
2
3 import java.util.ArrayList;
4
5 import com.sun.xml.internal.ws.wsdl.parser.ParserUtil;
6
7 public class FunctionHeader {
8         private ArrayList<VariableDeclaration> templateList;
9         
10         public final String returnType;
11         public final QualifiedName qualifiedName;
12         public final ArrayList<VariableDeclaration> args;
13
14         public FunctionHeader(String returnType, QualifiedName qualifiedName,
15                         ArrayList<VariableDeclaration> args) {
16                 this.templateList = null;
17                 this.returnType = returnType;
18                 this.qualifiedName = qualifiedName;
19                 this.args = args;
20         }
21         
22         public void setTemplateList(ArrayList<VariableDeclaration> templateList) {
23                 this.templateList = templateList;
24         }
25         
26         public ArrayList<VariableDeclaration> getTemplateList() {
27                 return this.templateList;
28         }
29         
30         public String getTemplateFullStr() {
31                 String templateStr = "";
32                 if (templateList == null)
33                         return templateStr;
34                 VariableDeclaration decl;
35                 decl = templateList.get(0);
36                 templateStr = "<" + decl.type + " " + decl.name;
37                 for (int i = 1; i < templateList.size(); i++) {
38                         decl = templateList.get(i);
39                         templateStr = templateStr + ", " + decl.type + " " + decl.name;
40                 }
41                 templateStr = templateStr + ">";
42                 return templateStr;
43         }
44         
45         public String getTemplateArgStr() {
46                 String templateStr = null;
47                 if (templateList.size() == 0)
48                         return templateStr;
49                 templateStr = "<" + templateList.get(0).name;
50                 for (int i = 1; i < templateList.size(); i++) {
51                         templateStr = templateStr + ", " + templateList.get(i);
52                 }
53                 templateStr = templateStr + ">";
54                 return templateStr;
55         }
56         
57         public String getFuncStr() {
58                 String res = returnType + " " + qualifiedName.fullName + "(";
59                 if (args.size() >= 1) {
60                         res = res + args.get(0);
61                 }
62                 for (int i = 1; i < args.size(); i++) {
63                         res = res + ", " + args.get(i);
64                 }
65                 res = res + ")";
66                 return res;
67         }
68
69         public String toString() {
70                 String res = returnType + " " + qualifiedName.fullName + "(";
71                 if (args.size() >= 1) {
72                         res = res + args.get(0);
73                 }
74                 for (int i = 1; i < args.size(); i++) {
75                         res = res + ", " + args.get(i);
76                 }
77                 res = res + ")";
78                 return res;
79         }
80
81         public FunctionHeader getRenamedHeader(String prefix) {
82                 String newFullName = qualifiedName.qualifiedName + prefix + "_"
83                                 + qualifiedName.bareName;
84                 FunctionHeader newHeader = new FunctionHeader(returnType,
85                                 new QualifiedName(newFullName), args);
86                 return newHeader;
87         }
88
89         public String getRenamedCall(String prefix) {
90                 String res = prefix + "_" + qualifiedName.fullName + "(";
91                 if (args.size() >= 1) {
92                         res = res + args.get(0).name;
93                 }
94                 for (int i = 1; i < args.size(); i++) {
95                         res = res + ", " + args.get(i).name;
96                 }
97                 res = res + ")";
98                 return res;
99         }
100 }