int index= bytes.readUnsignedShort();
ConstantFieldref fieldRef= (ConstantFieldref) constantPool.getConstant(index, Constants.CONSTANT_Fieldref);
Expression ex= stack.pop();
FieldAccess fa= new FieldRead();
fa.setType(new ObjectType(fieldRef.getClass(constantPool)));
fa.setName(getFieldName(fieldRef));
fa.setExpression(ex);
fa.initialize(methodDecl);
instruction= fa;
break;
}
case Const.GETSTATIC:
{
int index= bytes.readUnsignedShort();
ConstantFieldref fieldRef= (ConstantFieldref) constantPool.getConstant(index, Constants.CONSTANT_Fieldref);
FieldAccess fa= new FieldRead();
fa.setType(new ObjectType(fieldRef.getClass(constantPool)));
fa.setName(getFieldName(fieldRef));
fa.initialize(methodDecl);
instruction= fa;
break;
}
case Const.DUP:
{
dup1();
instruction= stack.pop();
break;
}
case Const.DUP2:
if (form.getIndex() == 0)
{
dup2();
instruction= stack.pop();
}
else
{
dup1();
instruction= stack.pop();
}
break;
case Const.DUP_X1:
{
dup1();
stack.rotate(2);
instruction= stack.pop();
break;
}
case Const.DUP_X2:
{
if (form.getIndex() == 0)
{
dup1();
stack.rotate(3);
}
else
{
dup1();
stack.rotate(2);
}
instruction= stack.pop();
break;
}
case Const.DUP2_X1:
if (form.getIndex() == 0)
{
dup2();
stack.rotate(4);
stack.rotate(4);
}
else
{
dup1();
stack.rotate(2);
}
instruction= stack.pop();
break;
case Const.DUP2_X2:
if (form.getIndex() == 0)
{
dup2();
stack.rotate(5);
stack.rotate(5);
}
else if (form.getIndex() == 1)
{
dup1();
stack.rotate(3);
}
else if (form.getIndex() == 2)
{
dup2();
stack.rotate(4);
stack.rotate(4);
}
else
{
dup1();
stack.rotate(2);
}
instruction= stack.pop();
break;
case Const.SWAP:
{
stack.rotate(1);
instruction= new NoOperation();
break;
}
case Const.I2S:
case Const.I2F:
case Const.L2I:
case Const.F2I:
case Const.F2L:
case Const.L2F:
case Const.L2D:
case Const.D2I:
case Const.D2L:
case Const.D2F:
case Const.I2B:
case Const.I2C:
instruction= new PrimitiveCast(opcode, stack.pop(), form.getResultType());
break;
case Const.I2L:
stack.peek().setTypeBinding(Type.LONG);
instruction= new NoOperation();
break;
case Const.I2D:
case Const.F2D:
stack.peek().setTypeBinding(Type.DOUBLE);
instruction= new NoOperation();
break;
case Const.INEG:
case Const.LNEG:
case Const.FNEG:
case Const.DNEG:
instruction= createPrefix(PrefixExpression.MINUS, stack.pop(), form.getResultType());
break;
case Const.ISHR:
case Const.LSHR:
instruction= createInfixRightLeft(InfixExpression.Operator.RIGHT_SHIFT_SIGNED, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.ISHL:
case Const.LSHL:
instruction= createInfixRightLeft(InfixExpression.Operator.LEFT_SHIFT, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IUSHR:
case Const.LUSHR:
instruction= createInfixRightLeft(InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IADD:
case Const.LADD:
case Const.FADD:
case Const.DADD:
instruction= createInfixRightLeft(InfixExpression.Operator.PLUS, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.ISUB:
case Const.LSUB:
case Const.FSUB:
case Const.DSUB:
instruction= createInfixRightLeft(InfixExpression.Operator.MINUS, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IMUL:
case Const.LMUL:
case Const.FMUL:
case Const.DMUL:
instruction= createInfixRightLeft(InfixExpression.Operator.TIMES, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IDIV:
case Const.LDIV:
case Const.FDIV:
case Const.DDIV:
instruction= createInfixRightLeft(InfixExpression.Operator.DIVIDE, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IREM:
case Const.LREM:
case Const.FREM:
case Const.DREM:
instruction= createInfixRightLeft(InfixExpression.Operator.REMAINDER, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IXOR:
case Const.LXOR:
instruction= createInfixRightLeft(InfixExpression.Operator.XOR, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IAND:
case Const.LAND:
instruction= createInfixRightLeft(InfixExpression.Operator.AND, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IOR:
case Const.LOR:
instruction= createInfixRightLeft(InfixExpression.Operator.OR, stack.pop(), stack.pop(), form.getResultType());
break;
case Const.IINC:
{
boolean isWide= wide;
int index= readUnsigned();
wide= isWide;
int constByte= readSigned();
VariableBinding reference= createVariableBinding(index, Type.INT, true);
reference.setField(false);
Assignment assign= new Assignment(Assignment.Operator.PLUS_ASSIGN);
assign.setLeftHandSide(reference);
assign.setRightHandSide(NumberLiteral.create(new Integer(constByte)));
instruction= assign;
break;
}
case Const.ARRAYLENGTH:
{
Expression arrayRef= stack.pop();
FieldAccess access= new FieldRead();
access.setExpression(arrayRef);
access.setName("length");
instruction= access;
break;
}