Class: LLVM::User::OperandCollection
- Inherits:
-
Object
- Object
- LLVM::User::OperandCollection
- Includes:
- Enumerable
- Defined in:
- lib/llvm/core/value.rb
Instance Method Summary collapse
-
#[](i) ⇒ Object
Get a reference to an operand by index.
-
#[]=(i, v) ⇒ Object
Set or replace an operand by index.
-
#each ⇒ Object
Iterates through each operand in the collection.
-
#initialize(user) ⇒ OperandCollection
constructor
A new instance of OperandCollection.
-
#size ⇒ Object
Returns the number of operands in the collection.
Constructor Details
#initialize(user) ⇒ OperandCollection
Returns a new instance of OperandCollection.
195 196 197 |
# File 'lib/llvm/core/value.rb', line 195 def initialize(user) @user = user end |
Instance Method Details
#[](i) ⇒ Object
Get a reference to an operand by index.
200 201 202 203 |
# File 'lib/llvm/core/value.rb', line 200 def [](i) ptr = C.LLVMGetOperand(@user, i) Value.from_ptr(ptr) unless ptr.null? end |
#[]=(i, v) ⇒ Object
Set or replace an operand by index.
206 207 208 |
# File 'lib/llvm/core/value.rb', line 206 def []=(i, v) C.LLVMSetOperand(@user, i, v) end |
#each ⇒ Object
Iterates through each operand in the collection.
216 217 218 219 220 |
# File 'lib/llvm/core/value.rb', line 216 def each return to_enum :each unless block_given? 0.upto(size-1) { |i| yield self[i] } self end |
#size ⇒ Object
Returns the number of operands in the collection.
211 212 213 |
# File 'lib/llvm/core/value.rb', line 211 def size C.LLVMGetNumOperands(@user) end |