Don't forget to pop the condition off the stack

This commit is contained in:
Andrey Breslav
2013-10-06 15:07:58 +04:00
parent c376619790
commit 55e861e503
2 changed files with 29 additions and 0 deletions
@@ -114,12 +114,14 @@ fun interpreterLoop(
RETURN -> return ValueReturned(VOID_VALUE)
IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IFNULL, IFNONNULL -> {
if (interpreter.checkUnaryCondition(frame.getStack(0)!!, insnOpcode)) {
frame.execute(currentInsn, interpreter)
goto((currentInsn as JumpInsnNode).label)
continue
}
}
IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE -> {
if (interpreter.checkBinaryCondition(frame.getStack(0)!!, frame.getStack(1)!!, insnOpcode)) {
frame.execute(currentInsn, interpreter)
goto((currentInsn as JumpInsnNode).label)
continue
}
@@ -35,4 +35,31 @@ class TestData {
static double returnDouble() {
return 2.0d;
}
static int variable() {
int i = 153;
return i;
}
static int unaryMinus() {
int i = 153;
return -i;
}
static int ifThen() {
boolean a = true;
if (a)
return 2;
return 1;
}
static int ifElse() {
boolean a = false;
if (a) {
return 2;
}
else {
return 1;
}
}
}