org.luaj.vm2.luajc
Class LuaJC

java.lang.Object
  extended by org.luaj.vm2.luajc.LuaJC
All Implemented Interfaces:
LoadState.LuaCompiler

public class LuaJC
extends java.lang.Object
implements LoadState.LuaCompiler

Implementation of LoadState.LuaCompiler which does direct lua-to-java-bytecode compiling.

This requires the bcel library to be on the class path to work as expected. If the library is not found, the default LuaC lua-to-lua-bytecode compiler will be used.

The compiler should be installed as part of globals initialization, and before any scripts or lua code is executed. A typical example is to install it following the globals creation, as in the following:

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

See Also:
LoadState.LuaCompiler, LuaC, JsePlatform, JmePlatform, BaseLib, LuaValue

Constructor Summary
LuaJC()
           
 
Method Summary
 java.util.Hashtable compileAll(java.io.InputStream script, java.lang.String chunkname, java.lang.String filename)
           
static LuaJC getInstance()
           
static void install()
          Install the compiler as the main compiler to use.
 LuaFunction load(java.io.InputStream stream, java.lang.String name, LuaValue env)
          Load into a Closure or LuaFunction from a Stream and initializes the environment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuaJC

public LuaJC()
Method Detail

getInstance

public static LuaJC getInstance()

install

public static final void install()
Install the compiler as the main compiler to use. Will fall back to the LuaC prototype compiler.


compileAll

public java.util.Hashtable compileAll(java.io.InputStream script,
                                      java.lang.String chunkname,
                                      java.lang.String filename)
                               throws java.io.IOException
Throws:
java.io.IOException

load

public LuaFunction load(java.io.InputStream stream,
                        java.lang.String name,
                        LuaValue env)
                 throws java.io.IOException
Description copied from interface: LoadState.LuaCompiler
Load into a Closure or LuaFunction from a Stream and initializes the environment

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


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