1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.interpreter.operations;
11
12 import java.io.DataInput;
13 import java.io.IOException;
14
15 import nl.tudelft.simulation.dsol.interpreter.Operation;
16
17 /***
18 * A InterpreterFactory <br>
19 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
20 * University of Technology </a>, the Netherlands. <br>
21 * See for project information <a
22 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
23 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24 * License (GPL) </a>, no warranty <br>
25 *
26 * @version 1.0 Jan 14, 2004 <br>
27 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
28 * Jacobs </a>
29 */
30 public class InterpreterFactory implements FactoryInterface
31 {
32 /***
33 * constructs a new InterpreterFactory
34 */
35 public InterpreterFactory()
36 {
37 super();
38 }
39
40 /***
41 * @see nl.tudelft.simulation.dsol.interpreter.operations.FactoryInterface#readOperation(java.io.DataInput,
42 * int)
43 */
44 public Operation readOperation(final DataInput dataInput,
45 final int startBytePosition) throws IOException
46 {
47 int operand = dataInput.readUnsignedByte();
48 return this.readOperation(operand, dataInput, startBytePosition);
49 }
50
51 /***
52 * @see nl.tudelft.simulation.dsol.interpreter.operations.FactoryInterface#readOperation(int,
53 * java.io.DataInput, int)
54 */
55 public Operation readOperation(final int operand,
56 final DataInput dataInput, final int startBytePositon)
57 throws IOException
58 {
59 switch (operand)
60 {
61 case AALOAD.OP :
62 return new AALOAD();
63 case AASTORE.OP :
64 return new AASTORE();
65 case ACONST_NULL.OP :
66 return new ACONST_NULL();
67 case ALOAD.OP :
68 return new ALOAD(dataInput);
69 case ALOAD_0.OP :
70 return new ALOAD_0();
71 case ALOAD_1.OP :
72 return new ALOAD_1();
73 case ALOAD_2.OP :
74 return new ALOAD_2();
75 case ALOAD_3.OP :
76 return new ALOAD_3();
77 case ANEWARRAY.OP :
78 return new ANEWARRAY(dataInput);
79 case ARETURN.OP :
80 return new ARETURN();
81 case ARRAYLENGTH.OP :
82 return new ARRAYLENGTH();
83 case ASTORE.OP :
84 return new ASTORE(dataInput);
85 case ASTORE_0.OP :
86 return new ASTORE_0();
87 case ASTORE_1.OP :
88 return new ASTORE_1();
89 case ASTORE_2.OP :
90 return new ASTORE_2();
91 case ASTORE_3.OP :
92 return new ASTORE_3();
93 case ATHROW.OP :
94 return new ATHROW();
95 case BALOAD.OP :
96 return new BALOAD();
97 case BASTORE.OP :
98 return new BASTORE();
99 case BIPUSH.OP :
100 return new BIPUSH(dataInput);
101 case CALOAD.OP :
102 return new CALOAD();
103 case CASTORE.OP :
104 return new CASTORE();
105 case CHECKCAST.OP :
106 return new CHECKCAST(dataInput);
107 case D2F.OP :
108 return new D2F();
109 case D2I.OP :
110 return new D2I();
111 case D2L.OP :
112 return new D2L();
113 case DADD.OP :
114 return new DADD();
115 case DALOAD.OP :
116 return new DALOAD();
117 case DASTORE.OP :
118 return new DASTORE();
119 case DCMPG.OP :
120 return new DCMPG();
121 case DCMPL.OP :
122 return new DCMPL();
123 case DCONST_0.OP :
124 return new DCONST_0();
125 case DCONST_1.OP :
126 return new DCONST_1();
127 case DDIV.OP :
128 return new DDIV();
129 case DLOAD.OP :
130 return new DLOAD(dataInput);
131 case DLOAD_0.OP :
132 return new DLOAD_0();
133 case DLOAD_1.OP :
134 return new DLOAD_1();
135 case DLOAD_2.OP :
136 return new DLOAD_2();
137 case DLOAD_3.OP :
138 return new DLOAD_3();
139 case DMUL.OP :
140 return new DMUL();
141 case DNEG.OP :
142 return new DNEG();
143 case DREM.OP :
144 return new DREM();
145 case DRETURN.OP :
146 return new DRETURN();
147 case DSTORE.OP :
148 return new DSTORE(dataInput);
149 case DSTORE_0.OP :
150 return new DSTORE_0();
151 case DSTORE_1.OP :
152 return new DSTORE_1();
153 case DSTORE_2.OP :
154 return new DSTORE_2();
155 case DSTORE_3.OP :
156 return new DSTORE_3();
157 case DSUB.OP :
158 return new DSUB();
159 case DUP.OP :
160 return new DUP();
161 case DUP_X1.OP :
162 return new DUP_X1();
163 case DUP_X2.OP :
164 return new DUP_X2();
165 case DUP2.OP :
166 return new DUP2();
167 case DUP2_X1.OP :
168 return new DUP2_X1();
169 case DUP2_X2.OP :
170 return new DUP2_X2();
171 case F2D.OP :
172 return new F2D();
173 case F2I.OP :
174 return new F2I();
175 case F2L.OP :
176 return new F2L();
177 case FADD.OP :
178 return new FADD();
179 case FALOAD.OP :
180 return new FALOAD();
181 case FASTORE.OP :
182 return new FASTORE();
183 case FCMPG.OP :
184 return new FCMPG();
185 case FCMPL.OP :
186 return new FCMPL();
187 case FCONST_0.OP :
188 return new FCONST_0();
189 case FCONST_1.OP :
190 return new FCONST_1();
191 case FCONST_2.OP :
192 return new FCONST_2();
193 case FDIV.OP :
194 return new FDIV();
195 case FLOAD.OP :
196 return new FLOAD(dataInput);
197 case FLOAD_0.OP :
198 return new FLOAD_0();
199 case FLOAD_1.OP :
200 return new FLOAD_1();
201 case FLOAD_2.OP :
202 return new FLOAD_2();
203 case FLOAD_3.OP :
204 return new FLOAD_3();
205 case FMUL.OP :
206 return new FMUL();
207 case FNEG.OP :
208 return new FNEG();
209 case FREM.OP :
210 return new FREM();
211 case FRETURN.OP :
212 return new FRETURN();
213 case FSTORE.OP :
214 return new FSTORE(dataInput);
215 case FSTORE_0.OP :
216 return new FSTORE_0();
217 case FSTORE_1.OP :
218 return new FSTORE_1();
219 case FSTORE_2.OP :
220 return new FSTORE_2();
221 case FSTORE_3.OP :
222 return new FSTORE_3();
223 case FSUB.OP :
224 return new FSUB();
225 case GETFIELD.OP :
226 return new GETFIELD(dataInput);
227 case GETSTATIC.OP :
228 return new GETSTATIC(dataInput);
229 case GOTO.OP :
230 return new GOTO(dataInput);
231 case GOTOW.OP :
232 return new GOTOW(dataInput);
233 case I2B.OP :
234 return new I2B();
235 case I2C.OP :
236 return new I2C();
237 case I2D.OP :
238 return new I2D();
239 case I2F.OP :
240 return new I2F();
241 case I2L.OP :
242 return new I2L();
243 case I2S.OP :
244 return new I2S();
245 case IADD.OP :
246 return new IADD();
247 case IALOAD.OP :
248 return new IALOAD();
249 case IAND.OP :
250 return new IAND();
251 case IASTORE.OP :
252 return new IASTORE();
253 case ICONST_m1.OP :
254 return new ICONST_m1();
255 case ICONST_0.OP :
256 return new ICONST_0();
257 case ICONST_1.OP :
258 return new ICONST_1();
259 case ICONST_2.OP :
260 return new ICONST_2();
261 case ICONST_3.OP :
262 return new ICONST_3();
263 case ICONST_4.OP :
264 return new ICONST_4();
265 case ICONST_5.OP :
266 return new ICONST_5();
267 case IDIV.OP :
268 return new IDIV();
269 case IF_ACMPEQ.OP :
270 return new IF_ACMPEQ(dataInput);
271 case IF_ACMPNE.OP :
272 return new IF_ACMPNE(dataInput);
273 case IF_ICMPEQ.OP :
274 return new IF_ICMPEQ(dataInput);
275 case IF_ICMPNE.OP :
276 return new IF_ICMPNE(dataInput);
277 case IF_ICMPGE.OP :
278 return new IF_ICMPGE(dataInput);
279 case IF_ICMPGT.OP :
280 return new IF_ICMPGT(dataInput);
281 case IF_ICMPLE.OP :
282 return new IF_ICMPLE(dataInput);
283 case IF_ICMPLT.OP :
284 return new IF_ICMPLT(dataInput);
285 case IFEQ.OP :
286 return new IFEQ(dataInput);
287 case IFGE.OP :
288 return new IFGE(dataInput);
289 case IFGT.OP :
290 return new IFGT(dataInput);
291 case IFLE.OP :
292 return new IFLE(dataInput);
293 case IFLT.OP :
294 return new IFLT(dataInput);
295 case IFNE.OP :
296 return new IFNE(dataInput);
297 case IFNONNULL.OP :
298 return new IFNONNULL(dataInput);
299 case IFNULL.OP :
300 return new IFNULL(dataInput);
301 case IINC.OP :
302 return new IINC(dataInput);
303 case ILOAD.OP :
304 return new ILOAD(dataInput);
305 case ILOAD_0.OP :
306 return new ILOAD_0();
307 case ILOAD_1.OP :
308 return new ILOAD_1();
309 case ILOAD_2.OP :
310 return new ILOAD_2();
311 case ILOAD_3.OP :
312 return new ILOAD_3();
313 case IMUL.OP :
314 return new IMUL();
315 case INEG.OP :
316 return new INEG();
317 case INSTANCEOF.OP :
318 return new INSTANCEOF(dataInput);
319 case nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKEINTERFACE.OP :
320 return new INVOKEINTERFACE(dataInput);
321 case nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKESPECIAL.OP :
322 return new INVOKESPECIAL(dataInput);
323 case nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKESTATIC.OP :
324 return new INVOKESTATIC(dataInput);
325 case nl.tudelft.simulation.dsol.interpreter.operations.reflection.INVOKEVIRTUAL.OP :
326 return new INVOKEVIRTUAL(dataInput);
327 case IOR.OP :
328 return new IOR();
329 case IREM.OP :
330 return new IREM();
331 case IRETURN.OP :
332 return new IRETURN();
333 case ISHL.OP :
334 return new ISHL();
335 case ISHR.OP :
336 return new ISHR();
337 case ISTORE.OP :
338 return new ISTORE(dataInput);
339 case ISTORE_0.OP :
340 return new ISTORE_0();
341 case ISTORE_1.OP :
342 return new ISTORE_1();
343 case ISTORE_2.OP :
344 return new ISTORE_2();
345 case ISTORE_3.OP :
346 return new ISTORE_3();
347 case ISUB.OP :
348 return new ISUB();
349 case IUSHR.OP :
350 return new IUSHR();
351 case IXOR.OP :
352 return new IXOR();
353 case JSR_W.OP :
354 return new JSR_W(dataInput, startBytePositon);
355 case JSR.OP :
356 return new JSR(dataInput, startBytePositon);
357 case L2D.OP :
358 return new L2D();
359 case L2F.OP :
360 return new L2F();
361 case L2I.OP :
362 return new L2I();
363 case LADD.OP :
364 return new LADD();
365 case LALOAD.OP :
366 return new LALOAD();
367 case LAND.OP :
368 return new LAND();
369 case LASTORE.OP :
370 return new LASTORE();
371 case LCMP.OP :
372 return new LCMP();
373 case LCONST_0.OP :
374 return new LCONST_0();
375 case LCONST_1.OP :
376 return new LCONST_1();
377 case LDC_W.OP :
378 return new LDC_W(dataInput);
379 case LDC.OP :
380 return new LDC(dataInput);
381 case LDC2_W.OP :
382 return new LDC2_W(dataInput);
383 case LDIV.OP :
384 return new LDIV();
385 case LLOAD_0.OP :
386 return new LLOAD_0();
387 case LLOAD_1.OP :
388 return new LLOAD_1();
389 case LLOAD_2.OP :
390 return new LLOAD_2();
391 case LLOAD_3.OP :
392 return new LLOAD_3();
393 case LLOAD.OP :
394 return new LLOAD(dataInput);
395 case LMUL.OP :
396 return new LMUL();
397 case LNEG.OP :
398 return new LNEG();
399 case LOOKUPSWITCH.OP :
400 return new LOOKUPSWITCH(dataInput,
401 (4 - ((startBytePositon + 1) % 4)) % 4);
402 case LOR.OP :
403 return new LOR();
404 case LREM.OP :
405 return new LREM();
406 case LRETURN.OP :
407 return new LRETURN();
408 case LSHL.OP :
409 return new LSHL();
410 case LSHR.OP :
411 return new LSHR();
412 case LSTORE_0.OP :
413 return new LSTORE_0();
414 case LSTORE_1.OP :
415 return new LSTORE_1();
416 case LSTORE_2.OP :
417 return new LSTORE_2();
418 case LSTORE_3.OP :
419 return new LSTORE_3();
420 case LSTORE.OP :
421 return new LSTORE(dataInput);
422 case LSUB.OP :
423 return new LSUB();
424 case LUSHR.OP :
425 return new LUSHR();
426 case LXOR.OP :
427 return new LXOR();
428 case MONITORENTER.OP :
429 return new MONITORENTER();
430 case MONITOREXIT.OP :
431 return new MONITOREXIT();
432 case MULTIANEWARRAY.OP :
433 return new MULTIANEWARRAY(dataInput);
434 case NEW.OP :
435 return new NEW(dataInput);
436 case NEWARRAY.OP :
437 return new NEWARRAY(dataInput);
438 case NOP.OP :
439 return new NOP();
440 case POP.OP :
441 return new POP();
442 case POP2.OP :
443 return new POP2();
444 case PUTFIELD.OP :
445 return new PUTFIELD(dataInput);
446 case PUTSTATIC.OP :
447 return new PUTSTATIC(dataInput);
448 case RET.OP :
449 return new RET(dataInput);
450 case RETURN.OP :
451 return new RETURN();
452 case SALOAD.OP :
453 return new SALOAD();
454 case SASTORE.OP :
455 return new SASTORE();
456 case SIPUSH.OP :
457 return new SIPUSH(dataInput);
458 case SWAP.OP :
459 return new SWAP();
460 case TABLESWITCH.OP :
461 return new TABLESWITCH(dataInput,
462 (4 - ((startBytePositon + 1) % 4)) % 4);
463 case WIDE.OP :
464 return new WIDE(dataInput);
465 case IMPDEP1 :
466 return new NOP();
467 case IMPDEP2 :
468 return new NOP();
469 case BREAKPOINT :
470 return new NOP();
471 default :
472 throw new IOException("Unable to read operation[" + operand
473 + "]");
474 }
475 }
476 }