From 1adf3d871a1423adcab4382e601c6b156553e4a1 Mon Sep 17 00:00:00 2001 From: Jon Riehl Date: Tue, 23 Jul 2013 16:42:46 -0500 Subject: [PATCH] Added support for UNARY_INVERT bytecode. --- llpython/byte_translator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llpython/byte_translator.py b/llpython/byte_translator.py index a4dc980..278edce 100644 --- a/llpython/byte_translator.py +++ b/llpython/byte_translator.py @@ -590,7 +590,12 @@ class LLVMTranslator (BytecodeFlowVisitor): return ret_val def op_UNARY_INVERT (self, i, op, arg, *args, **kws): - raise NotImplementedError("LLVMTranslator.op_UNARY_INVERT") + arg1, = args + if isinstance(arg1.type, lc.IntegerType): + ret_val = [self.builder.xor(arg1, lc.Constant.int(arg1.type, -1))] + else: + raise NotImplementedError('Invert for type %r' % (arg1.type,)) + return ret_val def op_UNARY_NEGATIVE (self, i, op, arg, *args, **kws): raise NotImplementedError("LLVMTranslator.op_UNARY_NEGATIVE")