Package com.prineside.luaj.compiler
Class LuaC
java.lang.Object
com.prineside.luaj.Lua
com.prineside.luaj.compiler.Constants
com.prineside.luaj.compiler.LuaC
- All Implemented Interfaces:
Globals.Compiler
,Globals.Loader
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 org.luaj.vm2.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
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);
-
Field Summary
FieldsFields inherited from class com.prineside.luaj.Lua
_LUAJ_VERSION, _VERSION, BITRK, iAx, LFIELDS_PER_FLUSH, 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_CALL_STACK, 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, OPCODE_NAMES, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompile
(InputStream stream, String chunkname) Compile lua source into a Prototype.static void
Install the compiler so that LoadState will first try to use it when handed bytes that are not already a compiled lua chunk.Convert the prototype into a LuaFunction with the supplied environment.load
(InputStream stream, String chunkname, Globals globals) Deprecated.Use Globals.load(InputString, String, String) instead, or LuaC.compile(InputStream, String) and construct LuaClosure directly.
-
Field Details
-
instance
A sharable instance of the LuaC compiler.
-
-
Constructor Details
-
LuaC
public LuaC()
-
-
Method Details
-
install
Install the compiler so that LoadState will first try to use it when handed bytes that are not already a compiled lua chunk.- Parameters:
globals
- the Globals into which this is to be installed.
-
compile
Compile lua source into a Prototype.- Specified by:
compile
in interfaceGlobals.Compiler
- Parameters:
stream
- InputStream representing the text source conforming to lua source syntax.chunkname
- String name of the chunk to use.- Returns:
- Prototype representing the lua chunk for this source.
- Throws:
IOException
-
load
Description copied from interface:Globals.Loader
Convert the prototype into a LuaFunction with the supplied environment.- Specified by:
load
in interfaceGlobals.Loader
- Throws:
IOException
-
load
Deprecated.Use Globals.load(InputString, String, String) instead, or LuaC.compile(InputStream, String) and construct LuaClosure directly.- Throws:
IOException
-