Class: LLVM::User::OperandCollection

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

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ OperandCollection

Returns a new instance of OperandCollection.



289
290
291
# File 'lib/llvm/core/value.rb', line 289

def initialize(user)
  @user = user
end

Instance Method Details

#[](i) ⇒ Object

Get a reference to an operand by index.



294
295
296
297
# File 'lib/llvm/core/value.rb', line 294

def [](i)
  ptr = C.get_operand(@user, i)
  Value.from_ptr(ptr) unless ptr.null?
end

#[]=(i, v) ⇒ Object

Set or replace an operand by index.



300
301
302
# File 'lib/llvm/core/value.rb', line 300

def []=(i, v)
  C.set_operand(@user, i, v)
end

#eachObject

Iterates through each operand in the collection.



310
311
312
313
314
# File 'lib/llvm/core/value.rb', line 310

def each(&)
  return to_enum :each unless block_given?
  0.upto(size - 1) { |i| yield self[i] }
  self
end

#sizeObject

Returns the number of operands in the collection.



305
306
307
# File 'lib/llvm/core/value.rb', line 305

def size
  C.get_num_operands(@user)
end