Source Code Cross Referenced for Tables.java in  » 6.0-JDK-Modules-sun » tools » sun » tools » javap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules sun » tools » sun.tools.javap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 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.javap;
027:
028:        import java.io.IOException;
029:        import java.io.InputStream;
030:        import java.util.Hashtable;
031:        import java.util.Vector;
032:
033:        public class Tables implements  Constants {
034:            /**
035:             * Define mnemocodes table.
036:             */
037:            static Hashtable mnemocodes = new Hashtable(301, 0.5f);
038:            static String opcExtNamesTab[] = new String[128];
039:            static String opcPrivExtNamesTab[] = new String[128];
040:
041:            static void defineNonPriv(int opc, String mnem) {
042:                mnemocodes.put(opcExtNamesTab[opc] = mnem, new Integer(
043:                        opc_nonpriv * 256 + opc));
044:            }
045:
046:            static void definePriv(int opc, String mnem) {
047:                mnemocodes.put(opcPrivExtNamesTab[opc] = "priv_" + mnem,
048:                        new Integer(opc_priv * 256 + opc));
049:            }
050:
051:            static void defineExt(int opc, String mnem) {
052:                defineNonPriv(opc, mnem);
053:                definePriv(opc, mnem);
054:            }
055:
056:            static {
057:                int k;
058:                for (k = 0; k < opc_wide; k++) {
059:                    mnemocodes.put(opcNamesTab[k], new Integer(k));
060:                }
061:                for (k = opc_wide + 1; k < opcNamesTab.length; k++) {
062:                    mnemocodes.put(opcNamesTab[k], new Integer(k));
063:                }
064:                mnemocodes.put("invokenonvirtual", new Integer(
065:                        opc_invokespecial));
066:
067:                mnemocodes.put("iload_w", new Integer(opc_iload_w));
068:                mnemocodes.put("lload_w", new Integer(opc_lload_w));
069:                mnemocodes.put("fload_w", new Integer(opc_fload_w));
070:                mnemocodes.put("dload_w", new Integer(opc_dload_w));
071:                mnemocodes.put("aload_w", new Integer(opc_aload_w));
072:                mnemocodes.put("istore_w", new Integer(opc_istore_w));
073:                mnemocodes.put("lstore_w", new Integer(opc_lstore_w));
074:                mnemocodes.put("fstore_w", new Integer(opc_fstore_w));
075:                mnemocodes.put("dstore_w", new Integer(opc_dstore_w));
076:                mnemocodes.put("astore_w", new Integer(opc_astore_w));
077:                mnemocodes.put("ret_w", new Integer(opc_ret_w));
078:                mnemocodes.put("iinc_w", new Integer(opc_iinc_w));
079:
080:                mnemocodes.put("nonpriv", new Integer(opc_nonpriv));
081:                mnemocodes.put("priv", new Integer(opc_priv));
082:
083:                defineExt(0, "load_ubyte");
084:                defineExt(1, "load_byte");
085:                defineExt(2, "load_char");
086:                defineExt(3, "load_short");
087:                defineExt(4, "load_word");
088:                defineExt(10, "load_char_oe");
089:                defineExt(11, "load_short_oe");
090:                defineExt(12, "load_word_oe");
091:                defineExt(16, "ncload_ubyte");
092:                defineExt(17, "ncload_byte");
093:                defineExt(18, "ncload_char");
094:                defineExt(19, "ncload_short");
095:                defineExt(20, "ncload_word");
096:                defineExt(26, "ncload_char_oe");
097:                defineExt(27, "ncload_short_oe");
098:                defineExt(28, "ncload_word_oe");
099:                defineExt(30, "cache_flush");
100:                defineExt(32, "store_byte");
101:                defineExt(34, "store_short");
102:                defineExt(36, "store_word");
103:                defineExt(42, "store_short_oe");
104:                defineExt(44, "store_word_oe");
105:                defineExt(48, "ncstore_byte");
106:                defineExt(50, "ncstore_short");
107:                defineExt(52, "ncstore_word");
108:                defineExt(58, "ncstore_short_oe");
109:                defineExt(60, "ncstore_word_oe");
110:                defineExt(62, "zero_line");
111:                defineNonPriv(5, "ret_from_sub");
112:                defineNonPriv(63, "enter_sync_method");
113:                definePriv(5, "ret_from_trap");
114:                definePriv(6, "read_dcache_tag");
115:                definePriv(7, "read_dcache_data");
116:                definePriv(14, "read_icache_tag");
117:                definePriv(15, "read_icache_data");
118:                definePriv(22, "powerdown");
119:                definePriv(23, "read_scache_data");
120:                definePriv(31, "cache_index_flush");
121:                definePriv(38, "write_dcache_tag");
122:                definePriv(39, "write_dcache_data");
123:                definePriv(46, "write_icache_tag");
124:                definePriv(47, "write_icache_data");
125:                definePriv(54, "reset");
126:                definePriv(55, "write_scache_data");
127:                for (k = 0; k < 32; k++) {
128:                    definePriv(k + 64, "read_reg_" + k);
129:                }
130:                for (k = 0; k < 32; k++) {
131:                    definePriv(k + 96, "write_reg_" + k);
132:                }
133:            }
134:
135:            public static int opcLength(int opc)
136:                    throws ArrayIndexOutOfBoundsException {
137:                switch (opc >> 8) {
138:                case 0:
139:                    return opcLengthsTab[opc];
140:                case opc_wide:
141:                    switch (opc & 0xFF) {
142:                    case opc_aload:
143:                    case opc_astore:
144:                    case opc_fload:
145:                    case opc_fstore:
146:                    case opc_iload:
147:                    case opc_istore:
148:                    case opc_lload:
149:                    case opc_lstore:
150:                    case opc_dload:
151:                    case opc_dstore:
152:                    case opc_ret:
153:                        return 4;
154:                    case opc_iinc:
155:                        return 6;
156:                    default:
157:                        throw new ArrayIndexOutOfBoundsException();
158:                    }
159:                case opc_nonpriv:
160:                case opc_priv:
161:                    return 2;
162:                default:
163:                    throw new ArrayIndexOutOfBoundsException();
164:                }
165:            }
166:
167:            public static String opcName(int opc) {
168:                try {
169:                    switch (opc >> 8) {
170:                    case 0:
171:                        return opcNamesTab[opc];
172:                    case opc_wide: {
173:                        String mnem = opcNamesTab[opc & 0xFF] + "_w";
174:                        if (mnemocodes.get(mnem) == null)
175:                            return null; // non-existent opcode
176:                        return mnem;
177:                    }
178:                    case opc_nonpriv:
179:                        return opcExtNamesTab[opc & 0xFF];
180:                    case opc_priv:
181:                        return opcPrivExtNamesTab[opc & 0xFF];
182:                    default:
183:                        return null;
184:                    }
185:                } catch (ArrayIndexOutOfBoundsException e) {
186:                    switch (opc) {
187:                    case opc_nonpriv:
188:                        return "nonpriv";
189:                    case opc_priv:
190:                        return "priv";
191:                    default:
192:                        return null;
193:                    }
194:                }
195:            }
196:
197:            public static int opcode(String mnem) {
198:                Integer Val = (Integer) (mnemocodes.get(mnem));
199:                if (Val == null)
200:                    return -1;
201:                return Val.intValue();
202:            }
203:
204:            /**
205:             * Initialized keyword and token Hashtables
206:             */
207:            static Vector keywordNames = new Vector(40);
208:
209:            private static void defineKeywordName(String id, int token) {
210:
211:                if (token >= keywordNames.size()) {
212:                    keywordNames.setSize(token + 1);
213:                }
214:                keywordNames.setElementAt(id, token);
215:            }
216:
217:            public static String keywordName(int token) {
218:                if (token == -1)
219:                    return "EOF";
220:                if (token >= keywordNames.size())
221:                    return null;
222:                return (String) keywordNames.elementAt(token);
223:            }
224:
225:            static {
226:                defineKeywordName("ident", IDENT);
227:                defineKeywordName("STRINGVAL", STRINGVAL);
228:                defineKeywordName("intVal", INTVAL);
229:                defineKeywordName("longVal", LONGVAL);
230:                defineKeywordName("floatVal", FLOATVAL);
231:                defineKeywordName("doubleVal", DOUBLEVAL);
232:                defineKeywordName("SEMICOLON", SEMICOLON);
233:                defineKeywordName("COLON", COLON);
234:                defineKeywordName("LBRACE", LBRACE);
235:                defineKeywordName("RBRACE", RBRACE);
236:            }
237:
238:            static Hashtable keywords = new Hashtable(40);
239:
240:            public static int keyword(String idValue) {
241:                Integer Val = (Integer) (keywords.get(idValue));
242:                if (Val == null)
243:                    return IDENT;
244:                return Val.intValue();
245:            }
246:
247:            private static void defineKeyword(String id, int token) {
248:                keywords.put(id, new Integer(token));
249:                defineKeywordName(id, token);
250:            }
251:
252:            static {
253:                // Modifier keywords
254:                defineKeyword("private", PRIVATE);
255:                defineKeyword("public", PUBLIC);
256:                defineKeyword("protected", PROTECTED);
257:                defineKeyword("static", STATIC);
258:                defineKeyword("transient", TRANSIENT);
259:                defineKeyword("synchronized", SYNCHRONIZED);
260:                defineKeyword("super", SUPER);
261:                defineKeyword("native", NATIVE);
262:                defineKeyword("abstract", ABSTRACT);
263:                defineKeyword("volatile", VOLATILE);
264:                defineKeyword("final", FINAL);
265:                defineKeyword("interface", INTERFACE);
266:                defineKeyword("synthetic", SYNTHETIC);
267:                defineKeyword("strict", STRICT);
268:
269:                // Declaration keywords
270:                defineKeyword("package", PACKAGE);
271:                defineKeyword("class", CLASS);
272:                defineKeyword("extends", EXTENDS);
273:                defineKeyword("implements", IMPLEMENTS);
274:                defineKeyword("const", CONST);
275:                defineKeyword("throws", THROWS);
276:                defineKeyword("interface", INTERFACE);
277:                defineKeyword("Method", METHODREF);
278:                defineKeyword("Field", FIELDREF);
279:                defineKeyword("stack", STACK);
280:                defineKeyword("locals", LOCAL);
281:
282:                // used in switchtables
283:                defineKeyword("default", DEFAULT);
284:
285:                // used in inner class declarations
286:                defineKeyword("InnerClass", INNERCLASS);
287:                defineKeyword("of", OF);
288:
289:                // misc
290:                defineKeyword("bits", BITS);
291:                defineKeyword("Infinity", INF);
292:                defineKeyword("Inf", INF);
293:                defineKeyword("NaN", NAN);
294:            }
295:
296:            /**
297:             * Define tag table.
298:             */
299:            private static Vector tagNames = new Vector(10);
300:            private static Hashtable Tags = new Hashtable(10);
301:            static {
302:                defineTag("Asciz", CONSTANT_UTF8);
303:                defineTag("int", CONSTANT_INTEGER);
304:                defineTag("float", CONSTANT_FLOAT);
305:                defineTag("long", CONSTANT_LONG);
306:                defineTag("double", CONSTANT_DOUBLE);
307:                defineTag("class", CONSTANT_CLASS);
308:                defineTag("String", CONSTANT_STRING);
309:                defineTag("Field", CONSTANT_FIELD);
310:                defineTag("Method", CONSTANT_METHOD);
311:                defineTag("InterfaceMethod", CONSTANT_INTERFACEMETHOD);
312:                defineTag("NameAndType", CONSTANT_NAMEANDTYPE);
313:            }
314:
315:            private static void defineTag(String id, int val) {
316:                Tags.put(id, new Integer(val));
317:                if (val >= tagNames.size()) {
318:                    tagNames.setSize(val + 1);
319:                }
320:                tagNames.setElementAt(id, val);
321:            }
322:
323:            public static String tagName(int tag) {
324:                if (tag >= tagNames.size())
325:                    return null;
326:                return (String) tagNames.elementAt(tag);
327:            }
328:
329:            public static int tagValue(String idValue) {
330:                Integer Val = (Integer) (Tags.get(idValue));
331:                if (Val == null)
332:                    return 0;
333:                return Val.intValue();
334:            }
335:
336:            /**
337:             * Define type table. These types used in "newarray" instruction only.
338:             */
339:            private static Vector typeNames = new Vector(10);
340:            private static Hashtable Types = new Hashtable(10);
341:            static {
342:                defineType("int", T_INT);
343:                defineType("long", T_LONG);
344:                defineType("float", T_FLOAT);
345:                defineType("double", T_DOUBLE);
346:                defineType("class", T_CLASS);
347:                defineType("boolean", T_BOOLEAN);
348:                defineType("char", T_CHAR);
349:                defineType("byte", T_BYTE);
350:                defineType("short", T_SHORT);
351:            }
352:
353:            private static void defineType(String id, int val) {
354:                Types.put(id, new Integer(val));
355:                if (val >= typeNames.size()) {
356:                    typeNames.setSize(val + 1);
357:                }
358:                typeNames.setElementAt(id, val);
359:            }
360:
361:            public static int typeValue(String idValue) {
362:                Integer Val = (Integer) (Types.get(idValue));
363:                if (Val == null)
364:                    return -1;
365:                return Val.intValue();
366:            }
367:
368:            public static String typeName(int type) {
369:                if (type >= typeNames.size())
370:                    return null;
371:                return (String) typeNames.elementAt(type);
372:            }
373:
374:            /**
375:             * Define MapTypes table.
376:             * These constants used in stackmap tables only.
377:             */
378:            private static Vector mapTypeNames = new Vector(10);
379:            private static Hashtable MapTypes = new Hashtable(10);
380:            static {
381:                defineMapType("bogus", ITEM_Bogus);
382:                defineMapType("int", ITEM_Integer);
383:                defineMapType("float", ITEM_Float);
384:                defineMapType("double", ITEM_Double);
385:                defineMapType("long", ITEM_Long);
386:                defineMapType("null", ITEM_Null);
387:                defineMapType("this", ITEM_InitObject);
388:                defineMapType("CP", ITEM_Object);
389:                defineMapType("uninitialized", ITEM_NewObject);
390:            }
391:
392:            private static void defineMapType(String id, int val) {
393:                MapTypes.put(id, new Integer(val));
394:                if (val >= mapTypeNames.size()) {
395:                    mapTypeNames.setSize(val + 1);
396:                }
397:                mapTypeNames.setElementAt(id, val);
398:            }
399:
400:            public static int mapTypeValue(String idValue) {
401:                Integer Val = (Integer) (MapTypes.get(idValue));
402:                if (Val == null)
403:                    return -1;
404:                return Val.intValue();
405:            }
406:
407:            public static String mapTypeName(int type) {
408:                if (type >= mapTypeNames.size())
409:                    return null;
410:                return (String) mapTypeNames.elementAt(type);
411:            }
412:
413:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.