mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-10-06 12:21:40 +00:00
all binary operator supported
This commit is contained in:
parent
69548745c2
commit
8cdbf7a23b
@ -111,6 +111,81 @@ public class TypedBinary implements TypedExpression {
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPNE, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
ctx.getMv().visitLabel(returnTrue);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_1);
|
||||
ctx.getMv().visitLabel(end);
|
||||
} else if (op == Operator.GT) {
|
||||
Label end = new Label();
|
||||
Label returnTrue = new Label();
|
||||
Label returnFalse = new Label();
|
||||
left.codeGen(ctx);
|
||||
right.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPLE, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
ctx.getMv().visitLabel(returnTrue);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_1);
|
||||
ctx.getMv().visitLabel(end);
|
||||
} else if (op == Operator.LT) {
|
||||
Label end = new Label();
|
||||
Label returnTrue = new Label();
|
||||
Label returnFalse = new Label();
|
||||
left.codeGen(ctx);
|
||||
right.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPGE, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
ctx.getMv().visitLabel(returnTrue);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_1);
|
||||
ctx.getMv().visitLabel(end);
|
||||
} else if (op == Operator.GE) {
|
||||
Label end = new Label();
|
||||
Label returnTrue = new Label();
|
||||
Label returnFalse = new Label();
|
||||
left.codeGen(ctx);
|
||||
right.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPLT, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
ctx.getMv().visitLabel(returnTrue);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_1);
|
||||
ctx.getMv().visitLabel(end);
|
||||
} else if (op == Operator.LE) {
|
||||
Label end = new Label();
|
||||
Label returnTrue = new Label();
|
||||
Label returnFalse = new Label();
|
||||
left.codeGen(ctx);
|
||||
right.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPGT, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
ctx.getMv().visitLabel(returnTrue);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_1);
|
||||
ctx.getMv().visitLabel(end);
|
||||
} else if (op == Operator.NE) {
|
||||
Label end = new Label();
|
||||
Label returnTrue = new Label();
|
||||
Label returnFalse = new Label();
|
||||
left.codeGen(ctx);
|
||||
right.codeGen(ctx);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.IF_ICMPEQ, returnFalse);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, returnTrue);
|
||||
|
||||
ctx.getMv().visitLabel(returnFalse);
|
||||
ctx.getMv().visitInsn(Opcodes.ICONST_0);
|
||||
ctx.getMv().visitJumpInsn(Opcodes.GOTO, end);
|
||||
|
@ -5,7 +5,7 @@ public class ClassCanBeTyped {
|
||||
|
||||
|
||||
public boolean test(boolean b, boolean c) {
|
||||
return b == c;
|
||||
return b || c;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user