Class: LLVM::IntType

Inherits:
Type
  • Object
show all
Defined in:
lib/llvm/core/type.rb

Instance Attribute Summary

Attributes inherited from Type

#kind

Attributes included from PointerIdentity

#ptr

Instance Method Summary collapse

Methods inherited from Type

#===, #aggregate?, #align, array, double, #dump, #element_type, float, from_ptr, function, integer, label, #literal_struct?, named, #null, #null_pointer, opaque_struct, #opaque_struct?, #packed_struct?, #pointer, pointer, #poison, ptr, #size, struct, #to_s, #undef, vector, void, x86_amx, x86_mmx

Methods included from PointerIdentity

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

Instance Method Details

#all_onesObject

: -> ConstantInt



257
258
259
# File 'lib/llvm/core/type.rb', line 257

def all_ones
  from_ptr(C.const_all_ones(self))
end

#from_i(int, options = {}) ⇒ Object

: ((Numeric | String), ?Hash[untyped, untyped] | bool) -> Value



279
280
281
282
283
284
285
286
287
# File 'lib/llvm/core/type.rb', line 279

def from_i(int, options = {})
  signed = get_sign_option(options)

  return parse(int.to_s, 0) if width > 64 || int.is_a?(String)

  val = from_ptr(C.const_int(self, int, signed ? 1 : 0))
  unpoisoned = val.to_i(signed) == int
  unpoisoned ? val : poison
end

#from_ptr(ptr) ⇒ Object

: (FFI::Pointer) -> ConstantInt



290
291
292
# File 'lib/llvm/core/type.rb', line 290

def from_ptr(ptr)
  ConstantInt.from_ptr(ptr)
end

#parse(str, radix = 10) ⇒ Object

parse string using const_int_of_string_and_size alternative implementation parsing with ruby: from_i(str.to_i(radix)) : (untyped, ?Integer) -> Value



309
310
311
# File 'lib/llvm/core/type.rb', line 309

def parse(str, radix = 10)
  const_int_of_string_and_size(str.to_s, radix)
end

#typeObject

: -> self



314
315
316
# File 'lib/llvm/core/type.rb', line 314

def type
  self
end

#widthObject

: -> Integer



262
263
264
# File 'lib/llvm/core/type.rb', line 262

def width
  C.get_int_type_width(self)
end