Java 类org.apache.bcel.generic.AllocationInstruction 实例源码

项目:VestaClient    文件:BCELFactory.java   
public void visitAllocationInstruction( AllocationInstruction i ) {
    Type type;
    if (i instanceof CPInstruction) {
        type = ((CPInstruction) i).getType(_cp);
    } else {
        type = ((NEWARRAY) i).getType();
    }
    short opcode = ((Instruction) i).getOpcode();
    int dim = 1;
    switch (opcode) {
        case Constants.NEW:
            _out.println("il.append(_factory.createNew(\"" + ((ObjectType) type).getClassName()
                    + "\"));");
            break;
        case Constants.MULTIANEWARRAY:
            dim = ((MULTIANEWARRAY) i).getDimensions();
        case Constants.ANEWARRAY:
        case Constants.NEWARRAY:
            if (type instanceof ArrayType) {
                type = ((ArrayType) type).getBasicType();
            }
            _out.println("il.append(_factory.createNewArray(" + BCELifier.printType(type)
                    + ", (short) " + dim + "));");
            break;
        default:
            throw new RuntimeException("Oops: " + opcode);
    }
}