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 * The IASTORE 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 IASTORE extends VoidOperation
40 {
41 /*** OP refers to the operand code */
42 public static final int OP = 79;
43
44 /***
45 * constructs a new IASTORE
46 */
47 public IASTORE()
48 {
49 super();
50 }
51
52
53 /***
54 * @see nl.tudelft.simulation.dsol.interpreter.operations.VoidOperation
55 * #execute(nl.tudelft.simulation.dsol.interpreter.OperandStack,
56 * nl.tudelft.simulation.dsol.interpreter.classfile.Constant[],
57 * nl.tudelft.simulation.dsol.interpreter.LocalVariable[])
58 */
59 public void execute(final OperandStack stack,
60 final Constant[] constantPool, final LocalVariable[] localVariables)
61 {
62 int value = Primitive.toInteger(stack.pop()).intValue();
63 int index = Primitive.toInteger(stack.pop()).intValue();
64 Object arrayref = stack.pop();
65 Array.setInt(arrayref, index, value);
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 IASTORE.OP;
82 }
83 }