001: /*
002: * Copyright 1994-2004 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.tools.java;
027:
028: /**
029: * This interface defines constant that are used
030: * throughout the compiler. It inherits from RuntimeConstants,
031: * which is an autogenerated class that contains contstants
032: * defined in the interpreter.
033: *
034: * WARNING: The contents of this source file are not part of any
035: * supported API. Code that depends on them does so at its own risk:
036: * they are subject to change or removal without notice.
037: *
038: * @author Arthur van Hoff
039: * @version 1.98, 05/05/07
040: */
041:
042: public interface Constants extends RuntimeConstants {
043:
044: /*
045: * Enable/disable inclusion of certain debug tracing code in the
046: * compiler. When included, the tracing code may be selectively
047: * enabled at runtime, otherwise we save the space/time overhead.
048: * Should normally be 'false' for a release version.
049: */
050: public static final boolean tracing = true;
051:
052: /*
053: * Frequently used identifiers
054: */
055: Identifier idAppend = Identifier.lookup("append");
056: Identifier idClassInit = Identifier.lookup("<clinit>");
057: Identifier idCode = Identifier.lookup("Code");
058: Identifier idInit = Identifier.lookup("<init>");
059: Identifier idLength = Identifier.lookup("length");
060: Identifier idNull = Identifier.lookup("");
061: Identifier idStar = Identifier.lookup("*");
062: Identifier idSuper = Identifier.lookup("super");
063: Identifier idThis = Identifier.lookup("this");
064: Identifier idClass = Identifier.lookup("class");
065: Identifier idToString = Identifier.lookup("toString");
066: Identifier idValueOf = Identifier.lookup("valueOf");
067: Identifier idNew = Identifier.lookup("new");
068: Identifier idGetClass = Identifier.lookup("getClass");
069: Identifier idTYPE = Identifier.lookup("TYPE");
070: Identifier idFinallyReturnValue = Identifier.lookup("<return>");
071:
072: Identifier idJavaLang = Identifier.lookup("java.lang");
073:
074: Identifier idJavaLangCloneable = Identifier
075: .lookup("java.lang.Cloneable");
076:
077: Identifier idJavaLangError = Identifier.lookup("java.lang.Error");
078: Identifier idJavaLangException = Identifier
079: .lookup("java.lang.Exception");
080: Identifier idJavaLangObject = Identifier.lookup("java.lang.Object");
081: Identifier idJavaLangClass = Identifier.lookup("java.lang.Class");
082: Identifier idJavaLangRuntimeException = Identifier
083: .lookup("java.lang.RuntimeException");
084: Identifier idJavaLangString = Identifier.lookup("java.lang.String");
085: Identifier idJavaLangStringBuffer = Identifier
086: .lookup("java.lang.StringBuffer");
087: Identifier idJavaLangThrowable = Identifier
088: .lookup("java.lang.Throwable");
089:
090: Identifier idJavaIoSerializable = Identifier
091: .lookup("java.io.Serializable");
092:
093: Identifier idConstantValue = Identifier.lookup("ConstantValue");
094: Identifier idLocalVariableTable = Identifier
095: .lookup("LocalVariableTable");
096: Identifier idLineNumberTable = Identifier.lookup("LineNumberTable");
097: // JCOV
098: Identifier idCoverageTable = Identifier.lookup("CoverageTable");
099: // end JCOV
100: Identifier idSourceFile = Identifier.lookup("SourceFile");
101: Identifier idDocumentation = Identifier.lookup("Documentation");
102: Identifier idDeprecated = Identifier.lookup("Deprecated");
103: Identifier idSynthetic = Identifier.lookup("Synthetic");
104: Identifier idExceptions = Identifier.lookup("Exceptions");
105: Identifier idInnerClasses = Identifier.lookup("InnerClasses");
106:
107: /* methods we need to know about */
108: Identifier idClone = Identifier.lookup("clone");
109:
110: /* This is not a real signature marker, since it is also
111: * an identifier constituent character.
112: */
113: char SIGC_INNERCLASS = '$';
114: String SIG_INNERCLASS = "$";
115:
116: String prefixThis = "this$";
117: String prefixVal = "val$";
118: String prefixLoc = "loc$";
119: String prefixAccess = "access$";
120: String prefixClass = "class$";
121: String prefixArray = "array$";
122:
123: /*
124: * Flags
125: */
126: int F_VERBOSE = 1 << 0;
127: int F_DUMP = 1 << 1;
128: int F_WARNINGS = 1 << 2;
129:
130: // The meaning of -g has changed, so F_DEBUG flag is removed.
131: // public static final int F_DEBUG = 1 << 3;
132: int F_DEBUG_LINES = 1 << 12;
133: int F_DEBUG_VARS = 1 << 13;
134: int F_DEBUG_SOURCE = 1 << 18;
135:
136: // The meaning of -O has changed, so F_OPTIMIZE flag is removed.
137: // public static final int F_OPTIMIZE = 1 << 4;
138: int F_OPT = 1 << 14;
139: int F_OPT_INTERCLASS = 1 << 15;
140:
141: int F_DEPENDENCIES = 1 << 5;
142:
143: // JCOV
144: int F_COVERAGE = 1 << 6;
145: int F_COVDATA = 1 << 7;
146: // end JCOV
147:
148: int F_DEPRECATION = 1 << 9;
149: int F_PRINT_DEPENDENCIES = 1 << 10;
150: int F_VERSION12 = 1 << 11;
151:
152: int F_ERRORSREPORTED = 1 << 16;
153:
154: int F_STRICTDEFAULT = 1 << 17;
155:
156: /*
157: * Modifiers.
158: *
159: * There has been much confusion regarding modifiers. There
160: * are a number of distinct usages:
161: *
162: * - in classfiles to annotate classes, as per JVM pg. 102.
163: * - in classfiles to annotate methods, as per JVM pg. 104.
164: * - in classfiles to annotate InnerClass attributes, as per
165: * http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses
166: * - in the compiler to record java source level modifiers,
167: * as per JLS pg. 157 et al., plus misc. info such as whether
168: * a method is deprecated
169: * - in the JVM to record misc. info, such as whether a method has
170: * has been compiled
171: *
172: * To make matters worse, the terms "access flags" and "modifiers"
173: * are often used interchangably, and some information that might
174: * make sense as a flag is expressed using attributes (ie. Synthetic).
175: *
176: * The constants defined herein have been divided by whether they
177: * make sense only within the compiler (M_* and MM_*) or whether
178: * they only make sense to the JVM (ACC_* and ACCM_*). At an earlier
179: * time these were all lumped together. Future maintenance should
180: * strive to keep the distinction clear.
181: *
182: * Note that modifier M_STRICTFP is not in general recoverable from
183: * the ACC_STRICT bit in classfiles.
184: *
185: * Note also that the modifiers M_LOCAL and M_ANONYMOUS do not appear
186: * in the InnerClass attribute, as they are above the first 16 bits.
187: */
188:
189: // Modifiers meaningful to both Java source and the JVM. These
190: // have been kept the same bit in the M_* and ACC_* forms
191: // to avoid destabilizing the compiler.
192: int M_PUBLIC = ACC_PUBLIC;
193: int M_PRIVATE = ACC_PRIVATE;
194: int M_PROTECTED = ACC_PROTECTED;
195: int M_STATIC = ACC_STATIC;
196: int M_TRANSIENT = ACC_TRANSIENT;
197: int M_SYNCHRONIZED = ACC_SYNCHRONIZED; // collides with ACC_SUPER
198: int M_ABSTRACT = ACC_ABSTRACT;
199: int M_NATIVE = ACC_NATIVE;
200: int M_FINAL = ACC_FINAL;
201: int M_VOLATILE = ACC_VOLATILE;
202: int M_INTERFACE = ACC_INTERFACE;
203:
204: // Modifiers not meaningful to the JVM. The JVM only allows 16 bits
205: // for modifiers, so keeping these in the unusable bits after the first
206: // 16 is a good idea.
207: int M_ANONYMOUS = 0x00010000;
208: int M_LOCAL = 0x00020000;
209: int M_DEPRECATED = 0x00040000;
210: int M_SYNTHETIC = 0x00080000;
211: int M_INLINEABLE = 0x00100000;
212:
213: int M_STRICTFP = 0x00200000;
214:
215: String paraDeprecated = "@deprecated";
216:
217: // Masks for modifiers that apply to Java source code
218: int MM_CLASS = M_PUBLIC | M_INTERFACE | M_FINAL | M_ABSTRACT
219: | M_STRICTFP;
220: int MM_MEMBER = M_PUBLIC | M_PRIVATE | M_PROTECTED | M_FINAL
221: | M_STATIC;
222: int MM_FIELD = MM_MEMBER | M_TRANSIENT | M_VOLATILE;
223: int MM_METHOD = MM_MEMBER | M_SYNCHRONIZED | M_ABSTRACT | M_NATIVE
224: | M_STRICTFP;
225:
226: // Masks for modifiers that apply to class files.
227: // Note that the M_SYNTHETIC modifier is never written out to a class file.
228: // Synthetic members are indicated using the "Synthetic" attribute.
229: int ACCM_CLASS = ACC_PUBLIC | ACC_INTERFACE | ACC_FINAL
230: | ACC_ABSTRACT | ACC_SUPER | ACC_STRICT;
231: int ACCM_MEMBER = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED
232: | ACC_FINAL | ACC_STATIC;
233: // The M_ANONYMOUS and M_LOCAL modifiers are not mentioned in the
234: // inner classes specification and are never written to classfiles.
235: // Also note that ACC_SUPER should never be set in an InnerClass
236: // attribute.
237: int ACCM_INNERCLASS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED
238: | ACC_STATIC | ACC_ABSTRACT | ACC_FINAL | ACC_INTERFACE
239: | ACC_STRICT;
240: int ACCM_FIELD = ACCM_MEMBER | ACC_TRANSIENT | ACC_VOLATILE;
241: int ACCM_METHOD = ACCM_MEMBER | ACC_SYNCHRONIZED | ACC_ABSTRACT
242: | ACC_NATIVE | ACC_STRICT;
243:
244: /*
245: * Type codes
246: */
247: int TC_BOOLEAN = 0;
248: int TC_BYTE = 1;
249: int TC_CHAR = 2;
250: int TC_SHORT = 3;
251: int TC_INT = 4;
252: int TC_LONG = 5;
253: int TC_FLOAT = 6;
254: int TC_DOUBLE = 7;
255: int TC_NULL = 8;
256: int TC_ARRAY = 9;
257: int TC_CLASS = 10;
258: int TC_VOID = 11;
259: int TC_METHOD = 12;
260: int TC_ERROR = 13;
261:
262: // JCOV
263: /*
264: * Cover's types
265: */
266: int CT_FIRST_KIND = 1;
267: int CT_METHOD = 1;
268: int CT_FIKT_METHOD = 2;
269: int CT_BLOCK = 3;
270: int CT_FIKT_RET = 4;
271: int CT_CASE = 5;
272: int CT_SWITH_WO_DEF = 6;
273: int CT_BRANCH_TRUE = 7;
274: int CT_BRANCH_FALSE = 8;
275: int CT_LAST_KIND = 8;
276: // end JCOV
277:
278: /*
279: * Type Masks
280: */
281: int TM_NULL = 1 << TC_NULL;
282: int TM_VOID = 1 << TC_VOID;
283: int TM_BOOLEAN = 1 << TC_BOOLEAN;
284: int TM_BYTE = 1 << TC_BYTE;
285: int TM_CHAR = 1 << TC_CHAR;
286: int TM_SHORT = 1 << TC_SHORT;
287: int TM_INT = 1 << TC_INT;
288: int TM_LONG = 1 << TC_LONG;
289: int TM_FLOAT = 1 << TC_FLOAT;
290: int TM_DOUBLE = 1 << TC_DOUBLE;
291: int TM_ARRAY = 1 << TC_ARRAY;
292: int TM_CLASS = 1 << TC_CLASS;
293: int TM_METHOD = 1 << TC_METHOD;
294: int TM_ERROR = 1 << TC_ERROR;
295:
296: int TM_INT32 = TM_BYTE | TM_SHORT | TM_CHAR | TM_INT;
297: int TM_NUM32 = TM_INT32 | TM_FLOAT;
298: int TM_NUM64 = TM_LONG | TM_DOUBLE;
299: int TM_INTEGER = TM_INT32 | TM_LONG;
300: int TM_REAL = TM_FLOAT | TM_DOUBLE;
301: int TM_NUMBER = TM_INTEGER | TM_REAL;
302: int TM_REFERENCE = TM_ARRAY | TM_CLASS | TM_NULL;
303:
304: /*
305: * Class status
306: */
307: int CS_UNDEFINED = 0;
308: int CS_UNDECIDED = 1;
309: int CS_BINARY = 2;
310: int CS_SOURCE = 3;
311: int CS_PARSED = 4;
312: int CS_CHECKED = 5;
313: int CS_COMPILED = 6;
314: int CS_NOTFOUND = 7;
315:
316: /*
317: * Attributes
318: */
319: int ATT_ALL = 0xFFFFFFFF;
320: int ATT_CODE = 1 << 1;
321: int ATT_ALLCLASSES = 1 << 2;
322:
323: /*
324: * Number of bits used in file offsets. The line number and
325: * file offset are concatenated into a long, with enough room
326: * for other information to be added later if desired (such as
327: * token lengths). For the moment explicit bit manipulations
328: * are used to modify the fields. This makes sense for efficiency
329: * but at some point these ought to be better encapsulated.
330: */
331: int WHEREOFFSETBITS = 32;
332: long MAXFILESIZE = (1L << WHEREOFFSETBITS) - 1;
333: long MAXLINENUMBER = (1L << (64 - WHEREOFFSETBITS)) - 1;
334:
335: /*
336: * Operators
337: */
338: int COMMA = 0;
339: int ASSIGN = 1;
340:
341: int ASGMUL = 2;
342: int ASGDIV = 3;
343: int ASGREM = 4;
344: int ASGADD = 5;
345: int ASGSUB = 6;
346: int ASGLSHIFT = 7;
347: int ASGRSHIFT = 8;
348: int ASGURSHIFT = 9;
349: int ASGBITAND = 10;
350: int ASGBITOR = 11;
351: int ASGBITXOR = 12;
352:
353: int COND = 13;
354: int OR = 14;
355: int AND = 15;
356: int BITOR = 16;
357: int BITXOR = 17;
358: int BITAND = 18;
359: int NE = 19;
360: int EQ = 20;
361: int GE = 21;
362: int GT = 22;
363: int LE = 23;
364: int LT = 24;
365: int INSTANCEOF = 25;
366: int LSHIFT = 26;
367: int RSHIFT = 27;
368: int URSHIFT = 28;
369: int ADD = 29;
370: int SUB = 30;
371: int DIV = 31;
372: int REM = 32;
373: int MUL = 33;
374: int CAST = 34; // (x)y
375: int POS = 35; // +x
376: int NEG = 36; // -x
377: int NOT = 37;
378: int BITNOT = 38;
379: int PREINC = 39; // ++x
380: int PREDEC = 40; // --x
381: int NEWARRAY = 41;
382: int NEWINSTANCE = 42;
383: int NEWFROMNAME = 43;
384: int POSTINC = 44; // x++
385: int POSTDEC = 45; // x--
386: int FIELD = 46;
387: int METHOD = 47; // x(y)
388: int ARRAYACCESS = 48; // x[y]
389: int NEW = 49;
390: int INC = 50;
391: int DEC = 51;
392:
393: int CONVERT = 55; // implicit conversion
394: int EXPR = 56; // (x)
395: int ARRAY = 57; // {x, y, ...}
396: int GOTO = 58;
397:
398: /*
399: * Value tokens
400: */
401: int IDENT = 60;
402: int BOOLEANVAL = 61;
403: int BYTEVAL = 62;
404: int CHARVAL = 63;
405: int SHORTVAL = 64;
406: int INTVAL = 65;
407: int LONGVAL = 66;
408: int FLOATVAL = 67;
409: int DOUBLEVAL = 68;
410: int STRINGVAL = 69;
411:
412: /*
413: * Type keywords
414: */
415: int BYTE = 70;
416: int CHAR = 71;
417: int SHORT = 72;
418: int INT = 73;
419: int LONG = 74;
420: int FLOAT = 75;
421: int DOUBLE = 76;
422: int VOID = 77;
423: int BOOLEAN = 78;
424:
425: /*
426: * Expression keywords
427: */
428: int TRUE = 80;
429: int FALSE = 81;
430: int THIS = 82;
431: int SUPER = 83;
432: int NULL = 84;
433:
434: /*
435: * Statement keywords
436: */
437: int IF = 90;
438: int ELSE = 91;
439: int FOR = 92;
440: int WHILE = 93;
441: int DO = 94;
442: int SWITCH = 95;
443: int CASE = 96;
444: int DEFAULT = 97;
445: int BREAK = 98;
446: int CONTINUE = 99;
447: int RETURN = 100;
448: int TRY = 101;
449: int CATCH = 102;
450: int FINALLY = 103;
451: int THROW = 104;
452: int STAT = 105;
453: int EXPRESSION = 106;
454: int DECLARATION = 107;
455: int VARDECLARATION = 108;
456:
457: /*
458: * Declaration keywords
459: */
460: int IMPORT = 110;
461: int CLASS = 111;
462: int EXTENDS = 112;
463: int IMPLEMENTS = 113;
464: int INTERFACE = 114;
465: int PACKAGE = 115;
466:
467: /*
468: * Modifier keywords
469: */
470: int PRIVATE = 120;
471: int PUBLIC = 121;
472: int PROTECTED = 122;
473: int CONST = 123;
474: int STATIC = 124;
475: int TRANSIENT = 125;
476: int SYNCHRONIZED = 126;
477: int NATIVE = 127;
478: int FINAL = 128;
479: int VOLATILE = 129;
480: int ABSTRACT = 130;
481: int STRICTFP = 131;
482:
483: /*
484: * Punctuation
485: */
486: int SEMICOLON = 135;
487: int COLON = 136;
488: int QUESTIONMARK = 137;
489: int LBRACE = 138;
490: int RBRACE = 139;
491: int LPAREN = 140;
492: int RPAREN = 141;
493: int LSQBRACKET = 142;
494: int RSQBRACKET = 143;
495: int THROWS = 144;
496:
497: /*
498: * Special tokens
499: */
500: int ERROR = 145; // an error
501: int COMMENT = 146; // not used anymore.
502: int TYPE = 147;
503: int LENGTH = 148;
504: int INLINERETURN = 149;
505: int INLINEMETHOD = 150;
506: int INLINENEWINSTANCE = 151;
507:
508: /*
509: * Operator precedence
510: */
511: int opPrecedence[] = { 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
512: 11, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 19, 19, 19, 19,
513: 20, 20, 20, 21, 21, 22, 22, 22, 23, 24, 24, 24, 24, 24, 24,
514: 25, 25, 26, 26, 26, 26, 26, 26 };
515:
516: /*
517: * Operator names
518: */
519: String opNames[] = { ",", "=", "*=", "/=", "%=", "+=", "-=", "<<=",
520: ">>=", ">>>=", "&=", "|=", "^=", "?:", "||", "&&", "|",
521: "^", "&", "!=", "==", ">=", ">", "<=", "<", "instanceof",
522: "<<", ">>", ">>>", "+", "-", "/", "%", "*", "cast", "+",
523: "-", "!", "~", "++", "--", "new", "new", "new", "++", "--",
524: "field", "method", "[]", "new", "++", "--", null, null,
525: null,
526:
527: "convert", "expr", "array", "goto", null,
528:
529: "Identifier", "boolean", "byte", "char", "short", "int",
530: "long", "float", "double", "string",
531:
532: "byte", "char", "short", "int", "long", "float", "double",
533: "void", "boolean", null,
534:
535: "true", "false", "this", "super", "null", null, null, null,
536: null, null,
537:
538: "if", "else", "for", "while", "do", "switch", "case",
539: "default", "break", "continue", "return", "try", "catch",
540: "finally", "throw", "stat", "expression", "declaration",
541: "declaration", null,
542:
543: "import", "class", "extends", "implements", "interface",
544: "package", null, null, null, null,
545:
546: "private", "public", "protected", "const", "static",
547: "transient", "synchronized", "native", "final", "volatile",
548: "abstract", "strictfp", null, null, null,
549:
550: ";", ":", "?", "{", "}", "(", ")", "[", "]", "throws",
551: "error", "comment", "type", "length", "inline-return",
552: "inline-method", "inline-new" };
553: }
|