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.LocalVariable;
16 import nl.tudelft.simulation.dsol.interpreter.OperandStack;
17 import nl.tudelft.simulation.dsol.interpreter.classfile.Constant;
18
19 /***
20 * The IF_ACMPEQ operation as defined in <a
21 * href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html">
22 * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html
23 * </a>.
24 * <p>
25 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
26 * University of Technology </a>, the Netherlands. <br>
27 * See for project information <a
28 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
29 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
30 * License (GPL) </a>, no warranty <br>
31 *
32 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
33 * Jacobs </a><a
34 * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
35 * Verbraeck </a>
36 * @version 1.3 Apr 6, 2004
37 * @since 1.4
38 */
39 public class IF_ACMPEQ extends JumpOperation
40 {
41 /*** OP refers to the operand code */
42 public static final int OP = 165;
43
44 /*** the index to load */
45 private int offset = -1;
46
47 /***
48 * constructs a new IF_ACMPEQ
49 *
50 * @param dataInput the dataInput
51 * @throws IOException on IOfailure
52 */
53 public IF_ACMPEQ(final DataInput dataInput) throws IOException
54 {
55 super();
56 this.offset = dataInput.readShort();
57 }
58
59 /***
60 * @see nl.tudelft.simulation.dsol.interpreter.operations.JumpOperation
61 * #execute(nl.tudelft.simulation.dsol.interpreter.OperandStack,
62 * nl.tudelft.simulation.dsol.interpreter.classfile.Constant[],
63 * nl.tudelft.simulation.dsol.interpreter.LocalVariable[])
64 */
65 public int execute(final OperandStack stack, final Constant[] constantPool,
66 final LocalVariable[] localVariables)
67 {
68 Object obj2 = stack.pop();
69 Object obj1 = stack.pop();
70 if (obj1.equals(obj2))
71 {
72 return this.offset;
73 }
74 return this.getByteLength();
75 }
76
77 /***
78 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getByteLength()
79 */
80 public int getByteLength()
81 {
82 return OPCODE_BYTE_LENGTH + 2;
83 }
84
85 /***
86 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getOpcode()
87 */
88 public int getOpcode()
89 {
90 return IF_ACMPEQ.OP;
91 }
92 }