28 import com.sun.tools.javac.code.*; |
28 import com.sun.tools.javac.code.*; |
29 import com.sun.tools.javac.code.Symbol.*; |
29 import com.sun.tools.javac.code.Symbol.*; |
30 import com.sun.tools.javac.util.*; |
30 import com.sun.tools.javac.util.*; |
31 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
31 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
32 |
32 |
33 import static com.sun.tools.javac.code.TypeTags.*; |
33 import static com.sun.tools.javac.code.TypeTag.BOT; |
|
34 import static com.sun.tools.javac.code.TypeTag.INT; |
34 import static com.sun.tools.javac.jvm.ByteCodes.*; |
35 import static com.sun.tools.javac.jvm.ByteCodes.*; |
35 import static com.sun.tools.javac.jvm.UninitializedType.*; |
36 import static com.sun.tools.javac.jvm.UninitializedType.*; |
36 import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame; |
37 import static com.sun.tools.javac.jvm.ClassWriter.StackMapTableFrame; |
37 |
38 |
38 /** An internal structure that corresponds to the code attribute of |
39 /** An internal structure that corresponds to the code attribute of |
222 |
223 |
223 /** Given a type, return its type code (used implicitly in the |
224 /** Given a type, return its type code (used implicitly in the |
224 * JVM architecture). |
225 * JVM architecture). |
225 */ |
226 */ |
226 public static int typecode(Type type) { |
227 public static int typecode(Type type) { |
227 switch (type.tag) { |
228 switch (type.getTag()) { |
228 case BYTE: return BYTEcode; |
229 case BYTE: return BYTEcode; |
229 case SHORT: return SHORTcode; |
230 case SHORT: return SHORTcode; |
230 case CHAR: return CHARcode; |
231 case CHAR: return CHARcode; |
231 case INT: return INTcode; |
232 case INT: return INTcode; |
232 case LONG: return LONGcode; |
233 case LONG: return LONGcode; |
279 } |
280 } |
280 |
281 |
281 /** Given a type, return its code for allocating arrays of that type. |
282 /** Given a type, return its code for allocating arrays of that type. |
282 */ |
283 */ |
283 public static int arraycode(Type type) { |
284 public static int arraycode(Type type) { |
284 switch (type.tag) { |
285 switch (type.getTag()) { |
285 case BYTE: return 8; |
286 case BYTE: return 8; |
286 case BOOLEAN: return 4; |
287 case BOOLEAN: return 4; |
287 case SHORT: return 9; |
288 case SHORT: return 9; |
288 case CHAR: return 5; |
289 case CHAR: return 5; |
289 case INT: return 10; |
290 case INT: return 10; |
475 state.pop(1);// index |
476 state.pop(1);// index |
476 Type a = state.stack[state.stacksize-1]; |
477 Type a = state.stack[state.stacksize-1]; |
477 state.pop(1); |
478 state.pop(1); |
478 //sometimes 'null type' is treated as a one-dimensional array type |
479 //sometimes 'null type' is treated as a one-dimensional array type |
479 //see Gen.visitLiteral - we should handle this case accordingly |
480 //see Gen.visitLiteral - we should handle this case accordingly |
480 Type stackType = a.tag == BOT ? |
481 Type stackType = a.hasTag(BOT) ? |
481 syms.objectType : |
482 syms.objectType : |
482 types.erasure(types.elemtype(a)); |
483 types.erasure(types.elemtype(a)); |
483 state.push(stackType); } |
484 state.push(stackType); } |
484 break; |
485 break; |
485 case goto_: |
486 case goto_: |
1720 |
1721 |
1721 /** Force the top of the stack to be treated as this supertype |
1722 /** Force the top of the stack to be treated as this supertype |
1722 * of its current type. */ |
1723 * of its current type. */ |
1723 void forceStackTop(Type t) { |
1724 void forceStackTop(Type t) { |
1724 if (!alive) return; |
1725 if (!alive) return; |
1725 switch (t.tag) { |
1726 switch (t.getTag()) { |
1726 case CLASS: |
1727 case CLASS: |
1727 case ARRAY: |
1728 case ARRAY: |
1728 int width = width(t); |
1729 int width = width(t); |
1729 Type old = stack[stacksize-width]; |
1730 Type old = stack[stacksize-width]; |
1730 Assert.check(types.isSubtype(types.erasure(old), |
1731 Assert.check(types.isSubtype(types.erasure(old), |