@Override public void visit(NegateInstruction insn) { switch (insn.getOperandType()) { case INT: assign( castToInteger( Expr.unary(UnaryOperation.NEGATE, Expr.var(insn.getOperand().getIndex()))), insn.getReceiver()); break; case LONG: assign( Expr.unary(UnaryOperation.NEGATE_LONG, Expr.var(insn.getOperand().getIndex())), insn.getReceiver()); break; default: assign( Expr.unary(UnaryOperation.NEGATE, Expr.var(insn.getOperand().getIndex())), insn.getReceiver()); break; } }
@Override public void visit(CastIntegerInstruction insn) { Expr value = Expr.var(insn.getValue().getIndex()); switch (insn.getDirection()) { case FROM_INTEGER: switch (insn.getTargetType()) { case BYTE: value = Expr.unary(UnaryOperation.INT_TO_BYTE, value); break; case SHORT: value = Expr.unary(UnaryOperation.INT_TO_SHORT, value); break; case CHARACTER: value = Expr.unary(UnaryOperation.INT_TO_CHAR, value); break; } break; case TO_INTEGER: break; } assign(value, insn.getReceiver()); }
@Override public void visit(NullCheckInstruction insn) { assign( Expr.unary(UnaryOperation.NULL_CHECK, Expr.var(insn.getValue().getIndex())), insn.getReceiver()); }
private Expr castFromLong(Expr value) { return Expr.unary(UnaryOperation.LONG_TO_NUM, value); }
private Expr castIntToLong(Expr value) { return Expr.unary(UnaryOperation.INT_TO_LONG, value); }
private Expr castLongToInt(Expr value) { return Expr.unary(UnaryOperation.LONG_TO_INT, value); }
@Override public void visit(ArrayLengthInstruction insn) { assign( Expr.unary(UnaryOperation.LENGTH, Expr.var(insn.getArray().getIndex())), insn.getReceiver()); }