org.luaj.vm2.compiler
Class LuaC

java.lang.Object
  extended by org.luaj.vm2.Lua
      extended by org.luaj.vm2.compiler.LuaC
All Implemented Interfaces:
LoadState.LuaCompiler

public class LuaC
extends Lua
implements LoadState.LuaCompiler

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 LoadState.LuaCompiler interface for loading initialized chunks, which is an interface common to lua bytecode compiling and java bytecode compiling.

Teh 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:

 LuaValue _G = JsePlatform.standardGlobals();
 LoadState.load( new ByteArrayInputStream("print 'hello'".getBytes()), "main.lua", _G ).call();
  

See Also:
LoadState.LuaCompiler, LuaJC, JsePlatform, JmePlatform, BaseLib, LuaValue, LoadState.LuaCompiler, Prototype

Field Summary
static LuaC instance
           
static int MAXSTACK
           
 int nCcalls
           
 
Fields inherited from class org.luaj.vm2.Lua
_VERSION, BITRK, 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_B, MAXARG_Bx, MAXARG_C, MAXARG_sBx, MAXINDEXRK, NUM_OPCODES, OP_ADD, OP_AND, OP_CALL, OP_CLOSE, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_FORLOOP, OP_FORPREP, OP_GE, OP_GETGLOBAL, OP_GETTABLE, OP_GETUPVAL, OP_GT, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, 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_SETGLOBAL, OP_SETLIST, OP_SETTABLE, OP_SETUPVAL, OP_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORLOOP, OP_UNM, OP_VARARG, POS_A, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP, VARARG_HASARG, VARARG_ISVARARG, VARARG_NEEDSARG
 
Constructor Summary
protected LuaC()
           
 
Method Summary
protected static void _assert(boolean b)
           
static Prototype compile(java.io.InputStream stream, java.lang.String name)
          Compile a prototype or load as a binary chunk
static void install()
          Install the compiler so that LoadState will first try to use it when handed bytes that are not already a compiled lua chunk.
 LuaFunction load(java.io.InputStream stream, java.lang.String name, LuaValue env)
          Load into a Closure or LuaFunction, with the supplied initial environment
 LuaFunction load(Prototype p, java.lang.String filename, LuaValue env)
           
 LuaString newTString(byte[] bytes, int offset, int len)
           
 java.lang.String pushfstring(java.lang.String string)
           
 
Methods inherited from class org.luaj.vm2.Lua
GET_OPCODE, GETARG_A, 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

instance

public static final LuaC instance

MAXSTACK

public static final int MAXSTACK
See Also:
Constant Field Values

nCcalls

public int nCcalls
Constructor Detail

LuaC

protected LuaC()
Method Detail

install

public static void install()
Install the compiler so that LoadState will first try to use it when handed bytes that are not already a compiled lua chunk.


_assert

protected static void _assert(boolean b)

load

public LuaFunction load(java.io.InputStream stream,
                        java.lang.String name,
                        LuaValue env)
                 throws java.io.IOException
Load into a Closure or LuaFunction, with the supplied initial environment

Specified by:
load in interface LoadState.LuaCompiler
Throws:
java.io.IOException

compile

public static Prototype compile(java.io.InputStream stream,
                                java.lang.String name)
                         throws java.io.IOException
Compile a prototype or load as a binary chunk

Throws:
java.io.IOException

newTString

public LuaString newTString(byte[] bytes,
                            int offset,
                            int len)

pushfstring

public java.lang.String pushfstring(java.lang.String string)

load

public LuaFunction load(Prototype p,
                        java.lang.String filename,
                        LuaValue env)


Copyright © 2007-2008 Luaj.org. All Rights Reserved.