Added instruction operands (Seth Warn)

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@66 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2009-02-23 07:56:23 +00:00
commit 2eeb7630a1
6 changed files with 93 additions and 2 deletions

View file

@ -1772,6 +1772,10 @@ class GlobalValue(Constant):
def __init__(self, ptr):
Constant.__init__(self, ptr)
# Hang on to the module, don't let it die before we do.
# It is nice to have just a map of functions without
# retaining a ref to the owning module.
self._module_obj = self.module
def _get_linkage(self): return _core.LLVMGetLinkage(self.ptr)
def _set_linkage(self, value): _core.LLVMSetLinkage(self.ptr, value)
@ -2001,6 +2005,18 @@ class Instruction(Value):
def opcode_name(self):
return _core.LLVMInstGetOpcodeName(self.ptr)
@property
def operand_count(self):
return _core.LLVMInstGetNumOperands(self.ptr)
@property
def operands(self):
"""Yields operands of this instruction."""
return [self._get_operand(i) for i in range(self.operand_count)]
def _get_operand(self, i):
return _make_value(_core.LLVMInstGetOperand(self.ptr, i))
class CallOrInvokeInstruction(Instruction):