org.luaj.vm2.luajc
Class LuaJC
java.lang.Object
org.luaj.vm2.luajc.LuaJC
- All Implemented Interfaces:
- Globals.Loader
public class LuaJC
- extends java.lang.Object
- implements Globals.Loader
Implementation of Globals.Compiler
which does direct
lua-to-java-bytecode compiling.
By default, when using JsePlatform
or
JmePlatform
to construct globals, the plain compiler LuaC
is installed and lua code
will only be compiled into lua bytecode and execute as LuaClosure
.
To override the default compiling behavior with LuaJC
lua-to-java bytecode compiler, install it before undumping code,
for example:
LuaValue globals = JsePlatform.standardGlobals();
LuaJC.install(globals);
LuaValue chunk = globals.load( "print('hello, world'), "main.lua");
System.out.println(chunk.isclosure()); // Will be false when LuaJC is working.
chunk.call();
This requires the bcel library to be on the class path to work as expected.
If the library is not found, the default LuaC
lua-to-lua-bytecode
compiler will be used.
- See Also:
Globals.compiler
,
install(Globals)
,
LuaC
,
LuaValue
Constructor Summary |
protected |
LuaJC()
|
Method Summary |
java.util.Hashtable |
compileAll(java.io.InputStream script,
java.lang.String chunkname,
java.lang.String filename,
Globals globals,
boolean genmain)
|
java.util.Hashtable |
compileAll(java.io.Reader script,
java.lang.String chunkname,
java.lang.String filename,
Globals globals,
boolean genmain)
|
static void |
install(Globals G)
Install the compiler as the main Globals.Loader to use in a set of globals. |
LuaFunction |
load(Prototype p,
java.lang.String name,
LuaValue globals)
Convert the prototype into a LuaFunction with the supplied environment. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
instance
public static final LuaJC instance
LuaJC
protected LuaJC()
install
public static final void install(Globals G)
- Install the compiler as the main Globals.Loader to use in a set of globals.
Will fall back to the LuaC prototype compiler.
compileAll
public java.util.Hashtable compileAll(java.io.InputStream script,
java.lang.String chunkname,
java.lang.String filename,
Globals globals,
boolean genmain)
throws java.io.IOException
- Throws:
java.io.IOException
compileAll
public java.util.Hashtable compileAll(java.io.Reader script,
java.lang.String chunkname,
java.lang.String filename,
Globals globals,
boolean genmain)
throws java.io.IOException
- Throws:
java.io.IOException
load
public LuaFunction load(Prototype p,
java.lang.String name,
LuaValue globals)
throws java.io.IOException
- Description copied from interface:
Globals.Loader
- Convert the prototype into a LuaFunction with the supplied environment.
- Specified by:
load
in interface Globals.Loader
- Throws:
java.io.IOException
Copyright © 2007-2015 Luaj.org. All Rights Reserved.