Class: LLVM::Function::BasicBlockCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/llvm/core/value.rb

Instance Method Summary collapse

Constructor Details

#initialize(fun) ⇒ BasicBlockCollection



1039
1040
1041
# File 'lib/llvm/core/value.rb', line 1039

def initialize(fun)
  @fun = fun
end

Instance Method Details

#append(name = "") ⇒ Object

Adds a BasicBlock with the given name to the end of the collection.



1062
1063
1064
# File 'lib/llvm/core/value.rb', line 1062

def append(name = "")
  BasicBlock.create(@fun, name)
end

#eachObject

Iterates through each BasicBlock in the collection.



1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
# File 'lib/llvm/core/value.rb', line 1049

def each
  return to_enum :each unless block_given?

  ptr = C.get_first_basic_block(@fun)
  0.upto(size - 1) do |i|
    yield BasicBlock.from_ptr(ptr)
    ptr = C.get_next_basic_block(ptr)
  end

  self
end

#entryObject

Returns the entry BasicBlock in the collection. This is the block the function starts on.



1068
1069
1070
# File 'lib/llvm/core/value.rb', line 1068

def entry
  BasicBlock.from_ptr(C.get_entry_basic_block(@fun))
end

#firstObject

Returns the first BasicBlock in the collection.



1073
1074
1075
1076
# File 'lib/llvm/core/value.rb', line 1073

def first
  ptr = C.get_first_basic_block(@fun)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end

#lastObject

Returns the last BasicBlock in the collection.



1079
1080
1081
1082
# File 'lib/llvm/core/value.rb', line 1079

def last
  ptr = C.get_last_basic_block(@fun)
  BasicBlock.from_ptr(ptr) unless ptr.null?
end

#sizeObject

Returns the number of BasicBlocks in the collection.



1044
1045
1046
# File 'lib/llvm/core/value.rb', line 1044

def size
  C.count_basic_blocks(@fun)
end