From 55e861e503e24b81e8e836a80aabd8764e0bf16c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sun, 6 Oct 2013 15:07:58 +0400 Subject: [PATCH] Don't forget to pop the condition off the stack --- src/org/jetbrains/eval4j/interpreterLoop.kt | 2 ++ test/org/jetbrains/eval4j/test/TestData.java | 27 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/org/jetbrains/eval4j/interpreterLoop.kt b/src/org/jetbrains/eval4j/interpreterLoop.kt index 7761a345c4e..b3edf0705ec 100644 --- a/src/org/jetbrains/eval4j/interpreterLoop.kt +++ b/src/org/jetbrains/eval4j/interpreterLoop.kt @@ -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 } diff --git a/test/org/jetbrains/eval4j/test/TestData.java b/test/org/jetbrains/eval4j/test/TestData.java index aaba8cefad3..693e07a4e6d 100644 --- a/test/org/jetbrains/eval4j/test/TestData.java +++ b/test/org/jetbrains/eval4j/test/TestData.java @@ -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; + } + } }