1 package jrre.instructionset.objects;
2
3 import jrre.*;
4 import jrre.types.*;
5
6 public class CAStore extends jrre.instructionset.Instruction {
7
8 public CAStore(){
9
10 name = "castore";
11 description = "foo foo moo poo";
12 length = 0;
13 }
14
15 /***
16 * Executes the <strong><code>castore</code></strong> instruction.
17 *
18 * @param stackFrame
19 */
20 public void execute(){
21
22 //CharType valueToStore = new CharType((char)((PrimitiveType)Stack.popOperand()).getValue());
23 Type charRef = Stack.popOperand();
24
25 char charValue = ' ';
26
27 if(charRef instanceof PrimitiveType)
28 charValue = (char)((PrimitiveType)charRef).getValue();
29 else if(charRef instanceof CharType)
30 charValue = ((CharType)charRef).getValue();
31
32 CharType valueToStore = new CharType(charValue);
33 PrimitiveType index = (PrimitiveType)Stack.popOperand();
34
35 ReferenceType charArrayRef = (ReferenceType)Stack.popOperand();
36
37 ArrayInstance charArray = (ArrayInstance)charArrayRef.getValue();
38
39 charArray.setElement(index.getValue(), valueToStore);
40 }
41
42 public String toString(){
43 StringBuffer toReturn = new StringBuffer();
44 toReturn.append("castore ");
45 return toReturn.toString();
46 }
47 }
This page was automatically generated by Maven