changes`
[IRC.git] / Robust / src / IR / TypeDescriptor.java
1 package IR;
2
3 /**
4  * Descriptor 
5  *
6  * represents a symbol in the language (var name, function name, etc).
7  */
8
9 public class TypeDescriptor extends Descriptor {
10     public static final int BYTE=1;
11     public static final int SHORT=2;
12     public static final int INT=3;
13     public static final int LONG=4;
14     public static final int CHAR=5;
15     public static final int FLOAT=6;
16     public static final int DOUBLE=7;
17     public static final int CLASS=8;
18
19     int type;
20     NameDescriptor name_desc;
21     
22     public TypeDescriptor(NameDescriptor name) {
23         super(name.toString());
24         this.type=CLASS;
25         this.name_desc=name;
26     }
27
28     public TypeDescriptor(int t) {
29         super(decodeInt(t));
30         this.type=t;
31     }
32
33     public String toString() {
34         if (type==CLASS)
35             return name_desc.toString();
36         else 
37             return decodeInt(type);
38     }
39
40     private static String decodeInt(int type) {
41         if (type==BYTE)
42             return "byte";
43         else if (type==SHORT)
44             return "short";
45         else if (type==INT)
46             return "int";
47         else if (type==LONG)
48             return "long";
49         else if (type==CHAR)
50             return "char";
51         else if (type==FLOAT)
52             return "float";
53         else if (type==DOUBLE)
54             return "double";
55         else throw new Error();
56     }
57 }