#print "BinopNode.generate_result_code:", self.operand1, self.operand2 ###
if self.operand1.type.is_pyobject:
function = self.py_operation_function()
- if function == "PyNumber_Power":
+ if self.operator == '**':
extra_args = ", Py_None"
else:
extra_args = ""
BinopNode.is_py_operation_types(self, type1, type2))
def py_operation_function(self):
- return self.py_functions[self.operator]
+ fuction = self.py_functions[self.operator]
+ if self.inplace:
+ fuction = fuction.replace('PyNumber_', 'PyNumber_InPlace')
+ return fuction
py_functions = {
"|": "PyNumber_Or",
"**": "PyNumber_Power"
}
-
class IntBinopNode(NumBinopNode):
# Binary operation taking integer arguments.
"**": PowNode
}
-def binop_node(pos, operator, operand1, operand2):
+def binop_node(pos, operator, operand1, operand2, inplace=False):
# Construct binop node of appropriate class for
# given operator.
return binop_node_classes[operator](pos,
operator = operator,
operand1 = operand1,
- operand2 = operand2)
+ operand2 = operand2,
+ inplace = inplace)
#-------------------------------------------------------------------
#
self.rhs.generate_disposal_code(code)
self.rhs.free_temps(code)
- py_functions = {
- "|": "PyNumber_InPlaceOr",
- "^": "PyNumber_InPlaceXor",
- "&": "PyNumber_InPlaceAnd",
- "+": "PyNumber_InPlaceAdd",
- "-": "PyNumber_InPlaceSubtract",
- "*": "PyNumber_InPlaceMultiply",
- "/": "__Pyx_PyNumber_InPlaceDivide",
- "%": "PyNumber_InPlaceRemainder",
- "<<": "PyNumber_InPlaceLshift",
- ">>": "PyNumber_InPlaceRshift",
- "**": "PyNumber_InPlacePower",
- "//": "PyNumber_InPlaceFloorDivide",
- }
-
def annotate(self, code):
self.lhs.annotate(code)
self.rhs.annotate(code)
binop = binop_node(node.pos,
operator = node.operator,
operand1 = dup,
- operand2 = rhs)
- node = SingleAssignmentNode(node.pos, lhs=lhs, rhs=binop) #, inplace=True)
+ operand2 = rhs,
+ inplace=True)
+ node = SingleAssignmentNode(node.pos, lhs=lhs, rhs=binop)
# Use LetRefNode to avoid side effects.
let_ref_nodes.reverse()
for t in let_ref_nodes: