Package com.prineside.luaj.compiler
Class DumpState
java.lang.Object
com.prineside.luaj.compiler.DumpState
Class to dump a 
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(com.prineside.luaj.FPrototype, 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();
  - 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanset true to allow integer compilationstatic final intdefault number formatstatic final intformat corresponding to non-number-patched lua, all numbers are floats or doublesstatic final intformat corresponding to non-number-patched lua, all numbers are intsstatic final intformat corresponding to number-patched lua, all numbers are 32-bit (4 byte) ints - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic intdump(FPrototype f, OutputStream w, boolean strip) static intdump(FPrototype f, OutputStream w, boolean stripDebug, int numberFormat, boolean littleendian)  
- 
Field Details
- 
ALLOW_INTEGER_CASTING
public static boolean ALLOW_INTEGER_CASTINGset true to allow integer compilation - 
NUMBER_FORMAT_FLOATS_OR_DOUBLES
public static final int NUMBER_FORMAT_FLOATS_OR_DOUBLESformat corresponding to non-number-patched lua, all numbers are floats or doubles- See Also:
 
 - 
NUMBER_FORMAT_INTS_ONLY
public static final int NUMBER_FORMAT_INTS_ONLYformat corresponding to non-number-patched lua, all numbers are ints- See Also:
 
 - 
NUMBER_FORMAT_NUM_PATCH_INT32
public static final int NUMBER_FORMAT_NUM_PATCH_INT32format corresponding to number-patched lua, all numbers are 32-bit (4 byte) ints- See Also:
 
 - 
NUMBER_FORMAT_DEFAULT
public static final int NUMBER_FORMAT_DEFAULTdefault number format- See Also:
 
 
 - 
 - 
Constructor Details
- 
DumpState
 
 - 
 - 
Method Details
- 
dump
- Throws:
 IOException
 - 
dump
public static int dump(FPrototype f, OutputStream w, boolean stripDebug, int numberFormat, boolean littleendian) throws IOException - Parameters:
 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 endian- Returns:
 - 0 if dump succeeds
 - Throws:
 IOExceptionIllegalArgumentException- if the number format it not supported
 
 -