Fix ConstantExpr opcode to use C++ enum values.

Note: C++ opcode is different from C opcode values.
Add ConstantExpr opcode name.
Add test for these.
This commit is contained in:
Siu Kwan Lam 2012-09-01 20:53:33 -07:00
commit 5d14461c84
5 changed files with 51 additions and 3 deletions

17
test/constexpr.py Normal file
View file

@ -0,0 +1,17 @@
import unittest
from llvm.core import *
class TestConstExpr(unittest.TestCase):
def test_constexpr_opcode(self):
mod = Module.new('test_constexpr_opcode')
func = mod.add_function(Type.function(Type.void(), []), name="foo")
builder = Builder.new(func.append_basic_block('entry'))
a = builder.inttoptr(Constant.int(Type.int(), 123),
Type.pointer(Type.int()))
self.assertTrue(isinstance(a, ConstantExpr))
self.assertEqual(a.opcode, OPCODE_INTTOPTR)
self.assertEqual(a.opcode_name, "inttoptr")
if __name__ == '__main__':
unittest.main()