Class: LLVM::Constant
Direct Known Subclasses
ConstantArray, ConstantExpr, ConstantInt, ConstantNull, ConstantReal, ConstantStruct, ConstantVector, GlobalValue
Class Method Summary collapse
-
.null(type) ⇒ Object
Creates a null constant of Type.
-
.null_ptr(type) ⇒ Object
Creates a null pointer constant of Type.
- .poison(type) ⇒ Object
-
.undef(type) ⇒ Object
Creates a undefined constant of Type.
Instance Method Summary collapse
-
#bitcast_to(type) ⇒ Object
(also: #bit_cast)
Bitcast this constant to Type.
-
#gep(*indices) ⇒ Object
Returns the element pointer at the given indices of the constant.
-
#ptr_to_int(type) ⇒ Object
Conversion to integer.
Methods inherited from User
Methods inherited from Value
#add_attribute, #allocated_type, #allocated_type?, #constant?, #dump, from_ptr, from_ptr_kind, #gep_source_element_type, #gep_source_element_type?, #global_parent, #kind, #name, #name=, #null?, #poison?, #remove_attribute, to_ptr, #to_s, type, #type, #undef?
Methods included from PointerIdentity
Class Method Details
.null(type) ⇒ Object
Creates a null constant of Type.
310 311 312 |
# File 'lib/llvm/core/value.rb', line 310 def self.null(type) from_ptr(C.const_null(type)) end |
.null_ptr(type) ⇒ Object
Creates a null pointer constant of Type.
324 325 326 |
# File 'lib/llvm/core/value.rb', line 324 def self.null_ptr(type) from_ptr(C.const_pointer_null(type)) end |
.poison(type) ⇒ Object
319 320 321 |
# File 'lib/llvm/core/value.rb', line 319 def self.poison(type) from_ptr(C.get_poison(type)) end |
Instance Method Details
#bitcast_to(type) ⇒ Object Also known as: bit_cast
Bitcast this constant to Type.
329 330 331 |
# File 'lib/llvm/core/value.rb', line 329 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
338 339 340 341 342 343 344 345 |
# File 'lib/llvm/core/value.rb', line 338 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.
348 349 350 |
# File 'lib/llvm/core/value.rb', line 348 def ptr_to_int(type) ConstantInt.from_ptr(C.const_ptr_to_int(self, type)) end |