示例#1
0
 private String readTString(DataSource source) throws IOException {
   int size = source.getUShort();
   if (size == 0) return null;
   byte[] b = new byte[size];
   source.get(b, 0, size);
   for (int i = 0; i < b.length; i++) b[i] ^= 0xff;
   String s = new String(b);
   if (s.endsWith("\0")) s = s.substring(0, s.length() - 1);
   return s;
 }
示例#2
0
  private LuaFunction readFunction(DataSource source) throws IOException {
    LuaFunction lf = new LuaFunction();
    lf.lineNo = source.getUShort();
    lf.source = readTString(source);

    int codeSize = source.getInt();
    lf.code = new byte[codeSize];
    source.get(lf.code);
    lf.constants = readConstants(source);
    lf.localVars = readLocals(source);
    readFunctions(lf.constants, source);

    return lf;
  }