8b1a0bbb8212b32d47b9e4357055aba92b21f5d9
[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 boolean isScratch() {
59     return isglobal;
60   }
61
62   public String getDisjointId() {
63     return disjointId;
64   }
65
66   public String toString() {
67     String str = "FlatNew_"+dst.toString()+"= NEW "+type.toString();
68     if (size!=null)
69       str += "["+size.toString()+"]";
70     return str;
71   }
72
73   public int kind() {
74     return FKind.FlatNew;
75   }
76
77   public TempDescriptor [] writesTemps() {
78     return new TempDescriptor[] {dst};
79   }
80
81   public TempDescriptor [] readsTemps() {
82     if (size!=null)
83       return new TempDescriptor[] {size};
84     else
85       return new TempDescriptor[0];
86   }
87
88   public TempDescriptor getDst() {
89     return dst;
90   }
91
92   public TempDescriptor getSize() {
93     return size;
94   }
95
96   public TypeDescriptor getType() {
97     return type;
98   }
99 }