# Print (Luaj API)
Date: 2015-04-29

## org.luaj.vm2
Class Print

    java.lang.Object
      org.luaj.vm2.Lua
          org.luaj.vm2.Print

    public class Print

extends Lua

Debug helper class to pretty-print lua bytecodes.

See Also:
  `Prototype`, `LuaClosure`

Field Summary
`static java.lang.String[]` `OPNAMES` String names for each lua opcode value.
`static java.io.PrintStream` `ps`

Fields inherited from class org.luaj.vm2.Lua

`_VERSION, BITRK, iABC, iABx, iAsBx, iAx, 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_Ax, MAXARG_B, MAXARG_Bx, MAXARG_C, MAXARG_sBx, MAXINDEXRK, NO_REG, NUM_OPCODES, OP_ADD, OP_AND, OP_CALL, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_EXTRAARG, OP_FORLOOP, OP_FORPREP, OP_GE, OP_GETTABLE, OP_GETTABUP, OP_GETUPVAL, OP_GT, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, OP_LOADKX, 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_SETLIST, OP_SETTABLE, OP_SETTABUP, OP_SETUPVAL, OP_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORCALL, OP_TFORLOOP, OP_UNM, OP_VARARG, OpArgK, OpArgN, OpArgR, OpArgU, POS_A, POS_Ax, POS_B, POS_Bx, POS_C, POS_OP, SIZE_A, SIZE_Ax, SIZE_B, SIZE_Bx, SIZE_C, SIZE_OP`

Constructor Summary
`Print()`

Method Summary
`static void` `print(Prototype prototype)` Pretty-prints contents of a Prototype.
`static void` `printCode(Prototype f)` Print the code in a prototype
`static void` `printFunction(Prototype prototype, boolean full)` Pretty-prints contents of a Prototype in short or long form.
`static void` `printOpCode(java.io.PrintStream ps, Prototype f, int pc)` Print an opcode in a prototype
`static void` `printOpCode(Prototype f, int pc)` Print an opcode in a prototype
`static void` `printStack(LuaValue[] stack, int top, Varargs varargs)`
`static void` `printState(LuaClosure cl, int pc, LuaValue[] stack, int top, Varargs varargs)` Print the state of a `LuaClosure` that is being executed

Methods inherited from class org.luaj.vm2.Lua
`chunkid, GET_OPCODE, GETARG_A, GETARG_Ax, 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

### ps

    public static java.io.PrintStream ps

### OPNAMES

    public static final java.lang.String[] OPNAMES

  String names for each lua opcode value.

Constructor Detail

### Print

    public Print()

Method Detail

### printCode

    public static void printCode(Prototype f)

  Print the code in a prototype

  Parameters:
    `f` - the `Prototype`

### printOpCode

    public static void printOpCode(Prototype f,
                                   int pc)

  Print an opcode in a prototype

  Parameters:
    `f` - the `Prototype`
    `pc` - the program counter to look up and print

### printOpCode

    public static void printOpCode(java.io.PrintStream ps,
                                   Prototype f,
                                   int pc)

  Print an opcode in a prototype

  Parameters:
    `ps` - the `PrintStream` to print to
    `f` - the `Prototype`
    `pc` - the program counter to look up and print

### print

    public static void print(Prototype prototype)

  Pretty-prints contents of a Prototype.

  Parameters:
    `prototype` - Prototype to print.

### printFunction

    public static void printFunction(Prototype prototype,
                                     boolean full)

  Pretty-prints contents of a Prototype in short or long form.

  Parameters:
    `prototype` - Prototype to print.
    `full` - true to print all fields, false to print short form.

### printState

    public static void printState(LuaClosure cl,
                                  int pc,
                                  LuaValue[] stack,
                                  int top,
                                  Varargs varargs)

  Print the state of a `LuaClosure` that is being executed

  Parameters:
    `cl` - the `LuaClosure`
    `pc` - the program counter
    `stack` - the stack of `LuaValue`
    `top` - the top of the stack
    `varargs` - any `Varargs` value that may apply

### printStack

    public static void printStack(LuaValue[] stack,
                                  int top,
                                  Varargs varargs)

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