Added:
[repair.git] / Repair / RepairCompiler / MCC / IR / FieldDescriptor.java
1 /**
2  * FieldDescriptor
3  *
4  * represents a field of a type
5  */
6
7 package MCC.IR;
8
9 public class FieldDescriptor extends Descriptor {
10
11     TypeDescriptor type;
12     boolean ptr;
13
14     public FieldDescriptor(String name) {
15         super(name);
16     }
17
18     public TypeDescriptor getType() {
19         assert type != null;
20         return type;
21     }
22
23     public void setType(TypeDescriptor td) {
24         assert td != null;
25         type = td;
26     }
27
28     public void setPtr(boolean ptr) {
29         this.ptr = ptr;
30     }
31
32     public boolean getPtr() {
33         return ptr;
34     }
35
36     public Expr getBaseSizeExpr() {
37         if (ptr) { /* ptrs are 32bits */
38             return new IntegerLiteralExpr(32);
39         } else {
40             return type.getSizeExpr();
41         }
42     }
43
44 }