From f44de5cf17e0c29d6cf40dcfef32bd1f7353fcb6 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Thu, 3 Jul 2008 14:51:27 +0000 Subject: [PATCH] Fix jit repeat-until --- src/script/org/luaj/jit/LuaJit.java | 94 +++++++------------ .../java/org/luaj/jit/LuaJitBasicTest.java | 29 +++--- 2 files changed, 53 insertions(+), 70 deletions(-) diff --git a/src/script/org/luaj/jit/LuaJit.java b/src/script/org/luaj/jit/LuaJit.java index 0c6c2b6d..29994a15 100644 --- a/src/script/org/luaj/jit/LuaJit.java +++ b/src/script/org/luaj/jit/LuaJit.java @@ -131,28 +131,48 @@ public class LuaJit extends Lua implements LuaCompiler { return (s==null? t: t==null? s: s+t); } + private static void assertTrue(boolean b) { + if ( ! b ) + throw new RuntimeException("assert failed"); + } + private static String[] extractControlFlow( int[] code ) { int n = code.length; String[] s = new String[n]; - int jmp; + int jmp,i2; for ( int pc=0; pc0 do\n"+ " print( i )\n"+ " i = i-1\n"+ @@ -68,7 +73,7 @@ public class LuaJitBasicTest extends TestCase { public void testRepeatUntilBreak() throws IOException { stringTest( - "local i=7" + + "local i=7\n" + "repeat\n"+ " print(i)\n"+ " break\n"+ @@ -77,7 +82,7 @@ public class LuaJitBasicTest extends TestCase { public void testWhileDoBreak() throws IOException { stringTest( - "local i=4" + + "local i=4\n" + "while i>0 do\n"+ " print( i )\n"+ " break\n"+ @@ -105,14 +110,14 @@ public class LuaJitBasicTest extends TestCase { public void testIfThenElseifElseEnd() throws IOException { stringTest( - "if a then\n" + - " print(1)\n" + - "elseif b then \n" + - " print(2)\n" + - "else\n" + - " print(3)\n" + - "end\n" + - "print(4)\n" ); + "if a then\n" + + " print(1)\n" + + "elseif b then \n" + + " print(2)\n" + + "else\n" + + " print(3)\n" + + "end\n" + + "print(4)\n" ); } private void stringTest(String program) throws IOException {