diff --git a/README.html b/README.html index 7004a54b..1f994fa9 100644 --- a/README.html +++ b/README.html @@ -63,11 +63,11 @@ In addition to the basic goals of luaj, version 2.0 is aimed at improving on the 1.0 vm in the following aspects.
From the main distribution directory line type:
- java -cp lib/luaj-jse-1.0.jar luac examples/lua/hello.lua - java -cp lib/luaj-jse-1.0.jar lua luac.out + java -cp lib/luaj-jse-2.0-alpha1.jar luac examples/lua/hello.lua + java -cp lib/luaj-jse-2.0-alpha1.jar lua luac.out
-The compiled output should run and produce the same result. +The compiled output "luac.out" is lua bytecode and should run and produce the same result. + +
+Luaj can compile to lua bytecode if the bcel library is on the class path. From the main distribution directory line type: + +
+ ant bcel-lib + java -cp lib/luaj-jse-2.0-alpha1.jar;lib/bcel-5.2.jar luajc -s examples/lua -d . hello.lua + java -cp lib/luaj-jse-2.0-alpha1.jar;. lua -l hello ++ +
+The output hello.class is Java bytecode, should run and produce the same result. +There is no runtime dependency on the bcel library, but the compiled classes must be in the class path. + +
+
-The following pattern is used within MIDlets: +The for MIDlets the JmePlatform is used instead:
import org.luaj.vm2.*; @@ -157,16 +175,24 @@ A simple example may be found in-You must include the library lib/luaj-jme-2.0-alpha1.jar in your midlet jar. -They can be obfuscated if desired. -
Including the compiler
++An ant script to build and run the midlet is in +
+ build-midlet.xml ++ ++You must install the wireless toolkit and define WTK_HOME for this script to work. + +
Including the lua bytecode compiler
By default, the compiler is not included so as to minimize footprint. Without a compiler, files can still be executed, but they must be compiled elsewhere beforehand. The "luac" utility is provided in the jse jar for this purpose, or a standard lua compiler can be used.-To include the Java it, include the following sometime before lua source files are loaded: +To include the lua-to-lua-bytecode compiler, include the following sometime before lua source files are loaded:
org.luaj.vm2.compiler.LuaC.install();@@ -174,6 +200,22 @@ To include the Java it, include the following sometime before lua source files aTo omit the compiler, omit this line from your startup code. +
Including the lua-to-Java-bytecode compiler
+ ++To compile from lua to Java bytecode for all lua loaded at runtime, use the LuaJC class: + +
+ org.luaj.vm2.jse.luajc.LuaJC.install(); ++ ++This will compile all lua bytecode into Java bytecode, regardless of if they are loaded as +lua source or lua binary files. + +
+The bcel library must be on the class path for this to work. +
Run a script using JSR-233 Dynamic Scripting
@@ -199,48 +241,6 @@ A working example may be found in examples/jse/ScriptEngineSample.java
-A code generator that compiles lua to java bytecode base on the -bcel library is now included. - -
-To use it at runtime, the tool "lua" has an option "-j" to compile into java bytecode. - -
- java -cp luaj-jse-2.0-alpha1.jar;lib/bcel-5.2.jar lua -j examples/lua/hello.lua -- -
-To compile lua files into Java in advance, the tool "luajc" is provided: - -
- cp examples/lua/hello.lua . - java -cp luaj-jse-2.0-alpha1.jar;lib/bcel-5.2.jar luajc hello.lua - ls -l hello.class -- -You should see a class file of 906 bytes or so. A version of the bcel -library must be in your class path for code generation to work. -The ant script contains a target for fetching bcel v 5.2: - -
- ant bcel-lib -- -
-Files compiled into java in this way can be run via Java class loading, without the bcel libraries -(generated class files must be in your class path): - -
- java -cp luaj-jse-2.0-alpha1.jar;. lua -l hello -- -The current bytecode generator produces a separate class file for each prototype, -and generated class files do not work properly with module() or setfenv(). - -
- org.luaj.vm2.lib.DebugLib.install(vm); + _G.load( new DebugLib() );-or install from lua using: +or change startup code to use: +
+ LuaValue _G = JsePlatform.debugGlobals(); ++ +To install from lua use:
require 'org.luaj.vm2.lib.DebugLib'