decouple ssjava code gen to prevent crashes from the analysis, so we can turn it...
[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
69     int numEmptyBrackets = type.getArrayCount();
70     if( size != null ) {
71       --numEmptyBrackets;
72     }
73     for( int i = 0; i < numEmptyBrackets; ++i ) {
74       str += "[]";
75     }    
76     if( size != null ) {
77       str += "["+size.toString()+"]";
78     }    
79
80     return str;
81   }
82
83   public int kind() {
84     return FKind.FlatNew;
85   }
86
87   public TempDescriptor [] writesTemps() {
88     return new TempDescriptor[] {dst};
89   }
90
91   public TempDescriptor [] readsTemps() {
92     if (size!=null)
93       return new TempDescriptor[] {size};
94     else
95       return new TempDescriptor[0];
96   }
97
98   public TempDescriptor getDst() {
99     return dst;
100   }
101
102   public TempDescriptor getSize() {
103     return size;
104   }
105
106   public TypeDescriptor getType() {
107     return type;
108   }
109 }