Expand compiler interface, add bcel-based bytecode generator.

This commit is contained in:
James Roseborough
2009-10-29 22:20:56 +00:00
parent 0b6cd02bc6
commit f729c1b626
13 changed files with 1224 additions and 41 deletions

View File

@@ -57,7 +57,6 @@ public class AllTests {
// luajc regression tests
TestSuite luajc = new TestSuite("Luajc Tests");
luajc.addTestSuite(FragmentsTest.class);
luajc.addTest( new TestSuite( LuaJCCompatibilityTest.class, "LuaJC Compatiblity Tests" ) );
suite.addTest(luajc);
return suite;

View File

@@ -24,6 +24,8 @@ package org.luaj.vm2;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.luaj.vm2.luajc.JavaBytecodeCompiler;
/**
* Compatibility tests for the Luaj VM
*
@@ -59,6 +61,8 @@ public class CompatibiltyTest {
TestSuite suite = new TestSuite("Compatibility Tests");
suite.addTest( new TestSuite( JseCompatibilityTest.class, "JSE Tests" ) );
suite.addTest( new TestSuite( JmeCompatibilityTest.class, "JME Tests" ) );
suite.addTest( new TestSuite( JseBytecodeTest.class, "JSE Bytecode Tests" ) );
suite.addTest( new TestSuite( LuaJCCompatibilityTest.class, "LuaJC Gen Tests" ) );
return suite;
}
@@ -76,8 +80,18 @@ public class CompatibiltyTest {
super(ScriptDrivenTest.PlatformType.JSE);
}
protected void setUp() throws Exception {
System.setProperty("JME", "false");
super.setUp();
System.setProperty("JME", "false");
}
}
public static class JseBytecodeTest extends CompatibiltyTestSuite {
public JseBytecodeTest() {
super(ScriptDrivenTest.PlatformType.JSE);
}
protected void setUp() throws Exception {
super.setUp();
System.setProperty("JME", "false");
JavaBytecodeCompiler.install();
}
}
public static class LuaJCCompatibilityTest extends CompatibiltyTestSuite {
@@ -85,8 +99,8 @@ public class CompatibiltyTest {
super(ScriptDrivenTest.PlatformType.LUAJIT);
}
protected void setUp() throws Exception {
System.setProperty("JME", "false");
super.setUp();
System.setProperty("JME", "false");
}
// skipping - not supported yet
public void testDebugLib() {}

View File

@@ -31,9 +31,7 @@ import java.io.PrintStream;
import junit.framework.TestCase;
import org.luaj.vm2.compiler.LuaC;
import org.luaj.vm2.lib.BaseLib;
import org.luaj.vm2.lib.CoroutineLib;
import org.luaj.vm2.lib.DebugLib;
import org.luaj.vm2.luajc.LuaJCompiler;
@@ -58,7 +56,6 @@ public class ScriptDrivenTest extends TestCase {
try {
// create globals
LuaC.install();
LuaTable _G = null;
switch ( platform ) {
default:
@@ -120,8 +117,7 @@ public class ScriptDrivenTest extends TestCase {
}
default:
script = new FileInputStream(file);
Prototype p = LoadState.undump(script, "stdin");
return new LuaClosure(p,_G);
return LoadState.load(script, "stdin", _G);
}
} catch ( Exception e ) {
e.printStackTrace();