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:


101
102
103
# File 'lib/llvm/execution_engine.rb', line 101

def initialize(engine)
  @engine = engine
end

Instance Method Details

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

Parameters:

Returns:


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

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

#delete(mod) ⇒ LLVM::Module

Returns deleted module.

Parameters:

Returns:


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/llvm/execution_engine.rb', line 113

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