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