bug fixes
[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 TaskDescriptor task;
10     private int tag;
11     private Hashtable paramtotemp;
12     private Hashtable temptostore;
13     private int count;
14
15     public ParamsObject(MethodDescriptor md, int tag) {
16         pointerparams=new Vector();
17         primitiveparams=new Vector();
18         paramtotemp=new Hashtable();
19         temptostore=new Hashtable();
20         this.method=md;
21         this.tag=tag;
22         count=0;
23     }
24
25     public ParamsObject(TaskDescriptor task, int tag) {
26         pointerparams=new Vector();
27         primitiveparams=new Vector();
28         paramtotemp=new Hashtable();
29         temptostore=new Hashtable();
30         this.task=task;
31         this.tag=tag;
32         count=0;
33     }
34
35     public int getUID() {
36         return tag;
37     }
38
39     public void addPtr(TempDescriptor t) {
40         Position p=new Position(true, pointerparams.size());
41         pointerparams.add(t);
42         paramtotemp.put(new Integer(count++), t);
43         temptostore.put(t,p);
44     }
45
46     public boolean isParamPtr(TempDescriptor t) {
47         if (containsTemp(t)) {
48             ParamsObject.Position p=(ParamsObject.Position)temptostore.get(t);
49             return p.inStruct;
50         }
51         return false;
52     }
53
54     public boolean isParamPrim(TempDescriptor t) {
55         if (containsTemp(t)) {
56             ParamsObject.Position p=(ParamsObject.Position)temptostore.get(t);
57             return !p.inStruct;
58         }
59         return false;
60     }
61
62     public boolean containsTemp(TempDescriptor t) {
63         return temptostore.containsKey(t);
64     }
65
66     public void addPrim(TempDescriptor t) {
67         Position p=new Position(false, primitiveparams.size());
68         primitiveparams.add(t);
69         paramtotemp.put(new Integer(count++), t);
70         temptostore.put(t,p);
71     }
72
73     int numPointers() {
74         return pointerparams.size();
75     }
76
77     TempDescriptor getPointer(int i) {
78         return (TempDescriptor) pointerparams.get(i);
79     }
80     int numPrimitives() {
81         return primitiveparams.size();
82     }
83
84     TempDescriptor getPrimitive(int i) {
85         return (TempDescriptor) primitiveparams.get(i);
86     }
87     static class Position {
88         boolean inStruct;
89         int position;
90         Position(boolean inStruct, int position) {
91             this.inStruct=inStruct;
92             this.position=position;
93         }
94     }
95 }