Access to MetaData operands

This is not available in the C API, so add functions to extra.cpp:

- `LLVMMetaDataGetOperand` wraps MDNode::getOperand
- `LLVMMetaDataGetNumOperands` wraps MDNode::getNumOperands
This commit is contained in:
Wladimir J. van der Laan 2012-09-12 20:58:53 +02:00
commit 7f69beb258
5 changed files with 40 additions and 1 deletions

View file

@ -1466,6 +1466,18 @@ class MetaData(Value):
def add_named_operand(module, name, operand):
_core.LLVMAddNamedMetadataOperand(module.ptr, name, operand.ptr)
@property
def operand_count(self):
return _core.LLVMMetaDataGetNumOperands(self.ptr)
@property
def operands(self):
"""Yields operands of this metadata."""
return [self._get_operand(i) for i in range(self.operand_count)]
def _get_operand(self, i):
return _make_value(_core.LLVMMetaDataGetOperand(self.ptr, i))
#===----------------------------------------------------------------------===
# Instruction
#===----------------------------------------------------------------------===