6
|
1 |
/*
|
|
2 |
* reserved comment block
|
|
3 |
* DO NOT REMOVE OR ALTER!
|
|
4 |
*/
|
|
5 |
package com.sun.org.apache.bcel.internal.generic;
|
|
6 |
|
|
7 |
/* ====================================================================
|
|
8 |
* The Apache Software License, Version 1.1
|
|
9 |
*
|
|
10 |
* Copyright (c) 2001 The Apache Software Foundation. All rights
|
|
11 |
* reserved.
|
|
12 |
*
|
|
13 |
* Redistribution and use in source and binary forms, with or without
|
|
14 |
* modification, are permitted provided that the following conditions
|
|
15 |
* are met:
|
|
16 |
*
|
|
17 |
* 1. Redistributions of source code must retain the above copyright
|
|
18 |
* notice, this list of conditions and the following disclaimer.
|
|
19 |
*
|
|
20 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
21 |
* notice, this list of conditions and the following disclaimer in
|
|
22 |
* the documentation and/or other materials provided with the
|
|
23 |
* distribution.
|
|
24 |
*
|
|
25 |
* 3. The end-user documentation included with the redistribution,
|
|
26 |
* if any, must include the following acknowledgment:
|
|
27 |
* "This product includes software developed by the
|
|
28 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
29 |
* Alternately, this acknowledgment may appear in the software itself,
|
|
30 |
* if and wherever such third-party acknowledgments normally appear.
|
|
31 |
*
|
|
32 |
* 4. The names "Apache" and "Apache Software Foundation" and
|
|
33 |
* "Apache BCEL" must not be used to endorse or promote products
|
|
34 |
* derived from this software without prior written permission. For
|
|
35 |
* written permission, please contact apache@apache.org.
|
|
36 |
*
|
|
37 |
* 5. Products derived from this software may not be called "Apache",
|
|
38 |
* "Apache BCEL", nor may "Apache" appear in their name, without
|
|
39 |
* prior written permission of the Apache Software Foundation.
|
|
40 |
*
|
|
41 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
42 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
43 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
44 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
45 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
46 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
47 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
48 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
49 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
50 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
51 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
52 |
* SUCH DAMAGE.
|
|
53 |
* ====================================================================
|
|
54 |
*
|
|
55 |
* This software consists of voluntary contributions made by many
|
|
56 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
57 |
* information on the Apache Software Foundation, please see
|
|
58 |
* <http://www.apache.org/>.
|
|
59 |
*/
|
|
60 |
|
|
61 |
import com.sun.org.apache.bcel.internal.Constants;
|
|
62 |
|
|
63 |
/**
|
|
64 |
* This interface contains shareable instruction objects.
|
|
65 |
*
|
|
66 |
* In order to save memory you can use some instructions multiply,
|
|
67 |
* since they have an immutable state and are directly derived from
|
|
68 |
* Instruction. I.e. they have no instance fields that could be
|
|
69 |
* changed. Since some of these instructions like ICONST_0 occur
|
|
70 |
* very frequently this can save a lot of time and space. This
|
|
71 |
* feature is an adaptation of the FlyWeight design pattern, we
|
|
72 |
* just use an array instead of a factory.
|
|
73 |
*
|
|
74 |
* The Instructions can also accessed directly under their names, so
|
|
75 |
* it's possible to write il.append(Instruction.ICONST_0);
|
|
76 |
*
|
|
77 |
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
|
|
78 |
*/
|
|
79 |
public interface InstructionConstants {
|
|
80 |
/** Predefined instruction objects
|
|
81 |
*/
|
|
82 |
public static final Instruction NOP = new NOP();
|
|
83 |
public static final Instruction ACONST_NULL = new ACONST_NULL();
|
|
84 |
public static final Instruction ICONST_M1 = new ICONST(-1);
|
|
85 |
public static final Instruction ICONST_0 = new ICONST(0);
|
|
86 |
public static final Instruction ICONST_1 = new ICONST(1);
|
|
87 |
public static final Instruction ICONST_2 = new ICONST(2);
|
|
88 |
public static final Instruction ICONST_3 = new ICONST(3);
|
|
89 |
public static final Instruction ICONST_4 = new ICONST(4);
|
|
90 |
public static final Instruction ICONST_5 = new ICONST(5);
|
|
91 |
public static final Instruction LCONST_0 = new LCONST(0);
|
|
92 |
public static final Instruction LCONST_1 = new LCONST(1);
|
|
93 |
public static final Instruction FCONST_0 = new FCONST(0);
|
|
94 |
public static final Instruction FCONST_1 = new FCONST(1);
|
|
95 |
public static final Instruction FCONST_2 = new FCONST(2);
|
|
96 |
public static final Instruction DCONST_0 = new DCONST(0);
|
|
97 |
public static final Instruction DCONST_1 = new DCONST(1);
|
|
98 |
public static final ArrayInstruction IALOAD = new IALOAD();
|
|
99 |
public static final ArrayInstruction LALOAD = new LALOAD();
|
|
100 |
public static final ArrayInstruction FALOAD = new FALOAD();
|
|
101 |
public static final ArrayInstruction DALOAD = new DALOAD();
|
|
102 |
public static final ArrayInstruction AALOAD = new AALOAD();
|
|
103 |
public static final ArrayInstruction BALOAD = new BALOAD();
|
|
104 |
public static final ArrayInstruction CALOAD = new CALOAD();
|
|
105 |
public static final ArrayInstruction SALOAD = new SALOAD();
|
|
106 |
public static final ArrayInstruction IASTORE = new IASTORE();
|
|
107 |
public static final ArrayInstruction LASTORE = new LASTORE();
|
|
108 |
public static final ArrayInstruction FASTORE = new FASTORE();
|
|
109 |
public static final ArrayInstruction DASTORE = new DASTORE();
|
|
110 |
public static final ArrayInstruction AASTORE = new AASTORE();
|
|
111 |
public static final ArrayInstruction BASTORE = new BASTORE();
|
|
112 |
public static final ArrayInstruction CASTORE = new CASTORE();
|
|
113 |
public static final ArrayInstruction SASTORE = new SASTORE();
|
|
114 |
public static final StackInstruction POP = new POP();
|
|
115 |
public static final StackInstruction POP2 = new POP2();
|
|
116 |
public static final StackInstruction DUP = new DUP();
|
|
117 |
public static final StackInstruction DUP_X1 = new DUP_X1();
|
|
118 |
public static final StackInstruction DUP_X2 = new DUP_X2();
|
|
119 |
public static final StackInstruction DUP2 = new DUP2();
|
|
120 |
public static final StackInstruction DUP2_X1 = new DUP2_X1();
|
|
121 |
public static final StackInstruction DUP2_X2 = new DUP2_X2();
|
|
122 |
public static final StackInstruction SWAP = new SWAP();
|
|
123 |
public static final ArithmeticInstruction IADD = new IADD();
|
|
124 |
public static final ArithmeticInstruction LADD = new LADD();
|
|
125 |
public static final ArithmeticInstruction FADD = new FADD();
|
|
126 |
public static final ArithmeticInstruction DADD = new DADD();
|
|
127 |
public static final ArithmeticInstruction ISUB = new ISUB();
|
|
128 |
public static final ArithmeticInstruction LSUB = new LSUB();
|
|
129 |
public static final ArithmeticInstruction FSUB = new FSUB();
|
|
130 |
public static final ArithmeticInstruction DSUB = new DSUB();
|
|
131 |
public static final ArithmeticInstruction IMUL = new IMUL();
|
|
132 |
public static final ArithmeticInstruction LMUL = new LMUL();
|
|
133 |
public static final ArithmeticInstruction FMUL = new FMUL();
|
|
134 |
public static final ArithmeticInstruction DMUL = new DMUL();
|
|
135 |
public static final ArithmeticInstruction IDIV = new IDIV();
|
|
136 |
public static final ArithmeticInstruction LDIV = new LDIV();
|
|
137 |
public static final ArithmeticInstruction FDIV = new FDIV();
|
|
138 |
public static final ArithmeticInstruction DDIV = new DDIV();
|
|
139 |
public static final ArithmeticInstruction IREM = new IREM();
|
|
140 |
public static final ArithmeticInstruction LREM = new LREM();
|
|
141 |
public static final ArithmeticInstruction FREM = new FREM();
|
|
142 |
public static final ArithmeticInstruction DREM = new DREM();
|
|
143 |
public static final ArithmeticInstruction INEG = new INEG();
|
|
144 |
public static final ArithmeticInstruction LNEG = new LNEG();
|
|
145 |
public static final ArithmeticInstruction FNEG = new FNEG();
|
|
146 |
public static final ArithmeticInstruction DNEG = new DNEG();
|
|
147 |
public static final ArithmeticInstruction ISHL = new ISHL();
|
|
148 |
public static final ArithmeticInstruction LSHL = new LSHL();
|
|
149 |
public static final ArithmeticInstruction ISHR = new ISHR();
|
|
150 |
public static final ArithmeticInstruction LSHR = new LSHR();
|
|
151 |
public static final ArithmeticInstruction IUSHR = new IUSHR();
|
|
152 |
public static final ArithmeticInstruction LUSHR = new LUSHR();
|
|
153 |
public static final ArithmeticInstruction IAND = new IAND();
|
|
154 |
public static final ArithmeticInstruction LAND = new LAND();
|
|
155 |
public static final ArithmeticInstruction IOR = new IOR();
|
|
156 |
public static final ArithmeticInstruction LOR = new LOR();
|
|
157 |
public static final ArithmeticInstruction IXOR = new IXOR();
|
|
158 |
public static final ArithmeticInstruction LXOR = new LXOR();
|
|
159 |
public static final ConversionInstruction I2L = new I2L();
|
|
160 |
public static final ConversionInstruction I2F = new I2F();
|
|
161 |
public static final ConversionInstruction I2D = new I2D();
|
|
162 |
public static final ConversionInstruction L2I = new L2I();
|
|
163 |
public static final ConversionInstruction L2F = new L2F();
|
|
164 |
public static final ConversionInstruction L2D = new L2D();
|
|
165 |
public static final ConversionInstruction F2I = new F2I();
|
|
166 |
public static final ConversionInstruction F2L = new F2L();
|
|
167 |
public static final ConversionInstruction F2D = new F2D();
|
|
168 |
public static final ConversionInstruction D2I = new D2I();
|
|
169 |
public static final ConversionInstruction D2L = new D2L();
|
|
170 |
public static final ConversionInstruction D2F = new D2F();
|
|
171 |
public static final ConversionInstruction I2B = new I2B();
|
|
172 |
public static final ConversionInstruction I2C = new I2C();
|
|
173 |
public static final ConversionInstruction I2S = new I2S();
|
|
174 |
public static final Instruction LCMP = new LCMP();
|
|
175 |
public static final Instruction FCMPL = new FCMPL();
|
|
176 |
public static final Instruction FCMPG = new FCMPG();
|
|
177 |
public static final Instruction DCMPL = new DCMPL();
|
|
178 |
public static final Instruction DCMPG = new DCMPG();
|
|
179 |
public static final ReturnInstruction IRETURN = new IRETURN();
|
|
180 |
public static final ReturnInstruction LRETURN = new LRETURN();
|
|
181 |
public static final ReturnInstruction FRETURN = new FRETURN();
|
|
182 |
public static final ReturnInstruction DRETURN = new DRETURN();
|
|
183 |
public static final ReturnInstruction ARETURN = new ARETURN();
|
|
184 |
public static final ReturnInstruction RETURN = new RETURN();
|
|
185 |
public static final Instruction ARRAYLENGTH = new ARRAYLENGTH();
|
|
186 |
public static final Instruction ATHROW = new ATHROW();
|
|
187 |
public static final Instruction MONITORENTER = new MONITORENTER();
|
|
188 |
public static final Instruction MONITOREXIT = new MONITOREXIT();
|
|
189 |
|
|
190 |
/** You can use these constants in multiple places safely, if you can guarantee
|
|
191 |
* that you will never alter their internal values, e.g. call setIndex().
|
|
192 |
*/
|
|
193 |
public static final LocalVariableInstruction THIS = new ALOAD(0);
|
|
194 |
public static final LocalVariableInstruction ALOAD_0 = THIS;
|
|
195 |
public static final LocalVariableInstruction ALOAD_1 = new ALOAD(1);
|
|
196 |
public static final LocalVariableInstruction ALOAD_2 = new ALOAD(2);
|
|
197 |
public static final LocalVariableInstruction ILOAD_0 = new ILOAD(0);
|
|
198 |
public static final LocalVariableInstruction ILOAD_1 = new ILOAD(1);
|
|
199 |
public static final LocalVariableInstruction ILOAD_2 = new ILOAD(2);
|
|
200 |
public static final LocalVariableInstruction ASTORE_0 = new ASTORE(0);
|
|
201 |
public static final LocalVariableInstruction ASTORE_1 = new ASTORE(1);
|
|
202 |
public static final LocalVariableInstruction ASTORE_2 = new ASTORE(2);
|
|
203 |
public static final LocalVariableInstruction ISTORE_0 = new ISTORE(0);
|
|
204 |
public static final LocalVariableInstruction ISTORE_1 = new ISTORE(1);
|
|
205 |
public static final LocalVariableInstruction ISTORE_2 = new ISTORE(2);
|
|
206 |
|
|
207 |
|
|
208 |
/** Get object via its opcode, for immutable instructions like
|
|
209 |
* branch instructions entries are set to null.
|
|
210 |
*/
|
|
211 |
public static final Instruction[] INSTRUCTIONS = new Instruction[256];
|
|
212 |
|
|
213 |
/** Interfaces may have no static initializers, so we simulate this
|
|
214 |
* with an inner class.
|
|
215 |
*/
|
|
216 |
static final Clinit bla = new Clinit();
|
|
217 |
|
|
218 |
static class Clinit {
|
|
219 |
Clinit() {
|
|
220 |
INSTRUCTIONS[Constants.NOP] = NOP;
|
|
221 |
INSTRUCTIONS[Constants.ACONST_NULL] = ACONST_NULL;
|
|
222 |
INSTRUCTIONS[Constants.ICONST_M1] = ICONST_M1;
|
|
223 |
INSTRUCTIONS[Constants.ICONST_0] = ICONST_0;
|
|
224 |
INSTRUCTIONS[Constants.ICONST_1] = ICONST_1;
|
|
225 |
INSTRUCTIONS[Constants.ICONST_2] = ICONST_2;
|
|
226 |
INSTRUCTIONS[Constants.ICONST_3] = ICONST_3;
|
|
227 |
INSTRUCTIONS[Constants.ICONST_4] = ICONST_4;
|
|
228 |
INSTRUCTIONS[Constants.ICONST_5] = ICONST_5;
|
|
229 |
INSTRUCTIONS[Constants.LCONST_0] = LCONST_0;
|
|
230 |
INSTRUCTIONS[Constants.LCONST_1] = LCONST_1;
|
|
231 |
INSTRUCTIONS[Constants.FCONST_0] = FCONST_0;
|
|
232 |
INSTRUCTIONS[Constants.FCONST_1] = FCONST_1;
|
|
233 |
INSTRUCTIONS[Constants.FCONST_2] = FCONST_2;
|
|
234 |
INSTRUCTIONS[Constants.DCONST_0] = DCONST_0;
|
|
235 |
INSTRUCTIONS[Constants.DCONST_1] = DCONST_1;
|
|
236 |
INSTRUCTIONS[Constants.IALOAD] = IALOAD;
|
|
237 |
INSTRUCTIONS[Constants.LALOAD] = LALOAD;
|
|
238 |
INSTRUCTIONS[Constants.FALOAD] = FALOAD;
|
|
239 |
INSTRUCTIONS[Constants.DALOAD] = DALOAD;
|
|
240 |
INSTRUCTIONS[Constants.AALOAD] = AALOAD;
|
|
241 |
INSTRUCTIONS[Constants.BALOAD] = BALOAD;
|
|
242 |
INSTRUCTIONS[Constants.CALOAD] = CALOAD;
|
|
243 |
INSTRUCTIONS[Constants.SALOAD] = SALOAD;
|
|
244 |
INSTRUCTIONS[Constants.IASTORE] = IASTORE;
|
|
245 |
INSTRUCTIONS[Constants.LASTORE] = LASTORE;
|
|
246 |
INSTRUCTIONS[Constants.FASTORE] = FASTORE;
|
|
247 |
INSTRUCTIONS[Constants.DASTORE] = DASTORE;
|
|
248 |
INSTRUCTIONS[Constants.AASTORE] = AASTORE;
|
|
249 |
INSTRUCTIONS[Constants.BASTORE] = BASTORE;
|
|
250 |
INSTRUCTIONS[Constants.CASTORE] = CASTORE;
|
|
251 |
INSTRUCTIONS[Constants.SASTORE] = SASTORE;
|
|
252 |
INSTRUCTIONS[Constants.POP] = POP;
|
|
253 |
INSTRUCTIONS[Constants.POP2] = POP2;
|
|
254 |
INSTRUCTIONS[Constants.DUP] = DUP;
|
|
255 |
INSTRUCTIONS[Constants.DUP_X1] = DUP_X1;
|
|
256 |
INSTRUCTIONS[Constants.DUP_X2] = DUP_X2;
|
|
257 |
INSTRUCTIONS[Constants.DUP2] = DUP2;
|
|
258 |
INSTRUCTIONS[Constants.DUP2_X1] = DUP2_X1;
|
|
259 |
INSTRUCTIONS[Constants.DUP2_X2] = DUP2_X2;
|
|
260 |
INSTRUCTIONS[Constants.SWAP] = SWAP;
|
|
261 |
INSTRUCTIONS[Constants.IADD] = IADD;
|
|
262 |
INSTRUCTIONS[Constants.LADD] = LADD;
|
|
263 |
INSTRUCTIONS[Constants.FADD] = FADD;
|
|
264 |
INSTRUCTIONS[Constants.DADD] = DADD;
|
|
265 |
INSTRUCTIONS[Constants.ISUB] = ISUB;
|
|
266 |
INSTRUCTIONS[Constants.LSUB] = LSUB;
|
|
267 |
INSTRUCTIONS[Constants.FSUB] = FSUB;
|
|
268 |
INSTRUCTIONS[Constants.DSUB] = DSUB;
|
|
269 |
INSTRUCTIONS[Constants.IMUL] = IMUL;
|
|
270 |
INSTRUCTIONS[Constants.LMUL] = LMUL;
|
|
271 |
INSTRUCTIONS[Constants.FMUL] = FMUL;
|
|
272 |
INSTRUCTIONS[Constants.DMUL] = DMUL;
|
|
273 |
INSTRUCTIONS[Constants.IDIV] = IDIV;
|
|
274 |
INSTRUCTIONS[Constants.LDIV] = LDIV;
|
|
275 |
INSTRUCTIONS[Constants.FDIV] = FDIV;
|
|
276 |
INSTRUCTIONS[Constants.DDIV] = DDIV;
|
|
277 |
INSTRUCTIONS[Constants.IREM] = IREM;
|
|
278 |
INSTRUCTIONS[Constants.LREM] = LREM;
|
|
279 |
INSTRUCTIONS[Constants.FREM] = FREM;
|
|
280 |
INSTRUCTIONS[Constants.DREM] = DREM;
|
|
281 |
INSTRUCTIONS[Constants.INEG] = INEG;
|
|
282 |
INSTRUCTIONS[Constants.LNEG] = LNEG;
|
|
283 |
INSTRUCTIONS[Constants.FNEG] = FNEG;
|
|
284 |
INSTRUCTIONS[Constants.DNEG] = DNEG;
|
|
285 |
INSTRUCTIONS[Constants.ISHL] = ISHL;
|
|
286 |
INSTRUCTIONS[Constants.LSHL] = LSHL;
|
|
287 |
INSTRUCTIONS[Constants.ISHR] = ISHR;
|
|
288 |
INSTRUCTIONS[Constants.LSHR] = LSHR;
|
|
289 |
INSTRUCTIONS[Constants.IUSHR] = IUSHR;
|
|
290 |
INSTRUCTIONS[Constants.LUSHR] = LUSHR;
|
|
291 |
INSTRUCTIONS[Constants.IAND] = IAND;
|
|
292 |
INSTRUCTIONS[Constants.LAND] = LAND;
|
|
293 |
INSTRUCTIONS[Constants.IOR] = IOR;
|
|
294 |
INSTRUCTIONS[Constants.LOR] = LOR;
|
|
295 |
INSTRUCTIONS[Constants.IXOR] = IXOR;
|
|
296 |
INSTRUCTIONS[Constants.LXOR] = LXOR;
|
|
297 |
INSTRUCTIONS[Constants.I2L] = I2L;
|
|
298 |
INSTRUCTIONS[Constants.I2F] = I2F;
|
|
299 |
INSTRUCTIONS[Constants.I2D] = I2D;
|
|
300 |
INSTRUCTIONS[Constants.L2I] = L2I;
|
|
301 |
INSTRUCTIONS[Constants.L2F] = L2F;
|
|
302 |
INSTRUCTIONS[Constants.L2D] = L2D;
|
|
303 |
INSTRUCTIONS[Constants.F2I] = F2I;
|
|
304 |
INSTRUCTIONS[Constants.F2L] = F2L;
|
|
305 |
INSTRUCTIONS[Constants.F2D] = F2D;
|
|
306 |
INSTRUCTIONS[Constants.D2I] = D2I;
|
|
307 |
INSTRUCTIONS[Constants.D2L] = D2L;
|
|
308 |
INSTRUCTIONS[Constants.D2F] = D2F;
|
|
309 |
INSTRUCTIONS[Constants.I2B] = I2B;
|
|
310 |
INSTRUCTIONS[Constants.I2C] = I2C;
|
|
311 |
INSTRUCTIONS[Constants.I2S] = I2S;
|
|
312 |
INSTRUCTIONS[Constants.LCMP] = LCMP;
|
|
313 |
INSTRUCTIONS[Constants.FCMPL] = FCMPL;
|
|
314 |
INSTRUCTIONS[Constants.FCMPG] = FCMPG;
|
|
315 |
INSTRUCTIONS[Constants.DCMPL] = DCMPL;
|
|
316 |
INSTRUCTIONS[Constants.DCMPG] = DCMPG;
|
|
317 |
INSTRUCTIONS[Constants.IRETURN] = IRETURN;
|
|
318 |
INSTRUCTIONS[Constants.LRETURN] = LRETURN;
|
|
319 |
INSTRUCTIONS[Constants.FRETURN] = FRETURN;
|
|
320 |
INSTRUCTIONS[Constants.DRETURN] = DRETURN;
|
|
321 |
INSTRUCTIONS[Constants.ARETURN] = ARETURN;
|
|
322 |
INSTRUCTIONS[Constants.RETURN] = RETURN;
|
|
323 |
INSTRUCTIONS[Constants.ARRAYLENGTH] = ARRAYLENGTH;
|
|
324 |
INSTRUCTIONS[Constants.ATHROW] = ATHROW;
|
|
325 |
INSTRUCTIONS[Constants.MONITORENTER] = MONITORENTER;
|
|
326 |
INSTRUCTIONS[Constants.MONITOREXIT] = MONITOREXIT;
|
|
327 |
}
|
|
328 |
}
|
|
329 |
}
|