1 package jrre.instructionset.objects;
2
3 import jrre.*;
4 import jrre.types.*;
5
6 public class NewArray extends jrre.instructionset.Instruction {
7
8 private int operandOne;
9
10 public NewArray(int operandOne){
11
12 name = "newarray";
13 description = "foo foo moo poo";
14 length = 1;
15
16 this.operandOne = operandOne;
17 }
18
19 /***
20 * Executes the <strong><code>newarray</code></strong> instruction.
21 *
22 * @param stackFrame
23 */
24 public void execute(){
25
26 ArrayInstance newArray = new ArrayInstance(operandOne, ((PrimitiveType)Stack.popOperand()).getValue());
27
28 String key = Integer.toString(newArray.hashCode());
29
30 ObjectArea.addObject(newArray+":"+key, newArray);
31
32 ReferenceType newReference = new ReferenceType(newArray);
33 Stack.pushOperand(newReference);
34
35 }
36
37 public String toString(){
38 StringBuffer toReturn = new StringBuffer();
39 toReturn.append("newarray ");
40 toReturn.append(Integer.toHexString(operandOne));
41 return toReturn.toString();
42 }
43 }
This page was automatically generated by Maven