1 11 package org.eclipse.jdt.internal.debug.eval.ast.instructions; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.jdt.debug.core.IJavaArray; 15 import org.eclipse.jdt.debug.core.IJavaArrayType; 16 17 public class ArrayInitializerInstruction extends ArrayInstruction { 18 19 private String fTypeSignature; 20 21 private int fDimensions; 22 23 private int fLength; 24 25 29 public ArrayInitializerInstruction(String typeSignature, int length, int dimensions, int start) { 30 super(start); 31 fTypeSignature = typeSignature; 32 fDimensions = dimensions; 33 fLength = length; 34 } 35 36 39 public void execute() throws CoreException { 40 41 IJavaArrayType arrayType = getArrayType(fTypeSignature.replace('/','.'), fDimensions); 42 IJavaArray array = arrayType.newInstance(fLength); 43 44 for (int i = fLength - 1; i >= 0; i--) { 45 array.setValue(i, popValue()); 46 } 47 48 push(array); 49 50 } 51 52 public String toString() { 53 return InstructionsEvaluationMessages.ArrayInitializerInstruction_array_initializer_1; 54 } 55 56 } 57 | Popular Tags |