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.IJavaValue; 21 import org.eclipse.jdt.debug.core.IJavaVariable; 22 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 23 24 29 public class SendMessage extends CompoundInstruction { 30 31 private int fArgCount; 32 private String fSelector; 33 private String fSignature; 34 private String fDeclaringType; 35 36 public SendMessage(String selector, String signature, int argCount, String declaringType, int start) { 37 super(start); 38 fArgCount= argCount; 39 fSelector= selector; 40 fSignature= signature; 41 fDeclaringType= declaringType; 42 } 43 44 public void execute() throws CoreException { 45 IJavaValue[] args = new IJavaValue[fArgCount]; 46 for (int i= fArgCount - 1; i >= 0; i--) { 48 args[i] = popValue(); 49 } 50 Object receiver = pop(); 51 IJavaValue result = null; 52 53 if (receiver instanceof IJavaVariable) { 54 receiver = ((IJavaVariable) receiver).getValue(); 55 } 56 57 if (receiver instanceof IJavaObject) { 58 result = ((IJavaObject)receiver).sendMessage(fSelector, fSignature, args, getContext().getThread(), fDeclaringType); 59 } else { 60 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, InstructionsEvaluationMessages.SendMessage_Attempt_to_send_a_message_to_a_non_object_value_1, null)); 61 } 62 setLastValue(result); 63 if (!fSignature.endsWith(")V")) { push(result); 66 } 67 } 68 69 public String toString() { 70 return MessageFormat.format(InstructionsEvaluationMessages.SendMessage_send_message__0___1__2, new String []{fSelector,fSignature}); 71 } 72 } 73 74 | Popular Tags |