Program: 6340
Project: 6340
Buggy source:
public Instruction getInstruction(StackStatement stmt,VariableTable varTable,InstructionHandle[] targets) throws TypeException {
  if (stmt instanceof StackArrayLength) {
    return new ARRAYLENGTH();
  }
  if (stmt instanceof StackArrayLoad) {
    Instruction is;
    if (((StackArrayLoad)stmt).getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
      is=new AALOAD();
    }
 else {
switch (((StackArrayLoad)stmt).getArrayType().getType()) {
case TypeInfo.TYPE_BOOL:
        is=new BALOAD();
      break;
case TypeInfo.TYPE_BYTE:
    is=new BALOAD();
  break;
case TypeInfo.TYPE_CHAR:
is=new CALOAD();
break;
case TypeInfo.TYPE_SHORT:
is=new SALOAD();
break;
case TypeInfo.TYPE_INT:
is=new IALOAD();
break;
case TypeInfo.TYPE_LONG:
is=new LALOAD();
break;
case TypeInfo.TYPE_FLOAT:
is=new FALOAD();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DALOAD();
break;
default :
throw new TypeException("String_Node_Str" + ((StackArrayLoad)stmt).getArrayType().getTypeName() + "String_Node_Str");
}
}
return is;
}
if (stmt instanceof StackArrayStore) {
Instruction is;
if (((StackArrayStore)stmt).getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
is=new AASTORE();
}
 else {
switch (((StackArrayStore)stmt).getArrayType().getType()) {
case TypeInfo.TYPE_BOOL:
is=new BASTORE();
break;
case TypeInfo.TYPE_BYTE:
is=new BASTORE();
break;
case TypeInfo.TYPE_CHAR:
is=new CASTORE();
break;
case TypeInfo.TYPE_SHORT:
is=new SASTORE();
break;
case TypeInfo.TYPE_INT:
is=new IASTORE();
break;
case TypeInfo.TYPE_LONG:
is=new LASTORE();
break;
case TypeInfo.TYPE_FLOAT:
is=new FASTORE();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DASTORE();
break;
default :
throw new TypeException("String_Node_Str" + ((StackArrayStore)stmt).getArrayType().getTypeName() + "String_Node_Str");
}
}
return is;
}
if (stmt instanceof StackBinop) {
StackBinop binop=(StackBinop)stmt;
Instruction is=null;
switch (binop.getOperand()) {
case StackBinop.OP_ADD:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IADD();
break;
case TypeInfo.TYPE_LONG:
is=new LADD();
break;
case TypeInfo.TYPE_FLOAT:
is=new FADD();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DADD();
break;
}
break;
case StackBinop.OP_AND:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IAND();
break;
case TypeInfo.TYPE_LONG:
is=new LAND();
break;
}
break;
case StackBinop.OP_CMP:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_LONG:
is=new LCMP();
break;
}
break;
case StackBinop.OP_CMPG:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_FLOAT:
is=new FCMPG();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DCMPG();
break;
}
break;
case StackBinop.OP_CMPL:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_FLOAT:
is=new FCMPL();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DCMPL();
break;
}
break;
case StackBinop.OP_DIV:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IDIV();
break;
case TypeInfo.TYPE_LONG:
is=new LDIV();
break;
case TypeInfo.TYPE_FLOAT:
is=new FDIV();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DDIV();
break;
}
break;
case StackBinop.OP_LOGIC_SHIFT_RIGHT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IUSHR();
break;
case TypeInfo.TYPE_LONG:
is=new LUSHR();
break;
}
break;
case StackBinop.OP_MUL:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IMUL();
break;
case TypeInfo.TYPE_LONG:
is=new LMUL();
break;
case TypeInfo.TYPE_FLOAT:
is=new FMUL();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DMUL();
break;
}
break;
case StackBinop.OP_OR:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IOR();
break;
case TypeInfo.TYPE_LONG:
is=new LOR();
break;
}
break;
case StackBinop.OP_REMINDER:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IREM();
break;
case TypeInfo.TYPE_LONG:
is=new LREM();
break;
case TypeInfo.TYPE_FLOAT:
is=new FREM();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DREM();
break;
}
break;
case StackBinop.OP_SHIFT_LEFT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISHL();
break;
case TypeInfo.TYPE_LONG:
is=new LSHL();
break;
}
break;
case StackBinop.OP_SHIFT_RIGHT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISHR();
break;
case TypeInfo.TYPE_LONG:
is=new LSHR();
break;
}
break;
case StackBinop.OP_SUB:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISUB();
break;
case TypeInfo.TYPE_LONG:
is=new LSUB();
break;
case TypeInfo.TYPE_FLOAT:
is=new FSUB();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DSUB();
break;
}
break;
case StackBinop.OP_XOR:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IXOR();
break;
case TypeInfo.TYPE_LONG:
is=new LXOR();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackBreakpoint) {
return new BREAKPOINT();
}
if (stmt instanceof StackCheckcast) {
StackCheckcast cast=(StackCheckcast)stmt;
return new CHECKCAST(cp.addConstant(cast.getClassConstant()));
}
if (stmt instanceof StackConvert) {
StackConvert convert=(StackConvert)stmt;
Instruction is=null;
switch (convert.getFromType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (convert.getToType().getType()) {
case TypeInfo.TYPE_LONG:
is=new I2L();
break;
case TypeInfo.TYPE_FLOAT:
is=new I2F();
break;
case TypeInfo.TYPE_DOUBLE:
is=new I2D();
break;
case TypeInfo.TYPE_SHORT:
is=new I2S();
break;
case TypeInfo.TYPE_BYTE:
is=new I2B();
break;
case TypeInfo.TYPE_BOOL:
is=new I2B();
break;
case TypeInfo.TYPE_CHAR:
is=new I2C();
break;
}
break;
case TypeInfo.TYPE_LONG:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new L2I();
break;
case TypeInfo.TYPE_FLOAT:
is=new L2F();
break;
case TypeInfo.TYPE_DOUBLE:
is=new L2D();
break;
}
break;
case TypeInfo.TYPE_FLOAT:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new F2I();
break;
case TypeInfo.TYPE_LONG:
is=new F2L();
break;
case TypeInfo.TYPE_DOUBLE:
is=new F2D();
break;
}
break;
case TypeInfo.TYPE_DOUBLE:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new D2I();
break;
case TypeInfo.TYPE_LONG:
is=new D2L();
break;
case TypeInfo.TYPE_FLOAT:
is=new D2F();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackDup) {
StackDup dup=(StackDup)stmt;
Instruction is=null;
switch (dup.getTypeLength()) {
case 1:
switch (dup.getDownLength()) {
case 0:
is=new DUP();
break;
case 1:
is=new DUP_X1();
break;
case 2:
is=new DUP_X2();
break;
}
break;
case 2:
switch (dup.getDownLength()) {
case 0:
is=new DUP2();
break;
case 1:
is=new DUP2_X1();
break;
case 2:
is=new DUP2_X2();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + dup.getTypeLength() + "String_Node_Str"+ dup.getDownLength()+ "String_Node_Str");
}
return is;
}
if (stmt instanceof StackEntermonitor) {
return new MONITORENTER();
}
if (stmt instanceof StackExitmonitor) {
return new MONITOREXIT();
}
if (stmt instanceof StackGetField) {
StackGetField getfield=(StackGetField)stmt;
Instruction is;
if (getfield.isStatic()) {
is=new GETSTATIC(cp.addConstant(getfield.getConstantField()));
}
 else {
is=new GETFIELD(cp.addConstant(getfield.getConstantField()));
}
return is;
}
if (stmt instanceof StackGoto) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
return new GOTO(targets[0]);
}
if (stmt instanceof StackIfCmp) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
StackIfCmp cmp=(StackIfCmp)stmt;
Instruction is=null;
switch (cmp.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IF_ICMPEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IF_ICMPNE(targets[0]);
break;
case StackIfCmp.OP_GREATER:
is=new IF_ICMPGT(targets[0]);
break;
case StackIfCmp.OP_GREATER_OR_EQUAL:
is=new IF_ICMPGE(targets[0]);
break;
case StackIfCmp.OP_LESS:
is=new IF_ICMPLT(targets[0]);
break;
case StackIfCmp.OP_LESS_OR_EQUAL:
is=new IF_ICMPLE(targets[0]);
break;
}
break;
case TypeInfo.TYPE_REFERENCE:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IF_ACMPEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IF_ACMPNE(targets[0]);
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackIfZero) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
StackIfZero cmp=(StackIfZero)stmt;
Instruction is=null;
switch (cmp.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IFEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IFNE(targets[0]);
break;
case StackIfCmp.OP_GREATER:
is=new IFGT(targets[0]);
break;
case StackIfCmp.OP_GREATER_OR_EQUAL:
is=new IFGE(targets[0]);
break;
case StackIfCmp.OP_LESS:
is=new IFLT(targets[0]);
break;
case StackIfCmp.OP_LESS_OR_EQUAL:
is=new IFLE(targets[0]);
break;
}
break;
case TypeInfo.TYPE_REFERENCE:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IFNULL(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IFNONNULL(targets[0]);
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackIInc) {
StackIInc inc=(StackIInc)stmt;
return new IINC(varTable.getIndex(inc.getIncVariable()),inc.getIncrement());
}
if (stmt instanceof StackInstanceof) {
return new INSTANCEOF(cp.addConstant(((StackInstanceof)stmt).getClassConstant()));
}
if (stmt instanceof StackInvoke) {
StackInvoke invoke=(StackInvoke)stmt;
int cls=cp.addConstant(invoke.getMethodConstant());
Instruction is=null;
switch (invoke.getInvokeType()) {
case StackInvoke.TYPE_INTERFACE:
int count=invoke.getParamSlotCount();
is=new INVOKEINTERFACE(cls,count);
break;
case StackInvoke.TYPE_SPECIAL:
is=new INVOKESPECIAL(cls);
break;
case StackInvoke.TYPE_STATIC:
is=new INVOKESTATIC(cls);
break;
case StackInvoke.TYPE_VIRTUAL:
is=new INVOKEVIRTUAL(cls);
break;
}
return is;
}
if (stmt instanceof StackJSR) {
return new JSR(null);
}
if (stmt instanceof StackJSRReturn) {
return new RET(varTable.getIndex(((StackJSRReturn)stmt).getRetAddressVar()));
}
if (stmt instanceof StackLoad) {
StackLoad load=(StackLoad)stmt;
int index=varTable.getIndex(load.getVariable());
Instruction is=null;
switch (load.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ILOAD(index);
break;
case TypeInfo.TYPE_LONG:
is=new LLOAD(index);
break;
case TypeInfo.TYPE_FLOAT:
is=new FLOAD(index);
break;
case TypeInfo.TYPE_DOUBLE:
is=new DLOAD(index);
break;
case TypeInfo.TYPE_REFERENCE:
is=new ALOAD(index);
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackLookupswitch) {
StackLookupswitch ls=(StackLookupswitch)stmt;
int[] matchs=ls.getMatchs();
if (targets.length < matchs.length + 1) {
throw new TypeException("String_Node_Str");
}
InstructionHandle[] mTargets=new InstructionHandle[matchs.length];
System.arraycopy(targets,1,mTargets,0,mTargets.length);
return new LOOKUPSWITCH(matchs,mTargets,targets[0]);
}
if (stmt instanceof StackNegate) {
Instruction is=null;
switch (((StackNegate)stmt).getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new INEG();
break;
case TypeInfo.TYPE_LONG:
is=new LNEG();
break;
case TypeInfo.TYPE_FLOAT:
is=new FNEG();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DNEG();
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackNew) {
return new NEW(cp.addConstant(((StackNew)stmt).getObjectClass()));
}
if (stmt instanceof StackNewArray) {
StackNewArray newArray=(StackNewArray)stmt;
Instruction is;
if (newArray.getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
is=new ANEWARRAY(cp.addConstant(((RefTypeInfo)newArray.getArrayType()).getClassConstant()));
}
 else {
is=new NEWARRAY(getBcelType(newArray.getArrayType()).getType());
}
return is;
}
if (stmt instanceof StackNewMultiArray) {
StackNewMultiArray ma=(StackNewMultiArray)stmt;
return new MULTIANEWARRAY(cp.addConstant(ma.getArrayClass()),ma.getDimensions());
}
if (stmt instanceof StackNop) {
return new NOP();
}
if (stmt instanceof StackPop) {
Instruction is=null;
switch (((StackPop)stmt).getPopSize()) {
case 1:
is=new POP();
break;
case 2:
is=new POP2();
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + ((StackPop)stmt).getPopSize() + "String_Node_Str");
}
return is;
}
if (stmt instanceof StackPush) {
StackPush push=(StackPush)stmt;
ConstantValue value=push.getValue();
Instruction is=null;
switch (value.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
int iValue=value.getIntValue();
if (iValue >= -1 && iValue <= 5) {
is=InstructionConstants.INSTRUCTIONS[Constants.ICONST_0 + iValue];
}
 else if (iValue >= -128 && iValue <= 127) {
is=new BIPUSH((byte)iValue);
}
 else if (iValue >= -32768 && iValue <= 32767) {
is=new SIPUSH((short)iValue);
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC(index);
}
break;
case TypeInfo.TYPE_LONG:
long lValue=value.getLongValue();
if (lValue == 0) {
is=InstructionConstants.LCONST_0;
}
 else if (lValue == 1) {
is=InstructionConstants.LCONST_1;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC2_W(index);
}
break;
case TypeInfo.TYPE_FLOAT:
float fValue=value.getFloatValue();
if (fValue == 0.0f) {
is=InstructionConstants.FCONST_0;
}
 else if (fValue == 1.0f) {
is=InstructionConstants.FCONST_1;
}
 else if (fValue == 2.0f) {
is=InstructionConstants.FCONST_2;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC(index);
}
break;
case TypeInfo.TYPE_DOUBLE:
double dValue=value.getDoubleValue();
if (dValue == 0.0) {
is=InstructionConstants.DCONST_0;
}
 else if (dValue == 1.0) {
is=InstructionConstants.DCONST_1;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC2_W(index);
}
break;
case TypeInfo.TYPE_REFERENCE:
String txt=value.getTxtValue();
if (txt == null) {
is=InstructionConstants.ACONST_NULL;
}
 else {
is=new LDC(cp.addConstant(value));
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + push.getType().getTypeName() + "String_Node_Str");
}
return is;
}
if (stmt instanceof StackPutField) {
StackPutField putfield=(StackPutField)stmt;
Instruction is;
if (putfield.isStatic()) {
is=new PUTSTATIC(cp.addConstant(putfield.getConstantField()));
}
 else {
is=new PUTFIELD(cp.addConstant(putfield.getConstantField()));
}
return is;
}
if (stmt instanceof StackReturn) {
StackReturn ret=(StackReturn)stmt;
Instruction is=null;
if (ret.getType() == null) {
is=new RETURN();
}
 else {
switch (ret.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IRETURN();
break;
case TypeInfo.TYPE_LONG:
is=new LRETURN();
break;
case TypeInfo.TYPE_FLOAT:
is=new FRETURN();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DRETURN();
break;
case TypeInfo.TYPE_REFERENCE:
is=new ARETURN();
break;
}
}
return is;
}
if (stmt instanceof StackStore) {
StackStore store=(StackStore)stmt;
int index=varTable.getIndex(store.getVariable());
Instruction is=null;
switch (store.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISTORE(index);
break;
case TypeInfo.TYPE_LONG:
is=new LSTORE(index);
break;
case TypeInfo.TYPE_FLOAT:
is=new FSTORE(index);
break;
case TypeInfo.TYPE_DOUBLE:
is=new DSTORE(index);
break;
case TypeInfo.TYPE_REFERENCE:
is=new ASTORE(index);
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackSwap) {
return new SWAP();
}
if (stmt instanceof StackTableswitch) {
int[] matchs=((StackTableswitch)stmt).createMatchs();
if (targets.length < matchs.length + 1) {
throw new TypeException("String_Node_Str");
}
InstructionHandle[] mTargets=new InstructionHandle[matchs.length];
System.arraycopy(targets,1,mTargets,0,mTargets.length);
return new TABLESWITCH(matchs,mTargets,targets[0]);
}
if (stmt instanceof StackThrow) {
return new ATHROW();
}
if (stmt instanceof IdentityStmt) {
return null;
}
return null;
}

Fixed version (ground truth):
public Instruction getInstruction(StackStatement stmt,VariableTable varTable,InstructionHandle[] targets) throws TypeException {
  if (stmt instanceof StackArrayLength) {
    return new ARRAYLENGTH();
  }
  if (stmt instanceof StackArrayLoad) {
    Instruction is;
    if (((StackArrayLoad)stmt).getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
      is=new AALOAD();
    }
 else {
switch (((StackArrayLoad)stmt).getArrayType().getType()) {
case TypeInfo.TYPE_BOOL:
        is=new BALOAD();
      break;
case TypeInfo.TYPE_BYTE:
    is=new BALOAD();
  break;
case TypeInfo.TYPE_CHAR:
is=new CALOAD();
break;
case TypeInfo.TYPE_SHORT:
is=new SALOAD();
break;
case TypeInfo.TYPE_INT:
is=new IALOAD();
break;
case TypeInfo.TYPE_LONG:
is=new LALOAD();
break;
case TypeInfo.TYPE_FLOAT:
is=new FALOAD();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DALOAD();
break;
default :
throw new TypeException("String_Node_Str" + ((StackArrayLoad)stmt).getArrayType().getTypeName() + "String_Node_Str");
}
}
return is;
}
if (stmt instanceof StackArrayStore) {
Instruction is;
if (((StackArrayStore)stmt).getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
is=new AASTORE();
}
 else {
switch (((StackArrayStore)stmt).getArrayType().getType()) {
case TypeInfo.TYPE_BOOL:
is=new BASTORE();
break;
case TypeInfo.TYPE_BYTE:
is=new BASTORE();
break;
case TypeInfo.TYPE_CHAR:
is=new CASTORE();
break;
case TypeInfo.TYPE_SHORT:
is=new SASTORE();
break;
case TypeInfo.TYPE_INT:
is=new IASTORE();
break;
case TypeInfo.TYPE_LONG:
is=new LASTORE();
break;
case TypeInfo.TYPE_FLOAT:
is=new FASTORE();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DASTORE();
break;
default :
throw new TypeException("String_Node_Str" + ((StackArrayStore)stmt).getArrayType().getTypeName() + "String_Node_Str");
}
}
return is;
}
if (stmt instanceof StackBinop) {
StackBinop binop=(StackBinop)stmt;
Instruction is=null;
switch (binop.getOperand()) {
case StackBinop.OP_ADD:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IADD();
break;
case TypeInfo.TYPE_LONG:
is=new LADD();
break;
case TypeInfo.TYPE_FLOAT:
is=new FADD();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DADD();
break;
}
break;
case StackBinop.OP_AND:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IAND();
break;
case TypeInfo.TYPE_LONG:
is=new LAND();
break;
}
break;
case StackBinop.OP_CMP:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_LONG:
is=new LCMP();
break;
}
break;
case StackBinop.OP_CMPG:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_FLOAT:
is=new FCMPG();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DCMPG();
break;
}
break;
case StackBinop.OP_CMPL:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_FLOAT:
is=new FCMPL();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DCMPL();
break;
}
break;
case StackBinop.OP_DIV:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IDIV();
break;
case TypeInfo.TYPE_LONG:
is=new LDIV();
break;
case TypeInfo.TYPE_FLOAT:
is=new FDIV();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DDIV();
break;
}
break;
case StackBinop.OP_LOGIC_SHIFT_RIGHT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IUSHR();
break;
case TypeInfo.TYPE_LONG:
is=new LUSHR();
break;
}
break;
case StackBinop.OP_MUL:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IMUL();
break;
case TypeInfo.TYPE_LONG:
is=new LMUL();
break;
case TypeInfo.TYPE_FLOAT:
is=new FMUL();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DMUL();
break;
}
break;
case StackBinop.OP_OR:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IOR();
break;
case TypeInfo.TYPE_LONG:
is=new LOR();
break;
}
break;
case StackBinop.OP_REMINDER:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IREM();
break;
case TypeInfo.TYPE_LONG:
is=new LREM();
break;
case TypeInfo.TYPE_FLOAT:
is=new FREM();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DREM();
break;
}
break;
case StackBinop.OP_SHIFT_LEFT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISHL();
break;
case TypeInfo.TYPE_LONG:
is=new LSHL();
break;
}
break;
case StackBinop.OP_SHIFT_RIGHT:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISHR();
break;
case TypeInfo.TYPE_LONG:
is=new LSHR();
break;
}
break;
case StackBinop.OP_SUB:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISUB();
break;
case TypeInfo.TYPE_LONG:
is=new LSUB();
break;
case TypeInfo.TYPE_FLOAT:
is=new FSUB();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DSUB();
break;
}
break;
case StackBinop.OP_XOR:
switch (binop.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IXOR();
break;
case TypeInfo.TYPE_LONG:
is=new LXOR();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackBreakpoint) {
return new BREAKPOINT();
}
if (stmt instanceof StackCheckcast) {
StackCheckcast cast=(StackCheckcast)stmt;
return new CHECKCAST(cp.addConstant(cast.getClassConstant()));
}
if (stmt instanceof StackConvert) {
StackConvert convert=(StackConvert)stmt;
Instruction is=null;
switch (convert.getFromType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (convert.getToType().getType()) {
case TypeInfo.TYPE_LONG:
is=new I2L();
break;
case TypeInfo.TYPE_FLOAT:
is=new I2F();
break;
case TypeInfo.TYPE_DOUBLE:
is=new I2D();
break;
case TypeInfo.TYPE_SHORT:
is=new I2S();
break;
case TypeInfo.TYPE_BYTE:
is=new I2B();
break;
case TypeInfo.TYPE_BOOL:
is=new I2B();
break;
case TypeInfo.TYPE_CHAR:
is=new I2C();
break;
}
break;
case TypeInfo.TYPE_LONG:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new L2I();
break;
case TypeInfo.TYPE_FLOAT:
is=new L2F();
break;
case TypeInfo.TYPE_DOUBLE:
is=new L2D();
break;
}
break;
case TypeInfo.TYPE_FLOAT:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new F2I();
break;
case TypeInfo.TYPE_LONG:
is=new F2L();
break;
case TypeInfo.TYPE_DOUBLE:
is=new F2D();
break;
}
break;
case TypeInfo.TYPE_DOUBLE:
switch (convert.getToType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new D2I();
break;
case TypeInfo.TYPE_LONG:
is=new D2L();
break;
case TypeInfo.TYPE_FLOAT:
is=new D2F();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackDup) {
StackDup dup=(StackDup)stmt;
Instruction is=null;
switch (dup.getTypeLength()) {
case 1:
switch (dup.getDownLength()) {
case 0:
is=new DUP();
break;
case 1:
is=new DUP_X1();
break;
case 2:
is=new DUP_X2();
break;
}
break;
case 2:
switch (dup.getDownLength()) {
case 0:
is=new DUP2();
break;
case 1:
is=new DUP2_X1();
break;
case 2:
is=new DUP2_X2();
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + dup.getTypeLength() + "String_Node_Str"+ dup.getDownLength()+ "String_Node_Str");
}
return is;
}
if (stmt instanceof StackEntermonitor) {
return new MONITORENTER();
}
if (stmt instanceof StackExitmonitor) {
return new MONITOREXIT();
}
if (stmt instanceof StackGetField) {
StackGetField getfield=(StackGetField)stmt;
Instruction is;
if (getfield.isStatic()) {
is=new GETSTATIC(cp.addConstant(getfield.getConstantField()));
}
 else {
is=new GETFIELD(cp.addConstant(getfield.getConstantField()));
}
return is;
}
if (stmt instanceof StackGoto) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
return new GOTO(targets[0]);
}
if (stmt instanceof StackIfCmp) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
StackIfCmp cmp=(StackIfCmp)stmt;
Instruction is=null;
switch (cmp.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IF_ICMPEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IF_ICMPNE(targets[0]);
break;
case StackIfCmp.OP_GREATER:
is=new IF_ICMPGT(targets[0]);
break;
case StackIfCmp.OP_GREATER_OR_EQUAL:
is=new IF_ICMPGE(targets[0]);
break;
case StackIfCmp.OP_LESS:
is=new IF_ICMPLT(targets[0]);
break;
case StackIfCmp.OP_LESS_OR_EQUAL:
is=new IF_ICMPLE(targets[0]);
break;
}
break;
case TypeInfo.TYPE_REFERENCE:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IF_ACMPEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IF_ACMPNE(targets[0]);
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackIfZero) {
if (targets.length < 1) {
throw new TypeException("String_Node_Str");
}
StackIfZero cmp=(StackIfZero)stmt;
Instruction is=null;
switch (cmp.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IFEQ(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IFNE(targets[0]);
break;
case StackIfCmp.OP_GREATER:
is=new IFGT(targets[0]);
break;
case StackIfCmp.OP_GREATER_OR_EQUAL:
is=new IFGE(targets[0]);
break;
case StackIfCmp.OP_LESS:
is=new IFLT(targets[0]);
break;
case StackIfCmp.OP_LESS_OR_EQUAL:
is=new IFLE(targets[0]);
break;
}
break;
case TypeInfo.TYPE_REFERENCE:
switch (cmp.getOperand()) {
case StackIfCmp.OP_EQUAL:
is=new IFNULL(targets[0]);
break;
case StackIfCmp.OP_NOTEQUAL:
is=new IFNONNULL(targets[0]);
break;
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackIInc) {
StackIInc inc=(StackIInc)stmt;
return new IINC(varTable.getIndex(inc.getIncVariable()),inc.getIncrement());
}
if (stmt instanceof StackInstanceof) {
return new INSTANCEOF(cp.addConstant(((StackInstanceof)stmt).getClassConstant()));
}
if (stmt instanceof StackInvoke) {
StackInvoke invoke=(StackInvoke)stmt;
int cls=cp.addConstant(invoke.getMethodConstant());
Instruction is=null;
switch (invoke.getInvokeType()) {
case StackInvoke.TYPE_INTERFACE:
int count=invoke.getParamSlotCount();
is=new INVOKEINTERFACE(cls,count);
break;
case StackInvoke.TYPE_SPECIAL:
is=new INVOKESPECIAL(cls);
break;
case StackInvoke.TYPE_STATIC:
is=new INVOKESTATIC(cls);
break;
case StackInvoke.TYPE_VIRTUAL:
is=new INVOKEVIRTUAL(cls);
break;
}
return is;
}
if (stmt instanceof StackJSR) {
return new JSR(null);
}
if (stmt instanceof StackJSRReturn) {
return new RET(varTable.getIndex(((StackJSRReturn)stmt).getRetAddressVar()));
}
if (stmt instanceof StackLoad) {
StackLoad load=(StackLoad)stmt;
int index=varTable.getIndex(load.getVariable());
Instruction is=null;
switch (load.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ILOAD(index);
break;
case TypeInfo.TYPE_LONG:
is=new LLOAD(index);
break;
case TypeInfo.TYPE_FLOAT:
is=new FLOAD(index);
break;
case TypeInfo.TYPE_DOUBLE:
is=new DLOAD(index);
break;
case TypeInfo.TYPE_REFERENCE:
is=new ALOAD(index);
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackLookupswitch) {
StackLookupswitch ls=(StackLookupswitch)stmt;
int[] matchs=ls.getMatchs();
if (targets.length < matchs.length + 1) {
throw new TypeException("String_Node_Str");
}
InstructionHandle[] mTargets=new InstructionHandle[matchs.length];
System.arraycopy(targets,1,mTargets,0,mTargets.length);
return new LOOKUPSWITCH(matchs,mTargets,targets[0]);
}
if (stmt instanceof StackNegate) {
Instruction is=null;
switch (((StackNegate)stmt).getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new INEG();
break;
case TypeInfo.TYPE_LONG:
is=new LNEG();
break;
case TypeInfo.TYPE_FLOAT:
is=new FNEG();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DNEG();
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackNew) {
return new NEW(cp.addConstant(((StackNew)stmt).getObjectClass()));
}
if (stmt instanceof StackNewArray) {
StackNewArray newArray=(StackNewArray)stmt;
Instruction is;
if (newArray.getArrayType().getMachineType() == TypeInfo.TYPE_REFERENCE) {
is=new ANEWARRAY(cp.addConstant(((RefTypeInfo)newArray.getArrayType()).getClassConstant()));
}
 else {
is=new NEWARRAY(getBcelType(newArray.getArrayType()).getType());
}
return is;
}
if (stmt instanceof StackNewMultiArray) {
StackNewMultiArray ma=(StackNewMultiArray)stmt;
return new MULTIANEWARRAY(cp.addConstant(ma.getArrayClass()),ma.getDimensions());
}
if (stmt instanceof StackNop) {
return new NOP();
}
if (stmt instanceof StackPop) {
Instruction is=null;
switch (((StackPop)stmt).getPopSize()) {
case 1:
is=new POP();
break;
case 2:
is=new POP2();
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + ((StackPop)stmt).getPopSize() + "String_Node_Str");
}
return is;
}
if (stmt instanceof StackPush) {
StackPush push=(StackPush)stmt;
ConstantValue value=push.getValue();
Instruction is=null;
switch (value.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
int iValue=value.getIntValue();
if (iValue >= -1 && iValue <= 5) {
is=InstructionConstants.INSTRUCTIONS[Constants.ICONST_0 + iValue];
}
 else if (iValue >= -128 && iValue <= 127) {
is=new BIPUSH((byte)iValue);
}
 else if (iValue >= -32768 && iValue <= 32767) {
is=new SIPUSH((short)iValue);
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC(index);
}
break;
case TypeInfo.TYPE_LONG:
long lValue=value.getLongValue();
if (lValue == 0) {
is=InstructionConstants.LCONST_0;
}
 else if (lValue == 1) {
is=InstructionConstants.LCONST_1;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC2_W(index);
}
break;
case TypeInfo.TYPE_FLOAT:
float fValue=value.getFloatValue();
if (fValue == 0.0f) {
is=InstructionConstants.FCONST_0;
}
 else if (fValue == 1.0f) {
is=InstructionConstants.FCONST_1;
}
 else if (fValue == 2.0f) {
is=InstructionConstants.FCONST_2;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC(index);
}
break;
case TypeInfo.TYPE_DOUBLE:
double dValue=value.getDoubleValue();
if (dValue == 0.0) {
is=InstructionConstants.DCONST_0;
}
 else if (dValue == 1.0) {
is=InstructionConstants.DCONST_1;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC2_W(index);
}
break;
case TypeInfo.TYPE_REFERENCE:
String txt=value.getTxtValue();
if (txt == null) {
is=InstructionConstants.ACONST_NULL;
}
 else {
int index=cp.addConstant(value);
push.setPoolIndex(index);
is=new LDC(index);
}
break;
}
if (is == null) {
throw new TypeException("String_Node_Str" + push.getType().getTypeName() + "String_Node_Str");
}
return is;
}
if (stmt instanceof StackPutField) {
StackPutField putfield=(StackPutField)stmt;
Instruction is;
if (putfield.isStatic()) {
is=new PUTSTATIC(cp.addConstant(putfield.getConstantField()));
}
 else {
is=new PUTFIELD(cp.addConstant(putfield.getConstantField()));
}
return is;
}
if (stmt instanceof StackReturn) {
StackReturn ret=(StackReturn)stmt;
Instruction is=null;
if (ret.getType() == null) {
is=new RETURN();
}
 else {
switch (ret.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new IRETURN();
break;
case TypeInfo.TYPE_LONG:
is=new LRETURN();
break;
case TypeInfo.TYPE_FLOAT:
is=new FRETURN();
break;
case TypeInfo.TYPE_DOUBLE:
is=new DRETURN();
break;
case TypeInfo.TYPE_REFERENCE:
is=new ARETURN();
break;
}
}
return is;
}
if (stmt instanceof StackStore) {
StackStore store=(StackStore)stmt;
int index=varTable.getIndex(store.getVariable());
Instruction is=null;
switch (store.getType().getMachineType()) {
case TypeInfo.TYPE_INT:
is=new ISTORE(index);
break;
case TypeInfo.TYPE_LONG:
is=new LSTORE(index);
break;
case TypeInfo.TYPE_FLOAT:
is=new FSTORE(index);
break;
case TypeInfo.TYPE_DOUBLE:
is=new DSTORE(index);
break;
case TypeInfo.TYPE_REFERENCE:
is=new ASTORE(index);
break;
}
if (is == null) {
throw new TypeException("String_Node_Str");
}
return is;
}
if (stmt instanceof StackSwap) {
return new SWAP();
}
if (stmt instanceof StackTableswitch) {
int[] matchs=((StackTableswitch)stmt).createMatchs();
if (targets.length < matchs.length + 1) {
throw new TypeException("String_Node_Str");
}
InstructionHandle[] mTargets=new InstructionHandle[matchs.length];
System.arraycopy(targets,1,mTargets,0,mTargets.length);
return new TABLESWITCH(matchs,mTargets,targets[0]);
}
if (stmt instanceof StackThrow) {
return new ATHROW();
}
if (stmt instanceof IdentityStmt) {
return null;
}
return null;
}