case Const.CHECKCAST:
{
CastExpression cast= new CastExpression();
int index= bytes.readUnsignedShort();
ConstantClass c= (ConstantClass) constantPool.getConstant(index);
ObjectType type= new ObjectType(c.getBytes(constantPool).replace('/', '.'));
cast.setTypeBinding(type);
cast.setExpression(stack.pop());
instruction= cast;
break;
}
case Const.INSTANCEOF:
{
int index= bytes.readUnsignedShort();
InstanceofExpression ex= new InstanceofExpression();
Expression objectref= stack.pop();
ex.setLeftOperand(objectref);
ConstantClass c= (ConstantClass) constantPool.getConstant(index);
ObjectType type= new ObjectType(c.getBytes(constantPool).replace('/', '.'));
ex.setRightOperand(type);
ex.widen(objectref);
instruction= ex;
break;
}
case Const.ACONST_NULL:
instruction= new NullLiteral();
break;
case Const.JSR:
{
instruction= new JumpSubRoutine(currentIndex + bytes.readShort());
opStackDelta= 0;
break;
}
case Const.JSR_W:
{
instruction= new JumpSubRoutine(currentIndex + bytes.readInt());
break;
}
case Const.IFEQ:
instruction= createConditional(currentIndex, InfixExpression.Operator.EQUALS, NumberLiteral.create(0));
break;
case Const.IFNE:
instruction= createConditional(currentIndex, InfixExpression.Operator.NOT_EQUALS, NumberLiteral.create(0));
break;
case Const.IFGE:
instruction= createConditional(currentIndex, InfixExpression.Operator.GREATER_EQUALS, NumberLiteral.create(0));
break;
case Const.IFGT:
instruction= createConditional(currentIndex, InfixExpression.Operator.GREATER, NumberLiteral.create(0));
break;
case Const.IFLE:
instruction= createConditional(currentIndex, InfixExpression.Operator.LESS_EQUALS, NumberLiteral.create(0));
break;
case Const.IFLT:
instruction= createConditional(currentIndex, InfixExpression.Operator.LESS, NumberLiteral.create(0));
break;
case Const.IFNONNULL:
instruction= createConditional(currentIndex, InfixExpression.Operator.NOT_EQUALS, new NullLiteral());
break;
case Const.IFNULL:
instruction= createConditional(currentIndex, InfixExpression.Operator.EQUALS, new NullLiteral());
break;
case Const.IF_ACMPEQ:
case Const.IF_ICMPEQ:
instruction= createConditional(currentIndex, InfixExpression.Operator.EQUALS);
break;
case Const.IF_ACMPNE:
case Const.IF_ICMPNE:
instruction= createConditional(currentIndex, InfixExpression.Operator.NOT_EQUALS);
break;
case Const.IF_ICMPGE:
instruction= createConditional(currentIndex, InfixExpression.Operator.GREATER_EQUALS);
break;
case Const.IF_ICMPGT:
instruction= createConditional(currentIndex, InfixExpression.Operator.GREATER);
break;
case Const.IF_ICMPLE:
instruction= createConditional(currentIndex, InfixExpression.Operator.LESS_EQUALS);
break;
case Const.IF_ICMPLT:
instruction= createConditional(currentIndex, InfixExpression.Operator.LESS);
break;
case Const.LCMP:
case Const.FCMPL:
case Const.FCMPG:
case Const.DCMPL:
case Const.DCMPG:
{
MethodBinding binding= MethodBinding.lookup("javascript.Utils", "cmp", "(DDI)I");
MethodInvocation mi= new MethodInvocation(methodDecl, binding);
Expression value2= stack.pop();
mi.addArgument(stack.pop());
mi.addArgument(value2);
int gORl= 0;
if (instructionType.getName().endsWith("g"))
gORl= 1;
else if (instructionType.getName().endsWith("l"))
gORl= -1;
mi.addArgument(NumberLiteral.create(gORl));
instruction= mi;
break;
}
case Const.GOTO:
{
instruction= new Jump(currentIndex + bytes.readShort());
break;
}
case Const.GOTO_W:
{
instruction= new Jump(currentIndex + bytes.readInt());
break;
}
case Const.NEW:
{
ConstantClass c= (ConstantClass) constantPool.getConstant(bytes.readUnsignedShort());
ObjectType type= new ObjectType(c.getBytes(constantPool).replace('/', '.'));
instruction= new ClassInstanceCreation(type);
}
break;
case Const.NEWARRAY:
{
String componentSignature= BasicType.getType(bytes.readByte()).getSignature();
List<ASTNode> dimensions= new ArrayList<ASTNode>();
dimensions.add(stack.pop());
ArrayCreation ac= new ArrayCreation(methodDecl, new ObjectType("[" + componentSignature), dimensions);
instruction= ac;
break;
}
case Const.ANEWARRAY:
{
ConstantClass c= (ConstantClass) constantPool.getConstant(bytes.readUnsignedShort());
String componentSignature= c.getBytes(constantPool).replace('/', '.');
Type arrayType;
if (componentSignature.startsWith("["))
{
arrayType= new ObjectType("[" + componentSignature);
}
else
{
arrayType= new ObjectType("[L" + componentSignature + ";");
}
List<ASTNode> dimensions= new ArrayList<ASTNode>();
dimensions.add(stack.pop());
ArrayCreation ac= new ArrayCreation(methodDecl, arrayType, dimensions);
instruction= ac;
break;
}
case Const.MULTIANEWARRAY:
{
ConstantClass c= (ConstantClass) constantPool.getConstant(bytes.readUnsignedShort());
ObjectType arrayType= new ObjectType(c.getBytes(constantPool).replace('/', '.'));
int dimCount= bytes.readUnsignedByte();
opStackDelta= 1 - dimCount;
List<ASTNode> dimensions= new ArrayList<ASTNode>();
for (int i= 0; i < dimCount; i++)