Add version "Luaj ${version}" into _VERSION field at build time.
This commit is contained in:
@@ -92,7 +92,8 @@ public class BaseLib extends LFunction {
|
||||
globals.put( NAMES[i], new BaseLib(i) );
|
||||
next = new BaseLib(NEXT);
|
||||
inext = new BaseLib(INEXT);
|
||||
globals.put("_VERSION", new LString("Lua 5.1"));
|
||||
globals.put("_G", globals);
|
||||
globals.put("_VERSION", new LString(Lua._VERSION));
|
||||
}
|
||||
|
||||
private int id;
|
||||
|
||||
@@ -27,6 +27,8 @@ package org.luaj.vm;
|
||||
*
|
||||
*/
|
||||
public class Lua {
|
||||
/** version is supplied by ant build task */
|
||||
public static final String _VERSION = "Luaj 0.0";
|
||||
|
||||
/** use return values from previous op */
|
||||
public static final int LUA_MULTRET = -1;
|
||||
|
||||
@@ -112,7 +112,6 @@ public class LuaState extends Lua {
|
||||
*/
|
||||
protected LuaState() {
|
||||
_G = new LTable();
|
||||
_G.put("_G", _G);
|
||||
mainState = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaCompiler;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.StandardJavaFileManager;
|
||||
@@ -19,16 +17,24 @@ import javax.tools.JavaCompiler.CompilationTask;
|
||||
|
||||
import org.luaj.compiler.LuaC;
|
||||
import org.luaj.debug.Print;
|
||||
import org.luaj.jit.JitPrototype.JitClosure;
|
||||
import org.luaj.platform.J2sePlatform;
|
||||
import org.luaj.vm.LClosure;
|
||||
import org.luaj.vm.LPrototype;
|
||||
import org.luaj.vm.LValue;
|
||||
import org.luaj.vm.LoadState;
|
||||
import org.luaj.vm.Lua;
|
||||
import org.luaj.vm.LuaState;
|
||||
import org.luaj.vm.Platform;
|
||||
import org.luaj.vm.LoadState.LuaCompiler;
|
||||
|
||||
public class LuaJit extends Lua {
|
||||
public class LuaJit extends Lua implements LuaCompiler {
|
||||
|
||||
private static LuaC luac;
|
||||
|
||||
public static void install() {
|
||||
luac = new LuaC();
|
||||
LoadState.compiler = new LuaJit();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
@@ -54,12 +60,16 @@ public class LuaJit extends Lua {
|
||||
}
|
||||
}
|
||||
|
||||
private static int counter = 0;
|
||||
private static int filenum = 0;
|
||||
|
||||
private static synchronized String filename() {
|
||||
return "LuaJit"+(counter++);
|
||||
return "LuaJit"+(filenum++);
|
||||
}
|
||||
|
||||
|
||||
public LPrototype compile(int firstByte, InputStream stream, String name) throws IOException {
|
||||
return jitCompile( luac.compile(firstByte, stream, name) );
|
||||
}
|
||||
|
||||
public static LPrototype jitCompile( LPrototype p ) {
|
||||
try {
|
||||
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.luaj.jit;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.luaj.jit.LuaJit;
|
||||
import org.luaj.vm.LPrototype;
|
||||
import org.luaj.vm.LuaJTest;
|
||||
import org.luaj.vm.LuaState;
|
||||
Reference in New Issue
Block a user