1 11 package org.eclipse.jdt.internal.compiler.lookup; 12 13 public final class BaseTypeBinding extends TypeBinding { 14 15 public char[] simpleName; 16 private char[] constantPoolName; 17 18 BaseTypeBinding(int id, char[] name, char[] constantPoolName) { 19 20 this.tagBits |= TagBits.IsBaseType; 21 this.id = id; 22 this.simpleName = name; 23 this.constantPoolName = constantPoolName; 24 } 25 26 29 public char[] computeUniqueKey(boolean isLeaf) { 30 return constantPoolName(); 31 } 32 33 35 public char[] constantPoolName() { 36 37 return constantPoolName; 38 } 39 40 public PackageBinding getPackage() { 41 42 return null; 43 } 44 45 47 public final boolean isCompatibleWith(TypeBinding right) { 48 49 if (this == right) 50 return true; 51 if (!right.isBaseType()) 52 return this == TypeBinding.NULL; 53 54 switch (right.id) { 55 case TypeIds.T_boolean : 56 case TypeIds.T_byte : 57 case TypeIds.T_char : 58 return false; 59 case TypeIds.T_double : 60 switch (id) { 61 case TypeIds.T_byte : 62 case TypeIds.T_char : 63 case TypeIds.T_short : 64 case TypeIds.T_int : 65 case TypeIds.T_long : 66 case TypeIds.T_float : 67 return true; 68 default : 69 return false; 70 } 71 case TypeIds.T_float : 72 switch (id) { 73 case TypeIds.T_byte : 74 case TypeIds.T_char : 75 case TypeIds.T_short : 76 case TypeIds.T_int : 77 case TypeIds.T_long : 78 return true; 79 default : 80 return false; 81 } 82 case TypeIds.T_long : 83 switch (id) { 84 case TypeIds.T_byte : 85 case TypeIds.T_char : 86 case TypeIds.T_short : 87 case TypeIds.T_int : 88 return true; 89 default : 90 return false; 91 } 92 case TypeIds.T_int : 93 switch (id) { 94 case TypeIds.T_byte : 95 case TypeIds.T_char : 96 case TypeIds.T_short : 97 return true; 98 default : 99 return false; 100 } 101 case TypeIds.T_short : 102 return (id == TypeIds.T_byte); 103 } 104 return false; 105 } 106 107 public static final boolean isNarrowing(int left, int right) { 108 109 switch (left) { 112 case TypeIds.T_boolean : 113 return right == TypeIds.T_boolean; 114 case TypeIds.T_char : 115 case TypeIds.T_byte : 116 if (right == TypeIds.T_byte) 117 return true; 118 case TypeIds.T_short : 119 if (right == TypeIds.T_short) 120 return true; 121 if (right == TypeIds.T_char) 122 return true; 123 case TypeIds.T_int : 124 if (right == TypeIds.T_int) 125 return true; 126 case TypeIds.T_long : 127 if (right == TypeIds.T_long) 128 return true; 129 case TypeIds.T_float : 130 if (right == TypeIds.T_float) 131 return true; 132 case TypeIds.T_double : 133 if (right == TypeIds.T_double) 134 return true; 135 default : 136 return false; 137 } 138 } 139 143 public boolean isUncheckedException(boolean includeSupertype) { 144 return this == TypeBinding.NULL; 145 } 146 public static final boolean isWidening(int left, int right) { 147 148 switch (left) { 151 case TypeIds.T_boolean : 152 return right == TypeIds.T_boolean; 153 case TypeIds.T_char : 154 return right == TypeIds.T_char; 155 case TypeIds.T_double : 156 if (right == TypeIds.T_double) 157 return true; 158 case TypeIds.T_float : 159 if (right == TypeIds.T_float) 160 return true; 161 case TypeIds.T_long : 162 if (right == TypeIds.T_long) 163 return true; 164 case TypeIds.T_int : 165 if (right == TypeIds.T_int) 166 return true; 167 if (right == TypeIds.T_char) 168 return true; 169 case TypeIds.T_short : 170 if (right == TypeIds.T_short) 171 return true; 172 case TypeIds.T_byte : 173 if (right == TypeIds.T_byte) 174 return true; 175 default : 176 return false; 177 } 178 } 179 182 public int kind() { 183 return Binding.BASE_TYPE; 184 } 185 public char[] qualifiedSourceName() { 186 return simpleName; 187 } 188 189 public char[] readableName() { 190 return simpleName; 191 } 192 193 public char[] shortReadableName() { 194 return simpleName; 195 } 196 197 public char[] sourceName() { 198 return simpleName; 199 } 200 201 public String toString() { 202 return new String (constantPoolName) + " (id=" + id + ")"; } 204 } 205 | Popular Tags |