6 * represents a symbol in the language (var name, function name, etc).
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 BOOLEAN=6;
16 public static final int FLOAT=7;
17 public static final int DOUBLE=8;
18 public static final int VOID=9;
19 public static final int NULL=10;
20 public static final int CLASS=11;
25 ClassDescriptor class_desc;
27 public String getSafeSymbol() {
29 return class_desc.getSafeSymbol();
38 else if (isBoolean()) //Booleans are ints in C
48 else throw new Error("Error Type: "+type);
51 public String getSafeDescriptor() {
53 return class_desc.getSafeDescriptor();
70 else throw new Error();
73 public boolean isNumber() {
74 return (isIntegerType()||isFloat()||isDouble());
77 public boolean isByte() {
80 public boolean isNull() {
83 public boolean isShort() {
86 public boolean isInt() {
89 public boolean isLong() {
92 public boolean isChar() {
95 public boolean isBoolean() {
98 public boolean isFloat() {
101 public boolean isDouble() {
104 public boolean isVoid() {
108 public boolean isPtr() {
109 return (isClass()||isNull());
112 public boolean isIntegerType() {
113 return (isInt()||isLong()||isShort()||isChar()||isByte());
116 public void setClassDescriptor(ClassDescriptor cd) {
120 public boolean isPrimitive() {
121 return ((type>=BYTE)&&(type<=DOUBLE));
124 public boolean isClass() {
128 public TypeDescriptor(NameDescriptor name) {
129 super(name.toString());
131 this.class_desc=null;
134 public ClassDescriptor getClassDesc() {
138 public TypeDescriptor(ClassDescriptor cd) {
139 super(cd.getSymbol());
144 public TypeDescriptor(int t) {
149 public String toString() {
153 return decodeInt(type);
156 private static String decodeInt(int type) {
159 else if (type==BOOLEAN)
161 else if (type==SHORT)
169 else if (type==FLOAT)
171 else if (type==DOUBLE)
177 else throw new Error();