View Javadoc

1   /*
2    * @(#) AASTORE.java Jan 8, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
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   * The AASTORE operation as defined in <a
22   * href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc.html">
23   * http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc.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 AASTORE extends VoidOperation
41  {
42  	/*** OP refers to the operand code */
43  	public static final int OP = 83;
44  
45  	/***
46  	 * constructs a new AASTORE
47  	 */
48  	public AASTORE()
49  	{
50  		super();
51  	}
52  
53  	/***
54  	 * @see nl.tudelft.simulation.dsol.interpreter.operations.VoidOperation#execute(nl.tudelft.simulation.dsol.interpreter.OperandStack,
55  	 *      nl.tudelft.simulation.dsol.interpreter.classfile.Constant[],
56  	 *      nl.tudelft.simulation.dsol.interpreter.LocalVariable[])
57  	 */
58  	public void execute(final OperandStack stack,
59  			final Constant[] constantPool, final LocalVariable[] localVariables)
60  	{
61  		Object value = stack.pop();
62  		int index = Primitive.toInteger(stack.pop()).intValue();
63  		Object arrayref = stack.pop();
64  		Array.set(arrayref, index, value);
65  	}
66  
67  	/***
68  	 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getByteLength()
69  	 */
70  	public int getByteLength()
71  	{
72  		return OPCODE_BYTE_LENGTH;
73  	}
74  
75  	/***
76  	 * @see nl.tudelft.simulation.dsol.interpreter.Operation#getOpcode()
77  	 */
78  	public int getOpcode()
79  	{
80  		return AASTORE.OP;
81  	}
82  }