27e9a935565674cb134904fdadafd00576dd1ce7
[IRC.git] / Robust / src / IR / Flat / FlatNew.java
1 package IR.Flat;
2 import IR.TypeDescriptor;
3
4 public class FlatNew extends FlatNode {
5   TempDescriptor dst;
6   TypeDescriptor type;
7   TempDescriptor size;
8   boolean isglobal;
9   String disjointId;
10
11   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal) {
12     this.type=type;
13     this.dst=dst;
14     this.size=null;
15     this.isglobal=isglobal;
16     this.disjointId=null;
17   }
18
19   public void rewriteUse(TempMap t) {
20     size=t.tempMap(size);
21   }
22   public void rewriteDef(TempMap t) {
23     dst=t.tempMap(dst);
24   }
25
26   public FlatNode clone(TempMap t) {
27     return new FlatNew(type, t.tempMap(dst), t.tempMap(size), isglobal, disjointId);
28   }
29
30   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal, String disjointId) {
31     this.type=type;
32     this.dst=dst;
33     this.size=null;
34     this.isglobal=isglobal;
35     this.disjointId=disjointId;
36   }
37
38   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
39     this.type=type;
40     this.dst=dst;
41     this.size=size;
42     this.isglobal=isglobal;
43     this.disjointId=null;
44   }
45
46   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal, String disjointId) {
47     this.type=type;
48     this.dst=dst;
49     this.size=size;
50     this.isglobal=isglobal;
51     this.disjointId=disjointId;
52   }
53
54   public boolean isGlobal() {
55     return isglobal;
56   }
57
58   public String getDisjointId() {
59     return disjointId;
60   }
61
62   public String toString() {
63     String str = "FlatNew_"+dst.toString()+"= NEW "+type.toString();
64     if (size!=null)
65       str += "["+size.toString()+"]";
66     return str;
67   }
68
69   public int kind() {
70     return FKind.FlatNew;
71   }
72
73   public TempDescriptor [] writesTemps() {
74     return new TempDescriptor[] {dst};
75   }
76
77   public TempDescriptor [] readsTemps() {
78     if (size!=null)
79       return new TempDescriptor[] {size};
80     else
81       return new TempDescriptor[0];
82   }
83
84   public TempDescriptor getDst() {
85     return dst;
86   }
87
88   public TempDescriptor getSize() {
89     return size;
90   }
91
92   public TypeDescriptor getType() {
93     return type;
94   }
95 }