push a bunch of old changes i had related to inner classes and such... hope this...
[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     if (type==null)
13       throw new Error();
14     this.type=type;
15     this.dst=dst;
16     this.size=null;
17     this.isglobal=isglobal;
18     this.disjointId=null;
19   }
20
21   public void rewriteUse(TempMap t) {
22     size=t.tempMap(size);
23   }
24   public void rewriteDef(TempMap t) {
25     dst=t.tempMap(dst);
26   }
27
28   public FlatNode clone(TempMap t) {
29     return new FlatNew(type, t.tempMap(dst), t.tempMap(size), isglobal, disjointId);
30   }
31
32   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal, String disjointId) {
33     if (type==null)
34       throw new Error();
35     this.type=type;
36     this.dst=dst;
37     this.size=null;
38     this.isglobal=isglobal;
39     this.disjointId=disjointId;
40   }
41
42   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
43     if (type==null)
44       throw new Error();
45     this.type=type;
46     this.dst=dst;
47     this.size=size;
48     this.isglobal=isglobal;
49     this.disjointId=null;
50   }
51
52   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal, String disjointId) {
53     if (type==null)
54       throw new Error();
55     this.type=type;
56     this.dst=dst;
57     this.size=size;
58     this.isglobal=isglobal;
59     this.disjointId=disjointId;
60   }
61
62   public boolean isGlobal() {
63     return isglobal;
64   }
65
66   public boolean isScratch() {
67     return isglobal;
68   }
69
70   public String getDisjointId() {
71     return disjointId;
72   }
73
74   public String toString() {
75     String str = "FlatNew_"+dst.toString()+"= NEW "+type.toString();
76
77     int numEmptyBrackets = type.getArrayCount();
78     if( size != null ) {
79       --numEmptyBrackets;
80     }
81     for( int i = 0; i < numEmptyBrackets; ++i ) {
82       str += "[]";
83     }    
84     if( size != null ) {
85       str += "["+size.toString()+"]";
86     }    
87
88     return str;
89   }
90
91   public int kind() {
92     return FKind.FlatNew;
93   }
94
95   public TempDescriptor [] writesTemps() {
96     return new TempDescriptor[] {dst};
97   }
98
99   public TempDescriptor [] readsTemps() {
100     if (size!=null)
101       return new TempDescriptor[] {size};
102     else
103       return new TempDescriptor[0];
104   }
105
106   public TempDescriptor getDst() {
107     return dst;
108   }
109
110   public TempDescriptor getSize() {
111     return size;
112   }
113
114   public TypeDescriptor getType() {
115     return type;
116   }
117 }