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.IJavaClassType; 20 import org.eclipse.jdt.debug.core.IJavaType; 21 import org.eclipse.jdt.debug.core.IJavaValue; 22 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 23 24 29 public class SendStaticMessage extends CompoundInstruction { 30 31 private int fArgCount; 32 private String fSelector; 33 private String fSignature; 34 private String fTypeName; 35 36 public SendStaticMessage(String typeName, String selector, String signature, int argCount, int start) { 37 super(start); 38 fArgCount= argCount; 39 fSelector= selector; 40 fSignature= signature; 41 fTypeName= typeName; 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 51 IJavaType receiver= getType(fTypeName); 52 IJavaValue result; 53 if (receiver instanceof IJavaClassType) { 54 result= ((IJavaClassType)receiver).sendMessage(fSelector, fSignature, args, getContext().getThread()); 55 } else { 56 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, InstructionsEvaluationMessages.SendStaticMessage_Cannot_send_a_static_message_to_a_non_class_type_object_1, null)); 57 } 58 setLastValue(result); 59 if (!fSignature.endsWith(")V")) { push(result); 62 } 63 } 64 65 public String toString() { 66 return MessageFormat.format(InstructionsEvaluationMessages.SendStaticMessage_send_static_message__0___1__2, new String []{fSelector, fSignature}); 67 } 68 } 69 70 | Popular Tags |