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.debug.core.model.IVariable; 20 import org.eclipse.jdt.debug.core.IJavaVariable; 21 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 22 import org.eclipse.jdt.internal.debug.eval.ast.engine.IRuntimeContext; 23 24 28 public class PushLocalVariable extends SimpleInstruction { 29 30 33 private String fName; 34 35 public PushLocalVariable(String name) { 36 fName = name; 37 } 38 39 public void execute() throws CoreException { 40 IVariable internalVariable= getInternalVariable(fName); 41 if (internalVariable != null) { 42 push(internalVariable); 43 return; 44 } 45 IRuntimeContext context= getContext(); 46 IJavaVariable[] locals = context.getLocals(); 47 for (int i = 0; i < locals.length; i++) { 48 if (locals[i].getName().equals(getName())) { 49 push(locals[i]); 50 return; 51 } 52 } 53 54 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, MessageFormat.format(InstructionsEvaluationMessages.PushLocalVariable_Cannot_find_the_variable____1, new String []{fName}), null)); 55 } 56 57 64 protected String getName() { 65 return fName; 66 } 67 68 public String toString() { 69 return MessageFormat.format(InstructionsEvaluationMessages.PushLocalVariable_push____0___2, new String []{getName()}); 70 } 71 } 72 73 | Popular Tags |