src/share/classes/com/sun/tools/javac/jvm/Code.java

changeset 1374
c002fdee76fd
parent 1339
0e5899f09dab
child 1442
fcf89720ae71
equal deleted inserted replaced
1373:4a1c57a1c410 1374:c002fdee76fd
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;
240 case BOT: 241 case BOT:
241 case TYPEVAR: 242 case TYPEVAR:
242 case UNINITIALIZED_THIS: 243 case UNINITIALIZED_THIS:
243 case UNINITIALIZED_OBJECT: 244 case UNINITIALIZED_OBJECT:
244 return OBJECTcode; 245 return OBJECTcode;
245 default: throw new AssertionError("typecode " + type.tag); 246 default: throw new AssertionError("typecode " + type.getTag());
246 } 247 }
247 } 248 }
248 249
249 /** Collapse type code for subtypes of int to INTcode. 250 /** Collapse type code for subtypes of int to INTcode.
250 */ 251 */
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_:
1654 locks[nlocks] = -1; 1655 locks[nlocks] = -1;
1655 } 1656 }
1656 1657
1657 void push(Type t) { 1658 void push(Type t) {
1658 if (debugCode) System.err.println(" pushing " + t); 1659 if (debugCode) System.err.println(" pushing " + t);
1659 switch (t.tag) { 1660 switch (t.getTag()) {
1660 case TypeTags.VOID: 1661 case VOID:
1661 return; 1662 return;
1662 case TypeTags.BYTE: 1663 case BYTE:
1663 case TypeTags.CHAR: 1664 case CHAR:
1664 case TypeTags.SHORT: 1665 case SHORT:
1665 case TypeTags.BOOLEAN: 1666 case BOOLEAN:
1666 t = syms.intType; 1667 t = syms.intType;
1667 break; 1668 break;
1668 default: 1669 default:
1669 break; 1670 break;
1670 } 1671 }
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),
1822 System.err.println(); 1823 System.err.println();
1823 } 1824 }
1824 } 1825 }
1825 } 1826 }
1826 1827
1827 static Type jsrReturnValue = new Type(TypeTags.INT, null); 1828 static Type jsrReturnValue = new Type(INT, null);
1828 1829
1829 1830
1830 /* ************************************************************************** 1831 /* **************************************************************************
1831 * Local variables 1832 * Local variables
1832 ****************************************************************************/ 1833 ****************************************************************************/

mercurial