1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.interpreter.operations;
11
12 import nl.tudelft.simulation.dsol.interpreter.LocalVariable;
13 import nl.tudelft.simulation.dsol.interpreter.OperandStack;
14 import nl.tudelft.simulation.dsol.interpreter.classfile.Constant;
15 import nl.tudelft.simulation.language.primitives.Primitive;
16
17 /***
18 * The IADD operation as defined in <a
19 * href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html">
20 * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc6.html
21 * </a>.
22 * <p>
23 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
24 * University of Technology </a>, the Netherlands. <br>
25 * See for project information <a
26 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
27 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
28 * License (GPL) </a>, no warranty <br>
29 *
30 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
31 * Jacobs </a><a
32 * href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
33 * Verbraeck </a>
34 * @version 1.3 Apr 6, 2004
35 * @since 1.4
36 */
37 public class IADD extends VoidOperation
38 {
39 /*** OP refers to the operand code */
40 public static final int OP = 96;
41
42 /***
43 * constructs a new IADD
44 */
45 public IADD()
46 {
47 super();
48 }
49
50
51 /***
52 * @see nl.tudelft.simulation.dsol.interpreter.operations.VoidOperation
53 * #execute(nl.tudelft.simulation.dsol.interpreter.OperandStack,
54 * nl.tudelft.simulation.dsol.interpreter.classfile.Constant[],
55 * nl.tudelft.simulation.dsol.interpreter.LocalVariable[])
56 */
57 public void execute(final OperandStack stack,
58 final Constant[] constantPool, final LocalVariable[] localVariables)
59 {
60 int i2 = Primitive.toInteger(stack.pop()).intValue();
61 int i1 = Primitive.toInteger(stack.pop()).intValue();
62 stack.push(new Integer(i1 + i2));
63 }
64
65 /***
66 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getByteLength()
67 */
68 public int getByteLength()
69 {
70 return OPCODE_BYTE_LENGTH;
71 }
72
73 /***
74 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getOpcode()
75 */
76 public int getOpcode()
77 {
78 return IADD.OP;
79 }
80 }