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