f8e84bcb5508f3518ea198c15daae64c6b672c1d
[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 public class FunctionHeader {
6         public final String returnType;
7         public final QualifiedName qualifiedName;
8         public final ArrayList<VariableDeclaration> args;
9
10         public FunctionHeader(String returnType, QualifiedName qualifiedName,
11                         ArrayList<VariableDeclaration> args) {
12                 this.returnType = returnType;
13                 this.qualifiedName = qualifiedName;
14                 this.args = args;
15         }
16
17         public String toString() {
18                 String res = returnType + " " + qualifiedName.fullName + "(";
19                 if (args.size() >= 1) {
20                         res = res + args.get(0);
21                 }
22                 for (int i = 1; i < args.size(); i++) {
23                         res = res + ", " + args.get(i);
24                 }
25                 res = res + ")";
26                 return res;
27         }
28
29         public FunctionHeader getRenamedHeader(String prefix) {
30                 String newFullName = qualifiedName.qualifiedName + prefix + "_"
31                                 + qualifiedName.bareName;
32                 FunctionHeader newHeader = new FunctionHeader(returnType,
33                                 new QualifiedName(newFullName), args);
34                 return newHeader;
35         }
36
37         public String getRenamedCall(String prefix) {
38                 String res = prefix + "_" + qualifiedName.fullName + "(";
39                 if (args.size() >= 1) {
40                         res = res + args.get(0).name;
41                 }
42                 for (int i = 1; i < args.size(); i++) {
43                         res = res + ", " + args.get(i).name;
44                 }
45                 res = res + ")";
46                 return res;
47         }
48 }