View Javadoc
1 package jrre.instructionset.objects; 2 3 import jrre.*; 4 import jrre.types.*; 5 import jrre.classloader.classfile.pool_entries.*; 6 7 public class InstanceOf extends jrre.instructionset.Instruction { 8 9 private int operandOne; 10 private int operandTwo; 11 12 public InstanceOf(int operandOne, int operandTwo){ 13 14 name = "instanceof"; 15 description = "foo foo moo poo"; 16 length = 2; 17 18 this.operandOne = operandOne; 19 this.operandTwo = operandTwo; 20 } 21 22 /*** 23 * Executes the <strong><code>instanceof</code></strong> instruction. 24 * 25 */ 26 public void execute(){ 27 28 // Get this class. 29 jrre.api.java.lang.Class thisClass = Stack.getClassContainingMethod(); 30 31 int cpClassIndex = (operandOne << 8) | operandTwo; 32 33 CPClass classRef = (CPClass)thisClass.getSymbol(cpClassIndex); 34 String className = ((CPUTF8)thisClass.getSymbol(classRef.getNameIndex())).getValue(); 35 36 int result = 0; 37 38 ReferenceType objectToTest = (ReferenceType)Stack.popOperand(); 39 String objectsClassName = objectToTest.getValue().getClassData().getFullyQualifiedName(); 40 41 if(className.equals(objectsClassName)) 42 result = 1; 43 44 Stack.pushOperand(new PrimitiveType(result)); 45 /* 46 jrre.api.java.lang.Class classToDup = MethodArea.getClass(className); 47 if(classToDup == null){ 48 return; 49 } 50 51 ObjectInstance newObject = classToDup.instanceOf(); 52 53 String key = className; 54 ObjectArea.addObject(key, newObject); 55 56 Stack.pushOperand(new ReferenceType(newObject)); 57 */ 58 59 } 60 61 public String toString(){ 62 StringBuffer toReturn = new StringBuffer(); 63 toReturn.append("instanceof "); 64 toReturn.append(Integer.toHexString(operandOne)); 65 toReturn.append(" "); 66 toReturn.append(Integer.toHexString(operandTwo)); 67 return toReturn.toString(); 68 } 69 }

This page was automatically generated by Maven