public class LuaC extends Constants implements Globals.Compiler, Globals.Loader
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 org.luaj.vm2.lib.jme.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,
org.luaj.vm2.lib.jme.JmePlatform,
BaseLib,
LuaValue,
Prototype| 限定符和类型 | 字段和说明 |
|---|---|
static LuaC |
instance
A sharable instance of the LuaC compiler.
|
_VERSION, BITRK, iAx, LFIELDS_PER_FLUSH, LUA_FUNC_ENV, LUA_JAVA_OO, LUA_LOCAL_ENV, LUA_MULTRET, luaP_opmodes, MASK_A, MASK_Ax, MASK_B, MASK_Bx, MASK_C, MASK_NOT_A, MASK_NOT_B, MASK_NOT_Bx, MASK_NOT_C, MASK_NOT_OP, MASK_OP, MAX_OP, MAXARG_A, MAXARG_Ax, MAXARG_B, MAXARG_Bx, MAXARG_C, MAXARG_sBx, MAXINDEXRK, NUM_OPCODES, OP_ADD, OP_AND, OP_BAND, OP_BNOT, OP_BOR, OP_BXOR, OP_CALL, OP_CLOSURE, OP_CONCAT, OP_DEFER, OP_DIV, OP_EQ, OP_EXTRAARG, OP_FORLOOP, OP_FORPREP, OP_GE, OP_GETENV, OP_GETGLOBAL, OP_GETTABLE, OP_GETTABUP, OP_GETUPVAL, OP_GT, OP_IDIV, OP_IMPORT, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, OP_LOADKX, OP_LOADNIL, OP_LT, OP_MOD, OP_MODULE, OP_MOVE, OP_MUL, OP_NEQ, OP_NEWLIST, OP_NEWTABLE, OP_NOT, OP_OR, OP_POW, OP_RETURN, OP_SELF, OP_SETENV, OP_SETGLOBAL, OP_SETLIST, OP_SETTABLE, OP_SETTABUP, OP_SETUPVAL, OP_SHL, OP_SHR, OP_SUB, OP_TAILCALL, OP_TCALL, OP_TEST, OP_TESTSET, OP_TFORCALL, OP_TFOREACH, OP_TFORLOOP, OP_UNM, OP_VARARG, POS_A, POS_Ax, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_Ax, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP| 限定符 | 构造器和说明 |
|---|---|
protected |
LuaC() |
| 限定符和类型 | 方法和说明 |
|---|---|
Prototype |
compile(InputStream stream,
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(InputStream stream,
String chunkname,
Globals globals)
已过时。
Use Globals.load(InputString, String, String) instead,
or LuaC.compile(InputStream, String) and construct LuaClosure directly.
|
LuaFunction |
load(Prototype prototype,
String chunkname,
Globals globals,
LuaValue env)
Convert the prototype into a LuaFunction with the supplied environment.
|
public static final LuaC instance
public static void install(Globals globals)
globals - the Globals into which this is to be installed.public Prototype compile(InputStream stream, String chunkname) throws IOException
compile 在接口中 Globals.Compilerstream - InputStream representing the text source conforming to lua source syntax.chunkname - String name of the chunk to use.IOExceptionpublic LuaFunction load(Prototype prototype, String chunkname, Globals globals, LuaValue env) throws IOException
Globals.Loaderload 在接口中 Globals.LoaderIOExceptionpublic LuaValue load(InputStream stream, String chunkname, Globals globals) throws IOException
IOExceptionCopyright © 2020. All rights reserved.