public class DumpState extends Object
Prototype into an output stream, as part of compiling.
Generally, this class is not used directly, but rather indirectly via a command
line interface tool such as luac.
A lua binary file is created via dump(org.luaj.vm2.Prototype, java.io.OutputStream, boolean):
Globals globals = JsePlatform.standardGlobals();
Prototype p = globals.compilePrototype(new StringReader("print('hello, world')"), "main.lua");
ByteArrayOutputStream o = new ByteArrayOutputStream();
DumpState.dump(p, o, false);
byte[] lua_binary_file_bytes = o.toByteArray();
The LoadState may be used directly to undump these bytes:
Prototypep = LoadState.instance.undump(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua");
LuaClosure c = new LuaClosure(p, globals);
c.call();
More commonly, the Globals.undumper may be used to undump them:
Prototype p = globals.loadPrototype(new ByteArrayInputStream(lua_binary_file_bytes), "main.lua", "b");
LuaClosure c = new LuaClosure(p, globals);
c.call();
| 限定符和类型 | 字段和说明 |
|---|---|
static boolean |
ALLOW_INTEGER_CASTING
set true to allow integer compilation
|
static int |
NUMBER_FORMAT_DEFAULT
default number format
|
static int |
NUMBER_FORMAT_FLOATS_OR_DOUBLES
format corresponding to non-number-patched lua, all numbers are floats or doubles
|
static int |
NUMBER_FORMAT_INTS_ONLY
format corresponding to non-number-patched lua, all numbers are ints
|
static int |
NUMBER_FORMAT_NUM_PATCH_INT32
format corresponding to number-patched lua, all numbers are 32-bit (4 byte) ints
|
| 构造器和说明 |
|---|
DumpState(OutputStream w,
boolean strip) |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
dump(Prototype f,
OutputStream w,
boolean strip) |
static int |
dump(Prototype f,
OutputStream w,
boolean stripDebug,
int numberFormat,
boolean littleendian) |
public static boolean ALLOW_INTEGER_CASTING
public static final int NUMBER_FORMAT_FLOATS_OR_DOUBLES
public static final int NUMBER_FORMAT_INTS_ONLY
public static final int NUMBER_FORMAT_NUM_PATCH_INT32
public static final int NUMBER_FORMAT_DEFAULT
public DumpState(OutputStream w, boolean strip)
public static int dump(Prototype f, OutputStream w, boolean strip) throws IOException
IOExceptionpublic static int dump(Prototype f, OutputStream w, boolean stripDebug, int numberFormat, boolean littleendian) throws IOException
f - the function to dumpw - the output stream to dump tostripDebug - true to strip debugging info, false otherwisenumberFormat - one of NUMBER_FORMAT_FLOATS_OR_DOUBLES, NUMBER_FORMAT_INTS_ONLY, NUMBER_FORMAT_NUM_PATCH_INT32littleendian - true to use little endian for numbers, false for big endianIOExceptionIllegalArgumentException - if the number format it not supportedCopyright © 2020. All rights reserved.