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.IJavaArray; 20 import org.eclipse.jdt.debug.core.IJavaPrimitiveValue; 21 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; 22 23 28 public class ArrayAccess extends ArrayInstruction { 29 30 public ArrayAccess(int start) { 31 super(start); 32 } 33 34 public void execute() throws CoreException { 35 int index = ((IJavaPrimitiveValue)popValue()).getIntValue(); 36 IJavaArray array = (IJavaArray)popValue(); 37 if (index >= array.getLength() || index < 0) { 38 throw new CoreException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IStatus.OK, MessageFormat.format(InstructionsEvaluationMessages.ArrayAccess_illegal_index, new Object [] {new Integer (index)}), null)); 39 } 40 push(array.getVariable(index)); 41 } 42 43 public String toString() { 44 return InstructionsEvaluationMessages.ArrayAccess_array_access_1; 45 } 46 } 47 48 | Popular Tags |