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; }
@Override protected LuaChunk _read(DataSource source) throws IOException { int magic = source.getInt(); if (magic != 0x1B4C7561) throw new IOException("Invalid LUA file"); int version = source.getUByte(); if (version != 0x31) throw new IOException("Invalid LUA file version: " + Integer.toHexString(version)); if (source.getUByte() != 4) throw new IOException("Invalid LUA file, float length isn't 4..."); source.skip(4); // Todo: wtf are these? LuaFunction lf = readFunction(source); // Todo: decompile? haha, if it'll be anything like the java decompiler I wrote then f**k that return new LuaChunk(source.container, source.getName(), lf); }