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.debug.core.model.IVariable; 18 import org.eclipse.jdi.internal.PrimitiveTypeImpl; 19 import org.eclipse.jdi.internal.VirtualMachineImpl; 20 import org.eclipse.jdt.debug.core.IJavaType; 21 import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget; 22 import org.eclipse.jdt.internal.debug.core.model.JDIType; 23 24 import com.sun.jdi.VirtualMachine; 25 26 public class LocalVariableCreation extends CompoundInstruction { 27 28 31 private boolean fIsPrimitiveType; 32 33 36 private String fName; 37 38 41 private String fTypeSignature; 42 43 46 private int fDimension; 47 48 51 private boolean fHasInitializer; 52 53 63 public LocalVariableCreation(String name, String typeSignature, int dimension, boolean isPrimitiveType, boolean hasInitializer, int start) { 64 super(start); 65 fName= name; 66 fTypeSignature= typeSignature.replace('/', '.'); 67 fIsPrimitiveType= isPrimitiveType; 68 fHasInitializer= hasInitializer; 69 fDimension= dimension; 70 } 71 72 75 public void execute() throws CoreException { 76 IJavaType type; 77 if (fIsPrimitiveType) { 78 JDIDebugTarget debugTarget= (JDIDebugTarget)getVM(); 79 VirtualMachine vm = debugTarget.getVM(); 80 if (vm == null) { 81 debugTarget.requestFailed(InstructionsEvaluationMessages.LocalVariableCreation_Execution_failed___VM_disconnected__1, null); 82 } 83 type= JDIType.createType(debugTarget, PrimitiveTypeImpl.create((VirtualMachineImpl)vm, fTypeSignature)); 84 } else if (fDimension == 0) { 85 type= getType(RuntimeSignature.toString(fTypeSignature)); } else { 87 type= getArrayType(fTypeSignature, fDimension); 88 } 89 IVariable var= createInternalVariable(fName, type); 90 if (fHasInitializer) { 91 var.setValue(popValue()); 92 } 93 } 94 95 public String toString() { 96 return MessageFormat.format(InstructionsEvaluationMessages.LocalVariableCreation_create_local_variable__0___1___1, new String []{fName, fTypeSignature}); 97 } 98 } 99 | Popular Tags |