diff options
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-x | pp2cc.py | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -1315,13 +1315,11 @@ class Parse(object): else: operand = self.determineConstValue(LinkedNode(node.expr, linked_node)) - if op == "-": - # negating a value in PP2 is flipping the WORDSIZE-th bit - value = -operand - #(operand ^ (pow(2, self.WORDSIZE) - 1)) + 1 - elif op == "~": - # invert all bits + if op in ("-", "~"): value = operand ^ (pow(2, self.WORDSIZE) - 1) + # negating a value in PP2 is inverting the bits and adding 1 + if op == "-": + value += 1 else: value = int(getattr(operator, op)(operand)) elif linked_node.type == "BinaryOp": |