Add beginning of support for dsm
[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     
10     public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal) {
11         this.type=type;
12         this.dst=dst;
13         this.size=null;
14         this.isglobal=isglobal;
15     }
16
17     public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
18         this.type=type;
19         this.dst=dst;
20         this.size=size;
21         this.isglobal=isglobal;
22     }
23
24     public boolean isGlobal() {
25         return isglobal;
26     }
27
28     public String toString() {
29         if (size==null)
30             return dst.toString()+"= NEW "+type.toString();
31         else
32             return dst.toString()+"= NEW "+type.toString()+"["+size.toString()+"]";
33     }
34
35     public int kind() {
36         return FKind.FlatNew;
37     }
38
39     public TempDescriptor [] writesTemps() {
40         return new TempDescriptor[] {dst};
41     }
42
43     public TempDescriptor [] readsTemps() {
44         if (size!=null)
45             return new TempDescriptor[] {size};
46         else
47             return new TempDescriptor[0];
48     }
49
50     public TempDescriptor getDst() {
51         return dst;
52     }
53
54     public TempDescriptor getSize() {
55         return size;
56     }
57
58     public TypeDescriptor getType() {
59         return type;
60     }
61 }