Module: FFI::LLVMJIT::Library

Includes:
FFI::Library
Defined in:
lib/ffi/llvm_jit.rb,
ext/ffi_llvm_jit/ffi_llvm_jit.c

Overview

Extension to FFI::Library to support JIT compilation using LLVM

Instance Method Summary collapse

Instance Method Details

#attach_function(name, func, args, returns = nil, options = nil) ⇒ Object

Note:

Return type doesn’t match the original method, but it’s usually not used



101
102
103
104
105
106
# File 'lib/ffi/llvm_jit.rb', line 101

def attach_function(name, func, args, returns = nil, options = nil)
  mname, cname, arg_types, ret_type, options = convert_params(name, func, args, returns, options)
  return if attached_llvm_jit_function?(mname, cname, arg_types, ret_type, options)

  super(mname, cname, arg_types, ret_type, options)
end

#attach_llvm_jit_function(name, func, args, returns = nil, options = nil) ⇒ Object

Same as attach_function, but raises an exception if cannot create JIT function instead of falling back to the regular FFI function

Raises:

  • (NotImplementedError)


110
111
112
113
114
115
# File 'lib/ffi/llvm_jit.rb', line 110

def attach_llvm_jit_function(name, func, args, returns = nil, options = nil)
  mname, cname, arg_types, ret_type, options = convert_params(name, func, args, returns, options)
  return if attached_llvm_jit_function?(mname, cname, arg_types, ret_type, options)

  raise NotImplementedError, "Cannot create JIT function #{name}"
end