from.commonimportLLVMObjectfrom.commonimportc_object_pfrom.commonimportget_libraryfrom.importenumerationsfrom.coreimportMemoryBufferfrom.coreimportModulefrom.coreimportOpCodefromctypesimportPOINTERfromctypesimportbyreffromctypesimportc_char_pfromctypesimportcast__all__=['parse_bitcode']lib=get_library()defparse_bitcode(mem_buffer):"""Input is .core.MemoryBuffer"""module=c_object_p()result=lib.LLVMParseBitcode2(mem_buffer,byref(module))ifresult:raiseRuntimeError('LLVM Error')m=Module(module)m.take_ownership(mem_buffer)returnmdefregister_library(library):library.LLVMParseBitcode2.argtypes=[MemoryBuffer,POINTER(c_object_p)]library.LLVMParseBitcode2.restype=boolregister_library(lib)