Guest User

Untitled

a guest
Jul 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. require 'ffi'
  2. require 'llvm/core'
  3. require 'llvm/core/value'
  4.  
  5.  
  6. module LLVM
  7.  
  8. module C
  9. ffi_lib ['LLVMCPlus-2.8', 'libLLVMCPlus-2.8']
  10. attach_function :LLVMGetOperatorOpcode, [:pointer], :opcode
  11. attach_function :LLVMPushBackBasicBlock, [:pointer, :pointer], :void
  12. attach_function :LLVMRemoveGlobal, [:pointer], :void
  13. attach_function :LLVMRemoveFunction, [:pointer], :void
  14. attach_function :LLVMRemoveBasicBlock, [:pointer], :void
  15. end
  16.  
  17. class Instruction
  18.  
  19. def opcode
  20. return C.LLVMGetOperatorOpcode(self)
  21. end
  22.  
  23. end
  24.  
  25. class Function::BasicBlockCollection
  26.  
  27. def <<(block)
  28. C.LLVMPushBackBasicBlock(@fun, block)
  29. end
  30.  
  31. def remove(block)
  32. C.LLVMRemoveBasicBlock(block)
  33. end
  34.  
  35. end
  36.  
  37. class Module::GlobalCollection
  38.  
  39. def remove(global)
  40. C.LLVMRemoveGlobal(global)
  41. end
  42.  
  43. end
  44.  
  45. class Module::FunctionCollection
  46.  
  47. def remove(fn)
  48. C.LLVMRemoveFunction(fn)
  49. end
  50.  
  51. end
  52.  
  53. end
Add Comment
Please, Sign In to add comment