Add ways to get the value of a ConstantInt

- property z_ext_value gets the zero-extended value using LLVMConstIntGetZExtValue
- property s_ext_value gets the sign-extended value using LLVMConstIntGetSExtValue
- add test case for both
This commit is contained in:
Wladimir J. van der Laan 2012-09-09 11:57:42 +02:00
commit 41953602bf
3 changed files with 28 additions and 2 deletions

View file

@ -1193,7 +1193,17 @@ class ConstantDataVector(Constant):
pass
class ConstantInt(Constant):
pass
@property
def z_ext_value(self):
'''Obtain the zero extended value for an integer constant value.'''
# Warning: assertion failure when value does not fit in 64 bits
return _core.LLVMConstIntGetZExtValue(self.ptr)
@property
def s_ext_value(self):
'''Obtain the sign extended value for an integer constant value.'''
# Warning: assertion failure when value does not fit in 64 bits
return _core.LLVMConstIntGetSExtValue(self.ptr)
class ConstantFP(Constant):