01: package tide.classsyntax;
02:
03: import tide.sources.FileItem;
04:
05: /** A resolved type used for a chain element.
06: * Contains either the FileItem (preferred way) or the class (is more precise for inner classes...).
07: */
08: public final class RType {
09:
10: public Class rclass = null;
11: public FileItem fitem = null;
12: // int, double, short, boolean, float, char
13: public String primitiveType = null;
14:
15: public RType() {
16: }
17:
18: public boolean isResolved() {
19: return primitiveType != null || rclass != null || fitem != null;
20: }
21:
22: public boolean isPrimitive() {
23: return primitiveType != null;
24: }
25:
26: public String getJavaName() {
27: if (rclass != null)
28: return rclass.getName(); // Z for booleans, ...
29: if (primitiveType != null)
30: return primitiveType;
31: if (fitem != null)
32: return fitem.getJavaName();
33: return null;
34: }
35:
36: public void copyFrom(RType prev) {
37: rclass = prev.rclass;
38: fitem = prev.fitem;
39: primitiveType = prev.primitiveType;
40: }
41:
42: @Override
43: public final String toString() {
44: // new Throwable().printStackTrace();
45: if (!isResolved())
46: return "Unsolved RTYPE";
47: return "RTYPE, " + getJavaName() + " (cl:" + (rclass != null)
48: + ", it:" + (fitem != null) + ", pt:"
49: + (primitiveType != null) + ")";
50: }
51:
52: }
|