public void newObject(TypeDesc type, int dimensions) { if (dimensions <= 0) { // If type refers to an array, then this code is bogus. mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); return; } TypeDesc componentType = type.getComponentType(); if (dimensions == 1) { if (componentType.isPrimitive()) { addInstruction(0, type, Opcode.NEWARRAY, (byte)componentType.getTypeCode()); return; } addInstruction(0, type, Opcode.ANEWARRAY, mCp.addConstantClass(componentType)); return; } int stackAdjust = -(dimensions - 1); ConstantInfo info = mCp.addConstantClass(type); byte[] bytes = new byte[4]; bytes[0] = Opcode.MULTIANEWARRAY; //bytes[1] = (byte)0; //bytes[2] = (byte)0; bytes[3] = (byte)dimensions; mInstructions.new ConstantOperandInstruction(stackAdjust, type, bytes, info); }
public void newObject(TypeDesc type) { if (type.isArray()) { newObject(type, 1); } else { mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); } }
public void newObject(TypeDesc type, int dimensions) { if (dimensions <= 0) { // If type refers to an array, then this code is bogus. mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); return; } TypeDesc componentType = type.getComponentType(); if (dimensions == 1) { if (componentType.isPrimitive()) { addInstruction(0, type, Opcode.NEWARRAY, (byte)componentType.getTypeCode()); return; } addInstruction(0, type, Opcode.ANEWARRAY, mCp.addConstantClass(componentType)); return; } int stackAdjust = -(dimensions - 1); ConstantInfo info = mCp.addConstantClass(type); byte[] bytes = new byte[4]; bytes[0] = Opcode.MULTIANEWARRAY; //bytes[1] = (byte)0; //bytes[2] = (byte)0; bytes[3] = (byte)dimensions; mInstructions.new ConstantOperandInstruction(stackAdjust, type, bytes, info); }
public void newObject(TypeDesc type) { if (type.isArray()) { newObject(type, 1); } else { mInstructions.new NewObjectInstruction(mCp.addConstantClass(type)); } }