|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectConstants
org.luaj.vm2.compiler.LuaC
public class LuaC
Compiler for Lua.
Compiles lua source files into lua bytecode within a Prototype,
loads lua binary files directly into a Prototype,
and optionaly instantiates a LuaClosure around the result
using a user-supplied environment.
Implements the Globals.Compiler interface for loading
initialized chunks, which is an interface common to
lua bytecode compiling and java bytecode compiling.
The LuaC compiler is installed by default by both the
JsePlatform and JmePlatform classes,
so in the following example, the default LuaC compiler
will be used:
Globals globals = JsePlatform.standardGlobals();
globals.load(new StringReader("print 'hello'"), "main.lua" ).call();
To load the LuaC compiler manually, use the install method:
LuaC.install(globals);
install(Globals),
Globals.compiler,
Globals.loader,
LuaJC,
JsePlatform,
JmePlatform,
BaseLib,
LuaValue,
Prototype| Field Summary | |
|---|---|
static LuaC |
instance
A sharable instance of the LuaC compiler. |
| Constructor Summary | |
|---|---|
protected |
LuaC()
|
| Method Summary | |
|---|---|
Prototype |
compile(java.io.InputStream stream,
java.lang.String chunkname)
Compile lua source into a Prototype. |
static void |
install(Globals globals)
Install the compiler so that LoadState will first try to use it when handed bytes that are not already a compiled lua chunk. |
LuaValue |
load(java.io.InputStream stream,
java.lang.String chunkname,
Globals globals)
Deprecated. Use Globals.load(InputString, String, String) instead, or LuaC.compile(InputStream, String) and construct LuaClosure directly. |
LuaFunction |
load(Prototype prototype,
java.lang.String chunkname,
LuaValue env)
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 |
| Field Detail |
|---|
public static final LuaC instance
| Constructor Detail |
|---|
protected LuaC()
| Method Detail |
|---|
public static void install(Globals globals)
globals - the Globals into which this is to be installed.
public Prototype compile(java.io.InputStream stream,
java.lang.String chunkname)
throws java.io.IOException
compile in interface Globals.Compilerstream - InputStream representing the text source conforming to lua source syntax.chunkname - String name of the chunk to use.
java.io.IOException
public LuaFunction load(Prototype prototype,
java.lang.String chunkname,
LuaValue env)
throws java.io.IOException
Globals.Loader
load in interface Globals.Loaderjava.io.IOException
public LuaValue load(java.io.InputStream stream,
java.lang.String chunkname,
Globals globals)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||