1 package jrre.instructionset.controlflow;
2
3 import jrre.Stack;
4 import jrre.types.*;
5
6 public class Ifnonnull extends jrre.instructionset.Instruction {
7
8 int operandOne;
9 int operandTwo;
10
11 /***
12 * @task found possible error in J2VM book. They
13 * listed this instruction as having two operands.
14 * Online references show: ifnonnull operandOne
15 */
16 public Ifnonnull(int operandOne, int operandTwo){
17 //public Ifnonnull(int operandOne){
18
19 this.operandOne = operandOne;
20 this.operandTwo = operandTwo;
21
22 name = "ifnonnull";
23 description = "foo foo moo poo";
24 length = 2;
25 }
26
27 /***
28 * @task look into NullReference consistancy.
29 */
30 public void execute(){
31
32 Type valueOne = Stack.popOperand();
33
34 //if(valueOne.getValue() != null){
35 if(!(valueOne instanceof NullReference) && valueOne != null){
36
37 int offset = -(65536 - ((operandOne << 8) | operandTwo));
38 if(offset < -60000)
39 offset = ((operandOne << 8) | operandTwo);
40
41 Stack.branch(offset - 2);
42 }
43
44 }
45
46 public String toString(){
47 return "ifnonnull";
48 }
49 }
This page was automatically generated by Maven