Class: LLVM::Constant

Inherits:
User show all
Defined in:
lib/llvm/core/value.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from User

#operands

Methods inherited from Value

#add_attribute, #constant?, #dump, from_ptr, #name, #name=, #null?, to_ptr, #type, type, #undefined?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.null(type) ⇒ Object

Creates a null constant of Type.



203
204
205
# File 'lib/llvm/core/value.rb', line 203

def self.null(type)
  from_ptr(C.const_null(type))
end

.null_ptr(type) ⇒ Object

Creates a null pointer constant of Type.



213
214
215
# File 'lib/llvm/core/value.rb', line 213

def self.null_ptr(type)
  from_ptr(C.const_pointer_null(type))
end

.undef(type) ⇒ Object

Creates a undefined constant of Type.



208
209
210
# File 'lib/llvm/core/value.rb', line 208

def self.undef(type)
  from_ptr(C.get_undef(type))
end

Instance Method Details

#bitcast_to(type) ⇒ Object Also known as: bit_cast

Bitcast this constant to Type.



218
219
220
# File 'lib/llvm/core/value.rb', line 218

def bitcast_to(type)
  ConstantExpr.from_ptr(C.const_bit_cast(self, type))
end

#gep(*indices) ⇒ Object

Returns the element pointer at the given indices of the constant. For more information on gep go to: llvm.org/docs/GetElementPtr.html



227
228
229
230
231
232
233
234
# File 'lib/llvm/core/value.rb', line 227

def gep(*indices)
  indices = Array(indices)
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr|
    indices_ptr.write_array_of_pointer(indices)
    return ConstantExpr.from_ptr(
      C.const_gep(self, indices_ptr, indices.size))
  end
end

#ptr_to_int(type) ⇒ Object

Conversion to integer.



237
238
239
# File 'lib/llvm/core/value.rb', line 237

def ptr_to_int(type)
  ConstantInt.from_ptr(C.const_ptr_to_int(self, type))
end