Class: LLVM::ExecutionEngine::ModuleCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/llvm/execution_engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ ModuleCollection

Returns a new instance of ModuleCollection.

Parameters:



107
108
109
# File 'lib/llvm/execution_engine.rb', line 107

def initialize(engine)
  @engine = engine
end

Instance Method Details

#add(mod) ⇒ ModuleCollection Also known as: <<

Parameters:

Returns:



113
114
115
# File 'lib/llvm/execution_engine.rb', line 113

def add(mod)
  tap { C.add_module(@engine, mod) }
end

#delete(mod) ⇒ LLVM::Module

Returns deleted module.

Parameters:

Returns:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/llvm/execution_engine.rb', line 119

def delete(mod)
  error   = FFI::MemoryPointer.new(:pointer)
  out_mod = FFI::MemoryPointer.new(:pointer)

  status = C.remove_module(@engine, mod, out_mod, error)

  if status.zero?
    LLVM::Module.from_ptr(out_mod.read_pointer)
  else
    errorp  = error.read_pointer
    message = errorp.read_string unless errorp.null?

    C.dispose_message(error)
    error.autorelease = false

    raise "Error removing module: #{message}"
  end
end