generator.markLabel(exit);
return;
}
}
final Type unboxedType = TypeUtils.getUnderlyingPrimitiveOrSelf(operandType);
if (operandIsBoxed) {
generator.emitUnbox(operandType);
}
switch (op) {
case Not:
case OnesComplement: {
switch (unboxedType.getKind()) {
case BOOLEAN: {
final Label ifTrue = generator.defineLabel();
final Label exit = generator.defineLabel();
generator.emitBoolean(false);
generator.emit(OpCode.IF_ICMPNE, ifTrue);
generator.emitBoolean(true);
generator.emitGoto(exit);
generator.markLabel(ifTrue);
generator.emitBoolean(false);
generator.markLabel(exit);
break;
}
case BYTE:
case SHORT:
case INT: {
generator.emitInteger(-1);
generator.emit(OpCode.IXOR);
break;
}
case LONG: {
generator.emitLong(-1L);
generator.emit(OpCode.LXOR);
break;
}
case CHAR: {
generator.emitInteger(-1);
generator.emit(OpCode.IXOR);
break;
}
default: {
throw Error.unaryOperatorNotDefined(op, unboxedType);
}
}
break;
}
case IsFalse: {
final Label ifTrue = generator.defineLabel();
final Label exit = generator.defineLabel();
generator.emitBoolean(false);
generator.emit(OpCode.IF_ICMPNE, ifTrue);
generator.emitBoolean(true);
generator.emitGoto(exit);
generator.markLabel(ifTrue);
generator.emitBoolean(false);
generator.markLabel(exit);
// Not an arithmetic operation -> no conversion
return;
}
case IsTrue: {
final Label ifFalse = generator.defineLabel();
final Label exit = generator.defineLabel();
generator.emitBoolean(false);
generator.emit(OpCode.IF_ICMPEQ, ifFalse);
generator.emitBoolean(true);
generator.emitGoto(exit);
generator.markLabel(ifFalse);
generator.emitBoolean(false);
generator.markLabel(exit);
// Not an arithmetic operation -> no conversion
return;
}
case UnaryPlus: {
generator.emit(OpCode.NOP);
break;
}
case Negate: {
switch (unboxedType.getKind()) {
case BYTE:
case SHORT:
case INT: {
generator.emit(OpCode.INEG);
break;
}
case LONG: {
generator.emit(OpCode.LNEG);
break;
}
case CHAR: {
generator.emit(OpCode.INEG);
break;
}
case FLOAT: {
generator.emit(OpCode.FNEG);
break;
}
case DOUBLE: {
generator.emit(OpCode.DNEG);
break;
}
default: {
throw Error.unaryOperatorNotDefined(op, unboxedType);
}
}
break;
}
case Increment: {
switch (unboxedType.getKind()) {
case BYTE:
case SHORT:
case INT: {
generator.emitInteger(1);
generator.emit(OpCode.IADD);
break;
}
case LONG: {
generator.emitLong(1L);
generator.emit(OpCode.LADD);
break;
}
case CHAR: {
generator.emitInteger(1);
generator.emit(OpCode.IADD);
break;
}
case FLOAT: {
generator.emitFloat(1f);
generator.emit(OpCode.FADD);
break;
}
case DOUBLE: {
generator.emitDouble(1d);
generator.emit(OpCode.DADD);
break;
}
default: {
throw Error.unaryOperatorNotDefined(op, unboxedType);
}
}
break;
}
case Decrement: {
switch (unboxedType.getKind()) {
case BYTE:
case SHORT:
case INT: {
generator.emitInteger(1);
generator.emit(OpCode.ISUB);