Class: LLDB::InstructionList

Inherits:
Object
  • Object
show all
Includes:
Enumerable, NativeLifecycle
Defined in:
lib/lldb/instruction_list.rb

Instance Method Summary collapse

Methods included from NativeLifecycle

#close, #closed?, #context, #context!, #ensure_open!, #initialize_native_object

Constructor Details

#initialize(ptr, target: nil, context: nil) ⇒ InstructionList

Returns a new instance of InstructionList.

RBS:

  • target: Target?

  • context: Context?

  • return: void



13
14
15
16
17
18
19
20
# File 'lib/lldb/instruction_list.rb', line 13

def initialize(ptr, target: nil, context: nil)
  @target = target
  initialize_native_object(
    ptr,
    release: ->(released) { FFIBindings.lldb_instruction_list_destroy(released) },
    context: context || target&.context
  )
end

Instance Method Details

#[](index) ⇒ Object

RBS:

  • index: Integer

  • return: Instruction?



38
39
40
41
42
43
44
45
# File 'lib/lldb/instruction_list.rb', line 38

def [](index)
  return nil unless valid?

  ptr = FFIBindings.lldb_instruction_list_get_instruction_at_index(@ptr, index)
  return nil if ptr.nil? || ptr.null?

  Instruction.new(ptr, target: @target, context: context)
end

#each(&block) ⇒ Object

RBS:

  • &block: (Instruction) -> void

  • return: Enumerator[Instruction, void] | void



49
50
51
52
53
54
55
56
# File 'lib/lldb/instruction_list.rb', line 49

def each(&block)
  return enum_for(:each) unless block_given?

  (0...size).each do |index|
    instruction = self[index]
    block.call(instruction) if instruction
  end
end

#sizeObject Also known as: length

RBS:

  • return: Integer



28
29
30
31
32
# File 'lib/lldb/instruction_list.rb', line 28

def size
  return 0 unless valid?

  FFIBindings.lldb_instruction_list_get_size(@ptr)
end

#to_aObject

RBS:

  • return: Array[Instruction]



59
60
61
# File 'lib/lldb/instruction_list.rb', line 59

def to_a
  (0...size).map { |index| self[index] }.compact
end

#to_ptrObject

RBS:

  • return: FFI::Pointer



64
65
66
# File 'lib/lldb/instruction_list.rb', line 64

def to_ptr
  @ptr
end

#valid?Boolean

RBS:

  • return: bool

Returns:

  • (Boolean)


23
24
25
# File 'lib/lldb/instruction_list.rb', line 23

def valid?
  !@ptr.null? && FFIBindings.lldb_instruction_list_is_valid(@ptr) != 0
end