|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.luaj.vm2.Lua
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 aPrototype,
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,
LuaCompiler,
Prototype| Field Summary | |
|---|---|
static LuaC |
instance
A sharable instance of the LuaC compiler. |
static int |
MAXSTACK
|
int |
nCcalls
|
| Fields inherited from class org.luaj.vm2.Lua |
|---|
_VERSION, BITRK, iAx, LFIELDS_PER_FLUSH, LUA_MULTRET, luaP_opmodes, MASK_A, 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_CALL, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_EXTRAARG, OP_FORLOOP, OP_FORPREP, OP_GE, OP_GETTABLE, OP_GETTABUP, OP_GETUPVAL, OP_GT, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, OP_LOADKX, OP_LOADNIL, OP_LT, OP_MOD, OP_MOVE, OP_MUL, OP_NEQ, OP_NEWTABLE, OP_NOT, OP_OR, OP_POW, OP_RETURN, OP_SELF, OP_SETLIST, OP_SETTABLE, OP_SETTABUP, OP_SETUPVAL, OP_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORCALL, 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 |
| Constructor Summary | |
|---|---|
protected |
LuaC()
|
| Method Summary | |
|---|---|
protected static void |
_assert(boolean b)
|
LuaString |
cachedLuaString(LuaString s)
|
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.compil(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. |
LuaString |
newTString(LuaString s)
|
LuaString |
newTString(java.lang.String s)
|
java.lang.String |
pushfstring(java.lang.String string)
|
| Methods inherited from class org.luaj.vm2.Lua |
|---|
chunkid, GET_OPCODE, GETARG_A, GETARG_Ax, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, getBMode, getCMode, getOpMode, INDEXK, ISK, RKASK, testAMode, testTMode |
| 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
public static final int MAXSTACK
public int nCcalls
| Constructor Detail |
|---|
protected LuaC()
| Method Detail |
|---|
public static void install(Globals globals)
globals - the Globals into which this is to be installed.protected static void _assert(boolean b)
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 LuaValue load(java.io.InputStream stream,
java.lang.String chunkname,
Globals globals)
throws java.io.IOException
java.io.IOExceptionpublic LuaString newTString(java.lang.String s)
public LuaString newTString(LuaString s)
public LuaString cachedLuaString(LuaString s)
public java.lang.String pushfstring(java.lang.String string)
public LuaFunction load(Prototype prototype,
java.lang.String chunkname,
LuaValue env)
throws java.io.IOException
Globals.Loader
load in interface Globals.Loaderjava.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||