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