KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jasmin > InsnInfo


1 /* --- Copyright Jonathan Meyer 1997. All rights reserved. -----------------
2  > File: jasmin/src/jasmin/InsnInfo.java
3  > Purpose: Information about instructions (opcode, type of args, etc)
4  > Author: Jonathan Meyer, 8 Feb 1996
5  */

6
7 //
8
// InsnInfo is used to hold info about the opcode and parameters needed
9
// by an instruction. Instances of InsnInfo are created by a static
10
// initializer and stored in a table.
11
//
12

13 package jasmin;
14
15 import jas.RuntimeConstants;
16 import java.util.Hashtable JavaDoc;
17
18 class InsnInfo {
19     // maps instruction name -> InsnInfo object
20
static Hashtable JavaDoc infoTable;
21
22     // information maintained about each instruction:
23
public String JavaDoc name; // instruction name
24
public int opcode; // its opcode
25
public String JavaDoc args; // the argument code
26

27     public static InsnInfo get(String JavaDoc name) {
28     return (InsnInfo)infoTable.get(name);
29     }
30
31     public static boolean contains(String JavaDoc name) {
32     return infoTable.get(name) != null;
33     }
34
35     //
36
// used to initialize the infoTable table (see below)
37
//
38
static private void addInfo(String JavaDoc name, int opcode, String JavaDoc args) {
39     InsnInfo info = new InsnInfo();
40     info.name = name;
41     info.opcode = opcode;
42     info.args = args;
43         infoTable.put(name, info);
44     }
45
46     //
47
// initializes the infoTable table
48
//
49
static {
50         infoTable = new Hashtable JavaDoc();
51
52         addInfo("aaload", RuntimeConstants.opc_aaload, "");
53         addInfo("aastore", RuntimeConstants.opc_aastore, "");
54         addInfo("aconst_null", RuntimeConstants.opc_aconst_null, "");
55         addInfo("aload", RuntimeConstants.opc_aload, "i");
56         addInfo("aload_0", RuntimeConstants.opc_aload_0, "");
57         addInfo("aload_1", RuntimeConstants.opc_aload_1, "");
58         addInfo("aload_2", RuntimeConstants.opc_aload_2, "");
59         addInfo("aload_3", RuntimeConstants.opc_aload_3, "");
60         addInfo("anewarray", RuntimeConstants.opc_anewarray, "class");
61         addInfo("areturn", RuntimeConstants.opc_areturn, "");
62         addInfo("arraylength", RuntimeConstants.opc_arraylength, "");
63         addInfo("astore", RuntimeConstants.opc_astore, "i");
64         addInfo("astore_0", RuntimeConstants.opc_astore_0, "");
65         addInfo("astore_1", RuntimeConstants.opc_astore_1, "");
66         addInfo("astore_2", RuntimeConstants.opc_astore_2, "");
67         addInfo("astore_3", RuntimeConstants.opc_astore_3, "");
68         addInfo("athrow", RuntimeConstants.opc_athrow, "");
69         addInfo("baload", RuntimeConstants.opc_baload, "");
70         addInfo("bastore", RuntimeConstants.opc_bastore, "");
71         addInfo("bipush", RuntimeConstants.opc_bipush, "i");
72         addInfo("breakpoint", RuntimeConstants.opc_breakpoint, "");
73         addInfo("caload", RuntimeConstants.opc_caload, "");
74         addInfo("castore", RuntimeConstants.opc_castore, "");
75         addInfo("checkcast", RuntimeConstants.opc_checkcast, "class");
76         addInfo("d2f", RuntimeConstants.opc_d2f, "");
77         addInfo("d2i", RuntimeConstants.opc_d2i, "");
78         addInfo("d2l", RuntimeConstants.opc_d2l, "");
79         addInfo("dadd", RuntimeConstants.opc_dadd, "");
80         addInfo("daload", RuntimeConstants.opc_daload, "");
81         addInfo("dastore", RuntimeConstants.opc_dastore, "");
82         addInfo("dcmpg", RuntimeConstants.opc_dcmpg, "");
83         addInfo("dcmpl", RuntimeConstants.opc_dcmpl, "");
84         addInfo("dconst_0", RuntimeConstants.opc_dconst_0, "");
85         addInfo("dconst_1", RuntimeConstants.opc_dconst_1, "");
86         addInfo("ddiv", RuntimeConstants.opc_ddiv, "");
87         addInfo("dload", RuntimeConstants.opc_dload, "i");
88         addInfo("dload_0", RuntimeConstants.opc_dload_0, "");
89         addInfo("dload_1", RuntimeConstants.opc_dload_1, "");
90         addInfo("dload_2", RuntimeConstants.opc_dload_2, "");
91         addInfo("dload_3", RuntimeConstants.opc_dload_3, "");
92         addInfo("dmul", RuntimeConstants.opc_dmul, "");
93         addInfo("dneg", RuntimeConstants.opc_dneg, "");
94         addInfo("drem", RuntimeConstants.opc_drem, "");
95         addInfo("dreturn", RuntimeConstants.opc_dreturn, "");
96         addInfo("dstore", RuntimeConstants.opc_dstore, "i");
97         addInfo("dstore_0", RuntimeConstants.opc_dstore_0, "");
98         addInfo("dstore_1", RuntimeConstants.opc_dstore_1, "");
99         addInfo("dstore_2", RuntimeConstants.opc_dstore_2, "");
100         addInfo("dstore_3", RuntimeConstants.opc_dstore_3, "");
101         addInfo("dsub", RuntimeConstants.opc_dsub, "");
102         addInfo("dup", RuntimeConstants.opc_dup, "");
103         addInfo("dup2", RuntimeConstants.opc_dup2, "");
104         addInfo("dup2_x1", RuntimeConstants.opc_dup2_x1, "");
105         addInfo("dup2_x2", RuntimeConstants.opc_dup2_x2, "");
106         addInfo("dup_x1", RuntimeConstants.opc_dup_x1, "");
107         addInfo("dup_x2", RuntimeConstants.opc_dup_x2, "");
108         addInfo("f2d", RuntimeConstants.opc_f2d, "");
109         addInfo("f2i", RuntimeConstants.opc_f2i, "");
110         addInfo("f2l", RuntimeConstants.opc_f2l, "");
111         addInfo("fadd", RuntimeConstants.opc_fadd, "");
112         addInfo("faload", RuntimeConstants.opc_faload, "");
113         addInfo("fastore", RuntimeConstants.opc_fastore, "");
114         addInfo("fcmpg", RuntimeConstants.opc_fcmpg, "");
115         addInfo("fcmpl", RuntimeConstants.opc_fcmpl, "");
116         addInfo("fconst_0", RuntimeConstants.opc_fconst_0, "");
117         addInfo("fconst_1", RuntimeConstants.opc_fconst_1, "");
118         addInfo("fconst_2", RuntimeConstants.opc_fconst_2, "");
119         addInfo("fdiv", RuntimeConstants.opc_fdiv, "");
120         addInfo("fload", RuntimeConstants.opc_fload, "i");
121         addInfo("fload_0", RuntimeConstants.opc_fload_0, "");
122         addInfo("fload_1", RuntimeConstants.opc_fload_1, "");
123         addInfo("fload_2", RuntimeConstants.opc_fload_2, "");
124         addInfo("fload_3", RuntimeConstants.opc_fload_3, "");
125         addInfo("fmul", RuntimeConstants.opc_fmul, "");
126         addInfo("fneg", RuntimeConstants.opc_fneg, "");
127         addInfo("frem", RuntimeConstants.opc_frem, "");
128         addInfo("freturn", RuntimeConstants.opc_freturn, "");
129         addInfo("fstore", RuntimeConstants.opc_fstore, "i");
130         addInfo("fstore_0", RuntimeConstants.opc_fstore_0, "");
131         addInfo("fstore_1", RuntimeConstants.opc_fstore_1, "");
132         addInfo("fstore_2", RuntimeConstants.opc_fstore_2, "");
133         addInfo("fstore_3", RuntimeConstants.opc_fstore_3, "");
134         addInfo("fsub", RuntimeConstants.opc_fsub, "");
135         addInfo("getfield", RuntimeConstants.opc_getfield, "field");
136         addInfo("getstatic", RuntimeConstants.opc_getstatic, "field");
137         addInfo("goto", RuntimeConstants.opc_goto, "label");
138         addInfo("goto_w", RuntimeConstants.opc_goto_w, "label");
139         addInfo("i2d", RuntimeConstants.opc_i2d, "");
140         addInfo("i2f", RuntimeConstants.opc_i2f, "");
141         addInfo("i2l", RuntimeConstants.opc_i2l, "");
142         addInfo("iadd", RuntimeConstants.opc_iadd, "");
143         addInfo("iaload", RuntimeConstants.opc_iaload, "");
144         addInfo("iand", RuntimeConstants.opc_iand, "");
145         addInfo("iastore", RuntimeConstants.opc_iastore, "");
146         addInfo("iconst_0", RuntimeConstants.opc_iconst_0, "");
147         addInfo("iconst_1", RuntimeConstants.opc_iconst_1, "");
148         addInfo("iconst_2", RuntimeConstants.opc_iconst_2, "");
149         addInfo("iconst_3", RuntimeConstants.opc_iconst_3, "");
150         addInfo("iconst_4", RuntimeConstants.opc_iconst_4, "");
151         addInfo("iconst_5", RuntimeConstants.opc_iconst_5, "");
152         addInfo("iconst_m1", RuntimeConstants.opc_iconst_m1, "");
153         addInfo("idiv", RuntimeConstants.opc_idiv, "");
154         addInfo("if_acmpeq", RuntimeConstants.opc_if_acmpeq, "label");
155         addInfo("if_acmpne", RuntimeConstants.opc_if_acmpne, "label");
156         addInfo("if_icmpeq", RuntimeConstants.opc_if_icmpeq, "label");
157         addInfo("if_icmpge", RuntimeConstants.opc_if_icmpge, "label");
158         addInfo("if_icmpgt", RuntimeConstants.opc_if_icmpgt, "label");
159         addInfo("if_icmple", RuntimeConstants.opc_if_icmple, "label");
160         addInfo("if_icmplt", RuntimeConstants.opc_if_icmplt, "label");
161         addInfo("if_icmpne", RuntimeConstants.opc_if_icmpne, "label");
162         addInfo("ifeq", RuntimeConstants.opc_ifeq, "label");
163         addInfo("ifge", RuntimeConstants.opc_ifge, "label");
164         addInfo("ifgt", RuntimeConstants.opc_ifgt, "label");
165         addInfo("ifle", RuntimeConstants.opc_ifle, "label");
166         addInfo("iflt", RuntimeConstants.opc_iflt, "label");
167         addInfo("ifne", RuntimeConstants.opc_ifne, "label");
168         addInfo("ifnonnull", RuntimeConstants.opc_ifnonnull, "label");
169         addInfo("ifnull", RuntimeConstants.opc_ifnull, "label");
170         addInfo("iinc", RuntimeConstants.opc_iinc, "ii");
171         addInfo("iload", RuntimeConstants.opc_iload, "i");
172         addInfo("iload_0", RuntimeConstants.opc_iload_0, "");
173         addInfo("iload_1", RuntimeConstants.opc_iload_1, "");
174         addInfo("iload_2", RuntimeConstants.opc_iload_2, "");
175         addInfo("iload_3", RuntimeConstants.opc_iload_3, "");
176         addInfo("imul", RuntimeConstants.opc_imul, "");
177         addInfo("ineg", RuntimeConstants.opc_ineg, "");
178         addInfo("instanceof", RuntimeConstants.opc_instanceof, "class");
179         addInfo("int2byte", RuntimeConstants.opc_int2byte, "");
180         addInfo("int2char", RuntimeConstants.opc_int2char, "");
181         addInfo("int2short", RuntimeConstants.opc_int2short, "");
182         // added this synonym
183
addInfo("i2b", RuntimeConstants.opc_int2byte, "");
184         // added this synonym
185
addInfo("i2c", RuntimeConstants.opc_int2char, "");
186         // added this synonym
187
addInfo("i2s", RuntimeConstants.opc_int2short, "");
188         addInfo("invokeinterface", RuntimeConstants.opc_invokeinterface, "interface");
189         addInfo("invokenonvirtual", RuntimeConstants.opc_invokenonvirtual, "method");
190         // added this synonym
191
addInfo("invokespecial", RuntimeConstants.opc_invokenonvirtual, "method");
192         addInfo("invokestatic", RuntimeConstants.opc_invokestatic, "method");
193         addInfo("invokevirtual", RuntimeConstants.opc_invokevirtual, "method");
194         addInfo("ior", RuntimeConstants.opc_ior, "");
195         addInfo("irem", RuntimeConstants.opc_irem, "");
196         addInfo("ireturn", RuntimeConstants.opc_ireturn, "");
197         addInfo("ishl", RuntimeConstants.opc_ishl, "");
198         addInfo("ishr", RuntimeConstants.opc_ishr, "");
199         addInfo("istore", RuntimeConstants.opc_istore, "i");
200         addInfo("istore_0", RuntimeConstants.opc_istore_0, "");
201         addInfo("istore_1", RuntimeConstants.opc_istore_1, "");
202         addInfo("istore_2", RuntimeConstants.opc_istore_2, "");
203         addInfo("istore_3", RuntimeConstants.opc_istore_3, "");
204         addInfo("isub", RuntimeConstants.opc_isub, "");
205         addInfo("iushr", RuntimeConstants.opc_iushr, "");
206         addInfo("ixor", RuntimeConstants.opc_ixor, "");
207         addInfo("jsr", RuntimeConstants.opc_jsr, "label");
208         addInfo("jsr_w", RuntimeConstants.opc_jsr, "label"); // synonym for "jsr"
209
addInfo("l2d", RuntimeConstants.opc_l2d, "");
210         addInfo("l2f", RuntimeConstants.opc_l2f, "");
211         addInfo("l2i", RuntimeConstants.opc_l2i, "");
212         addInfo("ladd", RuntimeConstants.opc_ladd, "");
213         addInfo("laload", RuntimeConstants.opc_laload, "");
214         addInfo("land", RuntimeConstants.opc_land, "");
215         addInfo("lastore", RuntimeConstants.opc_lastore, "");
216         addInfo("lcmp", RuntimeConstants.opc_lcmp, "");
217         addInfo("lconst_0", RuntimeConstants.opc_lconst_0, "");
218         addInfo("lconst_1", RuntimeConstants.opc_lconst_1, "");
219         addInfo("ldc", RuntimeConstants.opc_ldc, "constant");
220         addInfo("ldc_w", RuntimeConstants.opc_ldc_w, "constant");
221         addInfo("ldc2_w", RuntimeConstants.opc_ldc2_w, "bigconstant");
222         addInfo("ldiv", RuntimeConstants.opc_ldiv, "");
223         addInfo("lload", RuntimeConstants.opc_lload, "i");
224         addInfo("lload_0", RuntimeConstants.opc_lload_0, "");
225         addInfo("lload_1", RuntimeConstants.opc_lload_1, "");
226         addInfo("lload_2", RuntimeConstants.opc_lload_2, "");
227         addInfo("lload_3", RuntimeConstants.opc_lload_3, "");
228         addInfo("lmul", RuntimeConstants.opc_lmul, "");
229         addInfo("lneg", RuntimeConstants.opc_lneg, "");
230         addInfo("lookupswitch", RuntimeConstants.opc_lookupswitch, "switch");
231         addInfo("lor", RuntimeConstants.opc_lor, "");
232         addInfo("lrem", RuntimeConstants.opc_lrem, "");
233         addInfo("lreturn", RuntimeConstants.opc_lreturn, "");
234         addInfo("lshl", RuntimeConstants.opc_lshl, "");
235         addInfo("lshr", RuntimeConstants.opc_lshr, "");
236         addInfo("lstore", RuntimeConstants.opc_lstore, "i");
237         addInfo("lstore_0", RuntimeConstants.opc_lstore_0, "");
238         addInfo("lstore_1", RuntimeConstants.opc_lstore_1, "");
239         addInfo("lstore_2", RuntimeConstants.opc_lstore_2, "");
240         addInfo("lstore_3", RuntimeConstants.opc_lstore_3, "");
241         addInfo("lsub", RuntimeConstants.opc_lsub, "");
242         addInfo("lushr", RuntimeConstants.opc_lushr, "");
243         addInfo("lxor", RuntimeConstants.opc_lxor, "");
244         addInfo("monitorenter", RuntimeConstants.opc_monitorenter, "");
245         addInfo("monitorexit", RuntimeConstants.opc_monitorexit, "");
246         addInfo("multianewarray", RuntimeConstants.opc_multianewarray, "marray");
247         addInfo("new", RuntimeConstants.opc_new, "class");
248         addInfo("newarray", RuntimeConstants.opc_newarray, "atype");
249         addInfo("nop", RuntimeConstants.opc_nop, "");
250         addInfo("pop", RuntimeConstants.opc_pop, "");
251         addInfo("pop2", RuntimeConstants.opc_pop2, "");
252         addInfo("putfield", RuntimeConstants.opc_putfield, "field");
253         addInfo("putstatic", RuntimeConstants.opc_putstatic, "field");
254         addInfo("ret", RuntimeConstants.opc_ret, "i");
255         addInfo("ret_w", RuntimeConstants.opc_ret, "i"); // synonym for ret
256
addInfo("return", RuntimeConstants.opc_return, "");
257         addInfo("saload", RuntimeConstants.opc_saload, "");
258         addInfo("sastore", RuntimeConstants.opc_sastore, "");
259         addInfo("sipush", RuntimeConstants.opc_sipush, "i");
260         addInfo("swap", RuntimeConstants.opc_swap, "");
261         addInfo("tableswitch", RuntimeConstants.opc_tableswitch, "switch");
262
263         // special case:
264
addInfo("wide", RuntimeConstants.opc_wide, "ignore");
265     }
266
267 };
268
269 /* --- Revision History ---------------------------------------------------
270 --- Jonathan Meyer, Feb 8 1997
271     Added invokespecial as a synonym for invokenonvirtual
272 */

273
Popular Tags