1 11 package org.eclipse.jdt.internal.debug.eval.ast.instructions; 12 13 import com.ibm.icu.text.MessageFormat; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.jdt.debug.core.IJavaObject; 19 import org.eclipse.jdt.debug.core.IJavaType; 20 import org.eclipse.jdt.debug.core.IJavaValue; 21 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 22 import org.eclipse.jdt.internal.debug.core.model.JDINullValue; 23 24 public class InstanceOfOperator extends CompoundInstruction { 25 public static final String IS_INSTANCE= "isInstance"; public static final String IS_INSTANCE_SIGNATURE= "(Ljava/lang/Object;)Z"; 28 public InstanceOfOperator(int start) { 29 super(start); 30 } 31 32 35 public void execute() throws CoreException { 36 IJavaType type= (IJavaType)pop(); 37 IJavaValue value= popValue(); 38 if (value instanceof JDINullValue) { 39 pushNewValue(false); 40 return; 41 } 42 IJavaObject object= (IJavaObject)value; 43 44 IJavaObject classObject= getClassObject(type); 45 if (classObject == null) { 46 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, MessageFormat.format(InstructionsEvaluationMessages.InstanceOfOperator_No_class_object, new String []{type.getName()}), null)); 47 } 48 push(classObject.sendMessage(IS_INSTANCE, IS_INSTANCE_SIGNATURE, new IJavaValue[] {object}, getContext().getThread(), false)); 49 } 50 51 public String toString() { 52 return InstructionsEvaluationMessages.InstanceOfOperator__instanceof___operator_3; 53 } 54 55 } 56 | Popular Tags |