Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
 def load(self, chunk):
     bc = BinaryChunk(chunk)
     proto = bc.undump()
     closure = Closure(proto, None)
     self.stack.push(closure)
     return ThreadStatus.OK
Пример #6
0
def main():
    bc = BinaryChunk('./test/hello.luac')
    bc.print_header()
    bc.check_header()
    bc.print_main_func()