Changes
[IRC.git] / Robust / src / IR / Flat / ParamsObject.java
1 package IR.Flat;
2 import IR.*;
3 import java.util.*;
4
5 public class ParamsObject {
6     private Vector pointerparams;
7     private Vector primitiveparams;
8     private MethodDescriptor method;
9     private int tag;
10     private Hashtable paramtotemp;
11     private Hashtable temptostore;
12     private int count;
13
14     public ParamsObject(MethodDescriptor md, int tag) {
15         pointerparams=new Vector();
16         primitiveparams=new Vector();
17         paramtotemp=new Hashtable();
18         temptostore=new Hashtable();
19         this.method=md;
20         this.tag=tag;
21         count=0;
22     }
23
24     public int getUID() {
25         return tag;
26     }
27
28     public void addPtr(TempDescriptor t) {
29         Position p=new Position(true, pointerparams.size());
30         pointerparams.add(t);
31         paramtotemp.put(new Integer(count++), t);
32         temptostore.put(t,p);
33     }
34
35     public boolean isParamPtr(TempDescriptor t) {
36         if (containsTemp(t)) {
37             ParamsObject.Position p=(ParamsObject.Position)temptostore.get(t);
38             return p.inStruct;
39         }
40         return false;
41     }
42
43     public boolean isParamPrim(TempDescriptor t) {
44         if (containsTemp(t)) {
45             ParamsObject.Position p=(ParamsObject.Position)temptostore.get(t);
46             return !p.inStruct;
47         }
48         return false;
49     }
50
51     public boolean containsTemp(TempDescriptor t) {
52         return temptostore.containsKey(t);
53     }
54
55     public void addPrim(TempDescriptor t) {
56         Position p=new Position(false, primitiveparams.size());
57         primitiveparams.add(t);
58         paramtotemp.put(new Integer(count++), t);
59         temptostore.put(t,p);
60     }
61
62     int numPointers() {
63         return pointerparams.size();
64     }
65
66     TempDescriptor getPointer(int i) {
67         return (TempDescriptor) pointerparams.get(i);
68     }
69     int numPrimitives() {
70         return primitiveparams.size();
71     }
72
73     TempDescriptor getPrimitive(int i) {
74         return (TempDescriptor) primitiveparams.get(i);
75     }
76     static class Position {
77         boolean inStruct;
78         int position;
79         Position(boolean inStruct, int position) {
80             this.inStruct=inStruct;
81             this.position=position;
82         }
83     }
84 }