1 11 package org.eclipse.jdt.internal.debug.eval.ast.instructions; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.jdt.debug.core.IJavaObject; 20 import org.eclipse.jdt.debug.core.IJavaVariable; 21 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 22 import org.eclipse.jdt.internal.debug.core.model.JDINullValue; 23 import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue; 24 25 29 public class PushFieldVariable extends CompoundInstruction { 30 31 private String fDeclaringTypeSignature; 32 33 private String fName; 34 35 private int fSuperClassLevel; 36 37 public PushFieldVariable(String name, int superClassLevel, int start) { 38 super(start); 39 fName= name; 40 fSuperClassLevel= superClassLevel; 41 } 42 43 public PushFieldVariable(String name, String declaringTypeSignature, int start) { 44 super(start); 45 fName= name; 46 fDeclaringTypeSignature= declaringTypeSignature; 47 } 48 49 public void execute() throws CoreException { 50 Object value= popValue(); 51 if (value instanceof JDINullValue) { 52 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, InstructionsEvaluationMessages.PushFieldVariable_0, null)); 53 } 54 IJavaObject receiver=(IJavaObject) value; 55 56 IJavaVariable field= null; 57 58 if (fDeclaringTypeSignature == null) { 59 field= ((JDIObjectValue)receiver).getField(fName, fSuperClassLevel); 60 } else { 61 field= receiver.getField(fName, fDeclaringTypeSignature); 62 } 63 64 if (field == null) { 65 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, MessageFormat.format(InstructionsEvaluationMessages.PushFieldVariable_Cannot_find_the_field__0__for_the_object__1__1, new String [] {fName, receiver.toString()}), null)); } 67 push(field); 68 } 69 70 public String toString() { 71 return MessageFormat.format(InstructionsEvaluationMessages.PushFieldVariable_push_field__0__2, new String [] {fName}); 72 } 73 } 74 75 | Popular Tags |