def main(): bc = BinaryChunk('./test/sum.luac') bc.print_header() bc.check_header() bc.print_main_func() proto = bc.get_main_func() lua_main(proto)
def main(): bc = BinaryChunk(sys.argv[1]) bc.print_header() bc.check_header() bc.print_main_func() proto = bc.get_main_func() lua_main(proto)
def load(self, chunk): bc = BinaryChunk(chunk) proto = bc.undump() closure = Closure(proto, None, 0) self.stack.push(closure) if len(proto.upvalues) > 0: env = self.registry.get(Consts.LUA_RIDX_GLOBALS) closure.upvals[0] = env print('env: ', end='') env.dump() return ThreadStatus.OK
def load(self, chunk_path): with open(chunk_path, 'rb') as f: chunk = f.read() if BinaryChunk.is_binary_chunk(chunk): bc = BinaryChunk(chunk) proto = bc.undump() else: with open(chunk_path, 'r') as f1: chunk = f1.read() proto = LuaCompiler.compile(chunk, chunk_path) closure = Closure(proto, None, 0) self.stack.push(closure) if len(proto.upvalues) > 0: env = self.registry.get(Consts.LUA_RIDX_GLOBALS) closure.upvals[0] = env print('env: ', end='') env.dump() return ThreadStatus.OK
def load(self, chunk): bc = BinaryChunk(chunk) proto = bc.undump() closure = Closure(proto, None) self.stack.push(closure) return ThreadStatus.OK
def main(): bc = BinaryChunk('./test/hello.luac') bc.print_header() bc.check_header() bc.print_main_func()