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